工序导入

This commit is contained in:
xielue 2023-06-05 11:56:45 +08:00
parent 3b055c6ff1
commit 25e1359d19
2 changed files with 59 additions and 35 deletions

View File

@ -156,7 +156,17 @@ export default {
};
for (let i = 0; i < this.options.exportColumns.length; i++) {
let item = this.options.exportColumns[i];
jsonRow[item.title] = row[item.field] || '';
var v = "";
if(item.dataField){
v = row[item.dataField];
if(item.textField && v){
v = v[item.textField]
}
}else{
v = row[item.field] || '';
}
jsonRow[item.title] = v;
}
jsonRows.push(jsonRow);
});

View File

@ -1,8 +1,6 @@
<template>
<div class="page-body">
<div class="split_wrapper">
<div class="page-body">
<div class="split_wrapper">
<div class="left">
<div class="treepanel">
<div class="treepanel-header">
@ -23,7 +21,7 @@
</a-tree>
</div>
</div>
</div>
<div class="right">
@ -31,9 +29,7 @@
</div>
</div>
</div>
</div>
</template>
<script>
@ -65,12 +61,13 @@ export default {
sourceDetailsData: [
],
typeData: [],
treeData: [],
treeLoading: true,
deletedDetailsData: [
],
selectedKeys: [],
selectedKeys: [],
selectedKey: null,
tableHeight: 500
};
@ -87,38 +84,53 @@ export default {
//
created() {
this.optionsInit();
this.$nextTick(() => {
this.$nextTick(() => {
this.tableHeight = this.$mk.getWindowSize().height - 260;
this.treeInit();
});
},
//
methods: {
getTypeId(name) {
for (let i = 0; i < this.typeData.length; i++) {
if (this.typeData[i].name == name) {
return this.typeData[i].id;
}
}
return 0;
},
getOptionValue({ label, options }) {
for (let i = 0; i < options.length; i++) {
if (options[i].label == label) {
return options[i].value;
}
}
return '';
},
pageImport({ data }) {
let rows = [];
data.forEach(item => {
let rows = [];
data.forEach(item => {
let row = {};
this.pageOptions.exportColumns.forEach(col => {
if (col.title in item) {
let v = item[col.title];
if(col.options){
col.options.forEach(op=>{
if(op.label == v){
row[col.field] = op.value;
}
})
}else{
row[col.field] = v;
if (col.options) {
v = this.getOptionValue({ options: col.options, label: v });
} else if (col.field == "sort_id") {
v = this.getTypeId(v);
}
console.log(col.options)
row[col.field] = v;
}
})
rows.push(row);
rows.push(row);
});
this.$mk.post({
@ -144,15 +156,16 @@ export default {
keyName: 'id', //
listFieldName: 'MesProcesses',
exportFileTitle :"工序",
exportFileTitle: "工序",
enabledExport: true,
enabledImport: true,
enabledImportTemplate: true,
exportColumns: [
{ title: '编码',field:"code" },
{ title: '工序名称',field:"name" },
{ title: '工序描述',field:"desc" },
{ title: '计工方式',field:"work_type",options:settings.options_work_type }
{ title: '编码', field: "code" },
{ title: '工序名称', field: "name" },
{ title: '工序描述', field: "desc" },
{ title: '计工方式', field: "work_type", options: settings.options_work_type },
{ title: '工序分类', field: "sort_id", dataField: 'mes_processes_sort', textField: "name" }
],
addPageUrl: "/MesProcesses/MesProcessesAdd",
editPageUrl: "/MesProcesses/MesProcessesUpdate/",
@ -243,8 +256,8 @@ export default {
//{ field: 'process_segment_id', sortable: true, title: 'id', width: 250 }, // id
//{ field: 'title', sortable: true, title: '', width: 250 }, //
{ field: 'code', sortable: true, title: '工序编码', width: 250 }, //
{ field: 'name', sortable: true, title: '工序名称', width: 250 },
{ field: 'name', sortable: true, title: '工序名称', width: 250 },
{ field: 'mes_processes_sort', formatter: 'formatRef', params: { dataType: "object", textField: "name" }, title: '工序分类', width: 250 },
{ field: 'desc', sortable: true, title: '工序描述', width: 250 }, //
@ -297,6 +310,7 @@ export default {
title: "工序分类",
key: "root"
};
this.typeData = r.data.MesProcessesSort;
let at = toArrayTree(r.data.MesProcessesSort, { parentKey: "parent_id" });
console.log(at);
treedata[childrenFieldName] = at;
@ -414,7 +428,7 @@ export default {
}
};
return find(this.treeData);
},
},
reloadData() {
if (this.selectedKey) {
this.loadData(this.selectedKey);
@ -441,7 +455,7 @@ export default {
if (key && key != "root") {
var node = this.findTreeNode(key);
if (node.children && node.children.length) {
if (node.children && node.children.length) {
var ids = this.getAllChildrenIds(node.children);
this.$refs.listPage.onSearch({
sort_id: [node.id, ...ids].join(',')
@ -453,7 +467,7 @@ export default {
}
}else{
} else {
this.$refs.listPage.onSearch(null);
}
@ -568,7 +582,7 @@ export default {
background: white;
padding: 8px;
}
.toolbarbtns .ant-btn {
margin-right: 10px;
}