Commit cc6d2e40 authored by renjintao's avatar renjintao

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

parents ce4350c0 c523529d
<template> <template>
<div class="master-data"> <div class="master-data">
<DataGrid :columns="cols" ref="grid" :conditions="easySearch" :action="action" :initsearch="sets" :high="false" :format="formatFun" :height="tableHeight" @on-selection-change="onSelect" :exportTitle="exportTitle"> <DataGrid
<template slot="easySearch"> :columns="cols"
<Form ref="formInline" :model="easySearch" inline> ref="grid"
<FormItem prop="keys"> :conditions="easySearch"
<Input placeholder="请输入编码/名称/状态" v-width="200" v-model="easySearch.keys.value" clearable /> :action="action"
</FormItem> :initsearch="sets"
<FormItem> :high="false"
<Button type="primary" @click="search">查询</Button> :format="formatFun"
</FormItem> :height="tableHeight"
</Form> @on-selection-change="onSelect"
</template> :exportTitle="exportTitle"
>
<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="buttons"> <template slot="buttons">
<Button type="primary" @click="add">新增</Button> <Button type="primary" @click="add">新增</Button>
<Button @click="openModalIm">导入</Button> <Button @click="openModalIm">导入</Button>
</template> </template>
<template slot="batch"> <template slot="batch">
<Button type="primary" @click="modalSchedule">批量送审</Button> <Button type="primary" @click="modalSchedule">批量送审</Button>
</template> </template>
</DataGrid> </DataGrid>
<Modal v-model="modal" :title="title" width="1000" footer-hide :mask-closable="false" :fullscreen="fullscreen"> <Modal
<component :is="detail" :eid="curId" :rootCategoryId="rootCategoryId" :rowsTable="rowsTable" :nodeInfo="nodeInfo" @on-close="cancel" @on-cancel="cancel" @on-ok="ok" ref="chlidren" /> v-model="modal"
:title="title"
width="1000"
footer-hide
:mask-closable="false"
:fullscreen="fullscreen"
>
<component
:is="detail"
:eid="curId"
:rootCategoryId="rootCategoryId"
:rowsTable="rowsTable"
:nodeInfo="nodeInfo"
@on-close="cancel"
@on-cancel="cancel"
@on-ok="ok"
ref="chlidren"
/>
</Modal> </Modal>
<ImportExcel ref="importExcel" @on-get-data="getData" :modalTitle="temTitle" :columns="cols" :open="ModalIm" @on-cancel="ModalImCancel" @on-ok="ok" /> <ImportExcel
</div> ref="importExcel"
@on-get-data="getData"
:modalTitle="temTitle"
:columns="cols"
:open="ModalIm"
@on-cancel="ModalImCancel"
@on-ok="ok"
/>
</div>
</template> </template>
<script> <script>
import Api from "./api"; import Api from "./api";
// import Search from "./search"; // import Search from "./search";
export default { export default {
name: "masterData", name: "masterData",
components: { components: {
// Search // Search
}, },
props: ["nodeInfo"], props: ["nodeInfo"],
data() { data() {
return { return {
action: Api.index, action: Api.index,
tableHeight: "", tableHeight: "",
modal: false, modal: false,
title: "新增", title: "新增",
curId: 0, curId: 0,
rootCategoryId: 0, rootCategoryId: 0,
selectRows: [], selectRows: [],
rowsTable: [], rowsTable: [],
fullscreen: false, fullscreen: false,
treeData: [], treeData: [],
codeRuleData: [], codeRuleData: [],
detail: null, detail: null,
temTitle: "物料管理", temTitle: "物料管理",
sets: v => { sets: (v) => {
v.categoryId = this.nodeInfo.categoryId; v.categoryId = this.nodeInfo.categoryId;
v.rootCategoryId = this.nodeInfo.rootCategoryId; v.rootCategoryId = this.nodeInfo.rootCategoryId;
}, },
easySearch: { easySearch: {
keys: { keys: {
op: "code,name", op: "code,name",
value: null value: null,
},
categoryId: {
op: "In",
value: this.nodeInfo.ids
}
},
columns: [{
type: "selection",
width: 70,
align: "center"
},
{
key: "codeRuleType",
title: "类型",
align: "center",
code: "material.code.type",
import: true,
hide: true,
},
{
key: "codeRuleId",
title: "编码名称",
materialKey: '3',
import: true,
hide: true,
render: (h, params) => {
return h(
"span", {},
this.getType3(params.row.codeRuleId)
);
}
},
{
key: "rootCategoryId",
title: "大类",
align: "right",
materialKey: '1',
import: true,
hide: true,
render: (h, params) => {
return h(
"span", {},
this.getType1(params.row.rootCategoryId)
);
}
},
{
key: "categoryId",
title: "子类",
align: "right",
materialKey: '2',
import: true,
hide: true,
render: (h, params) => {
return h(
"span", {},
this.getType2(params.row.categoryId)
);
}
},
{
key: "code",
title: "编码",
align: "left",
render: (h, params) => {
return h(
"a", {
props: {},
on: {
click: () => this.details(params.row)
}
},
!params.row.code || params.row.code == 0 ? "未分配" : params.row.code
);
}
},
{
key: "name",
title: "名称",
align: "left"
},
{
key: "status",
title: "状态",
align: "center",
code: "material.main.status",
},
{
key: "version",
title: "版本",
align: "left",
code: "material.main.version"
},
{
key: "drawing",
title: "图号",
align: "left"
},
{
key: "creationTime",
title: "创建时间",
hide: true,
align: "left",
type: "date"
},
{
key: "creatorUserId",
title: "创建人",
hide: true,
align: "left",
type: "user"
},
{
title: "操作",
key: "action",
width: 150,
align: "left",
render: (h, params) => {
return h("div", {
class: "action"
}, [
h(
"op", {
attrs: {
oprate: "edit"
},
on: {
click: () => this.edit(params.row)
}
},
"编辑"
),
h(
"op", {
attrs: {
oprate: "delete"
},
on: {
click: () => this.remove(params.row.id)
}
},
params.row.status == 3 ? "" : "删除"
),
h(
"op", {
attrs: {
oprate: "edit"
},
on: {
click: () => this.send(params.row)
}
},
(params.row.status == 0 || params.row.status == 1) &&
this.status == 0 ?
"送审" :
""
)
]);
}
}
], //基础咧
cols: [], //
status: null,
ModalIm: false,
addCol: [],
exportTitle: '物料管理',
};
},
async fetch({
store,
params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
this.tableHeight = window.innerHeight - 220;
if (this.nodeInfo.rootCategoryId == 0) {
this.cols = this.columns;
} else {
this.initCols();
}
Api.getbyid({
id: "b6303ddc-8b5e-40a3-a51b-294657d1d913"
}).then(r => {
this.status = r.result.status; //status为0的话为启用,有送审,为1的话,流程是禁用的,没有送审按钮
this.nodeInfo.status = this.status;
});
},
mounted() {
this.getTreeData()
this.getcodeRuleData()
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
this.tableHeight = window.innerHeight - 220;
})();
};
},
methods: {
//格式化原始数据
formatFun(data) {
data.map(e => {
if (e.status == 0) {
e._disabled = false;
} else {
e._disabled = true;
}
});
return data;
}, },
onSelect(a, b) { categoryId: {
// console.log(a); op: "In",
// console.log(b); value: this.nodeInfo.ids,
//批量选择
this.rootCategoryId = a[0].rootCategoryId;
this.selectRows = a;
}, },
modalSchedule() { },
this.fullscreen = true; columns: [
this.rowsTable = this.selectRows; {
this.title = "物料送审"; type: "selection",
this.curId = 0; width: 70,
this.detail = () => import("./submit"); align: "center",
this.modal = true;
}, },
search() { {
this.$refs.grid.reload(this.easySearch); key: "codeRuleType",
title: "类型",
align: "center",
code: "material.code.type",
import: true,
hide: true,
}, },
initCols(delay) { {
let conditions = [{ key: "codeRuleId",
conditionalType: "Equal", title: "编码名称",
fieldName: "categoryId", materialKey: "3",
fieldValue: this.nodeInfo.rootCategoryId import: true,
}]; hide: true,
render: (h, params) => {
Api.listTable({ return h("span", {}, this.getType3(params.row.codeRuleId));
conditions: conditions, },
sortBy: "id",
isDesc: false
}).then(r => {
if (r.result) {
var items = r.result.filter(u => {
return (
!this.columns.some(p => {
return p.key == u.field;
}) && u.dataType != 5
);
});
this.addCol = items;
this.cols = this.$u.clone(this.columns);
let extra = items.map(u => {
// console.log(u);
var col = {
key: u.field,
title: u.title
};
if (u.dataType == 3) {
col.code = u.note;
}
if (u.dataType == 4) {
col.type = "date";
}
if (u.unitName && (u.dataType == 1 || u.dataType == 2)) {
var units = this.$store.getters.dictionaryByKey(
"material.main.unitName"
);
let item = units.filter(p => {
return p.code == u.unitName;
});
// console.log(units, item);
col.title += "(" + item[0].name + ")";
}
return col;
});
this.cols = this.cols.concat(extra);
var action = this.cols.splice(this.columns.length - 1, 1);
this.cols.push(this.columns[this.columns.length - 1]);
if (delay) {
delay();
}
// console.log(this.cols)
}
});
this.exportTitle = "物料管理-" + this.nodeInfo.rootCategoryName;
}, },
add() { {
if (this.nodeInfo.categoryId) { key: "rootCategoryId",
if (this.nodeInfo.addChange == true) { title: "大类",
this.fullscreen = false; align: "right",
this.curId = 0; materialKey: "1",
this.title = "新增"; import: true,
this.detail = () => import("./add"); hide: true,
this.modal = true; render: (h, params) => {
} else { return h("span", {}, this.getType1(params.row.rootCategoryId));
this.$Message.error("请在设置的分类层级数下添加物料"); },
}
} else {
this.$Message.error("请先选择分类");
}
}, },
edit(row) { {
this.fullscreen = false; key: "categoryId",
this.curId = row.id; title: "子类",
this.title = "编辑"; align: "right",
this.detail = () => import("./edit"); materialKey: "2",
this.modal = true; import: true,
hide: true,
render: (h, params) => {
return h("span", {}, this.getType2(params.row.categoryId));
},
}, },
remove(id) { {
Api.delete(id).then(r => { key: "code",
if (r.success) { title: "编码",
this.$refs.grid.reload(this.easySearch); align: "left",
this.$Message.success("删除成功"); render: (h, params) => {
} return h(
}); "a",
{
props: {},
on: {
click: () => this.details(params.row),
},
},
!params.row.code || params.row.code == 0
? "未分配"
: params.row.code
);
},
}, },
details(row) { {
this.fullscreen = true; key: "name",
this.curId = row.id; title: "名称",
this.rootCategoryId = row.rootCategoryId; align: "left",
this.title = "详情";
this.detail = () => import("./details");
this.rowsTable = [];
this.modal = true;
}, },
send(row) { {
this.fullscreen = true; key: "status",
this.curId = row.id; title: "状态",
this.rootCategoryId = row.rootCategoryId; align: "center",
this.title = "物料送审"; code: "material.main.status",
this.detail = () => import("./submit");
this.rowsTable = [];
this.modal = true;
}, },
ok() { {
this.$refs.grid.reload(this.easySearch); key: "version",
this.modal = false; title: "版本",
this.ModalIm = false; align: "left",
this.curId = 0; code: "material.main.version",
}, },
cancel() { {
this.curId = 0; key: "drawing",
this.modal = false; title: "图号",
align: "left",
}, },
//批量导入start {
//导入功能 key: "creationTime",
openModalIm() { title: "创建时间",
if (this.nodeInfo.categoryId) { hide: true,
this.ModalIm = true align: "left",
} else { type: "date",
this.$Message.error("请先选择分类");
}
}, },
ModalImCancel() { {
this.ModalIm = false key: "creatorUserId",
title: "创建人",
hide: true,
align: "left",
type: "user",
}, },
getData(val) { {
let url = `${material}/materialimportservice/import`; title: "操作",
this.$refs.importExcel.deelData(url, this.cols, this.formatMethod(val)) key: "action",
width: 150,
align: "left",
render: (h, params) => {
return h(
"div",
{
class: "action",
},
[
h(
"op",
{
attrs: {
oprate: "edit",
},
on: {
click: () => this.edit(params.row),
},
},
params.row.status == 3 ? "" : "编辑"
),
h(
"op",
{
attrs: {
oprate: "delete",
},
on: {
click: () => this.remove(params.row.id),
},
},
params.row.status == 3 ? "" : "删除"
),
h(
"op",
{
attrs: {
oprate: "edit",
},
on: {
click: () => this.send(params.row),
},
},
(params.row.status == 0 || params.row.status == 1) &&
this.status == 0
? "送审"
: ""
),
]
);
},
}, },
//根据页面二次处理数据 ], //基础咧
formatMethod(val) { cols: [], //
let tempData = this.$u.clone(val); status: null,
let tempList = []; ModalIm: false,
tempData.forEach((ele) => { addCol: [],
let obj = { exportTitle: "物料管理",
name: ele.name ? ele.name : '', };
version: ele.version ? Number(ele.version) : '', },
drawing: ele.drawing ? ele.drawing : '', async fetch({ store, params }) {
description: ele.description ? ele.description : "", await store.dispatch("loadDictionary"); // 加载数据字典
code: 0, },
status: this.nodeInfo.status == 1 ? 3 : 0, created() {
codeRuleId: this.nodeInfo.codeRuleId, this.tableHeight = window.innerHeight - 220;
categoryId: this.nodeInfo.categoryId, //左侧树点击的id
customProperties: {},
rootCategoryId: this.nodeInfo.rootCategoryId, //左侧树点击的数据的最顶层id
codeRuleType: this.nodeInfo.codeRuleType
};
this.addCol.forEach(el => {
obj[el.field] = ele[el.field]
})
if (ele.name && ele.name != '') {
obj.ico = false
} else {
obj.ico = true
}
tempList.push(obj);
}); if (this.nodeInfo.rootCategoryId == 0) {
return tempList this.cols = this.columns;
} else {
}, this.initCols();
//批量导入end }
//物料大类和子类的解析start Api.getbyid({
getTreeData() { id: "b6303ddc-8b5e-40a3-a51b-294657d1d913",
let data = { }).then((r) => {
conditions: [] this.status = r.result.status; //status为0的话为启用,有送审,为1的话,流程是禁用的,没有送审按钮
}; this.nodeInfo.status = this.status;
Api.list(data).then((r) => { });
this.treeData = r.result },
}); mounted() {
}, this.getTreeData();
getType1(val) { this.getcodeRuleData();
let tempTreeList = this.$u.clone(this.treeData) window.onresize = () => {
let rootName = "" ///浏览器窗口大小变化
tempTreeList.forEach(ele => { return (() => {
if (ele.upId == 0 && ele.id == val) { window.screenHeight = window.innerHeight;
rootName = ele.name this.tableHeight = window.innerHeight - 220;
} })();
}) };
return rootName },
}, methods: {
getType2(val) { //格式化原始数据
let tempTreeList = this.$u.clone(this.treeData) formatFun(data) {
let childrenName = "" data.map((e) => {
tempTreeList.forEach(ele => { if (e.status == 0) {
if (ele.upId > 0 && ele.id == val) { e._disabled = false;
childrenName = ele.name } else {
} e._disabled = true;
}) }
return childrenName });
return data;
},
onSelect(a, b) {
// console.log(a);
// console.log(b);
//批量选择
this.rootCategoryId = a[0].rootCategoryId;
this.selectRows = a;
},
modalSchedule() {
this.fullscreen = true;
this.rowsTable = this.selectRows;
this.title = "物料送审";
this.curId = 0;
this.detail = () => import("./submit");
this.modal = true;
},
search() {
this.$refs.grid.reload(this.easySearch);
},
initCols(delay) {
let conditions = [
{
conditionalType: "Equal",
fieldName: "categoryId",
fieldValue: this.nodeInfo.rootCategoryId,
}, },
//获取编码名称 ];
getcodeRuleData() {
let data = { Api.listTable({
conditions: [] conditions: conditions,
sortBy: "id",
isDesc: false,
}).then((r) => {
if (r.result) {
var items = r.result.filter((u) => {
return (
!this.columns.some((p) => {
return p.key == u.field;
}) && u.dataType != 5
);
});
this.addCol = items;
this.cols = this.$u.clone(this.columns);
let extra = items.map((u) => {
// console.log(u);
var col = {
key: u.field,
title: u.title,
}; };
Api.pagedSlecet(data).then((r) => { if (u.dataType == 3) {
if (r.success) { col.code = u.note;
this.codeRuleData = r.result.items || [] }
} if (u.dataType == 4) {
}); col.type = "date";
}, }
getType3(val) { if (u.unitName && (u.dataType == 1 || u.dataType == 2)) {
let codeRuleDataList = this.$u.clone(this.codeRuleData) var units = this.$store.getters.dictionaryByKey(
let codeRuleName = "" "material.main.unitName"
codeRuleDataList.forEach(ele => { );
if (ele.id == val) {
codeRuleName = ele.name let item = units.filter((p) => {
} return p.code == u.unitName;
}) });
return codeRuleName // console.log(units, item);
}, col.title += "(" + item[0].name + ")";
//物料大类和子类的解析end }
return col;
});
this.cols = this.cols.concat(extra);
var action = this.cols.splice(this.columns.length - 1, 1);
this.cols.push(this.columns[this.columns.length - 1]);
if (delay) {
delay();
}
// console.log(this.cols)
}
});
this.exportTitle = "物料管理-" + this.nodeInfo.rootCategoryName;
}, },
watch: { add() {
nodeInfo: { if (this.nodeInfo.categoryId) {
handler(newName, oldName) { if (this.nodeInfo.addChange == true) {
// console.log("ovo", newName, oldName); this.fullscreen = false;
this.temTitle = "物料管理(" + newName.rootCategoryName + ")" this.curId = 0;
if (newName.rootCategoryId) { this.title = "新增";
this.initCols(() => { this.detail = () => import("./add");
if (newName.categoryId) { this.modal = true;
this.easySearch.categoryId.value = newName.ids; } else {
this.$refs.grid.reload(this.easySearch); this.$Message.error("请在设置的分类层级数下添加物料");
} }
}); } else {
} this.$Message.error("请先选择分类");
if (!newName.categoryId) { }
this.easySearch.categoryId.value = "-1"; },
} edit(row) {
}, this.fullscreen = false;
immediate: true, this.curId = row.id;
deep: true this.title = "编辑";
}, this.detail = () => import("./edit");
} this.modal = true;
},
remove(id) {
Api.delete(id).then((r) => {
if (r.success) {
this.$refs.grid.reload(this.easySearch);
this.$Message.success("删除成功");
}
});
},
details(row) {
this.fullscreen = true;
this.curId = row.id;
this.rootCategoryId = row.rootCategoryId;
this.title = "详情";
this.detail = () => import("./details");
this.rowsTable = [];
this.modal = true;
},
send(row) {
this.fullscreen = true;
this.curId = row.id;
this.rootCategoryId = row.rootCategoryId;
this.title = "物料送审";
this.detail = () => import("./submit");
this.rowsTable = [];
this.modal = true;
},
ok() {
this.$refs.grid.reload(this.easySearch);
this.modal = false;
this.ModalIm = false;
this.curId = 0;
},
cancel() {
this.curId = 0;
this.modal = false;
},
//批量导入start
//导入功能
openModalIm() {
if (this.nodeInfo.categoryId) {
this.ModalIm = true;
} else {
this.$Message.error("请先选择分类");
}
},
ModalImCancel() {
this.ModalIm = false;
},
getData(val) {
let url = `${material}/materialimportservice/import`;
this.$refs.importExcel.deelData(url, this.cols, this.formatMethod(val));
},
//根据页面二次处理数据
formatMethod(val) {
let tempData = this.$u.clone(val);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
name: ele.name ? ele.name : "",
version: ele.version ? Number(ele.version) : "",
drawing: ele.drawing ? ele.drawing : "",
description: ele.description ? ele.description : "",
code: 0,
status: this.nodeInfo.status == 1 ? 3 : 0,
codeRuleId: this.nodeInfo.codeRuleId,
categoryId: this.nodeInfo.categoryId, //左侧树点击的id
customProperties: {},
rootCategoryId: this.nodeInfo.rootCategoryId, //左侧树点击的数据的最顶层id
codeRuleType: this.nodeInfo.codeRuleType,
};
this.addCol.forEach((el) => {
obj[el.field] = ele[el.field];
});
if (ele.name && ele.name != "") {
obj.ico = false;
} else {
obj.ico = true;
}
tempList.push(obj);
});
return tempList;
},
//批量导入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;
},
//获取编码名称
getcodeRuleData() {
let data = {
conditions: [],
};
Api.pagedSlecet(data).then((r) => {
if (r.success) {
this.codeRuleData = r.result.items || [];
}
});
},
getType3(val) {
let codeRuleDataList = this.$u.clone(this.codeRuleData);
let codeRuleName = "";
codeRuleDataList.forEach((ele) => {
if (ele.id == val) {
codeRuleName = ele.name;
}
});
return codeRuleName;
},
//物料大类和子类的解析end
},
watch: {
nodeInfo: {
handler(newName, oldName) {
// console.log("ovo", newName, oldName);
this.temTitle = "物料管理(" + newName.rootCategoryName + ")";
if (newName.rootCategoryId) {
this.initCols(() => {
if (newName.categoryId) {
this.easySearch.categoryId.value = newName.ids;
this.$refs.grid.reload(this.easySearch);
}
});
}
if (!newName.categoryId) {
this.easySearch.categoryId.value = "-1";
}
},
immediate: true,
deep: true,
},
},
}; };
</script> </script>
<style lang="less"> <style lang="less">
.master-data { .master-data {
.ivu-footer-toolbar-right { .ivu-footer-toolbar-right {
margin-right: 72% !important; margin-right: 72% !important;
} }
} }
</style> </style>
<template> <template>
<div> <div>
<div class="mb10 pt5"> <div class="mb10 pt5">
<Input v-model="searchValue" placeholder="请输入库位名称" clearable style="width: 240px" /> <Input
v-model="searchValue"
placeholder="请输入库位名称"
clearable
style="width: 240px"
/>
<Button type="primary" class @click="handleSearch">查询</Button> <Button type="primary" class @click="handleSearch">查询</Button>
<div class="fr"> <div class="fr">
<Button type="primary" @click="add()">新增库位</Button> <Button type="primary" @click="add()">新增库位</Button>
...@@ -78,6 +83,12 @@ export default { ...@@ -78,6 +83,12 @@ export default {
title: "物料编号", title: "物料编号",
align: "left", align: "left",
}, },
{
key: "materialType",
title: "物料类型",
align: "left",
code: "material.main.type",
},
{ {
key: "userName", key: "userName",
title: this.l("userName"), title: this.l("userName"),
......
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