From 6d5a9b68644735008e5fe5a70b2aa483ba3d9a7c Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期一, 22 四月 2024 10:50:37 +0800
Subject: [PATCH] 库存调整模块 添加点击自身报错位置id的问题修改
---
src/views/productManage/product/AddProductDialog.vue | 480 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 407 insertions(+), 73 deletions(-)
diff --git a/src/views/productManage/product/AddProductDialog.vue b/src/views/productManage/product/AddProductDialog.vue
index 5c63af6..18ba9bc 100644
--- a/src/views/productManage/product/AddProductDialog.vue
+++ b/src/views/productManage/product/AddProductDialog.vue
@@ -66,11 +66,37 @@
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"
>
@@ -106,14 +132,46 @@
</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"
@@ -121,6 +179,14 @@
style="width: 85%"
:disabled="!showFooter"
></el-input>
+ </el-form-item>
+ <el-form-item label="鍥剧墖涓婁紶锛�" prop="imageUrl">
+ <IconCropper
+ :isView="isView"
+ :image-url="editConfig.infomation.imageSrc"
+ @getImageData="getImageData"
+ style="width: 85%"
+ />
</el-form-item>
</div>
<div class="right">
@@ -132,7 +198,7 @@
:min="0"
:controls="false"
size="mini"
- style="width: 81%"
+ style="width: 85%"
:disabled="!showFooter"
></el-input-number>
</el-form-item>
@@ -154,7 +220,7 @@
:min="0"
:controls="false"
size="mini"
- style="width: 81%"
+ style="width: 85%"
:disabled="!showFooter"
></el-input-number>
</el-form-item>
@@ -163,6 +229,8 @@
v-model="editConfig.infomation.categoryId"
placeholder="璇烽�夋嫨"
size="mini"
+ clearable
+ filterable
style="width: 85%"
:disabled="!showFooter"
>
@@ -174,6 +242,23 @@
>
</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
@@ -197,9 +282,9 @@
</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"
@@ -235,13 +320,18 @@
placeholder="璇烽�夋嫨"
size="mini"
style="width: 85%"
- :disabled="!showFooter"
+ 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="璇疯緭鍏�"
@@ -252,7 +342,63 @@
:disabled="!showFooter"
></el-input-number>
<span> kg</span>
- </el-form-item>
+ </el-form-item> -->
+ <el-form-item label="姣涢噸" prop="grossWeight">
+ <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="4">
+ <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">
+ <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="4">
+ <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"
@@ -458,16 +604,38 @@
<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"
+ :workList="unitList"
+ :unitRight='editConfig.infomation.unit'
+ :dataList="editConfig.infomation.moreUnitList"
+ title="鍚敤澶氬崟浣�"
+ ></UnitMoreDialog>
</div>
</template>
<script>
-// import CommonFormTableView from "@/components/makepager/CommonFormTableView"
+import IconCropper from "./IconCropper"
import { getProductCategoryList } from "@/api/product/productCategory"
-import { getProductList, addProduct, updateProduct } from "@/api/product/product"
+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";
-let inputElement = null
export default {
+ mixins: [codeMixin],
name: "AddProductDialog",
props: {
editCommonConfig: {
@@ -482,7 +650,11 @@
}
}
},
- components: {},
+ components: {
+ IconCropper,
+ BomDialog,
+ UnitMoreDialog,
+ },
computed: {
modalTitle() {
if (this.editConfig.title === "缂栬緫" && this.editConfig.autoEdit) {
@@ -500,11 +672,36 @@
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 },
@@ -541,22 +738,141 @@
{ name: "鍏朵粬", id: "鍏朵粬" }
],
statisticsMap: {
- inLibrary: 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, // 涓婁紶鍥剧墖鍏ュ弬
+ bomPurchaseTypeList: getDataByType("purchaseType"),
+ grossUnitList:getDataByType("grossUnit"),
+ unitList: [],
+ editRow:{
+ editDialogVisible:false,
+ BomTableData:[]
}
}
},
created() {
+ if (this.editConfig.title === "缂栬緫" && !this.editConfig.autoEdit) {
+ this.isView = true
+ }
this.getProductCategoryList()
this.getProductList()
this.setTableForm()
this.setBottonView()
this.statisticsMap.inLibrary = this.editConfig?.infomation?.amount ?? 0
+ // 杩涘嚭鍙g殑浜у搧 鏁伴噺 杩樻病鏈�
+ this.statisticsMap.enter = this.editConfig?.infomation?.amount ?? 0
+ this.statisticsMap.exit = this.editConfig?.infomation?.amount ?? 0
if (this.editConfig.autoEdit) {
this.editClick()
}
this.setOptionalFieldsToEmpty()
+ this.formInfo()
+ this.getUserInfo()
+ this.getUnitInfo()
},
methods: {
+ 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.moreUnitList=list
+ },
+ // 鍚敤澶氬崟浣嶇殑寮�鍏�
+ 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,琛ㄥ崟闇�瑕佺┖涓叉墠鑳借涓烘湭閫夋嫨鍥炴樉
*/
@@ -631,6 +947,7 @@
this.showEdit = false
this.showButton = false
this.showFooter = true
+ this.isView = false
this.setTableForm()
},
// 淇濆瓨
@@ -638,20 +955,55 @@
console.log(this.editConfig.infomation)
this.$refs[formName].validate((valid) => {
if (valid) {
- let requestUrl = this.editConfig.title === "鏂板缓" ? addProduct : updateProduct
- this.unsetFieldsToNumber()
- requestUrl({
- ...this.editConfig.infomation
- }).then((res) => {
- console.log(res)
- this.editConfig.visible = false
- if (res.code === 200) {
- this.$message.success("娣诲姞鎴愬姛")
- this.$parent.getData()
+ console.log(this.fileFormdata == null)
+ let attachmentIDs = []
+ if (this.fileFormdata == null) {
+ if (this.editConfig.infomation.attachmentList?.length > 0) {
+ this.editConfig.infomation.attachmentList.forEach((ele) => {
+ attachmentIDs.push(ele.id)
+ })
+ } else {
+ attachmentIDs = []
}
- }, console.error)
+ this.saveEditRequest(attachmentIDs)
+ } else {
+ uploadFiles(this.fileFormdata).then((res) => {
+ if (res.code == 200) {
+ res.data.forEach((ele) => {
+ attachmentIDs.push(ele.id)
+ })
+ }
+ this.saveEditRequest(attachmentIDs)
+ })
+ }
}
})
+ },
+ // 淇濆瓨/缂栬緫鎺ュ彛璇锋眰
+ saveEditRequest(attachmentIDs) {
+ let requestUrl = this.editConfig.title === "鏂板缓" ? addProduct : updateProduct
+ this.unsetFieldsToNumber()
+ let params = {
+ ...this.editConfig.infomation,
+ attachmentIDs
+ }
+ 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)
+ }
+ }
+ requestUrl(params).then((res) => {
+ console.log(res)
+ this.editConfig.visible = false
+ if (res.code === 200) {
+ this.$message.success(this.editConfig.title === "鏂板缓" ? "娣诲姞" : "缂栬緫" + "鎴愬姛!")
+ this.$parent.getData()
+ }
+ }, console.error)
},
// 鍒犻櫎
delClick() {},
@@ -712,57 +1064,22 @@
this.tableData.splice(scope.$index, 1)
},
// 涓婁紶鍥剧墖
- toGetImg() {
- if (this.showFooter) {
- if (inputElement === null) {
- // 鐢熸垚鏂囦欢涓婁紶鐨勬帶浠�
- inputElement = document.createElement("input")
- inputElement.setAttribute("type", "file")
- inputElement.style.display = "none"
- if (window.addEventListener) {
- inputElement.addEventListener("change", this.uploadFile, false)
- } else {
- inputElement.attachEvent("onchange", this.uploadFile)
- }
- document.body.appendChild(inputElement)
- }
- inputElement.click()
- }
- },
- uploadFile(el) {
- if (el && el.target && el.target.files && el.target.files.length > 0) {
- console.log(el)
- const files = el.target.files[0]
- const isLt2M = files.size / 1024 / 1024 < 2
- const size = files.size / 1024 / 1024
- console.log(size)
- // 鍒ゆ柇涓婁紶鏂囦欢鐨勫ぇ灏�
- if (!isLt2M) {
- this.$message.error("涓婁紶澶村儚鍥剧墖澶у皬涓嶈兘瓒呰繃 2MB!")
- } else if (files.type.indexOf("image") === -1) {
- //濡傛灉涓嶆槸鍥剧墖鏍煎紡
- this.$message.error("璇烽�夋嫨鍥剧墖鏂囦欢")
- } else {
- const that = this
- const reader = new FileReader() // 鍒涘缓璇诲彇鏂囦欢瀵硅薄
- reader.readAsDataURL(el.target.files[0]) // 鍙戣捣寮傛璇锋眰锛岃鍙栨枃浠�
- reader.onload = function () {
- // 璇诲彇瀹屾垚鍚庯紝灏嗙粨鏋滆祴鍊肩粰img鐨剆rc
- that.imageSrc = this.result
- console.log(this.result)
- // 鏁版嵁浼犲埌鍚庡彴
- //const formData = new FormData()
- //formData.append('file', files); // 鍙互浼犲埌鍚庡彴鐨勬暟鎹�
- }
- }
- }
+ getImageData(formdata) {
+ this.fileFormdata = formdata
+ // 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
@@ -818,6 +1135,23 @@
} 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
+ })
}
}
}
--
Gitblit v1.8.0