Commit 0a7df8a0 authored by renjintao's avatar renjintao

物料管理

parent b582466d
...@@ -100,6 +100,7 @@ export default { ...@@ -100,6 +100,7 @@ export default {
userConfig: null, //用户页面配置信息。, userConfig: null, //用户页面配置信息。,
// userId: 1 // userId: 1
userId: this.$store.state.userInfo.userId, userId: this.$store.state.userInfo.userId,
treeData: [], //物料数据
}; };
}, },
props: { props: {
...@@ -271,6 +272,8 @@ export default { ...@@ -271,6 +272,8 @@ export default {
this.$dragging.$on("dragend", (e) => { this.$dragging.$on("dragend", (e) => {
this.saveUserconfig(); this.saveUserconfig();
}); });
//物料加载类型数据
this.getTreeData()
}, },
methods: { methods: {
//数据加载 //数据加载
...@@ -513,6 +516,7 @@ export default { ...@@ -513,6 +516,7 @@ export default {
const tHeader = []; // 设置Excel的表格第一行的标题 const tHeader = []; // 设置Excel的表格第一行的标题
const filterVal = []; //list里对象的属性 const filterVal = []; //list里对象的属性
var tempCol = []; var tempCol = [];
var tempCol1 = [];
var columnsCur = this.$u.clone(this.columnsNow); //导出列标题信息griddata this.$refs.grid.columnsCur var columnsCur = this.$u.clone(this.columnsNow); //导出列标题信息griddata this.$refs.grid.columnsCur
columnsCur.forEach((el) => { columnsCur.forEach((el) => {
if ((el.hide && !el.import) || (!el.hide && el.key != "action" && el.type != "selection" && el.key != "ico")) { if ((el.hide && !el.import) || (!el.hide && el.key != "action" && el.type != "selection" && el.key != "ico")) {
...@@ -522,6 +526,12 @@ export default { ...@@ -522,6 +526,12 @@ export default {
code: el.code code: el.code
}); //临时存放code数据字典的字段及对应的数据字典code }); //临时存放code数据字典的字段及对应的数据字典code
} }
if (el.materialKey) {
tempCol1.push({
key: el.key,
code: el.materialKey
}); //临时存放物料管理大类和子类列表
}
tHeader.push(el.title); tHeader.push(el.title);
filterVal.push(el.key); filterVal.push(el.key);
} }
...@@ -534,7 +544,16 @@ export default { ...@@ -534,7 +544,16 @@ export default {
e[ele.key] e[ele.key]
); );
}); });
tempCol1.forEach((elcol1) => {
if (elcol1.code == 1) {
e[elcol1.key] = this.getType1(e[elcol1.key])
} else if (elcol1.code == 2) {
e[elcol1.key] = this.getType2(e[elcol1.key])
}
});
}); });
let nowDate = this.$u.getNowTime(); //年月日时分秒yyyyMMddhhmmss let nowDate = this.$u.getNowTime(); //年月日时分秒yyyyMMddhhmmss
//获取导出数据结束 //获取导出数据结束
this.$u.outExcel(this.exportTitle + this.$u.outExcel(this.exportTitle +
...@@ -545,6 +564,36 @@ export default { ...@@ -545,6 +564,36 @@ export default {
); );
}); });
}, },
//物料大类和子类的解析start
getTreeData() {
let data = {
conditions: []
};
this.$api.post(`${material}/category/list`, data).then((r) => {
this.treeData = r.result
});
},
getType1(val) {
let tempTreeList = this.$u.clone(this.treeData)
let rootName = ""
tempTreeList.forEach(ele => {
if (ele.upId == 0 && ele.id == val) {
rootName = ele.name
}
})
return rootName
},
getType2(val) {
let tempTreeList = this.$u.clone(this.treeData)
let childrenName = ""
tempTreeList.forEach(ele => {
if (ele.upId > 0 && ele.id == val) {
childrenName = ele.name
}
})
return childrenName
},
//物料大类和子类的解析end
}, },
computed: { computed: {
columnsNow() { columnsNow() {
......
...@@ -236,7 +236,6 @@ export default { ...@@ -236,7 +236,6 @@ export default {
} }
}); });
} }
arrTitleUse.forEach((elem) => { arrTitleUse.forEach((elem) => {
if (eles[elem.key] && eles[elem.key] != "" && eles[elem.key] != null) { if (eles[elem.key] && eles[elem.key] != "" && eles[elem.key] != null) {
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值 //如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值
...@@ -246,9 +245,9 @@ export default { ...@@ -246,9 +245,9 @@ export default {
); );
} }
}); });
}) })
this.dataIm = useData; this.dataIm = useData;
let tempData = this.$u.clone(this.dataIm); let tempData = this.$u.clone(this.dataIm);
this.$emit("on-get-data", tempData) this.$emit("on-get-data", tempData)
}, },
......
...@@ -233,28 +233,28 @@ export default { ...@@ -233,28 +233,28 @@ export default {
key: "creatorUserId", key: "creatorUserId",
title: this.l("creatorUserId"), title: this.l("creatorUserId"),
align: "left", align: "left",
import: false, import: true,
hide: true, hide: true,
}, },
{ {
key: "creationTime", key: "creationTime",
title: this.l("creationTime"), title: this.l("creationTime"),
align: "left", align: "left",
import: false, import: true,
hide: true, hide: true,
}, },
{ {
key: "lastModifierUserId", key: "lastModifierUserId",
title: this.l("lastModifierUserId"), title: this.l("lastModifierUserId"),
align: "left", align: "left",
import: false, import: true,
hide: true, hide: true,
}, },
{ {
key: "lastModificationTime", key: "lastModificationTime",
title: this.l("lastModificationTime"), title: this.l("lastModificationTime"),
align: "left", align: "left",
import: false, import: true,
hide: true, hide: true,
}, },
{ {
...@@ -262,7 +262,6 @@ export default { ...@@ -262,7 +262,6 @@ export default {
key: "action", key: "action",
width: 180, width: 180,
align: "right", align: "right",
import: false,
render: (h, params) => { render: (h, params) => {
return h( return h(
"div", { "div", {
......
<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 <DropdownItem v-for="item in cityList" :key="item.id" :name="item.id">{{ item.name }}</DropdownItem>
v-for="item in cityList" </DropdownMenu>
:key="item.id" </Dropdown>
:name="item.id" <div class="fr mr10 mt10">
>{{ item.name }}</DropdownItem> <ButtonGroup class="fr ddi" size="small">
</DropdownMenu> <Button :icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'" @click="toggle" title="展开/合并"></Button>
</Dropdown> <Button icon="md-refresh" title="刷新" @click="loadTree(model8,nodeInfo.codeRuleType)"></Button>
<div class="fr mr10 mt10"> <Button icon="md-rewind" title="收起" @click="hide"></Button>
<ButtonGroup class="fr ddi" size="small"> </ButtonGroup>
<Button </div>
:icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'" </h3>
@click="toggle" <div class="search">
title="展开/合并" <Input search placeholder="关键字" v-model="keys" clearable />
></Button> </div>
<Button <div class="fg">
icon="md-refresh" <div class="tree">
title="刷新" <Tree :data="data" ref="tree" @on-select-change="change" :render="renderContent"></Tree>
@click="loadTree(model8,nodeInfo.codeRuleType)" </div>
></Button> </div>
<Button icon="md-rewind" title="收起" @click="hide"></Button>
</ButtonGroup>
</div> </div>
</h3> </Sider>
<div class="search"> <div v-if="!showMenu" class="show_menu">
<Input search placeholder="关键字" v-model="keys" clearable /> <a class="menu_play fr" @click="showMenuFn" title="展开">
</div> <Icon type="ios-arrow-forward" size="24" />
<div class="fg"> </a>
<div class="tree">
<Tree :data="data" ref="tree" @on-select-change="change" :render="renderContent"></Tree>
</div>
</div>
</div> </div>
</Sider> <Content :class="!showMenu?'con_bord':''">
<div v-if="!showMenu" class="show_menu"> <MasterData ref="dataTable" :nodeInfo="nodeInfo" @on-ok="ok" />
<a class="menu_play fr" @click="showMenuFn" title="展开"> </Content>
<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>
...@@ -60,320 +48,325 @@ import MasterData from "./masterData.vue"; ...@@ -60,320 +48,325 @@ 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) {
console.log(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);
},
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);
});
}, },
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: [],
showMenuFn() { rootCategoryId: null,
//this.$Message.info("展开左侧树") categoryId: null,
this.showMenu = true; };
}, },
ok(row) { async fetch({
this.loadTree(this.nodeInfo.codeRuleId, this.nodeInfo.codeRuleType); store,
// this.modal = false; params
// this.curId = 0; }) {
// if (row) { await store.dispatch("loadDictionary"); // 加载数据字典
// this.dataList.map((e, index) => {
// if (e.id == row.id) {
// this.$set(this.$refs.dataTable.dataColumns, index, row);
// }
// });
// }
}, },
cancel() { created() {
this.curId = 0; // this.loadTree();
this.modal = false; this.listSlecet();
}, },
renderContent(h, { root, node, data }) { methods: {
return h( clickItem(val) {
"span", console.log(val);
{ this.nodeInfo.codeRuleId = val;
on: { this.model8 = val;
click: () => { this.cityList.forEach((e) => {
this.handleSelect(root, data); //手动选择树节点 if (val == e.id) {
}, this.downName = e.name;
}, this.nodeInfo.codeRuleType = e.type;
}
});
this.loadTree(this.nodeInfo.codeRuleId, this.nodeInfo.codeRuleType);
},
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);
});
}, },
data.title +
"(" +
(data.totalMaterialCount == undefined
? "0"
: data.totalMaterialCount) +
")"
);
},
handleSelect(root, data) {
let pid = -1; //定义最顶级id
var pname = "";
var upId = data.upId;
let roots = root;
function addId(roots, upId) { showMenuFn() {
roots.map((u) => { //this.$Message.info("展开左侧树")
if (u.node.id == upId) { this.showMenu = true;
if (u.node.upId == 0) { },
pid = u.node.id; ok(row) {
pname = u.node.name; this.loadTree(this.nodeInfo.codeRuleId, this.nodeInfo.codeRuleType);
} else { // this.modal = false;
upId = u.node.upId; // this.curId = 0;
addId(roots, upId); // 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) {
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);
}
}
});
} }
}
});
}
addId(roots, upId); addId(roots, upId);
this.nodeInfo.categoryId = data.id; this.nodeInfo.categoryId = data.id;
this.nodeInfo.rootCategoryName = data.name; this.nodeInfo.rootCategoryName = data.name;
if (pid == -1) { if (pid == -1) {
this.nodeInfo.rootCategoryId = data.id; this.nodeInfo.rootCategoryId = data.id;
this.nodeInfo.rootCategoryName = data.name; this.nodeInfo.rootCategoryName = data.name;
} else { } else {
this.nodeInfo.rootCategoryId = pid; this.nodeInfo.rootCategoryId = pid;
this.nodeInfo.rootCategoryName = pname; this.nodeInfo.rootCategoryName = pname;
} }
}, },
loadTree(id, codeRuleType) { loadTree(id, codeRuleType) {
let data = { let data = {
conditions: [ conditions: [{
{ fieldName: "codeRuleId",
fieldName: "codeRuleId", fieldValue: id,
fieldValue: id, conditionalType: "Equal",
conditionalType: "Equal", },
}, {
{ fieldName: "codeRuleType",
fieldName: "codeRuleType", fieldValue: codeRuleType,
fieldValue: codeRuleType, conditionalType: "Equal",
conditionalType: "Equal", },
}, ],
], sortBy: "code",
sortBy: "code", isDesc: false,
isDesc: false, };
}; Api.list(data).then((r) => {
Api.list(data).then((r) => { var data = this.$u.toTree(
var data = this.$u.toTree( r.result,
r.result, 0,
0, (u) => {
(u) => { u.title = u.code + u.name;
u.title = u.code + u.name; u.value = u.id;
u.value = u.id; u.expand = true;
u.expand = true; },
}, "upId"
"upId" );
); this.list = this.$u.clone(data);
this.list = this.$u.clone(data); });
}); },
}, toggle() {
toggle() { if (this.model8) {
if (this.model8) { this.expand = !this.expand;
this.expand = !this.expand; } else {
} else { this.$Message.error("请先选择类型");
this.$Message.error("请先选择类型"); }
} },
}, change(v, b) {
change(v, b) { if (b.level < b.ruleLevel && b.children.length > 0) {
if (b.level < b.ruleLevel && b.children.length > 0) { this.nodeInfo.addChange = false;
this.nodeInfo.addChange = false; } else {
} else { this.nodeInfo.addChange = true;
this.nodeInfo.addChange = true; }
} let ids = [];
let ids = []; ids.push(b.value);
ids.push(b.value); 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.value);
if (u.children) { if (u.children) {
addId(u.children); addId(u.children);
}
});
}
} }
}); this.nodeInfo.ids = ids;
} },
} hide() {
this.nodeInfo.ids = ids; this.showMenu = false;
}, },
hide() {
this.showMenu = false;
}, },
}, computed: {
computed: { data() {
data() { let items = this.$u.clone(this.list);
let items = this.$u.clone(this.list); let expand = this.expand;
let expand = this.expand; let result = [];
let result = []; search(this.keys, items);
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 { .menu_play {
width: 30px; width: 30px;
height: 30px; height: 30px;
line-height: 34px; line-height: 34px;
font-size: 14px; font-size: 14px;
text-align: center; text-align: center;
color: #515a6e; color: #515a6e;
border-top-right-radius: 5px; border-top-right-radius: 5px;
border-bottom-right-radius: 5px; border-bottom-right-radius: 5px;
background: #ffffff; background: #ffffff;
box-shadow: #ccc 2px 2px 4px 1px; box-shadow: #ccc 2px 2px 4px 1px;
} }
.menu_play:hover { .menu_play:hover {
background-color: #2d8cf0; background-color: #2d8cf0;
color: white; color: white;
}
} }
}
.ivu-layout-content { .ivu-layout-content {
// margin-left: 5px; // margin-left: 5px;
background: rgba(255, 255, 255, 1); background: rgba(255, 255, 255, 1);
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15); box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
overflow: auto; overflow: auto;
padding: 10px; padding: 10px;
height: 88vh; height: 88vh;
overflow-y: hidden; overflow-y: hidden;
} }
} }
</style> </style>
...@@ -47,6 +47,7 @@ export default { ...@@ -47,6 +47,7 @@ export default {
selectRows: [], selectRows: [],
rowsTable: [], rowsTable: [],
fullscreen: false, fullscreen: false,
treeData: [],
detail: null, detail: null,
temTitle: "物料管理", temTitle: "物料管理",
sets: v => { sets: v => {
...@@ -76,13 +77,27 @@ export default { ...@@ -76,13 +77,27 @@ export default {
}, },
{ {
key: "rootCategoryId", key: "rootCategoryId",
title: "大类编号", title: "大类",
align: "right", align: "right",
materialKey: '1',
render: (h, params) => {
return h(
"span", {},
this.getType1(params.row.rootCategoryId)
);
}
}, },
{ {
key: "categoryId", key: "categoryId",
title: "子类编号", title: "子类",
align: "right", align: "right",
materialKey: '2',
render: (h, params) => {
return h(
"span", {},
this.getType2(params.row.categoryId)
);
}
}, },
{ {
key: "code", key: "code",
...@@ -214,6 +229,7 @@ export default { ...@@ -214,6 +229,7 @@ export default {
}); });
}, },
mounted() { mounted() {
this.getTreeData()
window.onresize = () => { window.onresize = () => {
///浏览器窗口大小变化 ///浏览器窗口大小变化
return (() => { return (() => {
...@@ -401,6 +417,8 @@ export default { ...@@ -401,6 +417,8 @@ export default {
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
//codeRuleType: ele.codeRuleType ? Number(ele.codeRuleType) : ''
}; };
this.addCol.forEach(el => { this.addCol.forEach(el => {
obj[el.field] = ele[el.field] obj[el.field] = ele[el.field]
...@@ -417,6 +435,36 @@ export default { ...@@ -417,6 +435,36 @@ export default {
}, },
//批量导入end //批量导入end
//物料大类和子类的解析start
getTreeData() {
let data = {
conditions: []
};
Api.list(data).then((r) => {
this.treeData = r.result
});
},
getType1(val) {
let tempTreeList = this.$u.clone(this.treeData)
let rootName = ""
tempTreeList.forEach(ele => {
if (ele.upId == 0 && ele.id == val) {
rootName = ele.name
}
})
return rootName
},
getType2(val) {
let tempTreeList = this.$u.clone(this.treeData)
let childrenName = ""
tempTreeList.forEach(ele => {
if (ele.upId > 0 && ele.id == val) {
childrenName = ele.name
}
})
return childrenName
},
//物料大类和子类的解析end
}, },
watch: { watch: {
nodeInfo: { nodeInfo: {
......
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