Commit 7cd863e9 authored by 仇晓婷's avatar 仇晓婷

87bug

parent 2395cf89
<template>
<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">
<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>
<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"
>
<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">
<Button type="primary" @click="add">新增</Button>
<Button @click="openModalIm">导入</Button>
</template>
<template slot="batch">
<Button type="primary" @click="modalSchedule">批量送审</Button>
</template>
<template slot="buttons">
<Button type="primary" @click="add">新增</Button>
<Button @click="openModalIm">导入</Button>
</template>
<template slot="batch">
<Button type="primary" @click="modalSchedule">批量送审</Button>
</template>
</DataGrid>
<Modal 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
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>
<ImportExcel ref="importExcel" @on-get-data="getData" :modalTitle="temTitle" :columns="cols" :open="ModalIm" @on-cancel="ModalImCancel" @on-ok="ok" />
</div>
<ImportExcel
ref="importExcel"
@on-get-data="getData"
:modalTitle="temTitle"
:columns="cols"
:open="ModalIm"
@on-cancel="ModalImCancel"
@on-ok="ok"
/>
</div>
</template>
<script>
import Api from "./api";
// import Search from "./search";
export default {
name: "masterData",
components: {
// Search
},
props: ["nodeInfo"],
data() {
return {
action: Api.index,
tableHeight: "",
modal: false,
title: "新增",
curId: 0,
rootCategoryId: 0,
selectRows: [],
rowsTable: [],
fullscreen: false,
treeData: [],
codeRuleData: [],
detail: null,
temTitle: "物料管理",
sets: v => {
v.categoryId = this.nodeInfo.categoryId;
v.rootCategoryId = this.nodeInfo.rootCategoryId;
},
easySearch: {
keys: {
op: "code,name",
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;
name: "masterData",
components: {
// Search
},
props: ["nodeInfo"],
data() {
return {
action: Api.index,
tableHeight: "",
modal: false,
title: "新增",
curId: 0,
rootCategoryId: 0,
selectRows: [],
rowsTable: [],
fullscreen: false,
treeData: [],
codeRuleData: [],
detail: null,
temTitle: "物料管理",
sets: (v) => {
v.categoryId = this.nodeInfo.categoryId;
v.rootCategoryId = this.nodeInfo.rootCategoryId;
},
easySearch: {
keys: {
op: "code,name",
value: null,
},
onSelect(a, b) {
// console.log(a);
// console.log(b);
//批量选择
this.rootCategoryId = a[0].rootCategoryId;
this.selectRows = a;
categoryId: {
op: "In",
value: this.nodeInfo.ids,
},
modalSchedule() {
this.fullscreen = true;
this.rowsTable = this.selectRows;
this.title = "物料送审";
this.curId = 0;
this.detail = () => import("./submit");
this.modal = true;
},
columns: [
{
type: "selection",
width: 70,
align: "center",
},
search() {
this.$refs.grid.reload(this.easySearch);
{
key: "codeRuleType",
title: "类型",
align: "center",
code: "material.code.type",
import: true,
hide: true,
},
initCols(delay) {
let conditions = [{
conditionalType: "Equal",
fieldName: "categoryId",
fieldValue: this.nodeInfo.rootCategoryId
}];
Api.listTable({
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;
{
key: "codeRuleId",
title: "编码名称",
materialKey: "3",
import: true,
hide: true,
render: (h, params) => {
return h("span", {}, this.getType3(params.row.codeRuleId));
},
},
add() {
if (this.nodeInfo.categoryId) {
if (this.nodeInfo.addChange == true) {
this.fullscreen = false;
this.curId = 0;
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
} else {
this.$Message.error("请在设置的分类层级数下添加物料");
}
} else {
this.$Message.error("请先选择分类");
}
{
key: "rootCategoryId",
title: "大类",
align: "right",
materialKey: "1",
import: true,
hide: true,
render: (h, params) => {
return h("span", {}, this.getType1(params.row.rootCategoryId));
},
},
edit(row) {
this.fullscreen = false;
this.curId = row.id;
this.title = "编辑";
this.detail = () => import("./edit");
this.modal = true;
{
key: "categoryId",
title: "子类",
align: "right",
materialKey: "2",
import: true,
hide: true,
render: (h, params) => {
return h("span", {}, this.getType2(params.row.categoryId));
},
},
remove(id) {
Api.delete(id).then(r => {
if (r.success) {
this.$refs.grid.reload(this.easySearch);
this.$Message.success("删除成功");
}
});
{
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
);
},
},
details(row) {
this.fullscreen = true;
this.curId = row.id;
this.rootCategoryId = row.rootCategoryId;
this.title = "详情";
this.detail = () => import("./details");
this.rowsTable = [];
this.modal = true;
{
key: "name",
title: "名称",
align: "left",
},
send(row) {
this.fullscreen = true;
this.curId = row.id;
this.rootCategoryId = row.rootCategoryId;
this.title = "物料送审";
this.detail = () => import("./submit");
this.rowsTable = [];
this.modal = true;
{
key: "status",
title: "状态",
align: "center",
code: "material.main.status",
},
ok() {
this.$refs.grid.reload(this.easySearch);
this.modal = false;
this.ModalIm = false;
this.curId = 0;
{
key: "version",
title: "版本",
align: "left",
code: "material.main.version",
},
cancel() {
this.curId = 0;
this.modal = false;
{
key: "drawing",
title: "图号",
align: "left",
},
//批量导入start
//导入功能
openModalIm() {
if (this.nodeInfo.categoryId) {
this.ModalIm = true
} else {
this.$Message.error("请先选择分类");
}
{
key: "creationTime",
title: "创建时间",
hide: true,
align: "left",
type: "date",
},
ModalImCancel() {
this.ModalIm = false
{
key: "creatorUserId",
title: "创建人",
hide: true,
align: "left",
type: "user",
},
getData(val) {
let url = `${material}/materialimportservice/import`;
this.$refs.importExcel.deelData(url, this.cols, this.formatMethod(val))
{
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),
},
},
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) {
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);
], //基础咧
cols: [], //
status: null,
ModalIm: false,
addCol: [],
exportTitle: "物料管理",
};
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
this.tableHeight = window.innerHeight - 220;
});
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
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) {
// 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 = {
conditions: []
];
Api.listTable({
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 (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
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;
},
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
},
}
add() {
if (this.nodeInfo.categoryId) {
if (this.nodeInfo.addChange == true) {
this.fullscreen = false;
this.curId = 0;
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
} else {
this.$Message.error("请在设置的分类层级数下添加物料");
}
} else {
this.$Message.error("请先选择分类");
}
},
edit(row) {
this.fullscreen = false;
this.curId = row.id;
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>
<style lang="less">
.master-data {
.ivu-footer-toolbar-right {
margin-right: 72% !important;
}
.ivu-footer-toolbar-right {
margin-right: 72% !important;
}
}
</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