From e1a3c04432d808ca27e1158095d2564cd81ea379 Mon Sep 17 00:00:00 2001 From: zuozhengqing <a13193816592@163.com> Date: 星期三, 15 十一月 2023 19:22:16 +0800 Subject: [PATCH] 表格公共组件修改合并 --- src/components/makepager/CommonFormTableView.vue | 289 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 265 insertions(+), 24 deletions(-) diff --git a/src/components/makepager/CommonFormTableView.vue b/src/components/makepager/CommonFormTableView.vue index d2d5e5b..84d708e 100644 --- a/src/components/makepager/CommonFormTableView.vue +++ b/src/components/makepager/CommonFormTableView.vue @@ -151,6 +151,7 @@ v-model="scope.row[item.prop]" placeholder="璇烽�夋嫨" size="mini" + filterable style="width: 80%" @change=" (val) => { @@ -161,8 +162,69 @@ <el-option v-for="(item, index) in selLocationOptions" :key="index" - :label="item.name" - :value="{ value: item.id, label: item.name }" + :label="item.jointName" + :value="{ value: item.id, label: item.jointName }" + > + </el-option> + </el-select> + </div> + </el-form-item> + <!-- 浜у搧鍒拌揪浣嶇疆 --> + <el-form-item v-else-if="item.toLocation" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop"> + <div class="custom-name"> + <span v-if="scope.row.isEdit || scope.row.editable">{{ + scope.row[item.prop]?.label ?? scope.row[item.prop] + }}</span> + <el-select + v-else + v-model="scope.row[item.prop]" + placeholder="璇烽�夋嫨" + size="mini" + filterable + style="width: 80%" + @change=" + (val) => { + selLocationClick(val, item.prop) + } + " + > + <el-option + v-for="(item, index) in selToLocationOptions" + :key="index" + :label="item.jointName" + :value="{ value: item.id, label: item.jointName }" + > + </el-option> + </el-select> + </div> + </el-form-item> + <!-- 瀛愪綅缃� --> + <el-form-item + v-else-if="item.sonLocation" + label=" " + :prop="'tableData.' + scope.$index + '.' + item.prop" + > + <div class="custom-name"> + <span v-if="scope.row.isEdit || scope.row.editable">{{ + scope.row[item.prop]?.label ?? scope.row[item.prop] + }}</span> + <el-select + v-else + v-model="scope.row[item.prop]" + placeholder="璇烽�夋嫨" + size="mini" + style="width: 80%" + @change=" + (val) => { + selSonLocationClick(val, item.prop) + } + " + > + <el-option + v-for="(item, index) in selSonLocationOptions" + :key="index" + :label="item.jointName" + :value="{ value: item.id, label: item.jointName }" > </el-option> </el-select> @@ -180,6 +242,7 @@ v-model="locacionName" placeholder="璇烽�夋嫨" size="mini" + filterable style="width: 80%" @change=" (val) => { @@ -203,13 +266,16 @@ <!-- 浜у搧 --> <el-form-item v-else-if="item.product" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop"> <div class="custom-name"> - <span v-if="scope.row.isEdit || scope.row.editable">{{ scope.row[item.prop] }}</span> - <el-select + <span v-if="scope.row.isEdit || scope.row.editable">{{ scope.row.productName }}</span> + <!-- <el-select v-else v-model="scope.row[item.prop]" placeholder="璇烽�夋嫨" size="mini" + filterable style="width: 80%" + clearable + @clear="setValueNull(scope.row[item.prop])" @change=" (val) => { selProductClick(val) @@ -230,18 +296,31 @@ }" > </el-option> - </el-select> + </el-select> --> + <el-autocomplete + v-else + style="width: 100%" + v-model="scope.row.productName" + :fetch-suggestions=" + (queryString, callback) => { + querySearchAsync(queryString, callback, 'product') + } + " + value-key="name" + @select="handleSelectClient('product', $event)" + ></el-autocomplete> </div> </el-form-item> - <!-- 浜у搧绫诲瀷 --> + <!-- 浜у搧绫诲埆 --> <el-form-item v-else-if="item.productType" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop" > <div class="custom-name"> - <span v-if="scope.row.isEdit || scope.row.editable">{{ scope.row[item.prop] }}</span> - <el-select + <span v-if="scope.row.isEdit || scope.row.editable">{{ scope.row.productCategory }}</span> + + <!-- <el-select v-else v-model="scope.row[item.prop]" placeholder="璇烽�夋嫨" @@ -263,7 +342,20 @@ }" > </el-option> - </el-select> + </el-select> --> + <el-autocomplete + v-else + style="width: 100%" + v-model="scope.row.productCategory" + @focus="productTypeFocus" + :fetch-suggestions=" + (queryString, callback) => { + querySearchAsync(queryString, callback, 'productType') + } + " + value-key="name" + @select="handleSelectClient('productType', $event)" + ></el-autocomplete> </div> </el-form-item> <!-- 鐢ㄦ埛 --> @@ -408,12 +500,15 @@ { id: 2, name: "鎵�" } ], selLocationOptions: [], // 浣嶇疆 + selSonLocationOptions: [], //瀛愪綅缃� + selToLocationOptions: [], // 浜у搧鍒拌揪浣嶇疆 companyOptions: [], // 鍏徃 selRouteOptions: [{ id: 1, name: "鍒堕��" }], // 璺嚎 locacionName: "", locacionId: 0, productName: "", - productId: "" + productId: "", + initialPosition: "" } }, created() { @@ -427,7 +522,7 @@ this.getProductCategoryList() } if (this.islistingrules) { - this.getLocationList() + this.getToLocationList() // this.getCompanyList() } this.tableList = this.productTableList @@ -453,6 +548,55 @@ } }) }, + async handleSelectClient(value, item) { + this.$emit("selProductClick",value,item) + if (value === "product") { + if (item.categoryId === 0 || item.categoryName === "") { + this.productTypeNameOptions = [] + this.tableList.tableData[this.tableList.rowClickIndex].productCategory = "" + } else { + await getProductCategoryList({ + categoryId: item.categoryId, + keyWord: item.categoryName, + page: 1, + pageSize: 15 + }).then((res) => { + if (res.code === 200) { + const list = res.data ? res.data : [] + this.productTypeNameOptions = list + this.tableList.tableData[this.tableList.rowClickIndex].productCategory = list[0].name + } + }) + } + } else if (value === "productType") { + console.log("浜у搧绫诲瀷閫変腑") + } + }, + querySearchAsync(queryString, cb, value) { + let restaurants = "" + if (value === "product") { + restaurants = this.productNameOptions + } else if (value === "productType") { + restaurants = this.productTypeNameOptions + } + var results = queryString ? restaurants.filter(this.createStateFilter(queryString, value)) : restaurants + cb(results) + if (results.length === 0) { + this.productTypeNameOptions = [] + } + console.log(results, "results", value) + this.$emit("querySearchData", queryString, results, value) + }, + createStateFilter(queryString) { + return (state) => { + return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0 + } + }, + // 娓呴櫎閫変腑浜у搧 + setValueNull(val) { + console.log(val, "鐪嬬湅val") + }, + // 搴撳瓨璋冩暣鑾峰彇浣嶇疆鍜屼骇鍝� async getRuleList() { await getRuleList({ @@ -463,6 +607,7 @@ if (res.code === 200) { const list = res.data ? res.data : [] this.selLocationOptions = list.locationList + this.selSonLocationOptions = list.locationList this.productNameOptions = list.productList } }) @@ -475,7 +620,6 @@ page: 1, pageSize: 15 }).then((res) => { - console.log(res, "鐪嬬湅浜у搧绫诲瀷鍒楄〃") if (res.code === 200) { const list = res.data ? res.data : [] this.productTypeNameOptions = list @@ -485,18 +629,66 @@ // 浣嶇疆 async getLocationList() { await getLocationList({ - keyword: "", + // keyword: "", + jointName: this.initialPosition ? this.initialPosition : null, + productId: this.queryProductId ? this.queryProductId : null, + productCategoryId: this.categoryId ? this.categoryId : null, page: 1, pageSize: 100 }).then((res) => { + console.log(res, "newlocal") if (res.code === 200) { const list = res.data ? res.data : [] this.selLocationOptions = list + this.selSonLocationOptions = list + console.log(list, "999") if (this.isReorder) { this.locacionName = list[0]?.name this.locacionId = list[0]?.id this.$emit("selLocationClick", list[0], "locacionName") } + } + }) + }, + // 浜у搧鍒拌揪浣嶇疆 + async getToLocationList() { + await getLocationList({ + // keyword: "", + type: 3, + page: 1, + pageSize: 100 + }).then((res) => { + console.log(res, "newlocal") + if (res.code === 200) { + const list = res.data ? res.data : [] + this.selToLocationOptions = list + this.selSonLocationOptions = list + console.log(list, "999") + if (this.isReorder) { + this.locacionName = list[0]?.name + this.locacionId = list[0]?.id + this.$emit("selLocationClick", list[0], "locacionName") + } + } + }) + }, + // 璁剧疆瀛愪綅缃� + async setLocationList(jointName) { + await getLocationList({ + // keyword: "", + jointName: jointName, + page: 1, + pageSize: 100 + }).then((res) => { + console.log(res, "newlocal") + if (res.code === 200) { + const list = res.data ? res.data : [] + this.selSonLocationOptions = list + // if (this.isReorder) { + // this.locacionName = list[0]?.name + // this.locacionId = list[0]?.id + // this.$emit("selLocationClick", list[0], "locacionName") + // } } }) }, @@ -510,17 +702,16 @@ }) }, selProductNameClick(item) { - console.log(item) - this.tableList.tableData.map((ite) => { + this.productIndex = this.tableList.tableData.length - 1 + this.tableList.tableData.map((ite, index) => { console.log(ite) - // if (ite.productName === item.name) { - ite.productId = item.id - ite.productName = item.name - ite.amount = item.amount - ite.unit = item.unit - // } + if (index === this.productIndex) { + ite.productId = item.id + ite.productName = item.name + ite.amount = item.amount + ite.unit = item.unit + } }) - console.log(this.tableList.tableData) }, // 閫夋嫨浜у搧 selProductClick(item) { @@ -550,11 +741,12 @@ if (res.code === 200) { const list = res.data ? res.data : [] this.selLocationOptions = list.locationList + this.selSonLocationOptions = list.locationList } }) } console.log(this.tableList.tableData) - this.$emit("selProductClick", item) + // this.$emit("selProductClick", item) }, // 閫夋嫨浜у搧绫诲瀷 selProductTypeClick(item) { @@ -567,10 +759,43 @@ if (this.isinventory) { this.getProductCategoryList() } - this.$emit("selProductTypeClick", item) + // this.$emit("selProductTypeClick", item) + }, + // 浜у搧绫诲瀷鑾峰彇鐒︾偣 + productTypeFocus() { + getProductCategoryList({ + categoryId: 0, + keyWord: "", + page: 1, + pageSize: 15 + }).then((res) => { + if (res.code === 200) { + const list = res.data ? res.data : [] + this.productTypeNameOptions = list + } + }) }, // 閫夋嫨浣嶇疆 selLocationClick(item, prop, row) { + console.log(item, prop, row, "璧峰浣嶇疆") + if (prop === "areaName") { + // this.initialPosition=item.label + getLocationList({ + jointName: item.label, + page: 1, + pageSize: 100 + }).then((res) => { + if (res.code === 200) { + const list = res.data ? res.data : [] + this.selSonLocationOptions = list + if (this.isReorder) { + this.locacionName = list[0]?.name + this.locacionId = list[0]?.id + this.$emit("selLocationClick", list[0], "locacionName") + } + } + }) + } if (this.isReorder) { if (this.productId !== 0) { this.getAmountAndPrediction(row, "location", item) @@ -589,6 +814,10 @@ }) } this.$emit("selLocationClick", item, prop) + }, + // 閫夋嫨瀛愪綅缃� + selSonLocationClick(item) { + this.$emit("selSonLocationClick", item) }, // 鑾峰彇鍦ㄥ簱涓庨娴嬫暟閲� getAmountAndPrediction(item, val, ite) { @@ -744,6 +973,15 @@ } } ::v-deep { + .el-autocomplete { + height: 28px; + .el-input { + height: 28px; + .el-input__inner { + height: 28px; + } + } + } .el-form-item__label { display: none; } @@ -781,4 +1019,7 @@ height: 35px; text-align: center; } +::v-deep .el-table__body-wrapper { + height: unset !important; +} </style> -- Gitblit v1.8.0