MES基础档案
This commit is contained in:
parent
fa69689738
commit
65662498d1
|
|
@ -52,6 +52,7 @@ export default {
|
|||
actions: { // api地址
|
||||
getList: `${BASE_URL}/api/web/listdata` // 获取列表数据
|
||||
},
|
||||
actionParams:null,
|
||||
modalVisible: false, // 弹出框显示
|
||||
lastKey: '', // 上次输入的值
|
||||
modelName: '', // 模块名称
|
||||
|
|
@ -151,6 +152,9 @@ export default {
|
|||
if (params.dataUrl) {
|
||||
this.actions.getList = params.dataUrl;
|
||||
}
|
||||
if(params.actionParams){
|
||||
this.actionParams = params.actionParams;
|
||||
}
|
||||
}
|
||||
|
||||
if (params.dataType == "string") {
|
||||
|
|
@ -179,7 +183,10 @@ export default {
|
|||
},
|
||||
|
||||
getData(key) { // 获取数据
|
||||
var params = {}; // 定义请求参数
|
||||
|
||||
var params = Object.assign({},this.actionParams ||{}) // 定义请求参数
|
||||
|
||||
|
||||
params.page = this.tablePage.currentPage; // 当前页码
|
||||
params.limit = this.tablePage.pageSize; // 每页条数
|
||||
params.order_bys = []; // 排序信息
|
||||
|
|
@ -197,6 +204,7 @@ export default {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
return this.$mk.getPagedData({
|
||||
url: this.actions.getList,
|
||||
data: params
|
||||
|
|
|
|||
|
|
@ -1,23 +1,42 @@
|
|||
<template>
|
||||
<div class="page-body">
|
||||
<vxe-form :data="options.formOptions.data" ref="xForm" :title-width="options.formOptions.titleWidth"
|
||||
:title-align="options.formOptions.titleAlign" :rules="options.formOptions.rules" :items="options.formOptions.items"
|
||||
titleColon>
|
||||
<template #sort_id="{}">
|
||||
<vxe-pulldown style="width:100%" ref="pulldownParent" transfer>
|
||||
<template #default>
|
||||
<vxe-input v-model="sortName" suffix-icon="vxe-icon-search" placeholder="选择分类" @keyup="pulldownKeyupEvent"
|
||||
@focus="pulldownFocusEvent" @suffix-click="pulldownSuffixClick"></vxe-input>
|
||||
|
||||
<a-tabs v-model="tabKey" hide-add>
|
||||
<a-tab-pane key="1" tab="基础信息">
|
||||
|
||||
<vxe-form :data="options.formOptions.data" ref="xForm" :title-width="options.formOptions.titleWidth"
|
||||
:title-align="options.formOptions.titleAlign" :rules="options.formOptions.rules"
|
||||
:items="options.formOptions.items" titleColon>
|
||||
<template #sort_id="{}">
|
||||
<vxe-pulldown style="width:100%" ref="pulldownParent" transfer>
|
||||
<template #default>
|
||||
<vxe-input v-model="sortName" suffix-icon="vxe-icon-search" placeholder="选择分类" @keyup="pulldownKeyupEvent"
|
||||
@focus="pulldownFocusEvent" @suffix-click="pulldownSuffixClick"></vxe-input>
|
||||
</template>
|
||||
<template #dropdown>
|
||||
<div class="my-dropdown">
|
||||
<vxe-grid ref="gridParent" v-bind="gridParentOptions" @cell-click="pulldownCellClickEvent">
|
||||
</vxe-grid>
|
||||
</div>
|
||||
</template>
|
||||
</vxe-pulldown>
|
||||
</template>
|
||||
<template #dropdown>
|
||||
<div class="my-dropdown">
|
||||
<vxe-grid ref="gridParent" v-bind="gridParentOptions" @cell-click="pulldownCellClickEvent">
|
||||
</vxe-grid>
|
||||
</div>
|
||||
</template>
|
||||
</vxe-pulldown>
|
||||
</template>
|
||||
</vxe-form>
|
||||
</vxe-form>
|
||||
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="2" tab="料品属性">
|
||||
|
||||
<vxe-form :data="options.formOptions2.data" ref="xForm2" :title-width="options.formOptions2.titleWidth"
|
||||
:title-align="options.formOptions2.titleAlign" :rules="options.formOptions2.rules"
|
||||
:items="options.formOptions2.items" titleColon>
|
||||
</vxe-form>
|
||||
|
||||
|
||||
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
|
||||
|
||||
|
||||
<div class="footerbar">
|
||||
<a-button type="primary" @click="ok">确定</a-button>
|
||||
|
|
@ -45,12 +64,14 @@ export default {
|
|||
|
||||
data() {
|
||||
|
||||
let pageData = {
|
||||
let pageData = {
|
||||
actions: {
|
||||
list: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/sort/list`,
|
||||
},
|
||||
|
||||
tabKey: '1',
|
||||
sortName: '',
|
||||
custom_attribute_value: [],
|
||||
attributes: [],
|
||||
gridParentOptions: {
|
||||
height: 400,
|
||||
id: 'datagrid_router_parent_1',
|
||||
|
|
@ -103,7 +124,7 @@ export default {
|
|||
},
|
||||
options: {}
|
||||
};
|
||||
|
||||
|
||||
pageData.gridParentOptions = Object.assign({}, this.$mk.config.defaults.gridOptions, pageData.gridParentOptions);
|
||||
return pageData;
|
||||
},
|
||||
|
|
@ -163,6 +184,9 @@ export default {
|
|||
MesMaterialsImportExcel: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/import/excel`, // 批量导入EXCEL料品数据
|
||||
|
||||
// =============================== 接口地址 自动生成 End ===============================
|
||||
|
||||
|
||||
productAttribute: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/get/productAttribute`
|
||||
},
|
||||
|
||||
keyName: 'id',
|
||||
|
|
@ -196,18 +220,154 @@ export default {
|
|||
{ field: 'name', title: '名称', span: 12, itemRender: { name: '$input' } },
|
||||
|
||||
{ title: '分类', span: 12, slots: { default: 'sort_id' } },
|
||||
|
||||
{ field: 'spec', title: '规格型号', span: 12, itemRender: { name: '$input' } },
|
||||
{ field: 'size', title: '尺寸', span: 12, itemRender: { name: '$input' } },
|
||||
{ field: 'color', title: '颜色', span: 12, itemRender: { name: '$input' } },
|
||||
{ field: 'face', title: '花面', span: 12, itemRender: { name: '$input' } },
|
||||
{ field: 'molding', title: '成型方式', span: 12, itemRender: { name: '$input' } },
|
||||
{ field: 'production_type', title: '布产方式', span: 12, itemRender: { name: '$input' } },
|
||||
{ field: 'size', title: '尺寸', span: 12, itemRender: { name: '$input' } },
|
||||
|
||||
{
|
||||
title: '颜色', span: 12,
|
||||
field: 'color',
|
||||
itemRender: {
|
||||
name: 'MkFormDataSelector', props: {
|
||||
params: {
|
||||
dataType: "string",
|
||||
valueField: "name",
|
||||
textField: "name",
|
||||
listdataFieldName: 'MesEnumValue',
|
||||
actionParams:{
|
||||
search_rules_enum: [
|
||||
{
|
||||
column:"code",
|
||||
mode:"=",
|
||||
value:"3"
|
||||
}
|
||||
]
|
||||
},
|
||||
dataUrl: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: '花面', span: 12,
|
||||
field: 'face',
|
||||
itemRender: {
|
||||
name: 'MkFormDataSelector', props: {
|
||||
params: {
|
||||
dataType: "string",
|
||||
valueField: "name",
|
||||
textField: "name",
|
||||
listdataFieldName: 'MesEnumValue',
|
||||
actionParams:{
|
||||
search_rules_enum: [
|
||||
{
|
||||
column:"code",
|
||||
mode:"=",
|
||||
value:"4"
|
||||
}
|
||||
]
|
||||
},
|
||||
dataUrl: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '成型方式', span: 12,
|
||||
field: 'molding',
|
||||
itemRender: {
|
||||
name: 'MkFormDataSelector', props: {
|
||||
params: {
|
||||
dataType: "string",
|
||||
valueField: "name",
|
||||
textField: "name",
|
||||
listdataFieldName: 'MesEnumValue',
|
||||
actionParams:{
|
||||
search_rules_enum: [
|
||||
{
|
||||
column:"code",
|
||||
mode:"=",
|
||||
value:"1"
|
||||
}
|
||||
]
|
||||
},
|
||||
dataUrl: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
title: '布产方式', span: 12,
|
||||
field: 'production_type',
|
||||
itemRender: {
|
||||
name: 'MkFormDataSelector', props: {
|
||||
params: {
|
||||
dataType: "string",
|
||||
valueField: "name",
|
||||
textField: "name",
|
||||
listdataFieldName: 'MesEnumValue',
|
||||
actionParams:{
|
||||
search_rules_enum: [
|
||||
{
|
||||
column:"code",
|
||||
mode:"=",
|
||||
value:"2"
|
||||
}
|
||||
]
|
||||
},
|
||||
dataUrl: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
{ field: 'theoretical_load', title: '理论装车量', span: 12, itemRender: { name: '$input' } },
|
||||
{ field: 'soil', title: '土质', span: 12, itemRender: { name: '$input' } },
|
||||
{ field: 'unit', title: '单位', span: 12, itemRender: { name: '$input' } },
|
||||
|
||||
{
|
||||
title: '土质', span: 12,
|
||||
field: 'soil',
|
||||
itemRender: {
|
||||
name: 'MkFormDataSelector', props: {
|
||||
params: {
|
||||
dataType: "string",
|
||||
valueField: "name",
|
||||
textField: "name",
|
||||
listdataFieldName: 'MesEnumValue',
|
||||
actionParams:{
|
||||
search_rules_enum: [
|
||||
{
|
||||
column:"code",
|
||||
mode:"=",
|
||||
value:"5"
|
||||
}
|
||||
]
|
||||
},
|
||||
dataUrl: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '单位', span: 12,
|
||||
field: 'unit',
|
||||
itemRender: {
|
||||
name: 'MkFormDataSelector', props: {
|
||||
params: {
|
||||
dataType: "string",
|
||||
valueField: "name",
|
||||
textField: "name",
|
||||
listdataFieldName: 'MesUnit',
|
||||
dataUrl: `${BASE_URL.BASE_URL}/MesUnit/v1/mes/unit/list`
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
]
|
||||
},
|
||||
// 新增模式表单项
|
||||
|
|
@ -215,6 +375,26 @@ export default {
|
|||
|
||||
],
|
||||
|
||||
formOptions2Done: false,
|
||||
formOptions2: {
|
||||
data: {
|
||||
|
||||
},
|
||||
// 标题宽度
|
||||
titleWidth: 150,
|
||||
// 标题对齐方式
|
||||
titleAlign: 'right',
|
||||
|
||||
// 表单校验规则
|
||||
rules: {
|
||||
|
||||
},
|
||||
// 表单项
|
||||
items: [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -232,7 +412,95 @@ export default {
|
|||
this.options = pageData;
|
||||
},
|
||||
|
||||
|
||||
attributeDataInit(){
|
||||
this.$mk.post({
|
||||
url: this.options.actions.productAttribute,
|
||||
loading: "加载中..."
|
||||
}).then(a => {
|
||||
|
||||
let getOptions = (id) => {
|
||||
|
||||
let options = [];
|
||||
a.data.field.forEach(fieldItem => {
|
||||
if (fieldItem.attribute_id.toString() == id.toString()) {
|
||||
options.push({
|
||||
value: fieldItem.id.toString(),
|
||||
label: fieldItem.name
|
||||
})
|
||||
}
|
||||
})
|
||||
return options
|
||||
}
|
||||
|
||||
this.attributes = a.data.attribute;
|
||||
|
||||
let formData = {};
|
||||
a.data.attribute.forEach(item => {
|
||||
|
||||
let formItem = { field: '', title: '', span: 12, itemRender: {} };
|
||||
|
||||
formItem.field = "attr" + item.id;
|
||||
formItem.title = item.name;
|
||||
//属性类型:1.文本,2.数字,3.日期,4.时间,5.日期时间,6.单选,7.布尔
|
||||
if (item.typeName == "2") {
|
||||
formItem.itemRender.props = { type: "nubmer" };
|
||||
|
||||
formItem.itemRender.name = "$input";
|
||||
formData[formItem.field] = 0;
|
||||
}
|
||||
else if (item.typeName == "3" ||
|
||||
item.typeName == "4" ||
|
||||
item.typeName == "5") {
|
||||
|
||||
formItem.itemRender.name = "$input";
|
||||
formItem.itemRender.props = { type: "date" };
|
||||
|
||||
formData[formItem.field] = '';
|
||||
}
|
||||
else if (item.typeName == "6") {
|
||||
formItem.itemRender.name = "$select";
|
||||
formItem.itemRender.options = getOptions(item.id);
|
||||
if (!formItem.itemRender.options.length) {
|
||||
return;
|
||||
}
|
||||
formData[formItem.field] = formItem.itemRender.options[0].value;
|
||||
}
|
||||
else if (item.typeName == "7") {
|
||||
formItem.itemRender.name = "$switch";
|
||||
formItem.itemRender.props = { openLabel: '是', openValue: "true", closeValue: "false", closeLabel: '否' };
|
||||
|
||||
formData[formItem.field] = '1';
|
||||
} else {
|
||||
|
||||
formItem.itemRender.name = "$input";
|
||||
formData[formItem.field] = '';
|
||||
}
|
||||
|
||||
let ov = this.getOldAttributeValue(item.id);
|
||||
if(ov !== null){
|
||||
formData[formItem.field] = ov;
|
||||
}
|
||||
|
||||
this.options.formOptions2.items.push(formItem);
|
||||
})
|
||||
this.options.formOptions2.data = formData;
|
||||
|
||||
|
||||
this.options.formOptions2Done = true;
|
||||
this.$forceUpdate();
|
||||
|
||||
}).catch((a) => {
|
||||
this.$mk.error(a.data.msg);
|
||||
});
|
||||
},
|
||||
|
||||
dataInit() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取路由的id参数
|
||||
let dataId = this.getDataId();
|
||||
// 如果有id参数,说明是编辑模式
|
||||
|
|
@ -257,13 +525,16 @@ export default {
|
|||
if (a.data[detailDataFieldName].update_time) {
|
||||
a.data[detailDataFieldName].update_time = new Date(a.data[detailDataFieldName].update_time * 1000);
|
||||
}
|
||||
if(a.data[detailDataFieldName].mes_materials_sort){
|
||||
this.sortName = a.data[detailDataFieldName].mes_materials_sort.name;
|
||||
}
|
||||
|
||||
if (a.data[detailDataFieldName].mes_materials_sort) {
|
||||
this.sortName = a.data[detailDataFieldName].mes_materials_sort.name;
|
||||
}
|
||||
|
||||
|
||||
this.options.formOptions.data = a.data[detailDataFieldName];
|
||||
|
||||
this.custom_attribute_value = a.data[detailDataFieldName].custom_attribute_value || [];
|
||||
|
||||
this.attributeDataInit();
|
||||
this.$forceUpdate()
|
||||
}).catch((a) => {
|
||||
this.$mk.error(a.data.msg);
|
||||
|
|
@ -272,15 +543,26 @@ if(a.data[detailDataFieldName].mes_materials_sort){
|
|||
this.options.isEdit = true;
|
||||
|
||||
this.$forceUpdate()
|
||||
} else {
|
||||
// 如果没有id参数,说明是新增模式
|
||||
this.addModeItems.forEach(item => {
|
||||
this.options.formOptions.items.push(item);
|
||||
})
|
||||
|
||||
} else{
|
||||
|
||||
this.attributeDataInit();
|
||||
}
|
||||
},
|
||||
|
||||
getOldAttributeValue(attribute_id) {
|
||||
for(let i =0;i<this.custom_attribute_value.length;i++){
|
||||
if(this.custom_attribute_value[i].attribute_id.toString() == attribute_id.toString()){
|
||||
return this.custom_attribute_value[i].value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
},
|
||||
getAttributeValue(attribute_id) {
|
||||
return this.options.formOptions2.data["attr" + attribute_id.toString()];
|
||||
|
||||
},
|
||||
|
||||
// 获取路由的id参数
|
||||
getDataId() {
|
||||
let dataId = this.dataId;
|
||||
|
|
@ -292,7 +574,11 @@ if(a.data[detailDataFieldName].mes_materials_sort){
|
|||
}
|
||||
return dataId;
|
||||
},
|
||||
|
||||
getDataId_BigInt() {
|
||||
let dataId = this.getDataId();
|
||||
return this.$mk.toBigInt(dataId);
|
||||
},
|
||||
|
||||
// 返回
|
||||
back() {
|
||||
this.isEdit = this.options.isEdit;
|
||||
|
|
@ -327,6 +613,44 @@ if(a.data[detailDataFieldName].mes_materials_sort){
|
|||
if (this.isEdit) {
|
||||
// postdata = { MesUnit: postdata }
|
||||
}
|
||||
|
||||
|
||||
postdata.custom_attribute_value = [];
|
||||
|
||||
let findOldAttribute = (id) => {
|
||||
|
||||
let attrs = this.custom_attribute_value.filter(a => a.attribute_id.toString() == id.toString());
|
||||
if (attrs.length) {
|
||||
return attrs[0]
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
this.attributes.forEach(item => {
|
||||
|
||||
let v = this.getAttributeValue(item.id);
|
||||
let old = findOldAttribute(item.id);
|
||||
if (old != null) {
|
||||
old.value = v;
|
||||
old.e_value = v;
|
||||
postdata.custom_attribute_value.push(old);
|
||||
} else {
|
||||
|
||||
let newItem = {
|
||||
attribute_id: item.id,
|
||||
"value": v,
|
||||
"e_value": v
|
||||
};
|
||||
if (this.isEdit) {
|
||||
newItem.product_id = this.getDataId_BigInt();
|
||||
}
|
||||
postdata.custom_attribute_value.push(newItem)
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
console.log(postdata)
|
||||
// 格式化提交的数据
|
||||
this.$mk.formatFormData({ data: postdata, rules: this.options.formOptions.items });
|
||||
|
||||
|
|
@ -376,14 +700,14 @@ if(a.data[detailDataFieldName].mes_materials_sort){
|
|||
this.$refs.pulldownParent.togglePanel()
|
||||
},
|
||||
pulldownCellClickEvent({ row }) {
|
||||
|
||||
if(row.children && row.children.length){
|
||||
return;
|
||||
}
|
||||
this.options.formOptions.data.sort_id = row.id;
|
||||
|
||||
if (row.children && row.children.length) {
|
||||
return;
|
||||
}
|
||||
this.options.formOptions.data.sort_id = row.id;
|
||||
this.sortName = row.name;
|
||||
this.$refs.pulldownParent.hidePanel()
|
||||
|
||||
|
||||
},
|
||||
},
|
||||
// 监听属性
|
||||
|
|
|
|||
|
|
@ -106,16 +106,16 @@ export default {
|
|||
|
||||
|
||||
|
||||
{ field: 'spec', title: '规格型号' },
|
||||
{ field: 'size', title: '尺寸' },
|
||||
{ field: 'color', title: '颜色' },
|
||||
{ field: 'face', title: '花面', },
|
||||
{ field: 'molding', title: '成型方式' },
|
||||
{ field: 'production_type', title: '布产方式' },
|
||||
{ field: 'spec', title: '规格型号' , width: 150},
|
||||
{ field: 'size', title: '尺寸', width: 150 },
|
||||
{ field: 'color', title: '颜色', width: 150 },
|
||||
{ field: 'face', title: '花面', width: 150 },
|
||||
{ field: 'molding', title: '成型方式' , width: 150},
|
||||
{ field: 'production_type', title: '布产方式' , width: 150},
|
||||
|
||||
{ field: 'theoretical_load', title: '理论装车量' },
|
||||
{ field: 'soil', title: '土质' },
|
||||
{ field: 'unit', title: '单位' },
|
||||
{ field: 'theoretical_load', title: '理论装车量', width: 150 },
|
||||
{ field: 'soil', title: '土质', width: 150 },
|
||||
{ field: 'unit', title: '单位', width: 150 },
|
||||
|
||||
{ field: 'create_time', formatter: 'formatDate', width: 160, sortable: true, title: '创建时间', showHeaderOverflow: true }, // 创建时间
|
||||
{ field: 'update_time', formatter: 'formatDate', width: 160, sortable: true, title: '更新时间', showHeaderOverflow: true }, // 更新时间
|
||||
|
|
|
|||
|
|
@ -189,16 +189,16 @@ export default {
|
|||
|
||||
|
||||
|
||||
{ field: 'spec', title: '规格型号' },
|
||||
{ field: 'size', title: '尺寸' },
|
||||
{ field: 'color', title: '颜色' },
|
||||
{ field: 'face', title: '花面', },
|
||||
{ field: 'molding', title: '成型方式' },
|
||||
{ field: 'production_type', title: '布产方式' },
|
||||
{ field: 'spec', title: '规格型号' , width: 150 },
|
||||
{ field: 'size', title: '尺寸' , width: 150},
|
||||
{ field: 'color', title: '颜色' , width: 150},
|
||||
{ field: 'face', title: '花面' , width: 150 },
|
||||
{ field: 'molding', title: '成型方式' , width: 150 },
|
||||
{ field: 'production_type', title: '布产方式' , width: 150 },
|
||||
|
||||
{ field: 'theoretical_load', title: '理论装车量' },
|
||||
{ field: 'soil', title: '土质' },
|
||||
{ field: 'unit', title: '单位' },
|
||||
{ field: 'theoretical_load', title: '理论装车量' , width: 150 },
|
||||
{ field: 'soil', title: '土质' , width: 150 },
|
||||
{ field: 'unit', title: '单位' , width: 150 },
|
||||
{ field: 'create_time', formatter: 'formatDate', width: 160, sortable: true, title: '创建时间', showHeaderOverflow: true }, // 创建时间
|
||||
{ field: 'update_time', formatter: 'formatDate', width: 160, sortable: true, title: '更新时间', showHeaderOverflow: true }, // 更新时间
|
||||
|
||||
|
|
@ -522,6 +522,7 @@ export default {
|
|||
.right {
|
||||
flex-grow: 1;
|
||||
height: 100%;
|
||||
width: calc(100% - 300px);
|
||||
}
|
||||
|
||||
.treepanel {
|
||||
|
|
|
|||
|
|
@ -157,7 +157,25 @@ export default {
|
|||
// 表单项
|
||||
items: [
|
||||
{ field: 'name', title: '工序名称', span: 12, itemRender: { name: '$input' } },
|
||||
// { field: 'title', title: '工序名称', span: 12, itemRender: { name: '$input' } },
|
||||
{
|
||||
title: '工序分类', span: 12,
|
||||
field: 'mes_processes_sort',
|
||||
dataRule: {
|
||||
fromField: "id",
|
||||
saveField: "sort_id" // 如果表单项存储的是对象,将从fromField中取得值保存到saveField
|
||||
},
|
||||
itemRender: {
|
||||
name: 'MkFormDataSelector', props: {
|
||||
params: {
|
||||
dataType: "object",
|
||||
valueField: "id",
|
||||
textField: "name",
|
||||
listdataFieldName: 'MesProcessesSort',
|
||||
dataUrl: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/list`
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{ field: 'code', title: '工序编码', span: 12, itemRender: { name: '$input' } },
|
||||
{ field: 'desc', title: '工序描述', span: 12, itemRender: { name: '$input' } },
|
||||
{ field: 'remark', title: '工序备注', span: 12, itemRender: { name: '$input' } },
|
||||
|
|
|
|||
|
|
@ -1,10 +1,43 @@
|
|||
<template>
|
||||
<basic-page-list :desc="desc" @importData="pageImport" :options="pageOptions"></basic-page-list>
|
||||
|
||||
|
||||
<div class="wrapper">
|
||||
<div class="left">
|
||||
<div class="treepanel" :style="'height:' + tableHeight + 'px'">
|
||||
<div class="treepanel-header">
|
||||
<a @click.stop="treeAdd(row)" title="新增">
|
||||
<a-icon type="plus-circle" />
|
||||
</a>
|
||||
<a @click.stop="treeEdit(row)" title="编辑">
|
||||
<a-icon type="edit" />
|
||||
</a>
|
||||
<a @click.stop="treeDelete(row)" title="删除">
|
||||
<a-icon type="delete" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="treepanel-content">
|
||||
<a-tree v-if="!treeLoading" show-line :tree-data="treeData" :default-expand-all="true" :block-node="true"
|
||||
@select="onTreeSelect" :default-selected-keys="selectedKeys">
|
||||
<a-icon slot="switcherIcon" type="down" />
|
||||
</a-tree>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
<basic-page-list ref="listPage" :desc="desc" @importData="pageImport" :options="pageOptions"></basic-page-list>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BASE_URL from '@/services/mes/api.js';
|
||||
|
||||
let childrenFieldName = 'children';
|
||||
import { toArrayTree } from "xe-utils"
|
||||
const settings = require('../../basic/settings.js');
|
||||
|
||||
export default {
|
||||
|
|
@ -14,7 +47,30 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
pageOptions: {}
|
||||
pageOptions: {},
|
||||
|
||||
modelName: "",
|
||||
|
||||
actions: {
|
||||
treedata: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/list`,
|
||||
delete: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/batchDelete`,
|
||||
listdata: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/list`,
|
||||
save: `${BASE_URL.BASE_URL}/MesEnum/v1/mes/enum/value/batchHandle`,
|
||||
},
|
||||
tipTimes: 0,
|
||||
detailsData: [
|
||||
],
|
||||
sourceDetailsData: [
|
||||
|
||||
],
|
||||
treeData: [],
|
||||
treeLoading: true,
|
||||
deletedDetailsData: [
|
||||
|
||||
],
|
||||
selectedKeys: [],
|
||||
selectedKey: null,
|
||||
tableHeight: 500
|
||||
};
|
||||
},
|
||||
// 计算属性
|
||||
|
|
@ -29,6 +85,14 @@ export default {
|
|||
// 创建完成
|
||||
created() {
|
||||
this.optionsInit();
|
||||
|
||||
this.$nextTick(() => {
|
||||
|
||||
this.tableHeight = this.$mk.getWindowSize().height - 320;
|
||||
this.treeInit();
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
// 动作
|
||||
methods: {
|
||||
|
|
@ -142,7 +206,8 @@ export default {
|
|||
// 搜索区配置
|
||||
searchRules: [
|
||||
{ key: "name", mode: "like" },
|
||||
{ key: "code", mode: "like" }
|
||||
{ key: "code", mode: "like" },
|
||||
{ key: "sort_id", mode: "in" },
|
||||
],
|
||||
//搜索区
|
||||
searchFormItems: [ // 子项
|
||||
|
|
@ -176,7 +241,10 @@ 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 }, // 工序描述
|
||||
{ field: 'remark', sortable: true, title: '工序备注', width: 250 }, // 工序备注
|
||||
|
||||
|
|
@ -205,12 +273,348 @@ export default {
|
|||
|
||||
this.pageOptions = pageData;
|
||||
},
|
||||
treeInit() {
|
||||
this.treeLoading = true;
|
||||
this.$mk.post({
|
||||
url: this.actions.treedata,
|
||||
loading: "加载中...",
|
||||
data: {
|
||||
"page": 1,
|
||||
"limit": 10000,
|
||||
"end_time": 0,
|
||||
"start_time": 0,
|
||||
"order_bys": [
|
||||
],
|
||||
"search_rules": [
|
||||
]
|
||||
}
|
||||
}).then(r => {
|
||||
|
||||
|
||||
let treedata = {
|
||||
title: "工序分类",
|
||||
key: "root"
|
||||
};
|
||||
let at = toArrayTree(r.data.MesProcessesSort, { parentKey: "parent_id" });
|
||||
console.log(at);
|
||||
treedata[childrenFieldName] = at;
|
||||
|
||||
|
||||
function formatTreedata(d) {
|
||||
if (d.id) {
|
||||
d.key = d.id.toString();
|
||||
} else {
|
||||
d.key = "root";
|
||||
}
|
||||
if (d.name) {
|
||||
d.title = d.name;
|
||||
}
|
||||
if (d[childrenFieldName] && d[childrenFieldName].length) {
|
||||
d[childrenFieldName].forEach(item => formatTreedata(item))
|
||||
}
|
||||
}
|
||||
treedata[childrenFieldName].forEach(item => formatTreedata(item))
|
||||
|
||||
this.treeData = [treedata];
|
||||
this.treeLoading = false;
|
||||
});
|
||||
|
||||
},
|
||||
treeAdd() {
|
||||
this.$mk.dialog.open({
|
||||
page: () => import("./treeEdit"),
|
||||
title: "新增-分类",
|
||||
dataId: 0,
|
||||
callback: ({ success }) => {
|
||||
success && this.treeInit();
|
||||
}
|
||||
})
|
||||
},
|
||||
treeEdit() {
|
||||
if (!this.selectedKey || this.selectedKey == "root") {
|
||||
this.$mk.error("请先选择分类");
|
||||
return;
|
||||
}
|
||||
let node = this.findTreeNode(this.selectedKey);
|
||||
|
||||
|
||||
this.$mk.dialog.open({
|
||||
page: () => import("./treeEdit"),
|
||||
title: "编辑-分类",
|
||||
dataId: node.id,
|
||||
callback: ({ success }) => {
|
||||
success && this.treeInit();
|
||||
}
|
||||
})
|
||||
},
|
||||
treeDelete() {
|
||||
if (!this.selectedKey || this.selectedKey == "root") {
|
||||
this.$mk.error("请先选择分类");
|
||||
return;
|
||||
}
|
||||
let node = this.findTreeNode(this.selectedKey);
|
||||
let ids = [
|
||||
node.id
|
||||
]; // 定义id数组
|
||||
|
||||
if (!ids.length) { // 如果没有选中行
|
||||
this.$mk.error("请选择行"); // 提示
|
||||
return;
|
||||
}
|
||||
|
||||
this.$mk.confirm('您确定要删除吗?').then(type => { // 确认删除
|
||||
if (type == 'confirm') { // 如果确认删除
|
||||
this.$mk.post({
|
||||
url: this.actions.delete, // 请求删除数据地址
|
||||
loading: "删除中...", // 加载提示
|
||||
data: {
|
||||
ids: ids // 传递id数组
|
||||
},
|
||||
useBigInt: true
|
||||
}).then(() => { // 成功
|
||||
this.$mk.success("删除成功"); // 提示成功
|
||||
this.treeInit(); // 重新加载数据
|
||||
}).catch((a) => { // 失败
|
||||
this.$mk.error(a.data.msg); // 提示错误信息
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
getDataId() {
|
||||
|
||||
let dataId = this.dataId;
|
||||
if (this.$route.params.id) {
|
||||
dataId = this.$route.params.id;
|
||||
}
|
||||
|
||||
return dataId;
|
||||
},
|
||||
|
||||
|
||||
onTreeSelect(selectedKeys) {
|
||||
if (selectedKeys && selectedKeys[0]) {
|
||||
this.selectedKey = selectedKeys[0];
|
||||
this.loadData(selectedKeys[0]);
|
||||
}
|
||||
},
|
||||
findTreeNode(key) {
|
||||
var find = (items) => {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (items[i].key == key) {
|
||||
return items[i];
|
||||
}
|
||||
if (items[i][childrenFieldName] && items[i][childrenFieldName].length) {
|
||||
var xx = find(items[i][childrenFieldName]);
|
||||
if (xx) {
|
||||
return xx;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return find(this.treeData);
|
||||
},
|
||||
reloadData() {
|
||||
if (this.selectedKey) {
|
||||
this.loadData(this.selectedKey);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
getAllChildrenIds(items) {
|
||||
let ids = [];
|
||||
let eachItems = (arr) => {
|
||||
arr.forEach(item => {
|
||||
if (item.children && item.children.length) {
|
||||
eachItems(item.children);
|
||||
} else {
|
||||
ids.push(item.id);
|
||||
}
|
||||
|
||||
})
|
||||
};
|
||||
eachItems(items);
|
||||
return ids;
|
||||
},
|
||||
loadData(key) {
|
||||
|
||||
if (key && key != "root") {
|
||||
var node = this.findTreeNode(key);
|
||||
if (node.children && node.children.length) {
|
||||
var ids = this.getAllChildrenIds(node.children);
|
||||
this.$refs.listPage.onSearch({
|
||||
sort_id: [node.id, ...ids].join(',')
|
||||
})
|
||||
} else {
|
||||
this.$refs.listPage.onSearch({
|
||||
sort_id: node.id
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
this.$refs.listPage.onSearch(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
findSourceInfo(idStr) {
|
||||
for (var i = 0; i < this.sourceDetailsData.length; i++) {
|
||||
let o = this.sourceDetailsData[i];
|
||||
if (o.id.toString() == idStr) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
},
|
||||
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() {
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.back();
|
||||
},
|
||||
pageAdd(row) {
|
||||
|
||||
const $table = this.$refs.xTable
|
||||
const record = {
|
||||
}
|
||||
if (row) {
|
||||
|
||||
this.detailsData.splice($table.getRowSeq(row), 0, record);
|
||||
} else {
|
||||
this.detailsData.push(record)
|
||||
}
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
pageDelete(row) {
|
||||
const $table = this.$refs.xTable;
|
||||
if (row.id) {
|
||||
this.deletedDetailsData.push(row.id)
|
||||
}
|
||||
this.detailsData.splice($table.getRowSeq(row) - 1, 1);
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.page-body {
|
||||
background: white;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* 左侧固定宽度 200px,右侧自适应 */
|
||||
.wrapper {
|
||||
display: flex;
|
||||
}
|
||||
.left {
|
||||
width: 200px;
|
||||
height: 100%;
|
||||
}
|
||||
.right {
|
||||
flex-grow: 1;
|
||||
height: 100%;
|
||||
width: calc(100% - 300px);
|
||||
}
|
||||
|
||||
.treepanel {
|
||||
width: calc(100% - 10px);
|
||||
|
||||
background: white;
|
||||
margin-right: 10px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.treepanel-content {
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
.treepanel-header {
|
||||
width: 100%;
|
||||
background: #F8F8F9;
|
||||
border-bottom: 1px solid #ccc;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
margin: 0;
|
||||
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.treepanel-header .anticon {
|
||||
margin-left: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toolbarbtns .ant-btn {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.toolbarbtns {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,150 @@
|
|||
<template>
|
||||
<div class="page-body">
|
||||
|
||||
<vxe-form :data="formOptions.data" ref="xForm" :title-width="formOptions.titleWidth"
|
||||
:title-align="formOptions.titleAlign" :rules="formOptions.rules" :items="formOptions.items" titleColon>
|
||||
</vxe-form>
|
||||
|
||||
<div class="footerbar">
|
||||
<a-button type="primary" @click="ok">确定</a-button>
|
||||
<a-button @click="cancel">取消</a-button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BASE_URL from '@/services/base/api.js';
|
||||
|
||||
export default {
|
||||
|
||||
props: {
|
||||
dataId: {
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
data() {
|
||||
|
||||
// 页面数据变量
|
||||
var pageData = {
|
||||
|
||||
actions: {
|
||||
create: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/create`,
|
||||
update: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/update`,
|
||||
get: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/detail`,
|
||||
list: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/sort/list`,
|
||||
},
|
||||
|
||||
|
||||
formOptions: {
|
||||
data: {
|
||||
"name": "",
|
||||
"e_name": ""
|
||||
},
|
||||
|
||||
titleWidth: 150,
|
||||
titleAlign: 'right',
|
||||
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: '请输入名称' }
|
||||
],
|
||||
e_name: [
|
||||
{ required: true, message: '请输入名称(英文)' }
|
||||
]
|
||||
},
|
||||
|
||||
items: [
|
||||
{ field: 'name', title: '名称', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入名称' } } },
|
||||
{ field: 'e_name', title: '名称(英文)', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入名称(英文)' } } },
|
||||
{ field: 'code', title: '编号', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入编号' } } },
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
pageData.formOptions = Object.assign({}, this.$mk.config.defaults.formOptions, pageData.formOptions);
|
||||
|
||||
return pageData;
|
||||
},
|
||||
created() {
|
||||
if (this.dataId) {
|
||||
this.$mk.post({
|
||||
url: this.actions.get,
|
||||
loading: "加载中...",
|
||||
data: {
|
||||
id: this.dataId
|
||||
},
|
||||
useBigInt: true
|
||||
}).then(a => {
|
||||
this.formOptions.data = a.data.mes_processes_sort;
|
||||
|
||||
this.parentNameInit() ;
|
||||
}).catch((a) => {
|
||||
this.$mk.error(a.data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
// 函数
|
||||
methods: {
|
||||
|
||||
|
||||
|
||||
loadData() {
|
||||
},
|
||||
|
||||
ok() {
|
||||
|
||||
let save = () => {
|
||||
let action = !this.dataId ? this.actions.create : this.actions.update;
|
||||
let postdata = Object.assign({ id: this.dataId }, this.formOptions.data);
|
||||
|
||||
|
||||
this.$mk.post({
|
||||
url: action,
|
||||
loading: "保存中...",
|
||||
data: postdata,
|
||||
useBigInt: true
|
||||
}).then(() => {
|
||||
this.$mk.success("保存成功");
|
||||
this.$emit("callback", { success: true });
|
||||
}).catch((a) => {
|
||||
this.$mk.error(a.data.msg);
|
||||
});
|
||||
};
|
||||
|
||||
this.$refs.xForm.validate((a) => {
|
||||
let count = 0;
|
||||
if (a) {
|
||||
for (let name in a) {
|
||||
a[name];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
this.$mk.error(`存在${count}项错误,请检查`);
|
||||
}
|
||||
else {
|
||||
save();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.$emit("callback", {});
|
||||
},
|
||||
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
<style></style>
|
||||
|
|
@ -1,13 +1,57 @@
|
|||
<template>
|
||||
<basic-page-edit :desc="desc" :dataId="getDataId()" :options="pageOptions"></basic-page-edit>
|
||||
<div class="page-body">
|
||||
|
||||
<vxe-form :data="formOptions.data" ref="xForm" :title-width="formOptions.titleWidth"
|
||||
:title-align="formOptions.titleAlign" :rules="formOptions.rules" :items="formOptions.items" titleColon>
|
||||
</vxe-form>
|
||||
|
||||
<vxe-table v-if="formOptions.data.typeName == '6'" border show-overflow keep-source ref="xTable"
|
||||
:height="table1Height" :data="detailsData" @pulldownSelected="onPulldownSelected" @popupSelected="onPopupSelected"
|
||||
:export-config="{}" @edit-closed="afterEditEvent" @edit-actived="beforeEditEvent"
|
||||
:edit-config="{ trigger: 'click', mode: 'cell', icon: 'vxe-icon-edit', showStatus: false, beforeEditMethod: beforeEditMethod }">
|
||||
<vxe-column width="60">
|
||||
<template #default="{ row }">
|
||||
<div class="oplinks2">
|
||||
<a @click.stop="pageAdd(row)" title="新增">
|
||||
<a-icon class="icon" type="plus-circle" />
|
||||
</a>
|
||||
<a @click.stop="pageDelete(row)" title="删除">
|
||||
<a-icon class="icon" type="delete" />
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
||||
</vxe-column>
|
||||
|
||||
<vxe-column field="name" title="属性选项" width="120" :edit-render="{ name: '$input', props: {} }">
|
||||
</vxe-column>
|
||||
<vxe-column field="code" title="编码" width="120" :edit-render="{ name: '$input', props: {} }">
|
||||
</vxe-column>
|
||||
<vxe-column field="e_name" title="属性选项(英文)" width="120" :edit-render="{ name: '$input', props: {} }">
|
||||
</vxe-column>
|
||||
<vxe-column field="description" title="描述" width="120" :edit-render="{ name: '$input', props: {} }">
|
||||
</vxe-column>
|
||||
|
||||
</vxe-table>
|
||||
|
||||
<div class="mk-toolbar" v-if="isEdit">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="footerbar">
|
||||
<a-button type="primary" @click="ok">确定</a-button>
|
||||
<a-button @click="cancel">取消</a-button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BASE_URL from '@/services/mes/api.js';
|
||||
|
||||
const settings = require('../../basic/settings.js');
|
||||
|
||||
export default {
|
||||
|
||||
name: 'BathroomPartsUpdate',
|
||||
i18n: require('./i18n'),
|
||||
components: {},
|
||||
props: {
|
||||
|
|
@ -17,13 +61,126 @@ export default {
|
|||
},
|
||||
dataId: {
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
data() {
|
||||
|
||||
return {
|
||||
pageOptions: {}
|
||||
//let _this = this;
|
||||
// 页面数据变量
|
||||
var pageData = {
|
||||
// 当前项目名称
|
||||
currentConfigName: "",
|
||||
// 当前项目ID
|
||||
currentBeid: 0,
|
||||
|
||||
uploadDefaultImg: null,
|
||||
detailDataFieldName: "attribute",
|
||||
|
||||
actions: {
|
||||
get: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/attribute/detail`,
|
||||
create: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/attribute/create`,
|
||||
update: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/attribute/update`,
|
||||
detailsData: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/field/list`,
|
||||
saveDetails: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/field/batchHandle`,
|
||||
},
|
||||
|
||||
keyName: 'id',
|
||||
// 是否编辑模式
|
||||
isEdit: false,
|
||||
// 表单数据
|
||||
formOptions: {
|
||||
data: {
|
||||
name: '',
|
||||
typeName: '1'
|
||||
},
|
||||
// 标题宽度
|
||||
titleWidth: 140,
|
||||
// 标题对齐方式
|
||||
titleAlign: 'right',
|
||||
|
||||
// 表单校验规则
|
||||
rules: {
|
||||
|
||||
name: [
|
||||
{ required: true, message: '请输入属性名称' }
|
||||
],
|
||||
category: [
|
||||
{ required: true, message: '请选择分类' }
|
||||
]
|
||||
|
||||
},
|
||||
// 表单项
|
||||
items: [
|
||||
|
||||
{ field: 'name', title: '属性名称', span: 8, itemRender: { name: '$input' } },
|
||||
{ field: 'e_name', title: '属性名称(英文)', span: 8, itemRender: { name: '$input' } },
|
||||
{ field: 'code', title: '编码', span: 8, itemRender: { name: '$input' } },
|
||||
{
|
||||
title: '分类', span: 8,
|
||||
field: 'category',
|
||||
dataRule: {
|
||||
fromField: "id",
|
||||
saveField: "category_id" // 如果表单项存储的是对象,将从fromField中取得值保存到saveField
|
||||
},
|
||||
itemRender: {
|
||||
name: 'MkFormDataSelector', props: {
|
||||
params: {
|
||||
dataType: "object",
|
||||
valueField: "id",
|
||||
textField: "name",
|
||||
listdataFieldName: 'Category',
|
||||
dataUrl: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/list`
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ field: 'typeName', title: '属性类型', span: 8, itemRender: { name: '$select', props: { options: settings.options_attribute_types } } },
|
||||
]
|
||||
},
|
||||
// 新增模式表单项
|
||||
addModeItems: [
|
||||
|
||||
],
|
||||
|
||||
|
||||
table1Height: 400,
|
||||
detailsSourceData: [
|
||||
],
|
||||
detailsData: [
|
||||
],
|
||||
deletedDetailsData: [
|
||||
|
||||
],
|
||||
editorMaterials: {
|
||||
dataType: "object",
|
||||
valueField: "id",
|
||||
textField: "name",
|
||||
listdataFieldName: 'MesMaterials',
|
||||
dataUrl: `${BASE_URL.BASE_URL}/MesMaterials/v1/mes/materials/list`
|
||||
},
|
||||
editorWarehouse: {
|
||||
dataType: "object",
|
||||
valueField: "id",
|
||||
textField: "warehouse_name",
|
||||
listdataFieldName: 'MesWarehouse',
|
||||
searchFieldNames: ['warehouse_name'],
|
||||
columns: [ // 表格列
|
||||
{ field: 'warehouse_name', title: '名称' }, // 字段名称,字段标题
|
||||
{ field: 'code', title: '编码' } // 字段名称,字段标题
|
||||
],
|
||||
dataUrl: `${BASE_URL.BASE_URL}/MesWarehouse/v1/mes/warehouse/list`
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
// 合并表单数据及配置
|
||||
pageData.formOptions = Object.assign({}, this.$mk.config.defaults.formOptions, pageData.formOptions);
|
||||
|
||||
return pageData;
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
|
@ -35,8 +192,50 @@ export default {
|
|||
|
||||
created() {
|
||||
|
||||
this.optionsInit();
|
||||
this.dataInit();
|
||||
|
||||
// 获取路由的id参数
|
||||
let dataId = this.getDataId();
|
||||
|
||||
// 如果有id参数,说明是编辑模式
|
||||
if (dataId) {
|
||||
this.$mk.post({
|
||||
url: this.actions.get,
|
||||
loading: "加载中...",
|
||||
data: { id: this.$mk.toBigInt(dataId) },
|
||||
useBigInt: true
|
||||
}).then(a => {
|
||||
// =============================== 时间字段判断 自动生成 Start ===============================
|
||||
|
||||
if (a.data[this.detailDataFieldName].create_time) {
|
||||
a.data[this.detailDataFieldName].create_time = new Date(a.data[this.detailDataFieldName].create_time * 1000);
|
||||
}
|
||||
if (a.data[this.detailDataFieldName].update_time) {
|
||||
a.data[this.detailDataFieldName].update_time = new Date(a.data[this.detailDataFieldName].update_time * 1000);
|
||||
}
|
||||
|
||||
// =============================== 时间字段判断 自动生成 End ===============================
|
||||
this.formOptions.data = a.data[this.detailDataFieldName];
|
||||
|
||||
}).catch((a) => {
|
||||
this.$mk.error(a.data.msg);
|
||||
});
|
||||
|
||||
this.isEdit = true;
|
||||
|
||||
this.detailsDataLoad(dataId);
|
||||
|
||||
} else {
|
||||
// 如果没有id参数,说明是新增模式
|
||||
this.addModeItems.forEach(item => {
|
||||
this.formOptions.items.push(item);
|
||||
})
|
||||
|
||||
this.detailsDataInit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.heightInit();
|
||||
|
||||
},
|
||||
// 函数
|
||||
|
|
@ -44,178 +243,50 @@ export default {
|
|||
|
||||
|
||||
|
||||
optionsInit() {
|
||||
// 页面数据变量
|
||||
var pageData = {
|
||||
// 当前项目名称
|
||||
currentConfigName: "",
|
||||
// 当前项目ID
|
||||
currentBeid: 0,
|
||||
detailsDataLoad(id) {
|
||||
|
||||
addPageUrl: "/MesProductCustomAttribute/MesProductCustomAttributeAdd",
|
||||
editPageUrl: "/MesProductCustomAttribute/MesProductCustomAttributeUpdate/",
|
||||
listPageUrl: "/MesProductCustomAttribute/MesProductCustomAttributeList",
|
||||
|
||||
|
||||
uploadDefaultImg: null,
|
||||
detailDataFieldName: "mes_product_custom_attribute",
|
||||
|
||||
actions: {
|
||||
// =============================== 接口地址 自动生成 Start ===============================
|
||||
MesProductCustomAttributeList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/list`, // 商品自定义属性分类列表
|
||||
MesProductCustomAttributeDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/detail`, // 商品自定义属性分类详情
|
||||
MesProductCustomAttributeCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/create`, // 创建商品自定义属性分类
|
||||
MesProductCustomAttributeUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/update`, // 更新商品自定义属性分类
|
||||
MesProductCustomAttributeDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/detele`, // 删除商品自定义属性分类
|
||||
MesProductCustomAttributeBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchDelete`, // 批量删除商品自定义属性分类
|
||||
MesProductCustomAttributeBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchUpdate`, // 批量更新商品自定义属性分类
|
||||
MesProductCustomAttributeBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchCreate`, // 批量创建商品自定义属性分类
|
||||
MesProductCustomAttributeExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/export/excel`, // 导出商品自定义属性分类数据到EXCEL
|
||||
MesProductCustomAttributeImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/import/excel`, // 批量导入EXCEL商品自定义属性分类数据
|
||||
ProductCustomAttributeList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/list`, // 商品自定义属性列表
|
||||
ProductCustomAttributeDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/detail`, // 商品自定义属性详情
|
||||
ProductCustomAttributeCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/create`, // 创建商品自定义属性
|
||||
ProductCustomAttributeUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/update`, // 更新商品自定义属性
|
||||
ProductCustomAttributeDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/detele`, // 删除商品自定义属性
|
||||
ProductCustomAttributeBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchDelete`, // 批量删除商品自定义属性
|
||||
ProductCustomAttributeBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchUpdate`, // 批量更新商品自定义属性
|
||||
ProductCustomAttributeBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchCreate`, // 批量创建商品自定义属性
|
||||
ProductCustomAttributeExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/export/excel`, // 导出商品自定义属性数据到EXCEL
|
||||
ProductCustomAttributeImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/import/excel`, // 批量导入EXCEL商品自定义属性数据
|
||||
ProductCustomAttributeFieldList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/list`, // 商品自定义属性字段列表
|
||||
ProductCustomAttributeFieldDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/detail`, // 商品自定义属性字段详情
|
||||
ProductCustomAttributeFieldCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/create`, // 创建商品自定义属性字段
|
||||
ProductCustomAttributeFieldUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/update`, // 更新商品自定义属性字段
|
||||
ProductCustomAttributeFieldDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/detele`, // 删除商品自定义属性字段
|
||||
ProductCustomAttributeFieldBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchDelete`, // 批量删除商品自定义属性字段
|
||||
ProductCustomAttributeFieldBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchUpdate`, // 批量更新商品自定义属性字段
|
||||
ProductCustomAttributeFieldBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchCreate`, // 批量创建商品自定义属性字段
|
||||
ProductCustomAttributeFieldExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/export/excel`, // 导出商品自定义属性字段数据到EXCEL
|
||||
ProductCustomAttributeFieldImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/import/excel`, // 批量导入EXCEL商品自定义属性字段数据
|
||||
ProductCustomAttributeValueList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/list`, // 商品自定义属性值列表
|
||||
ProductCustomAttributeValueDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/detail`, // 商品自定义属性值详情
|
||||
ProductCustomAttributeValueCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/create`, // 创建商品自定义属性值
|
||||
ProductCustomAttributeValueUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/update`, // 更新商品自定义属性值
|
||||
ProductCustomAttributeValueDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/detele`, // 删除商品自定义属性值
|
||||
ProductCustomAttributeValueBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchDelete`, // 批量删除商品自定义属性值
|
||||
ProductCustomAttributeValueBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchUpdate`, // 批量更新商品自定义属性值
|
||||
ProductCustomAttributeValueBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchCreate`, // 批量创建商品自定义属性值
|
||||
ProductCustomAttributeValueExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/export/excel`, // 导出商品自定义属性值数据到EXCEL
|
||||
ProductCustomAttributeValueImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/import/excel`, // 批量导入EXCEL商品自定义属性值数据
|
||||
|
||||
// =============================== 接口地址 自动生成 End ===============================
|
||||
},
|
||||
|
||||
keyName: 'id',
|
||||
// 是否编辑模式
|
||||
isEdit: false,
|
||||
// 表单数据
|
||||
formOptions: {
|
||||
data: {
|
||||
// =============================== 表单数据 自动生成 Start ===============================
|
||||
|
||||
id: 0,
|
||||
code: "",
|
||||
title: "",
|
||||
name: "",
|
||||
description: "",
|
||||
create_uid: 0,
|
||||
update_uid: 0,
|
||||
create_time: new Date(2100, 1, 1).getTime() / 10000,
|
||||
update_time: new Date(2100, 1, 1).getTime() / 10000,
|
||||
|
||||
// =============================== 表单数据 自动生成 End ===============================
|
||||
},
|
||||
// 标题宽度
|
||||
titleWidth: 160,
|
||||
// 标题对齐方式
|
||||
titleAlign: 'right',
|
||||
|
||||
// 表单校验规则
|
||||
rules: {
|
||||
// =============================== 表单校验 自动生成 Start ===============================
|
||||
|
||||
|
||||
name: [
|
||||
{ required: true, message: '请输入属性分类英文名称' }
|
||||
]
|
||||
|
||||
// =============================== 表单校验 自动生成 End ===============================
|
||||
},
|
||||
// 表单项
|
||||
items: [
|
||||
// =============================== 表单项 自动生成 Start ===============================
|
||||
|
||||
{ field: 'name', title: '属性名称', span: 24, itemRender: { name: '$input' } },
|
||||
{ field: 'title', title: '分类名称', span: 24, itemRender: { name: '$input' } },
|
||||
{ field: 'code', title: '编码', span: 24, itemRender: { name: '$input' } },
|
||||
{ field: 'description', title: '属性分类描述', span: 12, itemRender: { name: '$input' } },
|
||||
|
||||
// =============================== 表单项 自动生成 End ===============================
|
||||
this.$mk.post({
|
||||
url: this.actions.detailsData,
|
||||
loading: "加载中...",
|
||||
data: {
|
||||
"page": 1,
|
||||
"limit": 10000,
|
||||
"start_time": 0,
|
||||
"end_time": 0,
|
||||
"search_rules": [
|
||||
{
|
||||
column: "attribute_id", // 字段名
|
||||
mode: "=", // 搜索模式
|
||||
value: id.toString()
|
||||
}
|
||||
],
|
||||
"order_bys": [
|
||||
]
|
||||
},
|
||||
// 新增模式表单项
|
||||
addModeItems: [
|
||||
useBigInt: true
|
||||
}).then(a => {
|
||||
|
||||
],
|
||||
this.detailsSourceData = a.data.Field || [];
|
||||
this.detailsData = JSON.parse(JSON.stringify(a.data.Field || []));
|
||||
|
||||
|
||||
};
|
||||
|
||||
pageData.actions.get = pageData.actions.MesProductCustomAttributeDetail;
|
||||
pageData.actions.create = pageData.actions.MesProductCustomAttributeCreate;
|
||||
pageData.actions.update = pageData.actions.MesProductCustomAttributeUpdate;
|
||||
// 合并表单数据及配置
|
||||
pageData.formOptions = Object.assign({}, this.$mk.config.defaults.formOptions, pageData.formOptions);
|
||||
|
||||
this.pageOptions = pageData;
|
||||
this.detailsDataInit();
|
||||
});
|
||||
},
|
||||
|
||||
dataInit() {
|
||||
// 获取路由的id参数
|
||||
let dataId = this.getDataId();
|
||||
// 如果有id参数,说明是编辑模式
|
||||
if (dataId) {
|
||||
const json = `{"id":${dataId}}`;
|
||||
this.$mk.post({
|
||||
url: this.pageOptions.actions.get,
|
||||
loading: "加载中...",
|
||||
data: json,
|
||||
config: {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
}).then(a => {
|
||||
heightInit() {
|
||||
|
||||
let detailDataFieldName = this.pageOptions.detailDataFieldName;
|
||||
this.$nextTick(() => {
|
||||
let h = this.$mk.getWindowSize().height - this.$mk.getOffsetTop(this.$refs.xTable.$el) - 380;
|
||||
|
||||
if (a.data[detailDataFieldName].create_time) {
|
||||
a.data[detailDataFieldName].create_time = new Date(a.data[detailDataFieldName].create_time * 1000);
|
||||
}
|
||||
if (a.data[detailDataFieldName].update_time) {
|
||||
a.data[detailDataFieldName].update_time = new Date(a.data[detailDataFieldName].update_time * 1000);
|
||||
}
|
||||
|
||||
this.pageOptions.formOptions.data = a.data[detailDataFieldName];
|
||||
|
||||
this.$forceUpdate()
|
||||
}).catch((a) => {
|
||||
this.$mk.error(a.data.msg);
|
||||
});
|
||||
|
||||
this.pageOptions.isEdit = true;
|
||||
|
||||
this.$forceUpdate()
|
||||
} else {
|
||||
// 如果没有id参数,说明是新增模式
|
||||
this.addModeItems.forEach(item => {
|
||||
this.pageOptions.formOptions.items.push(item);
|
||||
})
|
||||
this.table1Height = h;
|
||||
});
|
||||
|
||||
},
|
||||
detailsDataInit() {
|
||||
for (let i = this.detailsData.length; i < 10; i++) {
|
||||
this.detailsData.push({});
|
||||
}
|
||||
},
|
||||
|
||||
// 获取路由的id参数
|
||||
getDataId() {
|
||||
let dataId = this.dataId;
|
||||
|
|
@ -226,7 +297,240 @@ export default {
|
|||
dataId = 0;
|
||||
}
|
||||
return dataId;
|
||||
}
|
||||
},
|
||||
getDataId_BigInt() {
|
||||
let dataId = this.getDataId();
|
||||
return this.$mk.toBigInt(dataId);
|
||||
},
|
||||
|
||||
|
||||
// 返回
|
||||
back() {
|
||||
// 如果是新增模式,关闭当前页面
|
||||
if (!this.isEdit) {
|
||||
this.$closePage({
|
||||
closeRoute: "/MesProductCustomAttribute/MesProductCustomAttributeAdd"
|
||||
});
|
||||
} else {
|
||||
// 如果是编辑模式,关闭当前页面
|
||||
this.$closePage({
|
||||
closeRoute: "/MesProductCustomAttribute/MesProductCustomAttributeUpdate"
|
||||
});
|
||||
}
|
||||
// 打开列表页面
|
||||
this.$openPage('/MesProductCustomAttribute/MesProductCustomAttributeList')
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 保存
|
||||
ok() {
|
||||
|
||||
|
||||
|
||||
|
||||
let saveDetails = (dataId) => {
|
||||
|
||||
dataId = dataId || this.getDataId_BigInt();
|
||||
let ds = [];
|
||||
|
||||
this.detailsData.forEach(item => {
|
||||
if (item.name) {
|
||||
let o = Object.assign({}, item);
|
||||
if (item.id) {
|
||||
o.id = this.$mk.toBigInt(item.id);
|
||||
}
|
||||
ds.push(o);
|
||||
}
|
||||
});
|
||||
|
||||
console.log(this.formOptions.data)
|
||||
var postdata = {
|
||||
insertList: [],
|
||||
updateList: [],
|
||||
deleteList: this.deletedDetailsData
|
||||
};
|
||||
|
||||
ds.forEach(item => {
|
||||
delete item._X_ROW_KEY;
|
||||
|
||||
item.attribute_id = dataId;
|
||||
if(this.formOptions.data.category_id){
|
||||
item.category_id = this.formOptions.data.category_id;
|
||||
}else if(this.formOptions.data.category && this.formOptions.data.category.id){
|
||||
item.category_id = this.formOptions.data.category.id;
|
||||
|
||||
}
|
||||
|
||||
if (item.id) {
|
||||
postdata.updateList.push(item);
|
||||
} else {
|
||||
postdata.insertList.push(item);
|
||||
}
|
||||
})
|
||||
this.$mk.post({
|
||||
url: this.actions.saveDetails,
|
||||
data: postdata,
|
||||
useBigInt: true
|
||||
}).then(a => {
|
||||
if (a.code == "200") {
|
||||
|
||||
this.$mk.success("保存成功");
|
||||
if (!this.isEdit) { // 如果是新增模式,关闭当前页面
|
||||
this.back();
|
||||
}
|
||||
|
||||
} else {
|
||||
this.$mk.error(a.msg || a.message);
|
||||
}
|
||||
|
||||
|
||||
}).catch((a) => {
|
||||
this.$mk.error(a.msg || a.data.msg);
|
||||
});
|
||||
};
|
||||
let save = () => {
|
||||
|
||||
|
||||
// 如果是新增模式,提交新增接口 如果是编辑模式,提交编辑接口
|
||||
let action = !this.isEdit ? this.actions.create : this.actions.update;
|
||||
// 如果是新增模式,提交的数据中加入id 如果是编辑模式,提交的数据中不加入id
|
||||
let postdata = Object.assign({}, this.formOptions.data);
|
||||
// 如果是编辑模式
|
||||
if (this.isEdit) {
|
||||
// postdata = { BathroomParts: postdata }
|
||||
}
|
||||
// 格式化提交的数据
|
||||
this.$mk.formatFormData({ data: postdata, rules: this.formOptions.items });
|
||||
|
||||
|
||||
|
||||
// 提交数据
|
||||
this.$mk.post({
|
||||
url: action,
|
||||
loading: "保存中...",
|
||||
data: postdata,
|
||||
useBigInt: true,
|
||||
}).then((a) => { // 成功回调
|
||||
if (a.code == "200") {
|
||||
|
||||
|
||||
saveDetails(a.data.id);
|
||||
|
||||
} else {
|
||||
this.$mk.error(a.msg || a.message);
|
||||
}
|
||||
|
||||
|
||||
}).catch((a) => {
|
||||
this.$mk.error(a.msg || a.data.msg );
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 验证表单
|
||||
this.$mk.validateForm({ form: this.$refs.xForm }).then(() => { // 验证表单
|
||||
|
||||
save(); // 提交保存
|
||||
|
||||
|
||||
}).catch(count => { // 验证失败
|
||||
this.$mk.error(`存在${count}项错误,请检查`);
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
// 取消 返回
|
||||
cancel() {
|
||||
this.back();
|
||||
},
|
||||
|
||||
|
||||
pageAdd(row) {
|
||||
const $table = this.$refs.xTable
|
||||
const record = {
|
||||
}
|
||||
if (row) {
|
||||
|
||||
this.detailsData.splice($table.getRowSeq(row), 0, record);
|
||||
} else {
|
||||
this.detailsData.push(record)
|
||||
}
|
||||
},
|
||||
|
||||
pageDelete(row) {
|
||||
const $table = this.$refs.xTable;
|
||||
if (row.id) {
|
||||
this.deletedDetailsData.push(this.$mk.toBigInt(row.id))
|
||||
}
|
||||
this.detailsData.splice($table.getRowSeq(row) - 1, 1);
|
||||
},
|
||||
beforeEditMethod({ column, row }) {
|
||||
|
||||
if (row.SourceTableID && column.field != "Quantity") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
afterEditEvent({ column, row }) {
|
||||
if (column.field == "Quantity" || column.field == "Price") {
|
||||
row.Amount = parseInt(row.Quantity || 0) * parseFloat(row.Price || 0);
|
||||
|
||||
}
|
||||
|
||||
if (column.field == "specification") {
|
||||
row.specification = this.specification;
|
||||
}
|
||||
},
|
||||
beforeEditEvent({ column, row }) {
|
||||
if (row.SourceTableID && column.field != "Quantity") {
|
||||
return false;
|
||||
}
|
||||
if (column.field == "specification") {
|
||||
this.specification = row.specification;
|
||||
}
|
||||
},
|
||||
|
||||
onPulldownSelected({ row, name, params }) {
|
||||
if (name == 'ag_inventory') {
|
||||
this.updateToGrid(row, this.detailsData[params.$rowIndex]);
|
||||
|
||||
setTimeout(() => {
|
||||
this.$refs.xTable.clearEdit();
|
||||
}, 50);
|
||||
}
|
||||
|
||||
},
|
||||
onPopupSelected({ rows, name, params }) {
|
||||
console.log(rows, name, params);
|
||||
if (name == 'ag_inventory') {
|
||||
|
||||
for (let i = params.$rowIndex, ri = 0; i < params.$rowIndex + rows.length; i++, ri++) {
|
||||
if (i == this.detailsData.length) {
|
||||
let newrow = {
|
||||
};
|
||||
this.detailsData.push(newrow);
|
||||
}
|
||||
let inv = rows[ri];
|
||||
|
||||
this.updateToGrid(inv, this.detailsData[i]);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.$refs.xTable.clearEdit();
|
||||
}, 50);
|
||||
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
|
@ -235,4 +539,44 @@ export default {
|
|||
};
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<style scoped lang="less">
|
||||
.page-body {
|
||||
padding: 30px;
|
||||
background: @base-bg-color;
|
||||
}
|
||||
|
||||
.formtabs .ant-tabs-tabpane {
|
||||
/* background: white; */
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.gridPanel {
|
||||
height: calc(100vh - 600px);
|
||||
}
|
||||
|
||||
.footerbar {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.imagePanel {
|
||||
cursor: pointer;
|
||||
padding: 10px;
|
||||
width: 100px;
|
||||
|
||||
img {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
}
|
||||
}
|
||||
|
||||
.oplinks2 svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.oplinks2 i {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,75 @@
|
|||
<template>
|
||||
<basic-page-list :desc="desc" :options="pageOptions"></basic-page-list>
|
||||
|
||||
|
||||
<div class="wrapper">
|
||||
<div class="left">
|
||||
<div class="treepanel" :style="'height:' + tableHeight + 'px'">
|
||||
<div class="treepanel-header">
|
||||
<a @click.stop="treeAdd(row)" title="新增">
|
||||
<a-icon type="plus-circle" />
|
||||
</a>
|
||||
<a @click.stop="treeEdit(row)" title="编辑">
|
||||
<a-icon type="edit" />
|
||||
</a>
|
||||
<a @click.stop="treeDelete(row)" title="删除">
|
||||
<a-icon type="delete" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="treepanel-content">
|
||||
<a-tree v-if="!treeLoading" show-line :tree-data="treeData" :default-expand-all="true" :block-node="true"
|
||||
@select="onTreeSelect" :default-selected-keys="selectedKeys">
|
||||
<a-icon slot="switcherIcon" type="down" />
|
||||
</a-tree>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
<basic-page-list ref="listPage" :desc="desc" @importData="pageImport" :options="pageOptions"></basic-page-list>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BASE_URL from '@/services/mes/api.js';
|
||||
let childrenFieldName = 'children';
|
||||
import { toArrayTree } from "xe-utils"
|
||||
|
||||
|
||||
export default {
|
||||
i18n: require("./i18n"),
|
||||
export default {
|
||||
i18n: require("./i18n"),
|
||||
props: {
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
pageOptions: {}
|
||||
pageOptions: {},
|
||||
|
||||
modelName: "",
|
||||
|
||||
actions: {
|
||||
treedata: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/list`,
|
||||
delete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/batchDelete`,
|
||||
listdata: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/list`,
|
||||
save: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/batchHandle`,
|
||||
},
|
||||
tipTimes: 0,
|
||||
detailsData: [
|
||||
],
|
||||
sourceDetailsData: [
|
||||
|
||||
],
|
||||
treeData: [],
|
||||
treeLoading: true,
|
||||
deletedDetailsData: [
|
||||
|
||||
],
|
||||
selectedKeys: [],
|
||||
selectedKey: null,
|
||||
tableHeight: 500
|
||||
};
|
||||
},
|
||||
// 计算属性
|
||||
|
|
@ -28,69 +84,82 @@ export default {
|
|||
// 创建完成
|
||||
created() {
|
||||
this.optionsInit();
|
||||
|
||||
this.$nextTick(() => {
|
||||
|
||||
this.tableHeight = this.$mk.getWindowSize().height - 320;
|
||||
this.treeInit();
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
// 动作
|
||||
methods: {
|
||||
|
||||
pageImport({ data }) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
})
|
||||
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.xGrid.commitProxy('query') // 提交搜索
|
||||
|
||||
}).catch((a) => { // 失败
|
||||
this.$mk.error(a.data.msg); // 提示错误信息
|
||||
});
|
||||
},
|
||||
optionsInit() {
|
||||
// 页面数据
|
||||
var pageData = { // 页面数据变量
|
||||
|
||||
keyName: 'id', // 主键字段名
|
||||
listFieldName: 'MesProductCustomAttribute',
|
||||
listFieldName: 'Attribute',
|
||||
|
||||
//exportFileTitle :"工序",
|
||||
//enabledExport: true,
|
||||
//enabledImport: true,
|
||||
//enabledImportTemplate: true,
|
||||
exportColumns: [
|
||||
{ title: '编码',field:"code" },
|
||||
{ title: '名称',field:"name" }
|
||||
],
|
||||
addPageUrl: "/MesProductCustomAttribute/MesProductCustomAttributeAdd",
|
||||
editPageUrl: "/MesProductCustomAttribute/MesProductCustomAttributeUpdate/",
|
||||
|
||||
// 接口动作
|
||||
actions: { // Api 接口地址
|
||||
// =============================== 接口地址 自动生成 Start ===============================
|
||||
MesProductCustomAttributeList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/list`, // 商品自定义属性分类列表
|
||||
MesProductCustomAttributeDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/detail`, // 商品自定义属性分类详情
|
||||
MesProductCustomAttributeCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/create`, // 创建商品自定义属性分类
|
||||
MesProductCustomAttributeUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/update`, // 更新商品自定义属性分类
|
||||
MesProductCustomAttributeDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/detele`, // 删除商品自定义属性分类
|
||||
MesProductCustomAttributeBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchDelete`, // 批量删除商品自定义属性分类
|
||||
MesProductCustomAttributeBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchUpdate`, // 批量更新商品自定义属性分类
|
||||
MesProductCustomAttributeBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/batchCreate`, // 批量创建商品自定义属性分类
|
||||
MesProductCustomAttributeExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/export/excel`, // 导出商品自定义属性分类数据到EXCEL
|
||||
MesProductCustomAttributeImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/mes/product/custom/attribute/import/excel`, // 批量导入EXCEL商品自定义属性分类数据
|
||||
ProductCustomAttributeList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/list`, // 商品自定义属性列表
|
||||
ProductCustomAttributeDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/detail`, // 商品自定义属性详情
|
||||
ProductCustomAttributeCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/create`, // 创建商品自定义属性
|
||||
ProductCustomAttributeUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/update`, // 更新商品自定义属性
|
||||
ProductCustomAttributeDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/detele`, // 删除商品自定义属性
|
||||
ProductCustomAttributeBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchDelete`, // 批量删除商品自定义属性
|
||||
ProductCustomAttributeBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchUpdate`, // 批量更新商品自定义属性
|
||||
ProductCustomAttributeBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/batchCreate`, // 批量创建商品自定义属性
|
||||
ProductCustomAttributeExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/export/excel`, // 导出商品自定义属性数据到EXCEL
|
||||
ProductCustomAttributeImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/import/excel`, // 批量导入EXCEL商品自定义属性数据
|
||||
ProductCustomAttributeFieldList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/list`, // 商品自定义属性字段列表
|
||||
ProductCustomAttributeFieldDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/detail`, // 商品自定义属性字段详情
|
||||
ProductCustomAttributeFieldCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/create`, // 创建商品自定义属性字段
|
||||
ProductCustomAttributeFieldUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/update`, // 更新商品自定义属性字段
|
||||
ProductCustomAttributeFieldDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/detele`, // 删除商品自定义属性字段
|
||||
ProductCustomAttributeFieldBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchDelete`, // 批量删除商品自定义属性字段
|
||||
ProductCustomAttributeFieldBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchUpdate`, // 批量更新商品自定义属性字段
|
||||
ProductCustomAttributeFieldBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/batchCreate`, // 批量创建商品自定义属性字段
|
||||
ProductCustomAttributeFieldExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/export/excel`, // 导出商品自定义属性字段数据到EXCEL
|
||||
ProductCustomAttributeFieldImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/field/import/excel`, // 批量导入EXCEL商品自定义属性字段数据
|
||||
ProductCustomAttributeValueList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/list`, // 商品自定义属性值列表
|
||||
ProductCustomAttributeValueDetail: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/detail`, // 商品自定义属性值详情
|
||||
ProductCustomAttributeValueCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/create`, // 创建商品自定义属性值
|
||||
ProductCustomAttributeValueUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/update`, // 更新商品自定义属性值
|
||||
ProductCustomAttributeValueDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/detele`, // 删除商品自定义属性值
|
||||
ProductCustomAttributeValueBatchDelete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchDelete`, // 批量删除商品自定义属性值
|
||||
ProductCustomAttributeValueBatchUpdate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchUpdate`, // 批量更新商品自定义属性值
|
||||
ProductCustomAttributeValueBatchCreate: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/batchCreate`, // 批量创建商品自定义属性值
|
||||
ProductCustomAttributeValueExportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/export/excel`, // 导出商品自定义属性值数据到EXCEL
|
||||
ProductCustomAttributeValueImportExcel: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/product/custom/attribute/value/import/excel`, // 批量导入EXCEL商品自定义属性值数据
|
||||
// 接口动作
|
||||
actions: { // Api 接口地址
|
||||
getList: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/attribute/list`,
|
||||
delete: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/attribute/batchDelete`,
|
||||
},
|
||||
|
||||
// =============================== 接口地址 自动生成 End ===============================
|
||||
},
|
||||
|
||||
start_time: 0, // 开始时间
|
||||
end_time: 0, // 结束时间
|
||||
start_time: 0, // 开始时间
|
||||
end_time: 0, // 结束时间
|
||||
|
||||
|
||||
//搜索区
|
||||
|
|
@ -101,7 +170,10 @@ export default {
|
|||
// 搜索区配置
|
||||
searchRules: [
|
||||
{ key: "title", mode: "like" },
|
||||
{ key: "desc", mode: "like" }
|
||||
{ key: "desc", mode: "like" },
|
||||
{ key: "category_id", mode: "in" },
|
||||
|
||||
|
||||
],
|
||||
//搜索区
|
||||
searchFormItems: [ // 子项
|
||||
|
|
@ -123,44 +195,379 @@ export default {
|
|||
stripe: true, // 启用斑马纹
|
||||
id: 'datagrid_1', // 表格唯一标识
|
||||
|
||||
// 表格列配置
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 50 }, // 多选框
|
||||
{ type: 'seq', width: 30 }, // 序号
|
||||
|
||||
// 表格列配置
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 50 }, // 多选框
|
||||
{ type: 'seq', width: 30 }, // 序号
|
||||
{ title: '操作', slots: { default: 'op' }, width: 120 },
|
||||
{ title: '操作', slots: { default: 'op' }, width: 120 },
|
||||
|
||||
|
||||
// =============================== 表格列 自动生成 Start ===============================
|
||||
|
||||
{ field: 'code', sortable: true, title: '编码', width: 250 }, // 编码
|
||||
{ field: 'title', sortable: true, title: '分类名称', width: 250 }, // 分类名称
|
||||
{ field: 'name', sortable: true, title: '属性名称', width: 250 }, // 属性分类英文名称
|
||||
{ field: 'description', sortable: true, title: '属性分类描述', width: 250 }, // 属性分类描述
|
||||
{ field: 'code', sortable: true, title: '编码', width: 250 }, // 编码
|
||||
{ field: 'name', sortable: true, title: '属性名称', width: 250 },
|
||||
|
||||
{ field: 'category', formatter: 'formatRef', params: { dataType: "object", textField: "name" }, title: '属性分类', width: 250 },
|
||||
|
||||
{ field: 'create_time', formatter: 'formatDate', width: 160, sortable: true, title: '创建时间', showHeaderOverflow: true }, // 创建时间
|
||||
{ field: 'update_time', formatter: 'formatDate', width: 160, sortable: true, title: '更新时间', showHeaderOverflow: true }, // 更新时间
|
||||
|
||||
// =============================== 表格列 自动生成 Start ===============================
|
||||
|
||||
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
pageData.actions.getList = pageData.actions.MesProductCustomAttributeList;
|
||||
pageData.actions.delete = pageData.actions.MesProductCustomAttributeBatchDelete;
|
||||
|
||||
pageData.gridOptions = Object.assign({}, this.$mk.config.defaults.gridOptions, pageData.gridOptions); // 合并表格数据
|
||||
|
||||
|
||||
this.pageOptions = pageData;
|
||||
},
|
||||
treeInit() {
|
||||
this.treeLoading = true;
|
||||
this.$mk.post({
|
||||
url: this.actions.treedata,
|
||||
loading: "加载中...",
|
||||
data: {
|
||||
"page": 1,
|
||||
"limit": 10000,
|
||||
"end_time": 0,
|
||||
"start_time": 0,
|
||||
"order_bys": [
|
||||
],
|
||||
"search_rules": [
|
||||
]
|
||||
}
|
||||
}).then(r => {
|
||||
|
||||
|
||||
let treedata = {
|
||||
title: "属性分类",
|
||||
key: "root"
|
||||
};
|
||||
let at = toArrayTree(r.data.Category, { parentKey: "parent_id" });
|
||||
console.log(at);
|
||||
treedata[childrenFieldName] = at;
|
||||
|
||||
|
||||
function formatTreedata(d) {
|
||||
if (d.id) {
|
||||
d.key = d.id.toString();
|
||||
} else {
|
||||
d.key = "root";
|
||||
}
|
||||
if (d.name) {
|
||||
d.title = d.name;
|
||||
}
|
||||
if (d[childrenFieldName] && d[childrenFieldName].length) {
|
||||
d[childrenFieldName].forEach(item => formatTreedata(item))
|
||||
}
|
||||
}
|
||||
treedata[childrenFieldName].forEach(item => formatTreedata(item))
|
||||
|
||||
this.treeData = [treedata];
|
||||
this.treeLoading = false;
|
||||
});
|
||||
|
||||
},
|
||||
treeAdd() {
|
||||
this.$mk.dialog.open({
|
||||
page: () => import("./treeEdit"),
|
||||
title: "新增-分类",
|
||||
dataId: 0,
|
||||
callback: ({ success }) => {
|
||||
success && this.treeInit();
|
||||
}
|
||||
})
|
||||
},
|
||||
treeEdit() {
|
||||
if (!this.selectedKey || this.selectedKey == "root") {
|
||||
this.$mk.error("请先选择分类");
|
||||
return;
|
||||
}
|
||||
let node = this.findTreeNode(this.selectedKey);
|
||||
|
||||
|
||||
this.$mk.dialog.open({
|
||||
page: () => import("./treeEdit"),
|
||||
title: "编辑-分类",
|
||||
dataId: node.id,
|
||||
callback: ({ success }) => {
|
||||
success && this.treeInit();
|
||||
}
|
||||
})
|
||||
},
|
||||
treeDelete() {
|
||||
if (!this.selectedKey || this.selectedKey == "root") {
|
||||
this.$mk.error("请先选择分类");
|
||||
return;
|
||||
}
|
||||
let node = this.findTreeNode(this.selectedKey);
|
||||
let ids = [
|
||||
node.id
|
||||
]; // 定义id数组
|
||||
|
||||
if (!ids.length) { // 如果没有选中行
|
||||
this.$mk.error("请选择行"); // 提示
|
||||
return;
|
||||
}
|
||||
|
||||
this.$mk.confirm('您确定要删除吗?').then(type => { // 确认删除
|
||||
if (type == 'confirm') { // 如果确认删除
|
||||
this.$mk.post({
|
||||
url: this.actions.delete, // 请求删除数据地址
|
||||
loading: "删除中...", // 加载提示
|
||||
data: {
|
||||
ids: ids // 传递id数组
|
||||
},
|
||||
useBigInt: true
|
||||
}).then(() => { // 成功
|
||||
this.$mk.success("删除成功"); // 提示成功
|
||||
this.treeInit(); // 重新加载数据
|
||||
}).catch((a) => { // 失败
|
||||
this.$mk.error(a.data.msg); // 提示错误信息
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
getDataId() {
|
||||
|
||||
let dataId = this.dataId;
|
||||
if (this.$route.params.id) {
|
||||
dataId = this.$route.params.id;
|
||||
}
|
||||
|
||||
return dataId;
|
||||
},
|
||||
|
||||
|
||||
onTreeSelect(selectedKeys) {
|
||||
if (selectedKeys && selectedKeys[0]) {
|
||||
this.selectedKey = selectedKeys[0];
|
||||
this.loadData(selectedKeys[0]);
|
||||
}
|
||||
},
|
||||
findTreeNode(key) {
|
||||
var find = (items) => {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (items[i].key == key) {
|
||||
return items[i];
|
||||
}
|
||||
if (items[i][childrenFieldName] && items[i][childrenFieldName].length) {
|
||||
var xx = find(items[i][childrenFieldName]);
|
||||
if (xx) {
|
||||
return xx;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return find(this.treeData);
|
||||
},
|
||||
reloadData() {
|
||||
if (this.selectedKey) {
|
||||
this.loadData(this.selectedKey);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
getAllChildrenIds(items) {
|
||||
let ids = [];
|
||||
let eachItems = (arr) => {
|
||||
arr.forEach(item => {
|
||||
if (item.children && item.children.length) {
|
||||
eachItems(item.children);
|
||||
} else {
|
||||
ids.push(item.id);
|
||||
}
|
||||
|
||||
})
|
||||
};
|
||||
eachItems(items);
|
||||
return ids;
|
||||
},
|
||||
loadData(key) {
|
||||
|
||||
if (key && key != "root") {
|
||||
var node = this.findTreeNode(key);
|
||||
if (node.children && node.children.length) {
|
||||
var ids = this.getAllChildrenIds(node.children);
|
||||
this.$refs.listPage.onSearch({
|
||||
category_id: [node.id, ...ids].join(',')
|
||||
})
|
||||
} else {
|
||||
this.$refs.listPage.onSearch({
|
||||
category_id: node.id
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
this.$refs.listPage.onSearch(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
findSourceInfo(idStr) {
|
||||
for (var i = 0; i < this.sourceDetailsData.length; i++) {
|
||||
let o = this.sourceDetailsData[i];
|
||||
if (o.id.toString() == idStr) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
},
|
||||
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() {
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.back();
|
||||
},
|
||||
pageAdd(row) {
|
||||
|
||||
const $table = this.$refs.xTable
|
||||
const record = {
|
||||
}
|
||||
if (row) {
|
||||
|
||||
this.detailsData.splice($table.getRowSeq(row), 0, record);
|
||||
} else {
|
||||
this.detailsData.push(record)
|
||||
}
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
pageDelete(row) {
|
||||
const $table = this.$refs.xTable;
|
||||
if (row.id) {
|
||||
this.deletedDetailsData.push(row.id)
|
||||
}
|
||||
this.detailsData.splice($table.getRowSeq(row) - 1, 1);
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.page-body {
|
||||
background: white;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* 左侧固定宽度 200px,右侧自适应 */
|
||||
.wrapper {
|
||||
display: flex;
|
||||
}
|
||||
.left {
|
||||
width: 200px;
|
||||
height: 100%;
|
||||
}
|
||||
.right {
|
||||
flex-grow: 1;
|
||||
height: 100%;
|
||||
width: calc(100% - 300px);
|
||||
}
|
||||
|
||||
.treepanel {
|
||||
width: calc(100% - 10px);
|
||||
|
||||
background: white;
|
||||
margin-right: 10px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.treepanel-content {
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
.treepanel-header {
|
||||
width: 100%;
|
||||
background: #F8F8F9;
|
||||
border-bottom: 1px solid #ccc;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
margin: 0;
|
||||
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.treepanel-header .anticon {
|
||||
margin-left: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toolbarbtns .ant-btn {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.toolbarbtns {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,150 @@
|
|||
<template>
|
||||
<div class="page-body">
|
||||
|
||||
<vxe-form :data="formOptions.data" ref="xForm" :title-width="formOptions.titleWidth"
|
||||
:title-align="formOptions.titleAlign" :rules="formOptions.rules" :items="formOptions.items" titleColon>
|
||||
</vxe-form>
|
||||
|
||||
<div class="footerbar">
|
||||
<a-button type="primary" @click="ok">确定</a-button>
|
||||
<a-button @click="cancel">取消</a-button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BASE_URL from '@/services/base/api.js';
|
||||
|
||||
export default {
|
||||
|
||||
props: {
|
||||
dataId: {
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
data() {
|
||||
|
||||
// 页面数据变量
|
||||
var pageData = {
|
||||
|
||||
actions: {
|
||||
create: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/create`,
|
||||
update: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/update`,
|
||||
get: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/detail`,
|
||||
list: `${BASE_URL.BASE_URL}/MesProductCustomAttribute/v1/category/list`,
|
||||
},
|
||||
|
||||
|
||||
formOptions: {
|
||||
data: {
|
||||
"name": "",
|
||||
"e_name": ""
|
||||
},
|
||||
|
||||
titleWidth: 150,
|
||||
titleAlign: 'right',
|
||||
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: '请输入名称' }
|
||||
],
|
||||
e_name: [
|
||||
{ required: true, message: '请输入名称(英文)' }
|
||||
]
|
||||
},
|
||||
|
||||
items: [
|
||||
{ field: 'name', title: '名称', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入名称' } } },
|
||||
{ field: 'e_name', title: '名称(英文)', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入名称(英文)' } } },
|
||||
{ field: 'code', title: '编号', span: 24, itemRender: { name: '$input', props: { placeholder: '请输入编号' } } },
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
pageData.formOptions = Object.assign({}, this.$mk.config.defaults.formOptions, pageData.formOptions);
|
||||
|
||||
return pageData;
|
||||
},
|
||||
created() {
|
||||
if (this.dataId) {
|
||||
this.$mk.post({
|
||||
url: this.actions.get,
|
||||
loading: "加载中...",
|
||||
data: {
|
||||
id: this.dataId
|
||||
},
|
||||
useBigInt: true
|
||||
}).then(a => {
|
||||
this.formOptions.data = a.data.mes_processes_sort;
|
||||
|
||||
this.parentNameInit() ;
|
||||
}).catch((a) => {
|
||||
this.$mk.error(a.data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
// 函数
|
||||
methods: {
|
||||
|
||||
|
||||
|
||||
loadData() {
|
||||
},
|
||||
|
||||
ok() {
|
||||
|
||||
let save = () => {
|
||||
let action = !this.dataId ? this.actions.create : this.actions.update;
|
||||
let postdata = Object.assign({ id: this.dataId }, this.formOptions.data);
|
||||
|
||||
|
||||
this.$mk.post({
|
||||
url: action,
|
||||
loading: "保存中...",
|
||||
data: postdata,
|
||||
useBigInt: true
|
||||
}).then(() => {
|
||||
this.$mk.success("保存成功");
|
||||
this.$emit("callback", { success: true });
|
||||
}).catch((a) => {
|
||||
this.$mk.error(a.data.msg);
|
||||
});
|
||||
};
|
||||
|
||||
this.$refs.xForm.validate((a) => {
|
||||
let count = 0;
|
||||
if (a) {
|
||||
for (let name in a) {
|
||||
a[name];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
this.$mk.error(`存在${count}项错误,请检查`);
|
||||
}
|
||||
else {
|
||||
save();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.$emit("callback", {});
|
||||
},
|
||||
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
<style></style>
|
||||
|
|
@ -53,7 +53,16 @@ var config = {
|
|||
{value:6,label:'待返工'}
|
||||
],
|
||||
|
||||
|
||||
//属性类型:1.文本,2.数字,3.日期,4.时间,5.日期时间,6.单选,7.布尔
|
||||
options_attribute_types:[
|
||||
{value:"1",label:'文本'} ,
|
||||
{value:"2",label:'数字'} ,
|
||||
{value:"3",label:'日期'} ,
|
||||
{value:"4",label:'时间'} ,
|
||||
{value:"5",label:'日期时间'} ,
|
||||
{value:"6",label:'单选'} ,
|
||||
{value:"7",label:'布尔'} ,
|
||||
],
|
||||
}
|
||||
|
||||
module.exports = config
|
||||
Loading…
Reference in New Issue