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