Commit 2e96f4bc authored by renjintao's avatar renjintao

Merge branch 'product' of git.mes123.com:zhouyx/mes-ui into product-rjt

parents f8aed324 c4b7b181
......@@ -110,6 +110,7 @@ export default {
code: 0,
status: 0,
codeRuleId: this.nodeInfo.codeRuleId,
codeRuleType: this.nodeInfo.codeRuleType,
},
disabled: false,
codeList: [],
......
......@@ -108,6 +108,7 @@ export default {
upId: 0,
code: 0,
codeRuleId: this.nodeInfo.codeRuleId,
codeRuleType: this.nodeInfo.codeRuleType,
},
arr: [],
disabled: false,
......
<template>
<div class="classification">
<div class="classification">
<Layout>
<Sider width="300" v-if="showMenu">
<div class="p-list">
<h3>
<Dropdown @on-click="clickItem">
<a href="javascript:void(0)">
{{downName}}
<Icon type="ios-arrow-down"></Icon>
</a>
<DropdownMenu slot="list">
<DropdownItem v-for="item in cityList" :key="item.id" :name="item.id">{{ item.name }}</DropdownItem>
</DropdownMenu>
</Dropdown>
<div class="fr mr10 mt10">
<ButtonGroup class="fr" size="small">
<Button icon="md-add" title="新增顶级" @click="addNew"></Button>
<Button :icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'" @click="toggle" title="展开/合并"></Button>
<Button icon="md-refresh" title="刷新" @click="loadTree(model8)"></Button>
<Button icon="md-rewind" title="收起" @click="hide"></Button>
</ButtonGroup>
</div>
</h3>
<div class="search">
<Input search placeholder="关键字" v-model="keys" clearable />
</div>
<div class="fg">
<div class="tree">
<Tree :data="data" ref="tree" @on-select-change="change" :render="renderContent"></Tree>
<Dropdown transfer ref="contentMenu" style="display: none;" trigger="click" placement="right-start">
<DropdownMenu slot="list" ref="ppp" style="min-width: 80px;">
<DropdownItem @click.native="add">
<a>添加</a>
</DropdownItem>
<DropdownItem name="edit" @click.native="edit">
<a>修改</a>
</DropdownItem>
<DropdownItem name="del" @click.native="remove">
<a>删除</a>
</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
</div>
<Sider width="300" v-if="showMenu">
<div class="p-list">
<h3>
<Dropdown @on-click="clickItem">
<a href="javascript:void(0)">
{{downName}}
<Icon type="ios-arrow-down"></Icon>
</a>
<DropdownMenu slot="list">
<DropdownItem
v-for="item in cityList"
:key="item.id"
:name="item.id"
>{{ item.name }}</DropdownItem>
</DropdownMenu>
</Dropdown>
<div class="fr mr10 mt10">
<ButtonGroup class="fr" size="small">
<Button icon="md-add" title="新增顶级" @click="addNew"></Button>
<Button
:icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'"
@click="toggle"
title="展开/合并"
></Button>
<Button
icon="md-refresh"
title="刷新"
@click="loadTree(model8,nodeInfo.codeRuleType)"
></Button>
<Button icon="md-rewind" title="收起" @click="hide"></Button>
</ButtonGroup>
</div>
</Sider>
<div v-if="!showMenu" class="show_menu">
<a class="menu_play fr" @click="showMenuFn" title="展开">
<Icon type="ios-arrow-forward" size="24" />
</a>
</h3>
<div class="search">
<Input search placeholder="关键字" v-model="keys" clearable />
</div>
<div class="fg">
<div class="tree">
<Tree :data="data" ref="tree" @on-select-change="change" :render="renderContent"></Tree>
<Dropdown
transfer
ref="contentMenu"
style="display: none;"
trigger="click"
placement="right-start"
>
<DropdownMenu slot="list" ref="ppp" style="min-width: 80px;">
<DropdownItem @click.native="add">
<a>添加</a>
</DropdownItem>
<DropdownItem name="edit" @click.native="edit">
<a>修改</a>
</DropdownItem>
<DropdownItem name="del" @click.native="remove">
<a>删除</a>
</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
</div>
</div>
<Content :class="!showMenu?'con_bord':''">
<MasterData ref="dataTable" @on-edit="editRow" :root="root" @on-ok="ok" />
</Content>
</Sider>
<div v-if="!showMenu" class="show_menu">
<a class="menu_play fr" @click="showMenuFn" title="展开">
<Icon type="ios-arrow-forward" size="24" />
</a>
</div>
<Content :class="!showMenu?'con_bord':''">
<MasterData ref="dataTable" @on-edit="editRow" :root="root" @on-ok="ok" />
</Content>
</Layout>
<Modal v-model="modal" :title="title" width="1500" footer-hide :mask-closable="false">
<component :is="detail" :eid="curId" :nodeInfo="nodeInfo" @on-close="cancel" @on-ok="ok" ref="chlidren" />
<component
:is="detail"
:eid="curId"
:nodeInfo="nodeInfo"
@on-close="cancel"
@on-ok="ok"
ref="chlidren"
/>
</Modal>
</div>
</div>
</template>
<script>
......@@ -65,367 +90,373 @@ import MasterData from "./masterData.vue";
import Api from "./api";
export default {
components: {
MasterData
components: {
MasterData,
},
name: "classification",
data() {
return {
model8: "",
root: {
id: 0,
ids: [],
},
downName: "请选择类型",
cityList: [],
keys: "",
expand: false,
list: [],
nodeInfo: {
codeRuleId: "",
codeRuleType: "",
},
modal: false,
title: "新增",
curId: 0,
detail: null,
showMenu: true,
dataList: [],
};
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
// this.loadTree();
this.listSlecet();
},
methods: {
clickItem(val) {
this.nodeInfo.codeRuleId = val;
this.model8 = val;
this.cityList.forEach((e) => {
if (val == e.id) {
this.downName = e.name;
this.nodeInfo.codeRuleType = e.type;
}
});
this.loadTree(this.nodeInfo.codeRuleId, this.nodeInfo.codeRuleType);
},
name: "classification",
data() {
return {
model8: "",
root: {
id: 0,
ids: []
},
downName: "请选择类型",
cityList: [],
keys: "",
expand: false,
list: [],
nodeInfo: {
codeRuleId: ""
},
modal: false,
title: "新增",
curId: 0,
detail: null,
showMenu: true,
dataList: []
};
listSlecet() {
let data = {
conditions: [],
sortBy: "id",
isDesc: false,
};
Api.pagedSlecet(data).then((r) => {
this.cityList = r.result.items;
this.downName = this.cityList[0].name;
this.model8 = this.cityList[0].id;
this.nodeInfo.codeRuleId = this.cityList[0].id;
this.nodeInfo.codeRuleType = this.cityList[0].type;
this.loadTree(this.nodeInfo.codeRuleId, this.nodeInfo.codeRuleType);
});
},
async fetch({
store,
params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典
showMenuFn() {
//this.$Message.info("展开左侧树")
this.showMenu = true;
},
created() {
// this.loadTree();
this.listSlecet();
ok(row) {
this.loadTree(this.nodeInfo.codeRuleId, this.nodeInfo.codeRuleType);
this.modal = false;
this.curId = 0;
// if (row) {
// this.dataList.map((e, index) => {
// if (e.id == row.id) {
// this.$set(this.$refs.dataTable.dataColumns, index, row);
// }
// });
// }
},
methods: {
clickItem(val) {
this.nodeInfo.codeRuleId = val;
this.model8 = val;
this.loadTree(this.nodeInfo.codeRuleId);
this.cityList.forEach(e => {
if (val == e.id) {
this.downName = e.name;
}
});
this.model8 = val;
},
listSlecet() {
let data = {
conditions: [],
sortBy: "id",
isDesc: false
};
Api.pagedSlecet(data).then(r => {
this.cityList = r.result.items;
this.downName = this.cityList[0].name;
this.model8 = this.cityList[0].id;
this.nodeInfo.codeRuleId = this.cityList[0].id;
this.loadTree(this.nodeInfo.codeRuleId);
});
},
showMenuFn() {
//this.$Message.info("展开左侧树")
this.showMenu = true;
},
ok(row) {
this.loadTree(this.nodeInfo.codeRuleId);
this.modal = false;
this.curId = 0;
// if (row) {
// this.dataList.map((e, index) => {
// if (e.id == row.id) {
// this.$set(this.$refs.dataTable.dataColumns, index, row);
// }
// });
// }
},
addNew() {
if (this.model8) {
this.curId = 0;
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
this.$refs.chlidren.arr = [];
} else {
this.$Message.error("请先选择类型");
}
},
add() {
this.curId = 0;
this.title = "新增";
this.detail = () => import("./sonAdd");
this.modal = true;
},
editRow(row) {
this.nodeInfo = row;
this.edit();
},
edit() {
if (this.nodeInfo.upId == 0) {
this.detail = () => import("./edit");
this.$refs.chlidren.arr = [];
} else {
this.detail = () => import("./sonEdit");
}
this.curId = this.nodeInfo.id;
this.title = "编辑";
this.modal = true;
},
remove() {
// console.log(this.nodeInfo);
if (this.nodeInfo.children.length > 1) {
this.$Message.error("因为有子级,不能直接删除");
} else {
this.$Modal.confirm({
title: "删除",
content: "<p>您确定要删除吗?</p>",
onOk: () => {
Api.delete(this.nodeInfo.id).then(r => {
if (r.success) {
this.loadTree(this.nodeInfo.codeRuleId);
this.$Message.success("删除成功");
}
});
},
onCancel: () => {
this.$Message.success("取消删除");
}
});
}
},
cancel() {
this.curId = 0;
this.modal = false;
},
renderContent(h, {
root,
node,
data
}) {
return h(
"span", {
on: {
click: () => {
this.handleSelect(data); //手动选择树节点
},
//右键点击事件
contextmenu: e => {
e.preventDefault();
this.$refs.contentMenu.$refs.reference = event.target;
this.$refs.contentMenu.currentVisible = !this.$refs.contentMenu
.currentVisible;
this.nodeInfo = data;
}
}
},
data.title +
"(" +
(data.totalMaterialCount == undefined ?
"0" :
data.totalMaterialCount) +
")"
);
},
handleSelect(data) {
// let tableData = [];
// let obj = {};
// let children = 0;
// if (data.upId == 0 && data.children.length > 0) {
// data.children.forEach(e => {
// if (e.children.length > 0) {
// children = 1;
// } else {
// children = 0;
// }
// obj = {
// id: e.id,
// name: e.name,
// code: e.code,
// status: e.status,
// children: children,
// upId: e.upId,
// description: e.description
// };
// tableData.push(obj);
// });
// this.dataList = tableData;
// this.$refs.dataTable.dataColumns = tableData;
// }
},
loadTree(id) {
let data = {
conditions: [{
fieldName: "codeRuleId",
fieldValue: id,
conditionalType: "Equal"
}],
sortBy: "code",
isDesc: false
};
Api.list(data).then(r => {
var data = this.$u.toTree(
r.result,
0,
u => {
u.title = u.code + u.name;
u.value = u.id;
u.expand = true;
},
"upId"
addNew() {
if (this.model8) {
this.curId = 0;
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
this.$refs.chlidren.arr = [];
} else {
this.$Message.error("请先选择类型");
}
},
add() {
this.curId = 0;
this.title = "新增";
this.detail = () => import("./sonAdd");
this.modal = true;
},
editRow(row) {
this.nodeInfo = row;
this.edit();
},
edit() {
if (this.nodeInfo.upId == 0) {
this.detail = () => import("./edit");
this.$refs.chlidren.arr = [];
} else {
this.detail = () => import("./sonEdit");
}
this.curId = this.nodeInfo.id;
this.title = "编辑";
this.modal = true;
},
remove() {
// console.log(this.nodeInfo);
if (this.nodeInfo.children.length > 1) {
this.$Message.error("因为有子级,不能直接删除");
} else {
this.$Modal.confirm({
title: "删除",
content: "<p>您确定要删除吗?</p>",
onOk: () => {
Api.delete(this.nodeInfo.id).then((r) => {
if (r.success) {
this.loadTree(
this.nodeInfo.codeRuleId,
this.nodeInfo.codeRuleType
);
this.list = this.$u.clone(data);
this.$Message.success("删除成功");
}
});
},
onCancel: () => {
this.$Message.success("取消删除");
},
});
}
},
cancel() {
this.curId = 0;
this.modal = false;
},
renderContent(h, { root, node, data }) {
return h(
"span",
{
on: {
click: () => {
this.handleSelect(data); //手动选择树节点
},
//右键点击事件
contextmenu: (e) => {
e.preventDefault();
this.$refs.contentMenu.$refs.reference = event.target;
this.$refs.contentMenu.currentVisible = !this.$refs.contentMenu
.currentVisible;
this.nodeInfo = data;
},
},
},
toggle() {
if (this.model8) {
this.expand = !this.expand;
} else {
this.$Message.error("请先选择类型");
}
},
change(v, b) {
// console.log(v);
// alert(JSON.stringify(b));
let ids = [];
ids.push(b.id);
if (b.children) {
addId(b.children);
data.title +
"(" +
(data.totalMaterialCount == undefined
? "0"
: data.totalMaterialCount) +
")"
);
},
handleSelect(data) {
// let tableData = [];
// let obj = {};
// let children = 0;
// if (data.upId == 0 && data.children.length > 0) {
// data.children.forEach(e => {
// if (e.children.length > 0) {
// children = 1;
// } else {
// children = 0;
// }
// obj = {
// id: e.id,
// name: e.name,
// code: e.code,
// status: e.status,
// children: children,
// upId: e.upId,
// description: e.description
// };
// tableData.push(obj);
// });
// this.dataList = tableData;
// this.$refs.dataTable.dataColumns = tableData;
// }
},
loadTree(id, codeRuleType) {
let data = {
conditions: [
{
fieldName: "codeRuleId",
fieldValue: id,
conditionalType: "Equal",
},
{
fieldName: "codeRuleType",
fieldValue: codeRuleType,
conditionalType: "Equal",
},
],
sortBy: "code",
isDesc: false,
};
Api.list(data).then((r) => {
var data = this.$u.toTree(
r.result,
0,
(u) => {
u.title = u.code + u.name;
u.value = u.id;
u.expand = true;
},
"upId"
);
this.list = this.$u.clone(data);
});
},
toggle() {
if (this.model8) {
this.expand = !this.expand;
} else {
this.$Message.error("请先选择类型");
}
},
change(v, b) {
// console.log(v);
// alert(JSON.stringify(b));
let ids = [];
ids.push(b.id);
if (b.children) {
addId(b.children);
function addId(data) {
data.map(u => {
ids.push(u.id);
if (u.children) {
addId(u.children);
}
});
}
function addId(data) {
data.map((u) => {
ids.push(u.id);
if (u.children) {
addId(u.children);
}
this.root.ids = ids;
this.root.id = b.id;
// this.root.codeRuleId=b.codeRuleId
},
hide() {
this.showMenu = false;
});
}
}
this.root.ids = ids;
this.root.id = b.id;
// this.root.codeRuleId=b.codeRuleId
},
computed: {
data() {
let items = this.$u.clone(this.list);
let expand = this.expand;
let result = [];
search(this.keys, items);
hide() {
this.showMenu = false;
},
},
computed: {
data() {
let items = this.$u.clone(this.list);
let expand = this.expand;
let result = [];
search(this.keys, items);
function search(keys, data) {
data.map(u => {
if (keys.length < u.title) {
u.expand = expand;
result.push(u);
} else {
u.expand = expand;
if (u.title.indexOf(keys) > -1) {
result.push(u);
} else if (u.children) {
search(keys, u.children);
}
}
});
function search(keys, data) {
data.map((u) => {
if (keys.length < u.title) {
u.expand = expand;
result.push(u);
} else {
u.expand = expand;
if (u.title.indexOf(keys) > -1) {
result.push(u);
} else if (u.children) {
search(keys, u.children);
}
return result;
}
}
}
});
}
return result;
},
},
};
</script>
<style lang="less">
.classification {
font-family: Microsoft YaHei;
font-family: Microsoft YaHei;
.ivu-layout-sider {
background: rgba(255, 255, 255, 1);
margin-right: 10px;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
height: 87vh;
.ivu-layout-sider {
background: rgba(255, 255, 255, 1);
margin-right: 10px;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
height: 87vh;
h4 {
height: 30px;
line-height: 30px;
background: #eee;
padding-left: 10px;
}
h4 {
height: 30px;
line-height: 30px;
background: #eee;
padding-left: 10px;
}
.p-list {
h3 {
height: 50px;
font-size: 14px;
font-family: Microsoft YaHei;
font-weight: bold;
line-height: 50px;
color: rgba(81, 90, 110, 1);
background: rgba(245, 246, 250, 1);
opacity: 1;
padding-left: 10px;
}
.p-list {
h3 {
height: 50px;
font-size: 14px;
font-family: Microsoft YaHei;
font-weight: bold;
line-height: 50px;
color: rgba(81, 90, 110, 1);
background: rgba(245, 246, 250, 1);
opacity: 1;
padding-left: 10px;
}
.search {
height: 50px;
padding: 5px 10px;
}
.search {
height: 50px;
padding: 5px 10px;
}
.fg {
flex: none;
height: 100%;
overflow: auto;
padding-left: 10px;
}
.fg {
flex: none;
height: 100%;
overflow: auto;
padding-left: 10px;
}
.tree {
height: calc(100vh - 215px);
overflow: auto;
}
}
.tree {
height: calc(100vh - 215px);
overflow: auto;
}
}
}
.show_menu {
width: 30px;
height: 30px;
position: fixed;
top: 100px;
left: 0;
z-index: 9;
.menu_play {
width: 30px;
height: 30px;
line-height: 34px;
font-size: 14px;
text-align: center;
color: #515a6e;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
background: #ffffff;
box-shadow: #ccc 2px 2px 4px 1px;
}
.show_menu {
width: 30px;
height: 30px;
position: fixed;
top: 100px;
left: 0;
z-index: 9;
.menu_play:hover {
background-color: #2d8cf0;
color: white;
}
.menu_play {
width: 30px;
height: 30px;
line-height: 34px;
font-size: 14px;
text-align: center;
color: #515a6e;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
background: #ffffff;
box-shadow: #ccc 2px 2px 4px 1px;
}
.ivu-layout-content {
// margin-left: 5px;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
overflow: auto;
padding: 10px;
height: 87vh;
overflow-y: hidden;
.menu_play:hover {
background-color: #2d8cf0;
color: white;
}
}
.ivu-layout-content {
// margin-left: 5px;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
overflow: auto;
padding: 10px;
height: 87vh;
overflow-y: hidden;
}
}
</style>
......@@ -52,7 +52,8 @@ export default {
upId: this.nodeInfo.id,
code: 0,
status: 0,
codeRuleId:this.nodeInfo.codeRuleId
codeRuleId:this.nodeInfo.codeRuleId,
codeRuleType: this.nodeInfo.codeRuleType,
},
upName: this.nodeInfo.title,
disabled: false,
......
......@@ -51,13 +51,14 @@ export default {
entity: {
upId: 0,
code: 0,
codeRuleId:this.nodeInfo.codeRuleId
codeRuleId: this.nodeInfo.codeRuleId,
codeRuleType: this.nodeInfo.codeRuleType,
},
upName: this.nodeInfo.title,
disabled: false,
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }]
}
name: [{ required: true, message: "必填", trigger: "blur" }],
},
};
},
props: ["nodeInfo"],
......@@ -69,25 +70,25 @@ export default {
},
methods: {
get() {
Api.get({ id: this.nodeInfo.id }).then(r => {
Api.get({ id: this.nodeInfo.id }).then((r) => {
if (r.result) {
this.entity = r.result;
}
});
},
handleSubmit() {
this.$refs.form.validate(v => {
this.$refs.form.validate((v) => {
if (v) {
Api.update({ categoryDto: this.entity, pro: [] })
.then(r => {
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok",this.entity);
this.$emit("on-ok", this.entity);
} else {
this.$Message.error(r.error.message);
}
})
.catch(err => {
.catch((err) => {
this.disabled = false;
this.$Message.error(r.error.message);
});
......@@ -96,7 +97,7 @@ export default {
},
handleClose() {
this.$emit("on-close");
}
}
},
},
};
</script>
......@@ -91,14 +91,15 @@ export default {
codeRuleId: this.nodeInfo.codeRuleId,
categoryId: this.nodeInfo.categoryId, //左侧树点击的id
customProperties: {},
rootCategoryId: this.nodeInfo.rootCategoryId //左侧树点击的数据的最顶层id
rootCategoryId: this.nodeInfo.rootCategoryId, //左侧树点击的数据的最顶层id
codeRuleType: this.nodeInfo.codeRuleType,
},
disabled: false,
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }]
name: [{ required: true, message: "必填", trigger: "blur" }],
},
fileds: [] //扩展属性
fileds: [], //扩展属性
};
},
async fetch({ store, params }) {
......@@ -113,17 +114,17 @@ export default {
{
conditionalType: "Equal",
fieldName: "categoryId",
fieldValue: this.nodeInfo.rootCategoryId
}
fieldValue: this.nodeInfo.rootCategoryId,
},
];
Api.listTable({
conditions: conditions,
sortBy: "id",
isDesc: false
}).then(r => {
isDesc: false,
}).then((r) => {
if (r.result) {
this.fileds = r.result.filter(function(item) {
this.fileds = r.result.filter(function (item) {
item.span = 12;
if (item.dataType > 4) {
item.span = 24;
......@@ -131,7 +132,7 @@ export default {
delete item["id"];
return item.fieldType != 1;
});
this.fileds.map(u => {
this.fileds.map((u) => {
let v = "";
if (u.dataType == 1 || u.dataType == 2) {
v = 0;
......@@ -158,12 +159,12 @@ export default {
},
handleSubmit() {
this.$refs.form.validate(v => {
this.$refs.form.validate((v) => {
if (v) {
// let categoryDto = this.entity;
// let pro = this.checkList.concat(this.arr);
Api.create(this.entity)
.then(r => {
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
......@@ -171,7 +172,7 @@ export default {
this.$Message.error(r.error.message);
}
})
.catch(err => {
.catch((err) => {
this.disabled = false;
this.$Message.error(r.error.message);
});
......@@ -180,7 +181,7 @@ export default {
},
handleClose() {
this.$emit("on-close");
}
}
},
},
};
</script>
......@@ -89,14 +89,15 @@ export default {
categoryId: this.nodeInfo.categoryId, //左侧树点击的id
customProperties: {},
rootCategoryId: this.nodeInfo.rootCategoryId, //左侧树点击的数据的最顶层id
version: null
version: null,
codeRuleType: this.nodeInfo.codeRuleType,
},
fileds: [],
checkList: [],
disabled: false,
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }]
}
name: [{ required: true, message: "必填", trigger: "blur" }],
},
};
},
async fetch({ store, params }) {
......@@ -114,16 +115,16 @@ export default {
{
conditionalType: "Equal",
fieldName: "categoryId",
fieldValue: this.nodeInfo.rootCategoryId
}
fieldValue: this.nodeInfo.rootCategoryId,
},
];
Api.listTable({
conditions: conditions,
sortBy: "id",
isDesc: false
}).then(r => {
isDesc: false,
}).then((r) => {
if (r.result) {
this.fileds = r.result.filter(function(item) {
this.fileds = r.result.filter(function (item) {
item.span = 12;
if (item.dataType > 4) {
item.span = 24;
......@@ -131,7 +132,7 @@ export default {
delete item["id"];
return item.fieldType != 1;
});
this.fileds.map(u => {
this.fileds.map((u) => {
let v = "";
if (u.dataType == 1 || u.dataType == 2) {
v = 0;
......@@ -143,7 +144,7 @@ export default {
});
},
get() {
Api.get({ id: this.eid }).then(r => {
Api.get({ id: this.eid }).then((r) => {
if (r.result) {
this.entity = r.result;
this.entity.version = parseInt(r.result.version);
......@@ -155,23 +156,23 @@ export default {
{
conditionalType: "In",
fieldName: "fieldType",
fieldValue: "1,2"
fieldValue: "1,2",
},
{
conditionalType: "Equal",
fieldName: "categoryId",
fieldValue: "0"
}
fieldValue: "0",
},
];
Api.listTable({
conditions: conditions,
sortBy: "id",
isDesc: false
}).then(r => {
isDesc: false,
}).then((r) => {
if (r.result) {
var arr = r.result;
this.checkList = arr.filter(function(item) {
this.checkList = arr.filter(function (item) {
item.mid = item.id;
delete item["id"]; //删除属性id
return item;
......@@ -195,12 +196,12 @@ export default {
},
handleSubmit() {
this.$refs.form.validate(v => {
this.$refs.form.validate((v) => {
if (v) {
// let categoryDto = this.entity;
// let pro = this.checkList.concat(this.arr);
Api.update(this.entity)
.then(r => {
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
......@@ -208,7 +209,7 @@ export default {
this.$Message.error(r.error.message);
}
})
.catch(err => {
.catch((err) => {
this.disabled = false;
this.$Message.error(r.error.message);
});
......@@ -217,7 +218,7 @@ export default {
},
handleClose() {
this.$emit("on-close");
}
}
},
},
};
</script>
<template>
<div class="classification">
<div class="classification">
<Layout>
<Sider width="300" v-if="showMenu">
<div class="p-list">
<h3>
<Dropdown @on-click="clickItem">
<a href="javascript:void(0)">
{{downName}}
<Icon type="ios-arrow-down"></Icon>
</a>
<DropdownMenu slot="list">
<DropdownItem v-for="item in cityList" :key="item.id" :name="item.id">{{ item.name }}</DropdownItem>
</DropdownMenu>
</Dropdown>
<div class="fr mr10 mt10">
<ButtonGroup class="fr ddi" size="small">
<Button :icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'" @click="toggle" title="展开/合并"></Button>
<Button icon="md-refresh" title="刷新" @click="loadTree(model8)"></Button>
<Button icon="md-rewind" title="收起" @click="hide"></Button>
</ButtonGroup>
</div>
</h3>
<div class="search">
<Input search placeholder="关键字" v-model="keys" clearable />
</div>
<div class="fg">
<div class="tree">
<Tree :data="data" ref="tree" @on-select-change="change" :render="renderContent"></Tree>
</div>
</div>
<Sider width="300" v-if="showMenu">
<div class="p-list">
<h3>
<Dropdown @on-click="clickItem">
<a href="javascript:void(0)">
{{downName}}
<Icon type="ios-arrow-down"></Icon>
</a>
<DropdownMenu slot="list">
<DropdownItem
v-for="item in cityList"
:key="item.id"
:name="item.id"
>{{ item.name }}</DropdownItem>
</DropdownMenu>
</Dropdown>
<div class="fr mr10 mt10">
<ButtonGroup class="fr ddi" size="small">
<Button
:icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'"
@click="toggle"
title="展开/合并"
></Button>
<Button
icon="md-refresh"
title="刷新"
@click="loadTree(model8,nodeInfo.codeRuleType)"
></Button>
<Button icon="md-rewind" title="收起" @click="hide"></Button>
</ButtonGroup>
</div>
</Sider>
<div v-if="!showMenu" class="show_menu">
<a class="menu_play fr" @click="showMenuFn" title="展开">
<Icon type="ios-arrow-forward" size="24" />
</a>
</h3>
<div class="search">
<Input search placeholder="关键字" v-model="keys" clearable />
</div>
<div class="fg">
<div class="tree">
<Tree :data="data" ref="tree" @on-select-change="change" :render="renderContent"></Tree>
</div>
</div>
</div>
<Content :class="!showMenu?'con_bord':''">
<MasterData ref="dataTable" :nodeInfo="nodeInfo" @on-ok="ok" />
</Content>
</Sider>
<div v-if="!showMenu" class="show_menu">
<a class="menu_play fr" @click="showMenuFn" title="展开">
<Icon type="ios-arrow-forward" size="24" />
</a>
</div>
<Content :class="!showMenu?'con_bord':''">
<MasterData ref="dataTable" :nodeInfo="nodeInfo" @on-ok="ok" />
</Content>
</Layout>
</div>
</div>
</template>
<script>
......@@ -48,316 +60,319 @@ import MasterData from "./masterData.vue";
import Api from "./api";
export default {
components: {
MasterData,
components: {
MasterData,
},
name: "masterData",
data() {
return {
model8: "",
type: "",
keys: "",
cityList: [],
expand: false,
list: [],
nodeInfo: {
categoryId: 0,
rootCategoryId: 0,
rootCategoryName: "",
ids: [],
addChange: true,
codeRuleId: 0,
codeRuleType: "",
},
downName: "请选择类型",
modal: false,
title: "新增",
curId: 0,
detail: null,
showMenu: true,
dataList: [],
rootCategoryId: null,
categoryId: null,
};
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
// this.loadTree();
this.listSlecet();
},
methods: {
clickItem(val) {
this.nodeInfo.codeRuleId = val;
this.model8 = val;
this.cityList.forEach((e) => {
if (val == e.id) {
this.downName = e.name;
this.nodeInfo.codeRuleType = e.type;
}
});
this.loadTree(this.nodeInfo.codeRuleId, this.nodeInfo.codeRuleType);
},
name: "masterData",
data() {
return {
model8: "",
type: "",
keys: "",
cityList: [],
expand: false,
list: [],
nodeInfo: {
categoryId: 0,
rootCategoryId: 0,
rootCategoryName: "",
ids: [],
addChange: true,
codeRuleId: 0,
},
downName: "请选择类型",
modal: false,
title: "新增",
curId: 0,
detail: null,
showMenu: true,
dataList: [],
codeRuleId: "",
rootCategoryId: null,
categoryId: null,
};
listSlecet() {
let data = {
conditions: [],
sortBy: "id",
isDesc: false,
};
Api.pagedSlecet(data).then((r) => {
this.cityList = r.result.items;
this.downName = this.cityList[0].name;
this.model8 = this.cityList[0].id;
this.nodeInfo.codeRuleId = this.cityList[0].id;
this.nodeInfo.codeRuleType = this.cityList[0].type;
this.loadTree(this.nodeInfo.codeRuleId, this.nodeInfo.codeRuleType);
});
},
async fetch({
store,
params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典
showMenuFn() {
//this.$Message.info("展开左侧树")
this.showMenu = true;
},
created() {
// this.loadTree();
this.listSlecet();
ok(row) {
this.loadTree(this.nodeInfo.codeRuleId, this.nodeInfo.codeRuleType);
// this.modal = false;
// this.curId = 0;
// if (row) {
// this.dataList.map((e, index) => {
// if (e.id == row.id) {
// this.$set(this.$refs.dataTable.dataColumns, index, row);
// }
// });
// }
},
methods: {
clickItem(val) {
this.codeRuleId = val;
this.nodeInfo.codeRuleId = val;
this.model8 = val;
this.loadTree(this.codeRuleId);
this.cityList.forEach((e) => {
if (val == e.id) {
this.downName = e.name;
}
});
},
listSlecet() {
let data = {
conditions: [],
sortBy: "id",
isDesc: false,
};
Api.pagedSlecet(data).then((r) => {
this.cityList = r.result.items;
this.downName = this.cityList[0].name;
this.model8 = this.cityList[0].id;
this.nodeInfo.codeRuleId = this.cityList[0].id;
this.loadTree(this.nodeInfo.codeRuleId);
});
},
showMenuFn() {
//this.$Message.info("展开左侧树")
this.showMenu = true;
},
ok(row) {
this.loadTree(this.codeRuleId);
// this.modal = false;
// this.curId = 0;
// if (row) {
// this.dataList.map((e, index) => {
// if (e.id == row.id) {
// this.$set(this.$refs.dataTable.dataColumns, index, row);
// }
// });
// }
},
cancel() {
this.curId = 0;
this.modal = false;
},
renderContent(h, {
root,
node,
data
}) {
return h(
"span", {
on: {
click: () => {
this.handleSelect(root, data); //手动选择树节点
},
},
},
data.title +
"(" +
(data.totalMaterialCount == undefined ?
"0" :
data.totalMaterialCount) +
")"
);
cancel() {
this.curId = 0;
this.modal = false;
},
renderContent(h, { root, node, data }) {
return h(
"span",
{
on: {
click: () => {
this.handleSelect(root, data); //手动选择树节点
},
},
},
handleSelect(root, data) {
let pid = -1; //定义最顶级id
var pname = "";
var upId = data.upId;
let roots = root;
function addId(roots, upId) {
roots.map((u) => {
if (u.node.id == upId) {
if (u.node.upId == 0) {
pid = u.node.id;
pname = u.node.name;
} else {
upId = u.node.upId;
addId(roots, upId);
}
}
});
}
data.title +
"(" +
(data.totalMaterialCount == undefined
? "0"
: data.totalMaterialCount) +
")"
);
},
handleSelect(root, data) {
let pid = -1; //定义最顶级id
var pname = "";
var upId = data.upId;
let roots = root;
addId(roots, upId);
this.nodeInfo.categoryId = data.id;
this.nodeInfo.rootCategoryName = data.name;
if (pid == -1) {
this.nodeInfo.rootCategoryId = data.id;
this.nodeInfo.rootCategoryName = data.name;
} else {
this.nodeInfo.rootCategoryId = pid;
this.nodeInfo.rootCategoryName = pname
}
},
loadTree(id) {
let data = {
conditions: [{
fieldName: "codeRuleId",
fieldValue: id,
conditionalType: "Equal"
}, ],
sortBy: "code",
isDesc: false,
};
Api.list(data).then((r) => {
var data = this.$u.toTree(
r.result,
0,
(u) => {
u.title = u.code + u.name;
u.value = u.id;
u.expand = true;
},
"upId"
);
this.list = this.$u.clone(data);
});
},
toggle() {
if (this.model8) {
this.expand = !this.expand;
} else {
this.$Message.error("请先选择类型");
}
},
change(v, b) {
if (b.level < b.ruleLevel && b.children.length > 0) {
this.nodeInfo.addChange = false;
function addId(roots, upId) {
roots.map((u) => {
if (u.node.id == upId) {
if (u.node.upId == 0) {
pid = u.node.id;
pname = u.node.name;
} else {
this.nodeInfo.addChange = true;
upId = u.node.upId;
addId(roots, upId);
}
let ids = [];
ids.push(b.value);
if (b.children) {
addId(b.children);
}
});
}
function addId(data) {
data.map((u) => {
ids.push(u.value);
if (u.children) {
addId(u.children);
}
});
}
addId(roots, upId);
this.nodeInfo.categoryId = data.id;
this.nodeInfo.rootCategoryName = data.name;
if (pid == -1) {
this.nodeInfo.rootCategoryId = data.id;
this.nodeInfo.rootCategoryName = data.name;
} else {
this.nodeInfo.rootCategoryId = pid;
this.nodeInfo.rootCategoryName = pname;
}
},
loadTree(id, codeRuleType) {
let data = {
conditions: [
{
fieldName: "codeRuleId",
fieldValue: id,
conditionalType: "Equal",
},
{
fieldName: "codeRuleType",
fieldValue: codeRuleType,
conditionalType: "Equal",
},
],
sortBy: "code",
isDesc: false,
};
Api.list(data).then((r) => {
var data = this.$u.toTree(
r.result,
0,
(u) => {
u.title = u.code + u.name;
u.value = u.id;
u.expand = true;
},
"upId"
);
this.list = this.$u.clone(data);
});
},
toggle() {
if (this.model8) {
this.expand = !this.expand;
} else {
this.$Message.error("请先选择类型");
}
},
change(v, b) {
if (b.level < b.ruleLevel && b.children.length > 0) {
this.nodeInfo.addChange = false;
} else {
this.nodeInfo.addChange = true;
}
let ids = [];
ids.push(b.value);
if (b.children) {
addId(b.children);
function addId(data) {
data.map((u) => {
ids.push(u.value);
if (u.children) {
addId(u.children);
}
this.nodeInfo.ids = ids;
},
hide() {
this.showMenu = false;
},
});
}
}
this.nodeInfo.ids = ids;
},
hide() {
this.showMenu = false;
},
computed: {
data() {
let items = this.$u.clone(this.list);
let expand = this.expand;
let result = [];
search(this.keys, items);
},
computed: {
data() {
let items = this.$u.clone(this.list);
let expand = this.expand;
let result = [];
search(this.keys, items);
function search(keys, data) {
data.map((u) => {
if (keys.length < u.title) {
u.expand = expand;
result.push(u);
} else {
u.expand = expand;
if (u.title.indexOf(keys) > -1) {
result.push(u);
} else if (u.children) {
search(keys, u.children);
}
}
});
function search(keys, data) {
data.map((u) => {
if (keys.length < u.title) {
u.expand = expand;
result.push(u);
} else {
u.expand = expand;
if (u.title.indexOf(keys) > -1) {
result.push(u);
} else if (u.children) {
search(keys, u.children);
}
return result;
},
}
});
}
return result;
},
},
};
</script>
<style lang="less">
.classification {
font-family: Microsoft YaHei;
font-family: Microsoft YaHei;
.ivu-layout-sider {
background: rgba(255, 255, 255, 1);
margin-right: 10px;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
height: 88vh;
.ivu-layout-sider {
background: rgba(255, 255, 255, 1);
margin-right: 10px;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
height: 88vh;
h4 {
height: 30px;
line-height: 30px;
background: #eee;
padding-left: 10px;
}
h4 {
height: 30px;
line-height: 30px;
background: #eee;
padding-left: 10px;
}
.p-list {
h3 {
height: 50px;
font-size: 14px;
font-family: Microsoft YaHei;
font-weight: bold;
line-height: 50px;
color: rgba(81, 90, 110, 1);
background: rgba(245, 246, 250, 1);
opacity: 1;
padding-left: 10px;
}
.p-list {
h3 {
height: 50px;
font-size: 14px;
font-family: Microsoft YaHei;
font-weight: bold;
line-height: 50px;
color: rgba(81, 90, 110, 1);
background: rgba(245, 246, 250, 1);
opacity: 1;
padding-left: 10px;
}
.search {
height: 50px;
padding: 5px 10px;
}
.search {
height: 50px;
padding: 5px 10px;
}
.fg {
flex: none;
height: 100%;
overflow: auto;
padding-left: 10px;
}
.fg {
flex: none;
height: 100%;
overflow: auto;
padding-left: 10px;
}
.tree {
height: calc(100vh - 215px);
overflow: auto;
}
}
.tree {
height: calc(100vh - 215px);
overflow: auto;
}
}
}
.show_menu {
width: 30px;
height: 30px;
position: fixed;
top: 100px;
left: 0;
z-index: 9;
.menu_play {
width: 30px;
height: 30px;
line-height: 34px;
font-size: 14px;
text-align: center;
color: #515a6e;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
background: #ffffff;
box-shadow: #ccc 2px 2px 4px 1px;
}
.show_menu {
width: 30px;
height: 30px;
position: fixed;
top: 100px;
left: 0;
z-index: 9;
.menu_play:hover {
background-color: #2d8cf0;
color: white;
}
.menu_play {
width: 30px;
height: 30px;
line-height: 34px;
font-size: 14px;
text-align: center;
color: #515a6e;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
background: #ffffff;
box-shadow: #ccc 2px 2px 4px 1px;
}
.ivu-layout-content {
// margin-left: 5px;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
overflow: auto;
padding: 10px;
height: 88vh;
overflow-y: hidden;
.menu_play:hover {
background-color: #2d8cf0;
color: white;
}
}
.ivu-layout-content {
// margin-left: 5px;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
overflow: auto;
padding: 10px;
height: 88vh;
overflow-y: hidden;
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment