优化商品模块,使其能自动加载扩展字段的别名

This commit is contained in:
jishenghua
2025-03-25 23:45:36 +08:00
parent ecfbd396af
commit 0a3ce706c5
7 changed files with 67 additions and 72 deletions

View File

@@ -118,17 +118,17 @@
</a-col>
</a-row>
<a-row class="form-row" :gutter="24">
<a-col :lg="6" :md="6" :sm="6" v-if="mpShort.otherField1.enabled">
<a-col :lg="6" :md="6" :sm="6">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="mpShort.otherField1.name">
<a-input v-decorator.trim="[ 'otherField1' ]" />
</a-form-item>
</a-col>
<a-col :lg="6" :md="6" :sm="6" v-if="mpShort.otherField2.enabled">
<a-col :lg="6" :md="6" :sm="6">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="mpShort.otherField2.name">
<a-input v-decorator.trim="[ 'otherField2' ]" />
</a-form-item>
</a-col>
<a-col :lg="6" :md="6" :sm="6" v-if="mpShort.otherField3.enabled">
<a-col :lg="6" :md="6" :sm="6">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="mpShort.otherField3.name">
<a-input v-decorator.trim="[ 'otherField3' ]" />
</a-form-item>
@@ -1107,21 +1107,14 @@
loadParseMaterialProperty() {
let mpList = Vue.ls.get('materialPropertyList')
for (let i = 0; i < mpList.length; i++) {
if (mpList[i].nativeName === "制造商") {
this.mpShort.mfrs.name = mpList[i].anotherName
this.mpShort.mfrs.enabled = mpList[i].enabled
}
if (mpList[i].nativeName === "扩展1") {
this.mpShort.otherField1.name = mpList[i].anotherName
this.mpShort.otherField1.enabled = mpList[i].enabled
}
if (mpList[i].nativeName === "扩展2") {
this.mpShort.otherField2.name = mpList[i].anotherName
this.mpShort.otherField2.enabled = mpList[i].enabled
}
if (mpList[i].nativeName === "扩展3") {
this.mpShort.otherField3.name = mpList[i].anotherName
this.mpShort.otherField3.enabled = mpList[i].enabled
}
}
},

View File

@@ -17,13 +17,7 @@
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="名称">
<a-input placeholder="请输入名称" v-decorator.trim="[ 'nativeName' ]" :readOnly="model.id"/>
</a-form-item>
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="是否启用">
<a-switch checked-children="启用" un-checked-children="禁用" v-model="enabledSwitch" @change="onChange"></a-switch>
</a-form-item>
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="排序">
<a-input placeholder="请输入排序" v-decorator.trim="[ 'sort', validatorRules.sort]" />
{{model.nativeName}}
</a-form-item>
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="别名">
<a-input placeholder="请输入别名" v-decorator.trim="[ 'anotherName' ]" />
@@ -36,7 +30,7 @@
<script>
import pick from 'lodash.pick'
import {mixinDevice} from '@/utils/mixin'
import {editMaterialProperty } from '@/api/api'
import {addOrUpdateMaterialProperty } from '@/api/api'
export default {
name: "MaterialPropertyModal",
mixins: [mixinDevice],
@@ -45,7 +39,6 @@
title:"操作",
visible: false,
model: {},
enabledSwitch: true, //是否启用
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
@@ -69,9 +62,6 @@
created () {
},
methods: {
onChange(checked) {
this.model.enabled = checked
},
add () {
this.edit({});
},
@@ -79,11 +69,8 @@
this.form.resetFields();
this.model = Object.assign({}, record);
this.visible = true;
if(record.enabled!=null){
this.enabledSwitch = record.enabled?true:false;
}
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'nativeName', 'enabled', 'sort', 'anotherName'))
this.form.setFieldsValue(pick(this.model,'nativeName', 'anotherName'))
});
},
close () {
@@ -99,7 +86,7 @@
let formData = Object.assign(this.model, values);
let obj;
if(this.model.id){
obj=editMaterialProperty(formData);
obj=addOrUpdateMaterialProperty(formData);
}
obj.then((res)=>{
if(res.code === 200){