| | |
| | | <template> |
| | | <div class="add-common"> |
| | | <el-dialog |
| | | :title="editCommonConfig.title + '产品类别'" |
| | | :title="modalTitle + '产品类别'" |
| | | :visible.sync="editConfig.visible" |
| | | :width="dialogWidth" |
| | | :before-close="handleClose" |
| | | > |
| | | <!-- 头 --> |
| | | <div slot="title" class="dialog-header"> |
| | | <span>{{ editCommonConfig.title + "产品类别" }}</span> |
| | | <span>{{ modalTitle + "产品类别" }}</span> |
| | | <div class="header_btns"> |
| | | <!-- <span class="btn"> |
| | | <i class="el-icon-printer"></i> |
| | |
| | | style="width: 85%" |
| | | :disabled="!showFooter" |
| | | > |
| | | <el-option v-for="item in productCategoryListWithDefault" :key="item.id" :label="item.name" :value="item.id"> |
| | | <el-option v-for="item in productCategoryList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | |
| | | return { |
| | | visible: false, |
| | | title: "新建", |
| | | infomation: { type: [] } |
| | | infomation: { type: [] }, |
| | | autoEdit: false, |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | components: {}, |
| | | computed: { |
| | | productCategoryListWithDefault(){ |
| | | console.log(this.productCategoryList) |
| | | return [{id:0,name:'请选择'},...(this.productCategoryList?? [])] |
| | | modalTitle(){ |
| | | if (this.editConfig.title === '编辑' && this.editConfig.autoEdit){ |
| | | return '编辑' |
| | | }else if (this.editConfig.title === '编辑') { |
| | | return !this.showEdit ? '编辑' : '查看' |
| | | }else { |
| | | return '新建' |
| | | } |
| | | } |
| | | }, |
| | | data() { |
| | |
| | | created() { |
| | | this.setBottonView() |
| | | this.getProductCount() |
| | | if (this.editConfig.autoEdit){ |
| | | this.editClick() |
| | | } |
| | | this.setOptionalFieldsToEmpty() |
| | | }, |
| | | methods: { |
| | | /** |
| | | * 非必填项后端返回的是数字 0,表单需要空串才能视为未选择回显 |
| | | */ |
| | | setOptionalFieldsToEmpty(){ |
| | | ['parentId','costingMethod','inventoryValuation','forceRemovalStrategy'] |
| | | .filter(filed => this.editConfig.infomation[filed] === 0) |
| | | .forEach(filed => { |
| | | this.editConfig.infomation[filed] = '' |
| | | }) |
| | | }, |
| | | /** |
| | | * 后端只接受数字形式, 保存时还得再转回去 |
| | | */ |
| | | unsetFieldsToNumber(){ |
| | | ['parentId','costingMethod','inventoryValuation','forceRemovalStrategy'] |
| | | .filter(filed => this.editConfig.infomation[filed] === '') |
| | | .forEach(filed => { |
| | | this.editConfig.infomation[filed] = 0 |
| | | }) |
| | | }, |
| | | // 获取产品数量 |
| | | getProductCount(){ |
| | | getProductList({ |
| | |
| | | this.showFooter = true |
| | | }, |
| | | saveParams() { |
| | | this.unsetFieldsToNumber() |
| | | let data = JSON.parse(JSON.stringify(this.editConfig.infomation)) |
| | | |
| | | let params = { |