diff --git a/jshERP-web/src/api/api.js b/jshERP-web/src/api/api.js index 84c2d1d8..c8999378 100644 --- a/jshERP-web/src/api/api.js +++ b/jshERP-web/src/api/api.js @@ -130,6 +130,7 @@ const checkMaterial = (params)=>getAction("/material/checkIsExist",params); const getMaterialBySelect = (params)=>getAction("/material/findBySelect",params); const getSerialMaterialBySelect = (params)=>getAction("/material/getMaterialEnableSerialNumberList",params); const getMaterialByBarCode = (params)=>getAction("/material/getMaterialByBarCode",params); +const getMaxBarCode = (params)=>getAction("/material/getMaxBarCode",params); const checkMaterialBarCode = (params)=>getAction("/materialsExtend/checkIsBarCodeExist",params); //序列号 const addSerialNumber = (params)=>postAction("/serialNumber/add",params); @@ -140,6 +141,7 @@ const batAddSerialNumber = (params)=>postAction("/serialNumber/batAddSerialNumbe const addMaterialAttribute = (params)=>postAction("/materialAttribute/add",params); const editMaterialAttribute = (params)=>putAction("/materialAttribute/update",params); const checkMaterialAttribute = (params)=>getAction("/materialAttribute/checkIsNameExist",params); +const getAllMaterialAttribute = (params)=>getAction("/materialAttribute/getAll",params); //功能管理 const addFunction = (params)=>postAction("/function/add",params); const editFunction = (params)=>putAction("/function/update",params); @@ -255,6 +257,7 @@ export { getMaterialBySelect, getSerialMaterialBySelect, getMaterialByBarCode, + getMaxBarCode, checkMaterialBarCode, addSerialNumber, editSerialNumber, @@ -263,6 +266,7 @@ export { addMaterialAttribute, editMaterialAttribute, checkMaterialAttribute, + getAllMaterialAttribute, addFunction, editFunction, checkFunction, diff --git a/jshERP-web/src/views/material/modules/MaterialModal.vue b/jshERP-web/src/views/material/modules/MaterialModal.vue index 85cee513..e0195d35 100644 --- a/jshERP-web/src/views/material/modules/MaterialModal.vue +++ b/jshERP-web/src/views/material/modules/MaterialModal.vue @@ -67,7 +67,7 @@ - + @@ -79,17 +79,78 @@ + + + - + + + + + + + {{ item.name }} + + + + + + + + + {{ item.name }} + + + + + + + + + {{ item.name }} + + + + + + + + + + + {{ item.name }} + + + + + + + + + {{ item.name }} + + + + + + + + + + + +
+ +
@@ -158,7 +219,7 @@ import pick from 'lodash.pick' import JEditableTable from '@/components/jeecg/JEditableTable' import { FormTypes, VALIDATE_NO_PASSED, getRefPromise, validateFormAndTables } from '@/utils/JEditableTableUtil' - import {queryMaterialCategoryTreeList,checkMaterial,checkMaterialBarCode} from '@/api/api' + import {queryMaterialCategoryTreeList,checkMaterial,checkMaterialBarCode,getAllMaterialAttribute,getMaxBarCode} from '@/api/api' import { httpAction, getAction } from '@/api/manage' import JImageUpload from '@/components/jeecg/JImageUpload' import JDate from '@/components/jeecg/JDate' @@ -181,6 +242,20 @@ unitStatus: false, manyUnitStatus: true, unitChecked: false, + skuSwitch: false, //sku开启状态 + barCodeSwitch: false, //生成条码开关 + sku: { + manyColor: '颜色', + manySize: '尺寸', + other1: '自定义1', + other2: '自定义2', + other3: '自定义3', + manyColorList: [], + manySizeList: [], + other1List: [], + other2List: [], + other3List: [], + }, model: {}, isReadOnly: false, labelCol: { @@ -202,16 +277,19 @@ dataSource: [], columns: [ { - title: '条码', key: 'barCode', width: '30%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}', + title: '条码', key: 'barCode', width: '20%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}', validateRules: [{ required: true, message: '${title}不能为空' }, { pattern: /^[1-9]\d*$/, message: '请输入零以上的正整数' }, { pattern: /^\d{4,13}$/, message: '4到13位数字' }, { handler: this.validateBarCode}] }, { - title: '单位', key: 'commodityUnit', width: '12%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}', + title: '单位', key: 'commodityUnit', width: '10%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}', validateRules: [{ required: true, message: '${title}不能为空' }] }, + { + title: '多属性', key: 'sku', width: '12%', type: FormTypes.input, defaultValue: '', readonly:true + }, { title: '采购价', key: 'purchaseDecimal', width: '12%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}' }, @@ -297,6 +375,7 @@ this.form.setFieldsValue(pick(this.model, 'name', 'standard', 'unit', 'unitId', 'model', 'color', 'categoryId','enableSerialNumber','safetyStock','remark','mfrs','otherField1','otherField2','otherField3')) }); + this.initMaterialAttribute() // 加载子表数据 if (this.model.id) { // 判断是否是多单位 @@ -530,6 +609,91 @@ } }) }, + onSkuChange(checked) { + this.skuSwitch = checked + }, + onBarCodeChange(checked) { + let unit = this.form.getFieldValue('unit') + if(unit) { + if(checked){ + //计算多属性已经选择了几个 + let count = this.getNumByField('manyColor') + this.getNumByField('manySize') + + this.getNumByField('other1') + this.getNumByField('other2') + this.getNumByField('other3') + if(count === 2) { + let skuArr = [] + if(this.getNumByField('manyColor')) { + skuArr.push(this.form.getFieldValue('manyColor')) + } + if(this.getNumByField('manySize')) { + skuArr.push(this.form.getFieldValue('manySize')) + } + if(this.getNumByField('other1')) { + skuArr.push(this.form.getFieldValue('other1')) + } + if(this.getNumByField('other2')) { + skuArr.push(this.form.getFieldValue('other2')) + } + if(this.getNumByField('other3')) { + skuArr.push(this.form.getFieldValue('other3')) + } + let skuArrOne = skuArr[0] + let skuArrTwo = skuArr[1] + let barCodeSku = [] + for (let i = 0; i < skuArrOne.length; i++) { + for (let j = 0; j < skuArrTwo.length; j++) { + barCodeSku.push(skuArrOne[i] + ',' + skuArrTwo[j]) + } + } + let meTableData = [] + getMaxBarCode({}).then((res)=>{ + if(res && res.code===200) { + let maxBarCode = res.data.barCode-0 + for (let i = 0; i < barCodeSku.length; i++) { + let currentBarCode = maxBarCode + i + 1 + meTableData.push({barCode: currentBarCode, commodityUnit: unit, sku: barCodeSku[i]}) + } + this.meTable.dataSource = meTableData + } + }) + } else { + this.$message.warning('请选择两个属性!'); + this.barCodeSwitch = false; + } + } else { + this.meTable.dataSource = [] + } + } else { + this.$message.warning('请填写单位,注意不要勾选多单位!'); + this.barCodeSwitch = false; + } + }, + getNumByField(field) { + let num = 0 + if(this.form.getFieldValue(field)) { + if(this.form.getFieldValue(field).length>0) { + num = 1 + } + } + return num + }, + initMaterialAttribute() { + getAllMaterialAttribute({}).then((res)=>{ + if(res && res.code===200) { + if(res.data) { + this.sku.manyColor = res.data.manyColorName; + this.sku.manySize = res.data.manySizeName; + this.sku.other1 = res.data.other1Name; + this.sku.other2 = res.data.other2Name; + this.sku.other3 = res.data.other3Name; + this.sku.manyColorList = res.data.manyColorValue; + this.sku.manySizeList = res.data.manySizeValue; + this.sku.other1List = res.data.other1Value; + this.sku.other2List = res.data.other2Value; + this.sku.other3List = res.data.other3Value; + } + } + }); + }, loadParseMaterialProperty() { let mpList = Vue.ls.get('materialPropertyList') for (let i = 0; i < mpList.length; i++) {