Commit 705b5f77 authored by renjintao's avatar renjintao

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

parents c01fed9e 0c22ad29
import Api from '@/plugins/request' import Api from '@/plugins/request'
export default { export default {
index:`${systemUrl}/category/paged`,
paged(params){
return Api.post(`${systemUrl}/category/paged`,params);
},
listTable(params){ listTable(params){
return Api.post(`${systemUrl}/custompropertydefinition/list`,params); return Api.post(`${systemUrl}/custompropertydefinition/list`,params);
}, },
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
</a> </a>
</div> </div>
<Content :class="!showMenu?'con_bord':''"> <Content :class="!showMenu?'con_bord':''">
<MasterData ref="dataTable" @on-edit="editRow" /> <MasterData ref="dataTable" @on-edit="editRow" :root="root" @on-ok="ok"/>
</Content> </Content>
</Layout> </Layout>
<Modal v-model="modal" :title="title" width="1000" footer-hide :mask-closable="false"> <Modal v-model="modal" :title="title" width="1000" footer-hide :mask-closable="false">
...@@ -79,6 +79,10 @@ export default { ...@@ -79,6 +79,10 @@ export default {
name: "classification", name: "classification",
data() { data() {
return { return {
root: {
id: 0,
ids: []
},
keys: "", keys: "",
expand: false, expand: false,
list: [], list: [],
...@@ -106,13 +110,13 @@ export default { ...@@ -106,13 +110,13 @@ export default {
this.loadTree(); this.loadTree();
this.modal = false; this.modal = false;
this.curId = 0; this.curId = 0;
if (row) { // if (row) {
this.dataList.map((e, index) => { // this.dataList.map((e, index) => {
if (e.id == row.id) { // if (e.id == row.id) {
this.$set(this.$refs.dataTable.dataColumns, index, row); // this.$set(this.$refs.dataTable.dataColumns, index, row);
} // }
}); // });
} // }
}, },
addNew() { addNew() {
this.curId = 0; this.curId = 0;
...@@ -186,34 +190,40 @@ export default { ...@@ -186,34 +190,40 @@ export default {
} }
} }
}, },
data.title data.title +
"(" +
(
data.totalMaterialCount == undefined
? "0"
: data.totalMaterialCount) +
")"
); );
}, },
handleSelect(data) { handleSelect(data) {
let tableData = []; // let tableData = [];
let obj = {}; // let obj = {};
let children = 0; // let children = 0;
if (data.upId == 0 && data.children.length > 0) { // if (data.upId == 0 && data.children.length > 0) {
data.children.forEach(e => { // data.children.forEach(e => {
if (e.children.length > 0) { // if (e.children.length > 0) {
children = 1; // children = 1;
} else { // } else {
children = 0; // children = 0;
} // }
obj = { // obj = {
id: e.id, // id: e.id,
name: e.name, // name: e.name,
code: e.code, // code: e.code,
status: e.status, // status: e.status,
children: children, // children: children,
upId: e.upId, // upId: e.upId,
description: e.description // description: e.description
}; // };
tableData.push(obj); // tableData.push(obj);
}); // });
this.dataList = tableData; // this.dataList = tableData;
this.$refs.dataTable.dataColumns = tableData; // this.$refs.dataTable.dataColumns = tableData;
} // }
}, },
loadTree() { loadTree() {
let conditions = []; let conditions = [];
...@@ -238,19 +248,20 @@ export default { ...@@ -238,19 +248,20 @@ export default {
// console.log(v); // console.log(v);
// console.log(b); // console.log(b);
let ids = []; let ids = [];
ids.push(b.value); ids.push(b.id);
if (b.children) { if (b.children) {
addId(b.children); addId(b.children);
function addId(data) { function addId(data) {
data.map(u => { data.map(u => {
ids.push(u.value); ids.push(u.id);
if (u.children) { if (u.children) {
addId(u.children); addId(u.children);
} }
}); });
} }
} }
// this.$emit("on-select", b.value, b, ids); this.root.ids = ids;
this.root.id = b.id;
}, },
hide() { hide() {
this.showMenu = false; this.showMenu = false;
......
<template> <template>
<div class="master-data"> <div class="master-data">
<Table border :columns="columns" :data="dataColumns" :height="tableHeight"></Table>
<!-- <Table border :columns="columns" :data="dataColumns" :height="tableHeight"></Table> -->
<DataGrid :columns="columns" ref="grid" :action="action" :high="false" :height="750">
<template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys">
<Input
placeholder="请输入编码/名称/状态"
v-width="200"
v-model="easySearch.keys.value"
clearable
/>
</FormItem>
<FormItem>
<Button type="primary" @click="search">查询</Button>
</FormItem>
</Form>
</template>
<!-- <template slot="searchForm">
<Search />
</template>-->
<!-- <template slot="buttons">
<Button type="primary" @click="add">新增</Button>
</template>-->
</DataGrid>
</div> </div>
</template> </template>
<script> <script>
import Api from "./api"; import Api from "./api";
export default { export default {
name: "masterData", name: "masterData",
props: ["root"],
data() { data() {
return { return {
action: Api.index,
tableHeight: "", tableHeight: "",
dataColumns: [], dataColumns: [],
easySearch: {
keys: { op: "code,name", value: null },
id: { op: "In", value: this.root.ids }
},
columns: [ columns: [
// { // {
// key: "index", // key: "index",
...@@ -32,21 +62,18 @@ export default { ...@@ -32,21 +62,18 @@ export default {
key: "status", key: "status",
title: "状态", title: "状态",
align: "left", align: "left",
render: (h, params) => { code: "materail.category.status"
return h("state", { // render: (h, params) => {
props: { // return h("state", {
code: "materail.category.status", // props: {
type: "text", // code: "materail.category.status",
value: params.row.status + "" // type: "text",
} // value: params.row.status + ""
}); // }
} // });
}, // }
{
key: "banben",
title: "版本",
align: "left"
}, },
{ {
key: "description", key: "description",
title: "描述", title: "描述",
...@@ -74,7 +101,7 @@ export default { ...@@ -74,7 +101,7 @@ export default {
attrs: { oprate: "delete" }, attrs: { oprate: "delete" },
on: { click: () => this.remove(params.row.id) } on: { click: () => this.remove(params.row.id) }
}, },
params.row.children == 0 ? "删除" : "" "删除"
) )
]); ]);
} }
...@@ -98,26 +125,43 @@ export default { ...@@ -98,26 +125,43 @@ export default {
}; };
}, },
methods: { methods: {
search() {
this.$refs.grid.reload(this.easySearch);
},
edit(row) { edit(row) {
this.$emit("on-edit", row); this.$emit("on-edit", row);
}, },
remove(id) { remove(id) {
this.$Modal.confirm({ Api.delete(id).then(r => {
title: "删除", if (r.success) {
content: "<p>您确定要删除吗?</p>", this.$emit("on-ok");
onOk: () => { this.$refs.grid.reload(this.easySearch);
Api.delete(id).then(r => { this.$Message.success("删除成功");
if (r.success) {
this.loadTree();
this.$Message.success("删除成功");
}
});
},
onCancel: () => {
this.$Message.success("取消删除");
} }
}); });
} }
// this.$Modal.confirm({
// title: "删除",
// content: "<p>您确定要删除吗?</p>",
// onOk: () => {
// onCancel: () => {
// this.$Message.success("取消删除");
// }
// });
// }
},
watch: {
root: {
handler(newName, oldName) {
this.easySearch.id.value = newName.ids;
if (newName.id) {
this.$refs.grid.reload(this.easySearch);
}
},
immediate: true,
deep: true
}
} }
}; };
</script> </script>
......
<template> <template>
<div> <div>
<Form ref="form" :model="entity" :rules="rules" :label-width="90"> <Form ref="form" :model="entity" :rules="rules" :label-width="90">
<Row> <Row>
<Col :span="12"> <Col :span="12">
...@@ -46,12 +47,12 @@ ...@@ -46,12 +47,12 @@
<script> <script>
import Api from "./api"; import Api from "./api";
export default { export default {
props: ["nodeInfo"], props: ["nodeInfo",'eid'],
data() { data() {
return { return {
arr: [], arr: [],
entity: { entity: {
id: this.nodeInfo.id, id: this.eid,
code: 0, code: 0,
categoryId: this.nodeInfo.categoryId, //左侧树点击的id categoryId: this.nodeInfo.categoryId, //左侧树点击的id
customProperties: {}, customProperties: {},
...@@ -71,7 +72,7 @@ export default { ...@@ -71,7 +72,7 @@ export default {
}, },
methods: { methods: {
get() { get() {
Api.get({ id: this.nodeInfo.id }).then(r => { Api.get({ id: this.eid }).then(r => {
if (r.result) { if (r.result) {
this.entity = r.result; this.entity = r.result;
} }
...@@ -79,15 +80,16 @@ export default { ...@@ -79,15 +80,16 @@ export default {
}, },
remove(index, row) { remove(index, row) {
if (row.add == 0) {
//新增的删除,直接删 // if (row.add == 0) {
this.checkList.splice(index, 1); // //新增的删除,直接删
} else { // this.checkList.splice(index, 1);
row.action = 2; //返回的默认删除,删除后保存在arr数组中,添加标识action = 2,然后点击保存的时候,一起传给后台 // } else {
this.$set(this.checkList, index, row); // row.action = 2; //返回的默认删除,删除后保存在arr数组中,添加标识action = 2,然后点击保存的时候,一起传给后台
this.arr.push(row); // this.$set(this.checkList, index, row);
this.checkList.splice(index, 1); // this.arr.push(row);
} // this.checkList.splice(index, 1);
// }
}, },
setRow(row, index) { setRow(row, index) {
this.$set(this.checkList, index, row); this.$set(this.checkList, index, row);
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</a> </a>
</div> </div>
<Content :class="!showMenu?'con_bord':''"> <Content :class="!showMenu?'con_bord':''">
<MasterData ref="dataTable" :nodeInfo="nodeInfo" /> <MasterData ref="dataTable" :nodeInfo="nodeInfo" @on-ok="ok" />
</Content> </Content>
</Layout> </Layout>
</div> </div>
...@@ -55,7 +55,8 @@ export default { ...@@ -55,7 +55,8 @@ export default {
list: [], list: [],
nodeInfo: { nodeInfo: {
categoryId: 0, categoryId: 0,
rootCategoryId: 0 rootCategoryId: 0,
ids: []
}, },
modal: false, modal: false,
title: "新增", title: "新增",
...@@ -78,15 +79,15 @@ export default { ...@@ -78,15 +79,15 @@ export default {
}, },
ok(row) { ok(row) {
this.loadTree(); this.loadTree();
this.modal = false; // this.modal = false;
this.curId = 0; // this.curId = 0;
if (row) { // if (row) {
this.dataList.map((e, index) => { // this.dataList.map((e, index) => {
if (e.id == row.id) { // if (e.id == row.id) {
this.$set(this.$refs.dataTable.dataColumns, index, row); // this.$set(this.$refs.dataTable.dataColumns, index, row);
} // }
}); // });
} // }
}, },
cancel() { cancel() {
this.curId = 0; this.curId = 0;
...@@ -102,12 +103,15 @@ export default { ...@@ -102,12 +103,15 @@ export default {
} }
} }
}, },
data.title data.title +
"(" +
(data.totalMaterialCount == undefined
? "0"
: data.totalMaterialCount) +
")"
); );
}, },
handleSelect(root, data) { handleSelect(root, data) {
// console.log(root);
let pid = null; //定义最顶级id let pid = null; //定义最顶级id
let upId = data.upId; let upId = data.upId;
let roots = root; let roots = root;
...@@ -124,7 +128,6 @@ export default { ...@@ -124,7 +128,6 @@ export default {
}); });
} }
addId(roots, upId); addId(roots, upId);
this.nodeInfo.categoryId = data.id; this.nodeInfo.categoryId = data.id;
if (pid == null) { if (pid == null) {
this.nodeInfo.rootCategoryId = data.id; this.nodeInfo.rootCategoryId = data.id;
...@@ -151,7 +154,22 @@ export default { ...@@ -151,7 +154,22 @@ export default {
toggle() { toggle() {
this.expand = !this.expand; this.expand = !this.expand;
}, },
change(v, b) {}, change(v, b) {
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() { hide() {
this.showMenu = false; this.showMenu = false;
} }
......
<template> <template>
<div class="master-data"> <div class="master-data">
<DataGrid :columns="columns" ref="grid" :action="action" :initsearch="sets" :high="false">
<DataGrid
:columns="columns"
ref="grid"
:action="action"
:initsearch="sets"
:high="false"
:height="750"
>
<template slot="easySearch"> <template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline> <Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys"> <FormItem prop="keys">
...@@ -56,15 +64,11 @@ export default { ...@@ -56,15 +64,11 @@ export default {
v.rootCategoryId = this.nodeInfo.rootCategoryId; v.rootCategoryId = this.nodeInfo.rootCategoryId;
}, },
easySearch: { easySearch: {
keys: { op: "Code,Name", value: null } keys: { op: "code,name", value: null },
// categoryId: { categoryId: {
// op: "In", op: "In",
// value: this.nodeInfo.categoryId value: this.nodeInfo.ids
// }, }
// rootCategoryId: {
// op: "In",
// value: this.nodeInfo.rootCategoryId
// }
}, },
columns: [ columns: [
// { // {
...@@ -74,7 +78,7 @@ export default { ...@@ -74,7 +78,7 @@ export default {
// width: 60 // width: 60
// }, // },
{ {
key: "Code", key: "code",
title: "编码", title: "编码",
align: "left", align: "left",
render: (h, params) => { render: (h, params) => {
...@@ -86,17 +90,17 @@ export default { ...@@ -86,17 +90,17 @@ export default {
click: () => this.details(params.row) click: () => this.details(params.row)
} }
}, },
params.row.Code params.row.code
); );
} }
}, },
{ {
key: "Name", key: "name",
title: "名称", title: "名称",
align: "left" align: "left"
}, },
{ {
key: "Status", key: "status",
title: "状态", title: "状态",
align: "left", align: "left",
render: (h, params) => { render: (h, params) => {
...@@ -104,18 +108,18 @@ export default { ...@@ -104,18 +108,18 @@ export default {
props: { props: {
code: "materail.category.status", code: "materail.category.status",
type: "text", type: "text",
value: params.row.Status + "" value: params.row.status + ""
} }
}); });
} }
}, },
{ {
key: "Version", key: "version",
title: "版本", title: "版本",
align: "left" align: "left"
}, },
{ {
key: "Description", key: "description",
title: "描述", title: "描述",
align: "left" align: "left"
}, },
...@@ -140,7 +144,7 @@ export default { ...@@ -140,7 +144,7 @@ export default {
attrs: { oprate: "delete" }, attrs: { oprate: "delete" },
on: { click: () => this.remove(params.row.id) } on: { click: () => this.remove(params.row.id) }
}, },
params.row.children == 0 ? "删除" : "" "删除"
) )
]); ]);
} }
...@@ -151,7 +155,9 @@ export default { ...@@ -151,7 +155,9 @@ export default {
async fetch({ store, params }) { async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典 await store.dispatch("loadDictionary"); // 加载数据字典
}, },
created() {}, created() {
this.$refs.grid.reload(this.easySearch);
},
methods: { methods: {
search() { search() {
this.$refs.grid.reload(this.easySearch); this.$refs.grid.reload(this.easySearch);
...@@ -163,27 +169,37 @@ export default { ...@@ -163,27 +169,37 @@ export default {
this.modal = true; this.modal = true;
}, },
edit(row) { edit(row) {
this.nodeInfo.id = row.Id; console.log(row);
this.curId = row.id;
this.title = "编辑"; this.title = "编辑";
this.detail = () => import("./edit"); this.detail = () => import("./edit");
this.modal = true; this.modal = true;
}, },
remove(id) { remove(id) {
this.$Modal.confirm({ alert(id);
title: "删除", Api.delete(id).then(r => {
content: "<p>您确定要删除吗?</p>", if (r.success) {
onOk: () => { this.$emit("on-ok");
Api.delete(id).then(r => { this.$refs.grid.reload(this.easySearch);
if (r.success) { this.$Message.success("删除成功");
this.loadTree();
this.$Message.success("删除成功");
}
});
},
onCancel: () => {
this.$Message.success("取消删除");
} }
}); });
// this.$Modal.confirm({
// title: "删除",
// content: "<p>您确定要删除吗?</p>",
// onOk: () => {
// alert(1);
// Api.delete({ id: this.eid }).then(r => {
// if (r.success) {
// this.$emit("on-ok");
// this.$Message.success("删除成功");
// }
// });
// },
// onCancel: () => {
// this.$Message.success("取消删除");
// }
// });
}, },
details() { details() {
this.$router.push({ this.$router.push({
...@@ -201,10 +217,15 @@ export default { ...@@ -201,10 +217,15 @@ export default {
} }
}, },
watch: { watch: {
"nodeInfo.categoryId"(v) { nodeInfo: {
if (v) { handler(newName, oldName) {
this.$refs.grid.reload(this.easySearch); this.easySearch.categoryId.value = newName.ids;
} if (newName.categoryId) {
this.$refs.grid.reload(this.easySearch);
}
},
immediate: true,
deep: true
} }
} }
}; };
......
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