From d07ef537be9cc30e40aeecff097b393e52cbf41e Mon Sep 17 00:00:00 2001 From: haoxuan <haoxuan> Date: 星期三, 29 十一月 2023 17:32:10 +0800 Subject: [PATCH] 采购详情的采购状态枚举值修改 --- src/views/purchaseManage/purchase/components/AddPurchase.vue | 316 +++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 248 insertions(+), 68 deletions(-) diff --git a/src/views/purchaseManage/purchase/components/AddPurchase.vue b/src/views/purchaseManage/purchase/components/AddPurchase.vue index 8211eb2..3d78de0 100644 --- a/src/views/purchaseManage/purchase/components/AddPurchase.vue +++ b/src/views/purchaseManage/purchase/components/AddPurchase.vue @@ -27,9 +27,11 @@ <el-form-item label="閲囪喘绫诲瀷" prop="purchaseTypeId" - class="form-item float_left" + class="float_left" + style="width:100%;" > <el-select + :disabled="editConfig.isDisabled" placeholder="璇烽�夋嫨閲囪喘绫诲瀷" v-model="editConfig.infomation.purchaseTypeId" clearable @@ -37,12 +39,13 @@ > <el-option v-for="ele in plcBrandList" - :key="ele.id" + :key="ele.name" :label="ele.name" - :value="ele.name" + :value="ele.ID" ></el-option> </el-select> <i + v-if="!editConfig.isDisabled" class="el-icon-setting margin_left_10px cursor_pointer" style="font-size: 20px; color: #333" @click="handleShow" @@ -54,11 +57,12 @@ <el-form-item label="渚涘簲鍟嗗悕绉�" prop="supplierName"> <div class="custom-name"> <el-autocomplete + :disabled="editConfig.isDisabled" style="width: calc(100% - 40px)" v-model="editConfig.infomation.supplierName" :fetch-suggestions=" (queryString, callback) => { - querySearchAsync(queryString, callback, 'client'); + querySearchAsync(queryString, callback, 'supplier'); } " value-key="name" @@ -66,6 +70,7 @@ @select="handleSelectClient('client', $event)" ></el-autocomplete> <div + v-if="!editConfig.isDisabled" class="common-select-btn" @click="selClientClick('client')" > @@ -79,15 +84,16 @@ class="common-select-btn" @click="clearupClient('client')" > - <i class="el-icon-remove-outline" title="娓呴櫎"></i> + <i class="el-icon-remove-outline" + v-if="!editConfig.isDisabled" title="娓呴櫎"></i> </div> </div> </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="鍗曟嵁鏉ユ簮" prop="number"> + <el-form-item label="鍗曟嵁鏉ユ簮" prop="orderSource"> <el-input - v-model="editConfig.infomation.number" + v-model="editConfig.infomation.orderSource" disabled placeholder="璇峰~鍐�" ></el-input> @@ -96,6 +102,7 @@ <el-col :span="12"> <el-form-item label="閲囪喘鍗曞悕绉�" prop="name"> <el-input + :disabled="editConfig.isDisabled" v-model="editConfig.infomation.name" placeholder="璇峰~鍐�" clearable @@ -105,6 +112,7 @@ <el-col :span="12"> <el-form-item label="渚涘簲鍟嗚仈绯讳汉" prop="contact"> <el-input + :disabled="editConfig.isDisabled" v-model="editConfig.infomation.contact" placeholder="璇峰~鍐�" clearable @@ -114,8 +122,11 @@ <el-col :span="12"> <el-form-item label="鑱旂郴鐢佃瘽" prop="phone"> <el-input + :disabled="editConfig.isDisabled" v-model="editConfig.infomation.phone" placeholder="璇峰~鍐�" + maxlength="11" + show-word-limit clearable ></el-input> </el-form-item> @@ -123,6 +134,7 @@ <el-col :span="12"> <el-form-item label="绛剧害鏃ユ湡" prop="signingDate"> <el-date-picker + :disabled="editConfig.isDisabled" v-model="editConfig.infomation.signingDate" style="width: 100%" type="date" @@ -136,6 +148,7 @@ <el-col :span="12"> <el-form-item label="浜や粯鏃ユ湡" prop="deliveryDate"> <el-date-picker + :disabled="editConfig.isDisabled" v-model="editConfig.infomation.deliveryDate" style="width: 100%" type="date" @@ -149,6 +162,7 @@ <el-col :span="24"> <el-form-item label="澶囨敞淇℃伅" prop="remark"> <el-input + :disabled="editConfig.isDisabled" type="textarea" :autosize="{ minRows: 3, maxRows: 4 }" maxlength="500" @@ -163,13 +177,18 @@ <div class="basic-info-title" style="display: flex">浜у搧淇℃伅</div> <div class="product-view"> <CommonFormTableView + :detailEnter=editCommonConfig.detailEnter :show-summary="showSummary" :recalculateShow="false" :product-table-list="productTableList" + sign="purchase" @inputContent="inputContent" + @getSummaries="getSummaries" @addProductClick="addProductClick" @emptyProductClick="emptyProductClick" @clearupProduct="clearupProduct" + @rowClick="rowClick" + @handleProduct="handleProduct" /> </div> <div class="table-bottom"> @@ -177,9 +196,11 @@ <div class="table-bottom-l"> <el-form-item label="鏁村崟鎶樻墸" prop="member_id"> <el-select - v-model="editConfig.infomation.fieldName" + v-model="editConfig.infomation.wholeDiscountType" placeholder="璇烽�夋嫨" + :disabled="editConfig.isDisabled" filterable + @change="getTotal" > <el-option label="鐧惧垎姣旈檷浠�" :value="1"></el-option> <el-option label="鐩存帴闄嶄环" :value="2"></el-option> @@ -189,8 +210,10 @@ <div class="table-bottom-r"> <el-form-item label="" prop="member_id"> <el-input - v-model="editConfig.infomation.number" + v-model="editConfig.infomation.wholeDiscount" size="mini" + :disabled="editConfig.isDisabled" + @change="getTotal" placeholder="璇峰~鍐�" ></el-input> </el-form-item> @@ -200,9 +223,11 @@ <div class="table-bottom-l"> <el-form-item label="璋冩暣" prop="member_id"> <el-select - v-model="editConfig.infomation.fieldName" + :disabled="editConfig.isDisabled" + v-model="editConfig.infomation.priceAdjustmentType" placeholder="璇烽�夋嫨" filterable + @change="getTotal" > <el-option label="澧炲姞" :value="1"></el-option> <el-option label="鍑忓皯" :value="2"></el-option> @@ -212,8 +237,10 @@ <div class="table-bottom-r"> <el-form-item label="" prop="member_id"> <el-input - v-model="editConfig.infomation.number" + :disabled="editConfig.isDisabled" + v-model="editConfig.infomation.priceAdjustment" size="mini" + @change="getTotal" placeholder="璇峰~鍐�" ></el-input> </el-form-item> @@ -221,17 +248,17 @@ </div> <div class="table-bottom-item"> <div class="table-bottom-l">鍚堣</div> - <div class="table-bottom-r">26000.00</div> + <div class="table-bottom-r">{{ total }}</div> </div> </div> </div> </el-form> <div slot="footer" class="dialog-footer"> <!-- <el-button type="primary" size="small" @click="editConfig.visible = false">淇濆苟鎻愪氦瀹℃壒</el-button> --> - <el-button type="primary" size="small" @click="saveClick('form')" + <el-button type="primary" v-if="this.editConfig.title != '鏌ョ湅'" size="small" @click="saveClick('form')" >淇濆瓨</el-button > - <el-button size="small" @click="editConfig.visible = false" + <el-button size="small" v-if="this.editConfig.title != '鏌ョ湅'" @click="editConfig.visible = false" >鍙栨秷</el-button > </div> @@ -246,6 +273,7 @@ ref="editDialog" @sucessSet="handleGetBomKindDictList" @handleConfirmSave="handleConfirmSave" + :editRow="editRow" :workList="plcBrandList" title="閲囪喘绫诲瀷" ></BomDialog> @@ -255,16 +283,17 @@ <script> import CommonFormTableView from "@/components/makepager/CommonFormTableView"; import BomDialog from "@/components/makepager/BomDialog"; +import { getProductList } from "@/api/productManage/product" import { addPurchase, updatePurchase, + savePurchaseType, + getPurchaseType, } from "@/api/purchaseManage/purchase"; -// import { -// postGetUnitDictList, -// postGetSaveSUnitDict, -// } from "@/api/purchaseManage/purchase"; + import SelectSupplierDialog from "@/views/purchaseManage/purchase/components/SelectSupplierDialog"; +// import { formToJSON } from "axios"; export default { name: "QuotationDialog", components: { SelectSupplierDialog, CommonFormTableView,BomDialog }, @@ -273,6 +302,7 @@ type: Object, default: () => { return { + detailEnter:true, visible: false, title: "鍒涘缓", infomation: {}, @@ -284,6 +314,7 @@ return { editConfig: this.editCommonConfig, rules: { + purchaseTypeId:[{ required: true, message: "璇烽�夋嫨", trigger: "change" }], supplierName: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], phone: [ { @@ -293,12 +324,29 @@ }, { validator: this.validatorPhone, trigger: "change" }, ], + wholeDiscount: [ + { + required: false, + message: "璇峰~鍐�0-100鐨勬暟瀛�", + trigger: "change", + }, + { validator: this.validatorNum, trigger: "change" }, + ], + priceAdjustment: [ + { + required: false, + message: "璇峰~鍐�", + trigger: "change", + }, + { validator: this.validatorNumThree, trigger: "change" }, + ], }, productTableList: {}, showSummary: { show: true, total: false, sumProp: ["price", "total"], + multiply:['amount','price'], titleProp: [ "缂栧彿", "浜у搧鍚嶇О", @@ -309,6 +357,7 @@ "鎻忚堪", ], mergeNumber: 4, + totalName:'灏忚' }, editSelectSupplierConfig: { editVisible: false, @@ -317,61 +366,120 @@ }, supplierId: this.editCommonConfig.infomation.supplierId, tableData: [], - productId: 1, + productIndex: 0, + productId:'', isNoProduct: true, clientList: [], plcBrandList:[], + editRow:{ + isDefault:'pin' + }, + total:0, + totalTwo:0, + productListIdx:0 }; }, created() { - this.setTableForm(); + this.handleGetBomKindDictList(); + this.$store.dispatch("getSupplier") }, computed: { + supplierList() { + return this.$store.state.getSupplierName.supplierList + } }, watch:{ 'editCommonConfig.visible':{ immediate:true, handler:function(){ - this.setTableForm(); + + this.handleGetBomKindDictList(true); } } }, methods: { + validatorNum(rule, value, callback) { + if(this.editConfig.infomation.wholeDiscountType==1){ + if(value==undefined||value==null||(!value&&value!=0)){ + callback(new Error("璇疯緭鍏ユ湁鏁堟暟瀛�")); + }else{ + var reg=/^\+?[0-9]\d*$/ + if(!reg.test(value)){ + callback(new Error('璇峰~鍐�0-100鐨勬暟瀛�')) + }else{ + if(Number(value)>100){ + callback(new Error('璇峰~鍐�0-100鐨勬暟瀛�')) + }else{ + callback() + } + } + } + }else{ + this.validatorNumThree(rule, value, callback) + } + }, + validatorNumThree(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)){ + callback(new Error('璇峰~鍐�2浣嶅皬鏁扮殑鏁板瓧')) + }else{ + callback() + } + } + }else{ + callback() + } + }, // PLC閰嶇疆璁剧疆 handleShow() { - // this.handleGetBomKindDictList(); + this.handleGetBomKindDictList(); this.$refs.editDialog.editDialogVisible = true; }, // PLC閰嶇疆 handleGetBomKindDictList(val) { - console.log(val,'val') - // postGetUnitDictList().then((res) => { - // this.plcBrandList = res.data; - // if (val) { - // for (let i in this.plcBrandList) { - // if (this.plcBrandList[i].isDefault) { - // this.form.unit = this.form.unit - // ? this.form.unit - // : this.plcBrandList[i].name; - // this.$set(this.form, "unit", this.form.unit); - // break; - // } - // } - // } - // }); + getPurchaseType().then((res) => { + this.plcBrandList = res.data; + this.setTableForm() + if (val) { + for (let i in this.plcBrandList) { + if (this.plcBrandList[i][this.editRow.isDefault]) { + this.editConfig.infomation.purchaseTypeId = this.editConfig.infomation.purchaseTypeId + ? this.editConfig.infomation.purchaseTypeId + : this.plcBrandList[i].ID; + this.$set(this.editConfig.infomation, "purchaseTypeId", this.editConfig.infomation.purchaseTypeId); + + break; + } + } + } + }); }, handleConfirmSave(data) { console.log(data,'data') - // postGetSaveSUnitDict({ data: data }).then((res) => { - // if (res.code == 200) { - // this.$message({ - // message: "鎿嶄綔鎴愬姛锛�", - // type: "success", - // }); - // this.$refs.editDialog.editDialogVisible = false; - // this.handleGetBomKindDictList(); - // } - // }); + data.forEach(ele=>{ + delete ele.created_at + }) + + savePurchaseType(data).then((res) => { + if (res.code === 200) { + this.$message({ + message: "鎿嶄綔鎴愬姛锛�", + type: "success", + }); + this.$refs.editDialog.editDialogVisible = false; + this.handleGetBomKindDictList(true); + } + },(err)=>{ + console.error(err) + this.$message({ + message: "鎿嶄綔澶辫触锛�", + type: "warning", + }); + }); }, validatorPhone(rule, value, callback) { if (value) { @@ -410,10 +518,8 @@ this.$message.error("浜у搧鍚嶇О涓嶈兘涓虹┖"); } else { const params = this.saveParams(); - console.log(params); if (this.editConfig.title === "鍒涘缓") { addPurchase(params).then((res) => { - console.log(res); this.editConfig.visible = false; if (res.code === 200) { this.$message.success("娣诲姞鎴愬姛"); @@ -437,19 +543,32 @@ }); }, saveParams() { - debugger let data =JSON.parse(JSON.stringify(this.editConfig.infomation)); + + if(this.editConfig.infomation.wholeDiscountType==2&&this.editConfig.infomation.wholeDiscount){ + if(Number(this.editConfig.infomation.wholeDiscount)>Number(this.totalTwo)){ + this.$message.error('鐩存帴闄嶄环涓嶈兘瓒呰繃浠风◣鍚堣鐨勬�诲拰锛�') + return true; + } + } let params = { productList:this.tableData, purchase:{ - supplierId:this.supplierId||0, + supplierId:data.supplierId, signingDate:data.signingDate||'', remark:data.remark, - purchaseTypeId:this.purchaseTypeId||0, + orderSource:data.orderSource||'', + purchaseTypeId:data.purchaseTypeId||0, phone:data.phone||'', name:data.name||'', deliveryDate:data.deliveryDate||'', - contact:data.contact + contact:data.contact, + wholeDiscountType:data.wholeDiscountType?data.wholeDiscountType:0, + wholeDiscount:data.wholeDiscount?Number(data.wholeDiscount):0, + priceAdjustmentType:data.priceAdjustmentType?data.priceAdjustmentType:0, + priceAdjustment:data.priceAdjustment?Number(data.priceAdjustment):0, + realTotalPrice:this.total?Number(this.total):0, + totalPrice:this.totalTwo?Number(this.totalTwo):0, } }; if(data.ID){ @@ -462,9 +581,10 @@ }, // 閫夋嫨瀹㈡埛鐩稿叧鏂规硶 querySearchAsync(queryString, cb, value) { + this.productTableList.tableProductList=[] var restaurants = []; - if (value === "client") { - restaurants = this.clientList; + if (value === "supplier") { + restaurants = this.supplierList; } var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) @@ -478,11 +598,22 @@ ); }; }, - handleSelectClient(value, item) { - console.log(value); + async handleSelectClient(value, item) { + this.productTableList.supplierId=item.ID if (value === "client") { this.supplierId = item.id; + this.editConfig.infomation.supplierId=item.ID } + await getProductList({ + supplierId:item.ID, + page:1, + pageSize:100 + }).then((res)=>{ + if(res.code===200){ + this.productTableList.tableProductList = res.data.list + console.log(this.productTableList.tableProductList,"pop") + } + }) }, selClientClick() { this.editSelectSupplierConfig.editVisible = true; @@ -495,6 +626,7 @@ }, // 娓呴櫎宸查�夋嫨鐢ㄦ埛 clearupClient(value) { + this.emptyProductClick() if (value == "client") { this.$set(this.editConfig.infomation, "supplierName", ""); this.supplierId = null; @@ -509,6 +641,7 @@ this.tableData = [ { productId: this.productId, + productIndex:this.productIndex, id: 0, amount: 0, desc: "", @@ -525,43 +658,79 @@ // }); } this.productTableList = { + tableProductList:[], + supplierId:undefined, tableData: this.tableData, + disabled:this.editConfig.isDisabled, tableColumn: [ { label: "浜у搧鍚嶇О", prop: "name", + min: 180, productName: true, isRequird: true, + disabled:this.editConfig.isDisabled, }, - { label: "浜у搧缂栧彿", prop: "number" }, + { label: "浜у搧缂栧彿", prop: "number", min: 150,}, { label: "璁¢噺鍗曚綅", prop: "unit" }, - { label: "瑙勬牸鍨嬪彿", prop: "specifications" }, - { label: "鏁伴噺", prop: "amount", inputNumber: true, isRequird: true }, + { label: "瑙勬牸鍨嬪彿", prop: "specifications",}, + { label: "鏁伴噺", prop: "amount", inputNumber: true,disabled:this.editConfig.isDisabled, }, { label: "閲囪喘鍗曚环", prop: "price", inputFloat: true, isRequird: true, + disabled:this.editConfig.isDisabled, }, - { label: "浠风◣鍚堣", prop: "total", inputFloat: true }, - { label: "鎻忚堪", prop: "remark", input: true }, + { label: "浠风◣鍚堣", prop: "total", inputFloat: true,disabled:this.editConfig.isDisabled,multiply:true, }, + { label: "鎻忚堪", prop: "remark", input: true,disabled:this.editConfig.isDisabled}, ], }; + this.toal=this.editConfig.infomation.realTotalPrice + }, // 浜у搧鍒楄〃杈撳叆 inputContent(val, prop, row) { - this.productId = row.productId; + // this.productId = row.productId; + this.productIndex=row.productIndex; + console.log(row,val,prop,"浜у搧ID",this.tableData) this.tableData.map((item) => { - if (item.productId === row.productId) { + if (item.productIndex === row.productIndex) { item[prop] = val; } }); + + }, + getSummaries(total){ + this.totalTwo= JSON.parse(JSON.stringify(total)); + this.total=total; + this.getTotal() + }, + getTotal(){ + let prie=0 + if(this.editConfig.infomation.priceAdjustmentType==1){ + prie=Number(this.editConfig.infomation.priceAdjustment) + }else if(this.editConfig.infomation.priceAdjustmentType==2){ + prie=(-1)*Number(this.editConfig.infomation.priceAdjustment) + }else{ + prie=0 + } + let t=0 + if(this.editConfig.infomation.wholeDiscountType==1){ + t=this.totalTwo*Number(this.editConfig.infomation.wholeDiscount)/100 + }else if(this.editConfig.infomation.wholeDiscountType==2){ + t=Number(this.editConfig.infomation.wholeDiscount) + }else{ + t=0 + } + this.total=this.totalTwo-t+Number(prie) }, // 浜у搧鏂板 addProductClick() { - this.productId++; + this.productIndex++; this.tableData.push({ - productId: this.productId, + productIndex: this.productIndex, + productId:'', id: 0, amount: 0, desc: "", @@ -574,10 +743,11 @@ }, // 浜у搧娓呯┖ emptyProductClick() { - this.productId = 1; + this.productIndex = 1; this.tableData = [ { - productId: this.productId, + productId: '', + productIndex:this.productIndex, id: 0, amount: 0, desc: "", @@ -593,6 +763,16 @@ this.tableData = data; this.productTableList.tableData = this.tableData; }, + //閫夋嫨琛� + rowClick(row){ + console.log(row,"xuanze") + this.productListIdx=row.productIndex + }, + //閫変腑浜у搧 + handleProduct(item){ + this.tableData[this.productListIdx].productId=item.ID + console.log(item,"閫変腑浜у搧",this.tableData) + } }, }; </script> -- Gitblit v1.8.0