| | |
| | | style="width: 85%" |
| | | ></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="产品编码" prop="id"> |
| | | <el-input |
| | | style="width: 85%" |
| | | v-if=" |
| | | editConfig.title == '编辑' || |
| | | (editConfig.title == '新建' && codenumer && (explain != '' || isIdDisabled)) |
| | | " |
| | | :disabled="editConfig.title != '新建'" |
| | | v-model="editConfig.infomation.id" |
| | | placeholder="请输入编码" |
| | | > |
| | | </el-input> |
| | | <span v-else-if="editConfig.title == '新建'" style="color: #f56c6c; width: 85%" |
| | | >请优先配置编码规范 <el-button type="text" @click="numberClick"> 配置规范 </el-button></span |
| | | > |
| | | </el-form-item> |
| | | <el-form-item label="产品规格" prop="specs"> |
| | | <el-input |
| | | style="width: 85%" |
| | | :disabled="!showFooter" |
| | | clearable |
| | | v-model="editConfig.infomation.specs" |
| | | placeholder="请输入" |
| | | ></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="产品类型" prop="productType"> |
| | | <el-select |
| | | v-model="editConfig.infomation.productType" |
| | | placeholder="请选择" |
| | | size="mini" |
| | | clearable |
| | | style="width: 85%" |
| | | :disabled="!showFooter" |
| | | > |
| | |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="单位" prop="unit"> |
| | | <!-- <el-form-item label="单位old" prop="unit"> |
| | | <el-input |
| | | v-model="editConfig.infomation.unit" |
| | | placeholder="请输入" |
| | | style="width: 85%" |
| | | :disabled="!showFooter" |
| | | ></el-input> |
| | | </el-form-item> --> |
| | | |
| | | <el-form-item label="单位" prop="unit"> |
| | | <el-select |
| | | :disabled="!showFooter" |
| | | v-model="editConfig.infomation.unit" |
| | | placeholder="单位" |
| | | filterable |
| | | @change="Gtechange" |
| | | style="width: calc(85% - 120px)" |
| | | > |
| | | <el-option |
| | | v-for="ele in unitList" |
| | | :key="ele.id" |
| | | :label="ele.name" |
| | | :value="ele.name" |
| | | ></el-option> |
| | | </el-select> |
| | | <i |
| | | class="el-icon-setting margin_left_10px cursor_pointer" |
| | | style="font-size: 20px; color: gray" |
| | | @click="handleUnitShow" |
| | | ></i> |
| | | <el-checkbox |
| | | class="margin_left_10px" |
| | | :disabled="editConfig.infomation.unit&&showFooter?false:true" |
| | | v-model="editConfig.infomation.moreUnit" |
| | | @change="moreUnitChange">启用多单位</el-checkbox> |
| | | <!-- <span class="margin_left_10px cursor_pointer" @click="handleUnitMore">启用多单位</span> --> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="产品标签" prop="productTagName"> |
| | | <el-input |
| | | v-model="editConfig.infomation.productTagName" |
| | |
| | | v-model="editConfig.infomation.categoryId" |
| | | placeholder="请选择" |
| | | size="mini" |
| | | clearable |
| | | filterable |
| | | style="width: 85%" |
| | | :disabled="!showFooter" |
| | | > |
| | |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="产品型号" prop="type"> |
| | | <el-input |
| | | style="width: 85%" |
| | | :disabled="!showFooter" |
| | | filterable |
| | | v-model="editConfig.infomation.type" |
| | | placeholder="请输入" |
| | | ></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="采购类型" prop="purchaseTypeList"> |
| | | <el-checkbox-group |
| | | v-model="editConfig.infomation.purchaseTypeList" |
| | | :disabled="!showFooter" |
| | | > |
| | | <el-checkbox v-for="item in bomPurchaseTypeList" :key="item.id" :label="item.id">{{ item.name }}</el-checkbox> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | <el-form-item label="内部编码" prop="internalReference"> |
| | | <el-input |
| | | v-model.trim="editConfig.infomation.internalReference" |
| | |
| | | :disabled="!showFooter" |
| | | ></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="条码" prop="barcode"> |
| | | <el-form-item label="条码" prop="barCode"> |
| | | <el-input |
| | | v-model.trim="editConfig.infomation.barcode" |
| | | v-model.trim="editConfig.infomation.barCode" |
| | | placeholder="请输入" |
| | | size="mini" |
| | | style="width: 85%" |
| | |
| | | </el-form-item> |
| | | </div> |
| | | </div> |
| | | <div class="dynamic-attribute"> |
| | | <el-form-item :label="attribute.name+':'" v-for="(attribute,index) in editConfig.attributeList" :key="attribute.id"> |
| | | <el-select v-if="attribute.dataType==3" v-model="attribute.value" style="width: 60%"> |
| | | <el-option v-for="ele in attribute.selectValues" :label="ele" :value="ele" :key="ele"></el-option> |
| | | </el-select> |
| | | <el-input |
| | | v-else |
| | | v-model.trim="attribute.value" |
| | | :type="attribute.dataType==2?'number':'text'" |
| | | :placeholder="`请输入${attribute.name}`" |
| | | size="mini" |
| | | style="width: 60%" |
| | | :disabled="!showFooter" |
| | | ></el-input> |
| | | <el-button :disabled="editConfig.title==='查看'" size="mini" @click="deleteDynamicAttribute(index)" style="margin-left: 10px">删除</el-button> |
| | | </el-form-item> |
| | | </div> |
| | | <div class="all"> |
| | | <!-- <div class="second-label">备注</div> --> |
| | | <el-form-item label="备注" prop="internalNotes"> |
| | | <el-form-item label="备注" prop="note"> |
| | | <el-input |
| | | v-model.trim="editConfig.infomation.internalNotes" |
| | | v-model.trim="editConfig.infomation.note" |
| | | placeholder="请输入" |
| | | size="mini" |
| | | type="textarea" |
| | |
| | | v-model="editConfig.infomation.principal" |
| | | placeholder="请选择" |
| | | size="mini" |
| | | style="width: 85%" |
| | | :disabled="!showFooter" |
| | | style="width: 88%" |
| | | disabled |
| | | > |
| | | <el-option v-for="item in memberOptions" :key="item.id" :label="item.name" :value="item.name"> |
| | | <el-option |
| | | v-for="(item, index) in memberOptions" |
| | | :key="index" |
| | | :label="item.userName" |
| | | :value="item.userName" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="重量" prop="weight" label-width="80px"> |
| | | <!-- <el-form-item label="重量" prop="weight" label-width="80px"> |
| | | <el-input-number |
| | | v-model="editConfig.infomation.weight" |
| | | placeholder="请输入" |
| | |
| | | :disabled="!showFooter" |
| | | ></el-input-number> |
| | | <span> kg</span> |
| | | </el-form-item> |
| | | </el-form-item> --> |
| | | <el-form-item label="毛重" prop="grossWeight" label-width="80px"> |
| | | <el-col :span="15" |
| | | > |
| | | <el-input |
| | | v-model="editConfig.infomation.grossWeight" |
| | | placeholder="请输入" |
| | | :disabled="!showFooter" |
| | | ></el-input> |
| | | </el-col> |
| | | <el-col :span="1"> </el-col> |
| | | <el-col :span="5"> |
| | | <el-select |
| | | v-model="editConfig.infomation.grossUnit" |
| | | placeholder="单位" |
| | | filterable |
| | | :disabled="!showFooter" |
| | | style="width: 100%; float: right" |
| | | :popper-append-to-body="false" |
| | | > |
| | | <el-option |
| | | v-for="ele in grossUnitList" |
| | | :key="ele.id" |
| | | :label="ele.name" |
| | | :value="ele.name" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-col> |
| | | </el-form-item> |
| | | <el-form-item label="净重" prop="netWeight" label-width="80px"> |
| | | <el-col :span="15" |
| | | > |
| | | <el-input |
| | | v-model="editConfig.infomation.netWeight" |
| | | :disabled="!showFooter" |
| | | placeholder="请输入" |
| | | ></el-input> |
| | | </el-col> |
| | | <el-col :span="1"> </el-col> |
| | | <el-col :span="5"> |
| | | <el-select |
| | | v-model="editConfig.infomation.netUnit" |
| | | placeholder="单位" |
| | | filterable |
| | | :disabled="!showFooter" |
| | | style="width: 100%; float: right" |
| | | :popper-append-to-body="false" |
| | | > |
| | | <el-option |
| | | v-for="ele in grossUnitList" |
| | | :key="ele.id" |
| | | :label="ele.name" |
| | | :value="ele.name" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-col> |
| | | </el-form-item> |
| | | <el-form-item label="体积" prop="volume" label-width="80px"> |
| | | <el-input-number |
| | | v-model="editConfig.infomation.volume" |
| | |
| | | <el-button size="small" @click="editConfig.visible = false">取消</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <BomDialog |
| | | ref="editDialog" |
| | | :editRow="editRow" |
| | | @handleConfirmSave="handleConfirmSave" |
| | | :workList="unitList" |
| | | title="计量单位" |
| | | ></BomDialog> |
| | | <UnitMoreDialog |
| | | ref="unitMoreDialog" |
| | | @saveUnitMore="saveUnitMore" |
| | | @cancelUnitMore='cancelUnitMore' |
| | | :workList="unitList" |
| | | :unitRight='editConfig.infomation.unit' |
| | | :dataList="editConfig.infomation.moreUnitList" |
| | | title="启用多单位" |
| | | ></UnitMoreDialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import IconCropper from "./IconCropper" |
| | | import { getProductCategoryList } from "@/api/product/productCategory" |
| | | import { getProductList, addProduct, updateProduct } from "@/api/product/product" |
| | | import { uploadFiles } from "@/api/common/other" |
| | | |
| | | import { getProductList, addProduct, updateProduct,saveUnitDict } from "@/api/product/product" |
| | | import { uploadFiles, getUserInfo, } from "@/api/common/other" |
| | | import codeMixin from "@/components/mixin/codeMixin" |
| | | import { getDataByType } from "@/api/data" |
| | | import BomDialog from "./components/bomDialog"; |
| | | import {getUnitInfo, } from "@/api/basic/standard"; |
| | | // import { postGetSaveSUnitDict } from "@/api/basic/standard"; |
| | | import UnitMoreDialog from "./components/UnitMoreDialog"; |
| | | export default { |
| | | mixins: [codeMixin], |
| | | name: "AddProductDialog", |
| | | props: { |
| | | editCommonConfig: { |
| | |
| | | } |
| | | } |
| | | }, |
| | | components: { IconCropper }, |
| | | components: { |
| | | IconCropper, |
| | | BomDialog, |
| | | UnitMoreDialog, |
| | | }, |
| | | computed: { |
| | | modalTitle() { |
| | | if (this.editConfig.title === "编辑" && this.editConfig.autoEdit) { |
| | |
| | | editConfig: this.editCommonConfig, |
| | | rules: { |
| | | name: [{ required: true, message: "请输入产品名称", trigger: "blur" }], |
| | | id: [{ required: true, validator: this.validateCheckCode, trigger: ["change", "blur"] }], |
| | | model: [{ required: true, message: "请选择物料类型", trigger: "change" }], |
| | | // salePrice: [{ required: true, message: "请输入销售价格", trigger: "blur" }], |
| | | unit: [{ required: true, message: "请输入单位", trigger: "blur" }] |
| | | unit: [{ required: true, message: "请输入单位", trigger: ["blur"] }], |
| | | // 采购类型 |
| | | purchaseTypeList: [{ required: true, message: "请选择", trigger: "blur" }], |
| | | netWeight: [ |
| | | { |
| | | required: false, |
| | | message: "请填写", |
| | | trigger: "change", |
| | | }, |
| | | { |
| | | validator: this.validatorNumFour, |
| | | trigger: "blur", |
| | | }, |
| | | ], |
| | | grossWeight: [ |
| | | { |
| | | required: false, |
| | | message: "请填写", |
| | | trigger: "change", |
| | | }, |
| | | { |
| | | validator: this.validatorNumFour, |
| | | trigger: "blur", |
| | | }, |
| | | ], |
| | | }, |
| | | memberOptions: [{ name: "管理员", id: 1 }], |
| | | memberOptions: [], |
| | | productCategoryOptions: [], // 产品类别 |
| | | productTypeOptions: [ |
| | | { name: "能消耗", id: 1 }, |
| | |
| | | { name: "其他", id: "其他" } |
| | | ], |
| | | statisticsMap: { |
| | | inLibrary: 0,// 在库 |
| | | enter:0,//进 |
| | | exit:0,//出 |
| | | amount: this.editCommonConfig.infomation.amount ? this.editCommonConfig.infomation.amount : 0, // 在库 |
| | | predictionAmount: this.editCommonConfig.infomation.predictionAmount |
| | | ? this.editCommonConfig.infomation.predictionAmount |
| | | : 0, //预测 |
| | | inputAmount: this.editCommonConfig.infomation.inputAmount ? this.editCommonConfig.infomation.inputAmount : 0, //进 |
| | | outputAmount: this.editCommonConfig.infomation.outputAmount ? this.editCommonConfig.infomation.outputAmount : 0, //出 |
| | | reorderRuleNum: this.editCommonConfig.infomation.reorderRuleNum |
| | | ? this.editCommonConfig.infomation.reorderRuleNum |
| | | : 0, //重订货规则数量 |
| | | minInventoryRule: this.editCommonConfig.infomation.minInventoryRule |
| | | ? this.editCommonConfig.infomation.minInventoryRule |
| | | : 0, //最小重订货 |
| | | maxInventoryRule: this.editCommonConfig.infomation.maxInventoryRule |
| | | ? this.editCommonConfig.infomation.maxInventoryRule |
| | | : 0 //最大重订货 |
| | | }, |
| | | isView: false, |
| | | fileFormdata: null // 上传图片入参 |
| | | fileFormdata: null, // 上传图片入参 |
| | | bomPurchaseTypeList: getDataByType("purchaseType"), |
| | | grossUnitList:getDataByType("grossUnit"), |
| | | unitList: [], |
| | | editRow:{ |
| | | editDialogVisible:false, |
| | | BomTableData:[] |
| | | } |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | this.editClick() |
| | | } |
| | | this.setOptionalFieldsToEmpty() |
| | | this.formInfo() |
| | | this.getUserInfo() |
| | | this.getUnitInfo() |
| | | //this.queryAttribute() |
| | | }, |
| | | methods: { |
| | | deleteDynamicAttribute(index){ |
| | | this.editConfig.attributeList.splice(index,1); |
| | | }, |
| | | |
| | | validatorNumFour(rule, value, callback) { |
| | | if (value != "") { |
| | | if (value == undefined || value == null) { |
| | | callback(new Error("请输入有效数字")); |
| | | } else { |
| | | let reg2 = |
| | | /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/; |
| | | if (!reg2.test(value) || value == 0) { |
| | | callback(new Error("请填写大于零的2位小数的数字")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | } |
| | | } else { |
| | | callback(); |
| | | } |
| | | }, |
| | | // 单位 |
| | | handleUnitShow() { |
| | | this.editRow.editDialogVisible = true; |
| | | }, |
| | | // 启用多单位 |
| | | handleUnitMore(){ |
| | | if(this.editConfig.infomation.unit){ |
| | | this.$refs.unitMoreDialog.editDialogVisible = true; |
| | | }else{ |
| | | this.$message.error('请先选择单位!') |
| | | } |
| | | }, |
| | | saveUnitMore(list){ |
| | | this.editConfig.infomation.moreUnit=true |
| | | this.editConfig.infomation.moreUnitList=list |
| | | }, |
| | | cancelUnitMore(){ |
| | | this.editConfig.infomation.moreUnit=false |
| | | }, |
| | | // 启用多单位的开关 |
| | | moreUnitChange(){ |
| | | // let string=false; |
| | | if(this.editConfig.infomation.unit){ |
| | | // if(this.editConfig.infomation.moreUnitList&&this.editConfig.infomation.moreUnitList.length>0){ |
| | | // for(let i in this.editConfig.infomation.moreUnitList){ |
| | | // if(this.editConfig.infomation.moreUnitList[i].unit&&this.editConfig.infomation.moreUnitList[i].amount){ |
| | | // string=true; |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | if(this.editConfig.infomation.moreUnit){ |
| | | // this.editConfig.infomation.moreUnit=false |
| | | // this.$message.error('请先配置多单位!') |
| | | this.$refs.unitMoreDialog.editDialogVisible = true; |
| | | } |
| | | }else{ |
| | | this.editConfig.infomation.moreUnit=false |
| | | this.$message.error('请先选择单位!') |
| | | } |
| | | |
| | | }, |
| | | handleConfirmSave(dataList) { |
| | | saveUnitDict({ data: dataList }).then((res) => { |
| | | if (res.code == 200) { |
| | | this.$message({ |
| | | message: "操作成功!", |
| | | type: "success", |
| | | }); |
| | | this.getUnitInfo() |
| | | } |
| | | }); |
| | | this.editRow.editDialogVisible = false; |
| | | |
| | | }, |
| | | // 获取登录用户信息 |
| | | getUserInfo() { |
| | | getUserInfo().then((res) => { |
| | | console.log(res) |
| | | if (res.code == 200) { |
| | | this.editConfig.infomation.principal = res.data.userName |
| | | this.memberOptions.push(res.data) |
| | | } |
| | | console.log(this.memberOptions) |
| | | }) |
| | | }, |
| | | formInfo() { |
| | | this.objCode.type = "物料编码" |
| | | this.objCode.codeStandID = "" |
| | | if (this.editConfig.infomation.codeStandardID) { |
| | | this.objCode.codeStandID = this.editConfig.infomation.codeStandardID |
| | | } |
| | | this.getRCodeStandardList() |
| | | }, |
| | | /** |
| | | * 非必填项后端返回的是数字 0,表单需要空串才能视为未选择回显 |
| | | */ |
| | |
| | | this.showEdit = false |
| | | this.showButton = false |
| | | this.showFooter = true |
| | | this.isView = false |
| | | this.setTableForm() |
| | | }, |
| | | // 保存 |
| | |
| | | saveEditRequest(attachmentIDs) { |
| | | let requestUrl = this.editConfig.title === "新建" ? addProduct : updateProduct |
| | | this.unsetFieldsToNumber() |
| | | requestUrl({ |
| | | let params = { |
| | | ...this.editConfig.infomation, |
| | | attachmentIDs |
| | | }).then((res) => { |
| | | } |
| | | if (this.editConfig.title == "新建") { |
| | | params.codeStandardID = this.autoCodeObj.codeStandardID |
| | | params.autoIncr = this.autoCodeObj.maxAutoIncr |
| | | } |
| | | if(params.moreUnitList&¶ms.moreUnitList.length>0){ |
| | | for(let i in params.moreUnitList){ |
| | | params.moreUnitList[i].amount=Number(params.moreUnitList[i].amount) |
| | | } |
| | | } |
| | | params.attributes=this.editConfig.attributeList||[]; |
| | | requestUrl(params).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("添加成功") |
| | | this.$message.success(this.editConfig.title === "新建" ? "添加" : "编辑" + "成功!") |
| | | this.$parent.getData() |
| | | } |
| | | }, console.error) |
| | |
| | | // console.log(formdata, "图片数据") |
| | | }, |
| | | // 进出点击 |
| | | inOutBoundClick() { |
| | | inOutBoundClick(val) { |
| | | if (this.editConfig.title !== "新建") { |
| | | console.log(this.editConfig.infomation) |
| | | let url='' |
| | | if(val=='进'){ |
| | | url='inboundOutboundDetail' |
| | | }else{ |
| | | url='outboundDetail' |
| | | } |
| | | this.$router.push({ |
| | | name: "inboundOutboundDetail", |
| | | name:url, |
| | | params: { |
| | | name: this.editConfig.infomation.name, |
| | | id: this.editConfig.infomation.id |
| | |
| | | } else if (val === "销售") { |
| | | this.showSale = param |
| | | } |
| | | }, |
| | | Gtechange(){ |
| | | this.$forceUpdate() |
| | | }, |
| | | // 获取单位列表数据 |
| | | async getUnitInfo(){ |
| | | await getUnitInfo().then((res)=>{ |
| | | if( this.editConfig.title==="新建"){ |
| | | res.data.map((item)=>{ |
| | | if(item.isDefault){ |
| | | this.editConfig.infomation.unit=item.name |
| | | } |
| | | }) |
| | | } |
| | | this.editRow.BomTableData = res.data; |
| | | this.unitList=res.data |
| | | }) |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | <!-- Add "scoped" attribute to limit CSS to this component only --> |
| | | <style lang="scss" scoped> |
| | | .dynamic-attribute{ |
| | | display:flex; |
| | | flex-wrap: wrap; |
| | | flex: 1; |
| | | ::v-deep{ |
| | | .el-form-item{ |
| | | width: 50%; |
| | | } |
| | | } |
| | | } |
| | | .dialog-header { |
| | | display: flex; |
| | | align-items: center; |