bom导入 料品导入
This commit is contained in:
parent
25e1359d19
commit
9d50a1aca7
|
|
@ -147,9 +147,11 @@ export default {
|
||||||
headerCells.push(item.title);
|
headerCells.push(item.title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let details = JSON.parse(JSON.stringify(this.$refs.xGrid.getTableData().fullData));
|
let details = JSON.parse(JSON.stringify(this.$refs.xGrid.getTableData().fullData));
|
||||||
|
|
||||||
|
|
||||||
details.forEach(row => {
|
details.forEach(row => {
|
||||||
let jsonRow = {
|
let jsonRow = {
|
||||||
|
|
@ -157,16 +159,19 @@ export default {
|
||||||
for (let i = 0; i < this.options.exportColumns.length; i++) {
|
for (let i = 0; i < this.options.exportColumns.length; i++) {
|
||||||
let item = this.options.exportColumns[i];
|
let item = this.options.exportColumns[i];
|
||||||
var v = "";
|
var v = "";
|
||||||
if(item.dataField){
|
if (item.valueGetter) {
|
||||||
v = row[item.dataField];
|
v = item.valueGetter({ row: row,column:item });
|
||||||
if(item.textField && v){
|
}
|
||||||
|
else if (item.dataField) {
|
||||||
|
v = row[item.dataField];
|
||||||
|
if (item.textField && v) {
|
||||||
v = v[item.textField]
|
v = v[item.textField]
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
v = row[item.field] || '';
|
v = row[item.field] || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonRow[item.title] = v;
|
jsonRow[item.title] = v;
|
||||||
}
|
}
|
||||||
jsonRows.push(jsonRow);
|
jsonRows.push(jsonRow);
|
||||||
});
|
});
|
||||||
|
|
@ -178,7 +183,7 @@ export default {
|
||||||
/* get binary string as output */
|
/* get binary string as output */
|
||||||
var wbout = XLSX.write(workbook, { bookType: 'xlsx', bookSST: true, type: 'array' })
|
var wbout = XLSX.write(workbook, { bookType: 'xlsx', bookSST: true, type: 'array' })
|
||||||
try {
|
try {
|
||||||
FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), (this.options.exportFileTitle || '导出数据' )+ '.xlsx')
|
FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), (this.options.exportFileTitle || '导出数据') + '.xlsx')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (typeof console !== 'undefined') {
|
if (typeof console !== 'undefined') {
|
||||||
console.log(e, wbout)
|
console.log(e, wbout)
|
||||||
|
|
@ -289,7 +294,7 @@ export default {
|
||||||
if (mode == "like") { // 如果是模糊搜索
|
if (mode == "like") { // 如果是模糊搜索
|
||||||
value = "%" + value + "%"; // 如果是模糊搜索就在两边加上%
|
value = "%" + value + "%"; // 如果是模糊搜索就在两边加上%
|
||||||
}
|
}
|
||||||
if(typeof(value) == "object" && value.id){
|
if (typeof (value) == "object" && value.id) {
|
||||||
value = value.id;
|
value = value.id;
|
||||||
}
|
}
|
||||||
rules.push({ // 添加搜索参数
|
rules.push({ // 添加搜索参数
|
||||||
|
|
@ -498,6 +503,10 @@ export default {
|
||||||
this.bindSearchData = arg;
|
this.bindSearchData = arg;
|
||||||
this.$refs.xGrid.commitProxy('query') // 提交搜索
|
this.$refs.xGrid.commitProxy('query') // 提交搜索
|
||||||
},
|
},
|
||||||
|
|
||||||
|
gridReload(){
|
||||||
|
this.$refs.xGrid.commitProxy('query')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 监听属性
|
// 监听属性
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<basic-page-list :desc="desc" :options="pageOptions"></basic-page-list>
|
<basic-page-list ref="listPage" :desc="desc" @importData="pageImport" :options="pageOptions"></basic-page-list>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -32,6 +32,238 @@ export default {
|
||||||
// 动作
|
// 动作
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
|
||||||
|
loadMaterials({ materials_names }) {
|
||||||
|
return this.$mk.post({
|
||||||
|
url: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/list`,
|
||||||
|
data: {
|
||||||
|
"page": 1,
|
||||||
|
"limit": 100000,
|
||||||
|
"end_time": 0,
|
||||||
|
"start_time": 0,
|
||||||
|
"order_bys": [
|
||||||
|
],
|
||||||
|
"search_rules": [
|
||||||
|
{ "column": "name", "mode": "in", "value": materials_names.join(",") }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
useBigInt: true
|
||||||
|
});
|
||||||
|
},
|
||||||
|
loadWarehouses({ warehouse_names }) {
|
||||||
|
return this.$mk.post({
|
||||||
|
url: `${BASE_URL.BASE_URL}/MesWarehouse/v1/mes/warehouse/list`,
|
||||||
|
data: {
|
||||||
|
"page": 1,
|
||||||
|
"limit": 100000,
|
||||||
|
"end_time": 0,
|
||||||
|
"start_time": 0,
|
||||||
|
"order_bys": [
|
||||||
|
],
|
||||||
|
"search_rules": [
|
||||||
|
{ "column": "warehouse_name", "mode": "in", "value": warehouse_names.join(",") }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
useBigInt: true
|
||||||
|
});
|
||||||
|
},
|
||||||
|
pageImport({ data }) {
|
||||||
|
|
||||||
|
|
||||||
|
let dataRows = [];
|
||||||
|
var materials_names = [];
|
||||||
|
var warehouse_names = [];
|
||||||
|
var materials_list = [];
|
||||||
|
var warehouse_list = [];
|
||||||
|
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
let dataRow = {};
|
||||||
|
this.pageOptions.exportColumns.forEach(col => {
|
||||||
|
|
||||||
|
if (col.title in item) {
|
||||||
|
let v = item[col.title];
|
||||||
|
dataRow[col.field] = v;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
dataRows.push(dataRow);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
dataRows.forEach(item => {
|
||||||
|
if (item.parent_material_name) {
|
||||||
|
let v = item.parent_material_name;
|
||||||
|
if (!materials_names.filter(a => a == v).length) {
|
||||||
|
materials_names.push(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.child_material_name) {
|
||||||
|
let v = item.child_material_name;
|
||||||
|
if (!materials_names.filter(a => a == v).length) {
|
||||||
|
materials_names.push(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.parent_warehouse_name) {
|
||||||
|
let v = item.parent_warehouse_name;
|
||||||
|
if (!warehouse_names.filter(a => a == v).length) {
|
||||||
|
warehouse_names.push(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.child_warehouse_name) {
|
||||||
|
let v = item.child_warehouse_name;
|
||||||
|
if (!warehouse_names.filter(a => a == v).length) {
|
||||||
|
warehouse_names.push(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
console.log(dataRows,materials_names,warehouse_names);
|
||||||
|
|
||||||
|
|
||||||
|
let getMaterialId = ({ name }) => {
|
||||||
|
if (!name) return 0;
|
||||||
|
for (let i = 0; i < materials_list.length; i++) {
|
||||||
|
if (materials_list[i].name == name) {
|
||||||
|
return materials_list[i].id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
let getWarehouseId = ({ name }) => {
|
||||||
|
if (!name) return 0;
|
||||||
|
for (let i = 0; i < warehouse_list.length; i++) {
|
||||||
|
if (warehouse_list[i].warehouse_name == name) {
|
||||||
|
return warehouse_list[i].id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let getParents = () => {
|
||||||
|
let rows = [];
|
||||||
|
dataRows.forEach(item => {
|
||||||
|
|
||||||
|
let material_id = getMaterialId({ name: item.parent_material_name });
|
||||||
|
|
||||||
|
if (material_id && rows.filter(a => a.material_id == material_id && a.version == item.parent_version).length == 0) {
|
||||||
|
|
||||||
|
let warehouse_id = getWarehouseId({ name: item.parent_warehouse_name });
|
||||||
|
|
||||||
|
rows.push({
|
||||||
|
material_id: material_id,
|
||||||
|
warehouse_id: warehouse_id,
|
||||||
|
version: (item.parent_version || "").toString(),
|
||||||
|
is_default: item.is_default == "1" ? 1 : 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
|
||||||
|
}
|
||||||
|
let getChidlren = ({ parent }) => {
|
||||||
|
let rows = [];
|
||||||
|
dataRows.forEach(item => {
|
||||||
|
|
||||||
|
let material_id = getMaterialId({ name: item.parent_material_name });
|
||||||
|
let child_material_id = getMaterialId({ name: item.child_material_name });
|
||||||
|
|
||||||
|
if (material_id &&
|
||||||
|
parent.material_id == material_id &&
|
||||||
|
parent.version == item.parent_version &&
|
||||||
|
child_material_id &&
|
||||||
|
rows.filter(a => a.material_id == child_material_id).length == 0) {
|
||||||
|
|
||||||
|
let warehouse_id = getWarehouseId({ name: item.child_warehouse_name });
|
||||||
|
|
||||||
|
rows.push({
|
||||||
|
material_id: child_material_id,
|
||||||
|
warehouse_id: warehouse_id,
|
||||||
|
loss_rate: parseFloat(item.loss_rate),
|
||||||
|
sub_qty: parseFloat(item.sub_qty)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
|
||||||
|
}
|
||||||
|
let getImportData = () => {
|
||||||
|
let parentData = getParents();
|
||||||
|
let data = [];
|
||||||
|
parentData.forEach(item => {
|
||||||
|
let children = getChidlren({ parent: item });
|
||||||
|
if (children.length) {
|
||||||
|
|
||||||
|
data.push({
|
||||||
|
parent: item,
|
||||||
|
child: children
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let startImport = () => {
|
||||||
|
let data = getImportData();
|
||||||
|
if (!data.length) {
|
||||||
|
this.$mk.error("无可导入数据");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(data)
|
||||||
|
this.$mk.post({
|
||||||
|
url: `${BASE_URL.BASE_URL}/MesBom/v1/mes/bom/batchCreateParentAndChild`,
|
||||||
|
loading: "导入中...",
|
||||||
|
data: {
|
||||||
|
"bom": data
|
||||||
|
},
|
||||||
|
useBigInt: true
|
||||||
|
}).then((a) => { // 成功
|
||||||
|
|
||||||
|
this.$mk.success(a.data.msg || "导入成功"); // 提示成功
|
||||||
|
this.$refs.listPage.gridReload();
|
||||||
|
}).catch((a) => { // 失败
|
||||||
|
this.$mk.error(a.data.msg); // 提示错误信息
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!materials_names.length){
|
||||||
|
this.$mk.error("没有可导入数据"); // 提示错误信息
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.loadMaterials({ materials_names }).then((a) => {
|
||||||
|
materials_list = a.data.MesMaterials;
|
||||||
|
|
||||||
|
if(warehouse_names.length){
|
||||||
|
this.loadWarehouses({ warehouse_names }).then((b) => {
|
||||||
|
warehouse_list = b.data.MesWarehouse;
|
||||||
|
|
||||||
|
|
||||||
|
startImport();
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
startImport();
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
optionsInit() {
|
optionsInit() {
|
||||||
// 页面数据
|
// 页面数据
|
||||||
var pageData = { // 页面数据变量
|
var pageData = { // 页面数据变量
|
||||||
|
|
@ -49,6 +281,21 @@ export default {
|
||||||
start_time: 0, // 开始时间
|
start_time: 0, // 开始时间
|
||||||
end_time: 0, // 结束时间
|
end_time: 0, // 结束时间
|
||||||
|
|
||||||
|
exportFileTitle: "物料清单",
|
||||||
|
enabledExport: false,
|
||||||
|
enabledImport: true,
|
||||||
|
enabledImportTemplate: true,
|
||||||
|
exportColumns: [
|
||||||
|
{ title: '父件', field: "parent_material_name" },
|
||||||
|
{ title: '版本号', field: "parent_version" },
|
||||||
|
{ title: '默认仓库', field: "parent_warehouse_name" },
|
||||||
|
{ title: '是否默认', field: "parent_is_default" },
|
||||||
|
{ title: '子件', field: "child_material_name" },
|
||||||
|
{ title: '预出仓库', field: "child_warehouse_name" },
|
||||||
|
{ title: '需用数量', field: "sub_qty" },
|
||||||
|
{ title: '损耗率', field: "loss_rate" },
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
//搜索区
|
//搜索区
|
||||||
searchFormData: {
|
searchFormData: {
|
||||||
|
|
@ -65,7 +312,7 @@ export default {
|
||||||
|
|
||||||
{
|
{
|
||||||
title: '父件', span: 6,
|
title: '父件', span: 6,
|
||||||
field: 'material_id',
|
field: 'material_id',
|
||||||
itemRender: {
|
itemRender: {
|
||||||
name: 'MkFormDataSelector', props: {
|
name: 'MkFormDataSelector', props: {
|
||||||
params: {
|
params: {
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@
|
||||||
<a style="margin-left: 10px;" class="link" @click.stop="treeAdd(row)" title="新增">
|
<a style="margin-left: 10px;" class="link" @click.stop="treeAdd(row)" title="新增">
|
||||||
<a-icon type="plus-circle" />
|
<a-icon type="plus-circle" />
|
||||||
</a>
|
</a>
|
||||||
<a class="link" @click.stop="treeEdit(row)" title="编辑">
|
<a class="link" @click.stop="treeEdit(row)" title="编辑">
|
||||||
<a-icon type="edit" />
|
<a-icon type="edit" />
|
||||||
</a>
|
</a>
|
||||||
<a class="link" @click.stop="treeDelete(row)" title="删除">
|
<a class="link" @click.stop="treeDelete(row)" title="删除">
|
||||||
<a-icon type="delete" />
|
<a-icon type="delete" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -23,22 +23,22 @@
|
||||||
</a-tree>
|
</a-tree>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
|
|
||||||
<basic-page-list ref="listPage" :options="pageOptions"></basic-page-list>
|
<basic-page-list ref="listPage" @importData="pageImport" :options="pageOptions"></basic-page-list>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -73,12 +73,13 @@ export default {
|
||||||
pageOptions: {},
|
pageOptions: {},
|
||||||
|
|
||||||
modelName: "",
|
modelName: "",
|
||||||
|
attributes: [],
|
||||||
|
typeData: [],
|
||||||
actions: {
|
actions: {
|
||||||
treedata: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/sort/list`,
|
treedata: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/sort/list`,
|
||||||
delete: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/sort/batchDelete`,
|
delete: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/sort/batchDelete`,
|
||||||
listdata: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`,
|
|
||||||
save: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/batchHandle`,
|
productAttribute: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/get/productAttribute`
|
||||||
},
|
},
|
||||||
tipTimes: 0,
|
tipTimes: 0,
|
||||||
detailsData: [
|
detailsData: [
|
||||||
|
|
@ -102,6 +103,7 @@ export default {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
||||||
|
this.attributeDataInit();
|
||||||
this.optionsInit();
|
this.optionsInit();
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|
||||||
|
|
@ -116,6 +118,143 @@ export default {
|
||||||
// 函数
|
// 函数
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
|
||||||
|
attributeDataInit() {
|
||||||
|
this.$mk.post({
|
||||||
|
url: this.actions.productAttribute,
|
||||||
|
loading: "加载中..."
|
||||||
|
}).then(a => {
|
||||||
|
|
||||||
|
this.attributes = a.data.attribute;
|
||||||
|
this.attributes.forEach(item => {
|
||||||
|
|
||||||
|
this.pageOptions.exportColumns.push(
|
||||||
|
{
|
||||||
|
title: item.name, type: "attribute", valueGetter: this.getExportAttributeValue
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}).catch((a) => {
|
||||||
|
this.$mk.error(a.data.msg);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getAttribute(name) {
|
||||||
|
for (let i = 0; this.attributes && i < this.attributes.length; i++) {
|
||||||
|
if (this.attributes[i].name == name) {
|
||||||
|
return this.attributes[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
getAttributeId(name) {
|
||||||
|
for (let i = 0; this.attributes && i < this.attributes.length; i++) {
|
||||||
|
if (this.attributes[i].name == name) {
|
||||||
|
return this.attributes[i].id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
getAttributeValue({ row, attribute_id }) {
|
||||||
|
for (let i = 0; row.custom_attribute_value && i < row.custom_attribute_value.length; i++) {
|
||||||
|
if (row.custom_attribute_value[i].attribute_id.toString() == attribute_id.toString()) {
|
||||||
|
return row.custom_attribute_value[i].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
getExportAttributeValue({ row, column }) {
|
||||||
|
console.log(row, column, this.attributes)
|
||||||
|
let attrid = this.getAttributeId(column.title);
|
||||||
|
if (!attrid) return '';
|
||||||
|
return this.getAttributeValue({ row: row, attribute_id: attrid })
|
||||||
|
|
||||||
|
},
|
||||||
|
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 = [];
|
||||||
|
console.log(data)
|
||||||
|
data.forEach(item => {
|
||||||
|
let row = {
|
||||||
|
custom_attribute_value: []
|
||||||
|
|
||||||
|
};
|
||||||
|
this.pageOptions.exportColumns.forEach(col => {
|
||||||
|
|
||||||
|
if (col.title in item) {
|
||||||
|
let v = item[col.title];
|
||||||
|
if (col.options) {
|
||||||
|
v = this.getOptionValue({ options: col.options, label: v });
|
||||||
|
} else if (col.field == "sort_id") {
|
||||||
|
v = this.getTypeId(v);
|
||||||
|
}
|
||||||
|
else if (col.type == "attribute") {
|
||||||
|
let attrid = this.getAttributeId(col.title);
|
||||||
|
if (!attrid) return;
|
||||||
|
let attr = this.getAttribute(col.title);
|
||||||
|
v = v || ""
|
||||||
|
if (attr.typeName == '7') {
|
||||||
|
v = (v == "1" || v == "TRUE" || v == "true" || v == "True") ? "true" : "false";
|
||||||
|
}
|
||||||
|
if (attr.typeName == "3" || attr.typeName == "4" || attr.typeName == "5") {
|
||||||
|
// 将数字转换为日期格式
|
||||||
|
let date = new Date((v - 1) * 24 * 60 * 60 * 1000 + 1);
|
||||||
|
|
||||||
|
v = date.getFullYear() + '-' + (date.getMonth() + 1).toString().padStart(2, '0') + '-' + date.getDate().toString().padStart(2, '0');
|
||||||
|
|
||||||
|
}
|
||||||
|
row.custom_attribute_value.push({
|
||||||
|
attribute_id: attrid,
|
||||||
|
"value": v.toString(),
|
||||||
|
"e_value": v.toString()
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
row[col.field] = v;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if(row.code && row.name){
|
||||||
|
rows.push(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$mk.post({
|
||||||
|
url: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/batchCreate`,
|
||||||
|
loading: "导入中...",
|
||||||
|
data: {
|
||||||
|
"list": rows
|
||||||
|
},
|
||||||
|
useBigInt: true
|
||||||
|
}).then((a) => { // 成功
|
||||||
|
|
||||||
|
this.$mk.success(a.data.msg || "导入成功"); // 提示成功
|
||||||
|
this.$refs.listPage.gridReload();
|
||||||
|
}).catch((a) => { // 失败
|
||||||
|
this.$mk.error(a.data.msg); // 提示错误信息
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
optionsInit() {
|
optionsInit() {
|
||||||
// 页面数据
|
// 页面数据
|
||||||
var pageData = { // 页面数据变量
|
var pageData = { // 页面数据变量
|
||||||
|
|
@ -126,6 +265,20 @@ export default {
|
||||||
addPageUrl: "/MesMaterials/MesMaterialsAdd",
|
addPageUrl: "/MesMaterials/MesMaterialsAdd",
|
||||||
editPageUrl: "/MesMaterials/MesMaterialsUpdate/",
|
editPageUrl: "/MesMaterials/MesMaterialsUpdate/",
|
||||||
|
|
||||||
|
|
||||||
|
enabledExport: true,
|
||||||
|
enabledImport: true,
|
||||||
|
enabledImportTemplate: true,
|
||||||
|
exportColumns: [
|
||||||
|
{ title: '编码', field: "code" },
|
||||||
|
{ title: '料品', field: "name" },
|
||||||
|
{ title: '规格型号', field: "spec" },
|
||||||
|
{ title: '分类', field: "sort_id", dataField: 'mes_materials_sort', textField: "name" },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
// 接口动作
|
// 接口动作
|
||||||
actions: { // Api 接口地址
|
actions: { // Api 接口地址
|
||||||
// =============================== 接口地址 自动生成 Start ===============================
|
// =============================== 接口地址 自动生成 Start ===============================
|
||||||
|
|
@ -189,16 +342,16 @@ export default {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ field: 'spec', title: '规格型号' , width: 150 },
|
{ field: 'spec', title: '规格型号', width: 150 },
|
||||||
{ field: 'size', title: '尺寸' , width: 150},
|
{ field: 'size', title: '尺寸', width: 150 },
|
||||||
{ field: 'color', title: '颜色' , width: 150},
|
{ field: 'color', title: '颜色', width: 150 },
|
||||||
{ field: 'face', title: '花面' , width: 150 },
|
{ field: 'face', title: '花面', width: 150 },
|
||||||
{ field: 'molding', title: '成型方式' , width: 150 },
|
{ field: 'molding', title: '成型方式', width: 150 },
|
||||||
{ field: 'production_type', title: '布产方式' , width: 150 },
|
{ field: 'production_type', title: '布产方式', width: 150 },
|
||||||
|
|
||||||
{ field: 'theoretical_load', title: '理论装车量' , width: 150 },
|
{ field: 'theoretical_load', title: '理论装车量', width: 150 },
|
||||||
{ field: 'soil', title: '土质' , width: 150 },
|
{ field: 'soil', title: '土质', width: 150 },
|
||||||
{ field: 'unit', title: '单位' , width: 150 },
|
{ field: 'unit', title: '单位', width: 150 },
|
||||||
{ field: 'create_time', formatter: 'formatDate', width: 160, sortable: true, title: '创建时间', showHeaderOverflow: true }, // 创建时间
|
{ field: 'create_time', formatter: 'formatDate', width: 160, sortable: true, title: '创建时间', showHeaderOverflow: true }, // 创建时间
|
||||||
{ field: 'update_time', formatter: 'formatDate', width: 160, sortable: true, title: '更新时间', showHeaderOverflow: true }, // 更新时间
|
{ field: 'update_time', formatter: 'formatDate', width: 160, sortable: true, title: '更新时间', showHeaderOverflow: true }, // 更新时间
|
||||||
|
|
||||||
|
|
@ -239,6 +392,7 @@ export default {
|
||||||
title: "料品分类",
|
title: "料品分类",
|
||||||
key: "root"
|
key: "root"
|
||||||
};
|
};
|
||||||
|
this.typeData = r.data.MesMaterialsSort;
|
||||||
let at = toArrayTree(r.data.MesMaterialsSort, { parentKey: "parent_id" });
|
let at = toArrayTree(r.data.MesMaterialsSort, { parentKey: "parent_id" });
|
||||||
console.log(at);
|
console.log(at);
|
||||||
treedata[childrenFieldName] = at;
|
treedata[childrenFieldName] = at;
|
||||||
|
|
@ -356,7 +510,7 @@ export default {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return find(this.treeData);
|
return find(this.treeData);
|
||||||
},
|
},
|
||||||
reloadData() {
|
reloadData() {
|
||||||
if (this.selectedKey) {
|
if (this.selectedKey) {
|
||||||
this.loadData(this.selectedKey);
|
this.loadData(this.selectedKey);
|
||||||
|
|
@ -383,7 +537,7 @@ export default {
|
||||||
|
|
||||||
if (key && key != "root") {
|
if (key && key != "root") {
|
||||||
var node = this.findTreeNode(key);
|
var node = this.findTreeNode(key);
|
||||||
if (node.children && node.children.length) {
|
if (node.children && node.children.length) {
|
||||||
var ids = this.getAllChildrenIds(node.children);
|
var ids = this.getAllChildrenIds(node.children);
|
||||||
this.$refs.listPage.onSearch({
|
this.$refs.listPage.onSearch({
|
||||||
sort_id: [node.id, ...ids].join(',')
|
sort_id: [node.id, ...ids].join(',')
|
||||||
|
|
@ -395,7 +549,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
this.$refs.listPage.onSearch(null);
|
this.$refs.listPage.onSearch(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -412,59 +566,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ok() {
|
|
||||||
|
|
||||||
let save = () => {
|
|
||||||
|
|
||||||
if (!this.selectedKey || this.selectedKey == "root") {
|
|
||||||
this.$mk.error("请先选择料品分类");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let node = this.findTreeNode(this.selectedKey);
|
|
||||||
|
|
||||||
let ds = JSON.parse(JSON.stringify(this.detailsData));
|
|
||||||
|
|
||||||
var postdata = {
|
|
||||||
insertList: [],
|
|
||||||
updateList: [],
|
|
||||||
deleteList: this.deletedDetailsData
|
|
||||||
};
|
|
||||||
|
|
||||||
ds.forEach(item => {
|
|
||||||
delete item._X_ROW_KEY;
|
|
||||||
|
|
||||||
item.enum_id = node.id;
|
|
||||||
if (item.id && item.id != "0") {
|
|
||||||
let source = this.findSourceInfo(item.id);
|
|
||||||
item.id = source.id;
|
|
||||||
postdata.updateList.push(item);
|
|
||||||
} else {
|
|
||||||
postdata.insertList.push(item);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
this.$mk.post({
|
|
||||||
url: this.actions.save,
|
|
||||||
loading: "保存中...",
|
|
||||||
data: postdata,
|
|
||||||
useBigInt: true
|
|
||||||
}).then(a => {
|
|
||||||
if (a.code == "200") {
|
|
||||||
this.$mk.success("保存成功");
|
|
||||||
this.reloadData();
|
|
||||||
} else {
|
|
||||||
this.$mk.error(a.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}).catch((a) => {
|
|
||||||
this.$mk.error(a.data.msg);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
save();
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
back() {
|
back() {
|
||||||
},
|
},
|
||||||
|
|
@ -509,7 +611,7 @@ export default {
|
||||||
.page-body {
|
.page-body {
|
||||||
background: white;
|
background: white;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.toolbarbtns .ant-btn {
|
.toolbarbtns .ant-btn {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue