From ec29f1ad88021cc49884d7dda09d0a78764ffd22 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期五, 20 十月 2023 19:00:45 +0800 Subject: [PATCH] 下拉选择框可搜索公共组件及新建调拨和新建报废选择产品内容修改 --- src/views/operate/scrap/AddScrapDialog.vue | 44 ++- src/assets/style/index.scss | 3 src/views/overview/index.vue | 35 ++ src/components/makepager/SimpleSearchInput.vue | 556 ++++++++++++++++++++++++++++++++++++++++++++++ src/components/makepager/CommonFormTableView.vue | 45 +-- 5 files changed, 632 insertions(+), 51 deletions(-) diff --git a/src/assets/style/index.scss b/src/assets/style/index.scss index 95f617a..dcbbdaf 100644 --- a/src/assets/style/index.scss +++ b/src/assets/style/index.scss @@ -132,6 +132,9 @@ .yes-cursor { cursor: pointer; } +.background_color_eee { + background: #eee; +} .Badge { background: #d3d3d3; diff --git a/src/components/makepager/CommonFormTableView.vue b/src/components/makepager/CommonFormTableView.vue index 7c82937..0e99386 100644 --- a/src/components/makepager/CommonFormTableView.vue +++ b/src/components/makepager/CommonFormTableView.vue @@ -59,25 +59,14 @@ :prop="'tableData.' + scope.$index + '.' + item.prop" > <div class="custom-name"> - <el-select - v-model="scope.row[item.prop]" - placeholder="璇烽�夋嫨" - size="mini" - style="width: 80%" - @change=" - (val) => { - selProductNameClick(val) - } - " + <SimpleSearchInput + :echoValue="scope.row[item.prop]" + :echoName="scope.row[item.prop]" + checkedNum="1" + :clearable="true" + @select-user="selProductNameClick" > - <el-option - v-for="item in productNameOptions" - :key="item.id" - :label="item.name" - :value="{ value: item.id, label: item.name, amount: item.amount, unit: item.unit }" - > - </el-option> - </el-select> + </SimpleSearchInput> </div> </el-form-item> <el-form-item @@ -260,10 +249,11 @@ import { getLocationList } from "@/api/warehouseManage/warehouse" import { getCompanyList } from "@/api/common/other" import { getRuleList } from "@/api/operate/inventoryAdjustment" +import SimpleSearchInput from "@/components/makepager/SimpleSearchInput" // import SelectCommonDialog from "@/views/other/commonDialog/SelectCommonDialog" export default { name: "CommmonFormTableView", - components: {}, + components: { SimpleSearchInput }, props: { detailEnter: { type: Boolean, @@ -387,13 +377,15 @@ }) }, selProductNameClick(item) { + console.log(item) this.tableList.tableData.map((ite) => { - if (ite.productName.label === item.label) { - ite.productId = item.value - ite.productName = item.label - ite.amount = item.amount - ite.unit = item.unit - } + console.log(ite) + // if (ite.productName === item.name) { + ite.productId = item.id + ite.productName = item.name + ite.amount = item.amount + ite.unit = item.unit + // } }) console.log(this.tableList.tableData) }, @@ -537,6 +529,9 @@ // 鍗曢�夎鐩稿叧 tableRowClassName({ row, rowIndex }) { row.index = rowIndex + }, + setFormItem(val) { + console.log(val) } } } diff --git a/src/components/makepager/SimpleSearchInput.vue b/src/components/makepager/SimpleSearchInput.vue new file mode 100644 index 0000000..ddd2114 --- /dev/null +++ b/src/components/makepager/SimpleSearchInput.vue @@ -0,0 +1,556 @@ +<template> + <el-select + v-model="selectValue" + ref="search-select" + popper-class="user-simple-search-input-popper" + :popper-append-to-body="true" + :disabled="disabled" + :placeholder="placeholder" + style="width: 100%" + class="user-simple-search-input" + @visible-change="changeSelectStatus" + :clearable="clearable" + filterable + size="mini" + @clear="selectClear" + > + <el-option :label="selectLabel" :value="selectValue"> + <div class="container" @click="endSelect"> + <div class="search"> + <el-input + placeholder="鎼滅储浜у搧鍚嶇О" + v-model.trim="keyword" + maxlength="20" + @keyup.enter.native="updateSearchList(true)" + > + <i slot="suffix" class="el-input__icon el-icon-search" @click="updateSearchList(true)"></i> + </el-input> + </div> + <div v-if="checkedNum > 1"> + <div class="selected-text"> + 宸查��({{ selectedUser.length }})锛� + <span class="user-text" v-for="(user, index) in selectedUser" :key="index"> + {{ user[obj.name] }} + <span class="iconfont ico-delete-user" @click="deleteUser(user.id)"></span> + {{ selectedUser.length > index + 1 ? "," : "" }} + </span> + </div> + <p class="fs12-tip" v-show="selectedUser.length == checkedNum">鎻愮ず锛氭渶澶氶�夋嫨{{ checkedNum }}浜猴紒</p> + </div> + <!-- <div class="bar"> + <span class="desc">璇烽�夋嫨浜у搧锛坽{ listData.length }}锛�</span> + </div> --> + <div class="list" v-loading="loading" element-loading-text="鎷煎懡鍔犺浇涓�"> + <ul class="infinite-list" @scroll="loadList"> + <div class="background_color_eee"> + <el-row :gutter="0"> + <el-col :span="8"> + <div class="grid-content bg-purple"> + <span class="name">浜у搧鍚嶇О</span> + </div> + </el-col> + <el-col :span="8"> + <div class="grid-content bg-purple">鍐呴儴缂栫爜</div> + </el-col> + + <el-col :span="5"> + <div class="grid-content bg-purple">鍦ㄥ簱鏁伴噺</div> + </el-col> + <el-col :span="3"> + <div class="grid-content bg-purple">璁¢噺鍗曚綅</div> + </el-col> + </el-row> + </div> + <li class="empty" v-if="listData.length === 0">鏆傛棤鏁版嵁</li> + <template v-else> + <li + v-for="(user, index) in listData" + :key="index" + @click="selectUser(user)" + :class="selectValue == user.id ? 'highlight-color' : ''" + > + <el-row :gutter="0"> + <el-col :span="8"> + <div class="grid-content bg-purple" :title="user[obj.name]"> + {{ user[obj.name] || "--" }} + </div> + </el-col> + <el-col :span="6"> + <div class="grid-content bg-purple" :title="user.internalReference"> + <span class="name">{{ user.internalReference || "--" }}</span> + </div> + </el-col> + <el-col :span="6"> + <div class="grid-content bg-purple" :title="user.amount"> + {{ user.amount || "--" }} + </div> + </el-col> + <el-col :span="4"> + <div class="grid-content bg-purple" :title="user.unit"> + {{ user.unit || "--" }} + </div> + </el-col> + </el-row> + </li> + <li class="loading">{{ loading ? "鍔犺浇涓�" : "宸茬粡鍒板簳" }}</li> + </template> + </ul> + </div> + </div> + </el-option> + <!-- <DataSet ref="dataSet" moduleName="鐗╂枡绠$悊"></DataSet> --> + </el-select> +</template> + +<script> +import { getProductList } from "@/api/product/product" +// import DataSet from "@/views/ShopFloorControl/facilty/components/DataSet"; +export default { + name: "UserSimpleSearchInput", + components: { + // DataSet, + }, + props: { + placeholder: { + type: [String], + default: "璇烽�夋嫨" + }, + disabled: { + type: [Boolean], + default: false + }, + // 鍥炴樉鍊糲ode + echoName: { + type: [String], + default: "" + }, + // 鍥炴樉鍚嶇Оname + echoValue: { + type: [String], + default: "" + }, + // 鍙�夋暟閲� + checkedNum: { + type: [String, Number], + default: 1 + }, + //鍙惁娓呯┖ + clearable: { + type: [Boolean], + default: false + }, + // 璇锋眰鎺ュ彛鐨勫弬鏁� + // types: { + // type: [Array], + // default: () => ["鍗婃垚鍝�", "鎴愬搧"] + // }, + request: { + type: [String, Number], + defalut: "" + }, + size: { + type: [String], + defalut: "medium" + } + }, + data() { + return { + // e-select缁勪欢model缁戝畾鍙橀噺锛屽崰浣嶄娇鐢� + selectValue: this.echoValue ? this.echoValue : this.echoName ? this.echoName : "", + selectLabel: "", + // 鎼滅储妗嗘悳绱㈣瘝 + keyword: "", + // 鏌ヨ椤� + page: 1, + // 姣忛〉灞曠ず鏁伴噺 + pageSize: 10, + // 鏁版嵁鎬婚噺 + count: 0, + // 鎼滅储鐢ㄦ埛缁撴灉鏁扮粍 + listData: [], + // 鏄惁缁撴潫閫夋嫨 + isEndSelect: false, + selectedUser: [], + loading: true, + num: 0, + obj: { + name: "name", + id: "id" + } + } + }, + computed: {}, + watch: { + echoName(val) { + console.log(val) + this.selectValue = this.echoValue ? this.echoValue : this.echoName ? this.echoName : "" + this.checkMoreInit() + }, + request(val) { + this.getName(val) + } + }, + beforeMount() { + this.checkMoreInit() + this.getName(this.request) + this.num = 0 + }, + methods: { + getName(val) { + if (val == 1) { + // 鍏朵粬鎼滅储閰嶇疆杩欓噷 + this.obj = { + name: "gaugeName", + id: "id" + } + } + }, + // 鏇存柊鎼滅储鍒楄〃 + updateSearchList(needInit = false, param = {}) { + let listParams + // 鍒濆鍖栫敤鎴蜂俊鎭垪琛ㄥ叆鍙� + if (needInit) { + this.page = 1 + this.count = 0 + this.listData = [] + } + console.log(this.keyword) + listParams = { + keyWord: this.keyword, + page: this.page, + pageSize: this.pageSize, + ...param + } + this.loading = true + if (this.request) { + // 鍏朵粬 + } else { + // 浜у搧 + getProductList(listParams).then((res) => { + if (res && res.code === 200 && res.data) { + this.loading = false + this.page = this.page + 1 + this.count = res.total + if (res.data && Array.isArray(res.data)) { + let arr = JSON.parse(JSON.stringify(res.data)) + this.listData = this.listData.concat(arr) + } + // if (this.num == 0 && this.listData.length == 0) { + // this.$refs.dataSet.materialVisible = true + // } + this.num += 1 + } + }) + } + + setTimeout(() => { + this.loading = false + }, 10000) + }, + // 鍔ㄦ�佸姞杞藉垪琛� + loadList(event) { + const { clientHeight, scrollTop, scrollHeight } = event.currentTarget + // 褰撴粴鍔╰op璺濈澶т簬涓�灞忕殑璺濈锛屽姞杞戒笅涓�椤垫暟鎹� + if (scrollTop > scrollHeight - clientHeight * 2) { + // 褰搇oading鍔ㄧ敾鏈粨鏉熸椂銆佹垨鑰呭垪琛ㄦ暟鎹潯鏁板ぇ浜庢帴鍙h繑鍥炴�绘潯鏁版椂涓嶅啀璇锋眰鏁版嵁 + if (!this.loading && this.listData.length <= this.count) { + this.updateSearchList() + } + } + }, + // 閫夋嫨鐢ㄦ埛 + selectUser(user) { + if (this.checkedNum > 1) { + if (this.selectedUser.length < this.checkedNum) { + if (this.selectValue.indexOf(user.id) == -1) { + this.selectedUser.push(user) + this.selectValue = this.selectedUser + .map((item) => { + return item.id + }) + .join(",") + this.selectLabel = this.selectedUser + .map((item) => { + return item[this.obj.name] + }) + .join(",") + } + } + this.$emit("select-user", this.selectValue, this.selectLabel, this.selectedUser) + } else { + // 鍙樻洿閫夋嫨寮�鍏� + this.isEndSelect = false + // 璧嬪�糴l-select缁勪欢鍊� + this.selectValue = user.id + this.selectLabel = user[this.obj.name] + // 鍛婄煡鐖剁粍浠舵墍閫夌敤鎴锋暟鎹� + this.selectedUser = user + this.$emit("select-user", user) + } + }, + deleteUser(id) { + for (let i = 0; i < this.selectedUser.length; i++) { + if (this.selectedUser[i].id == id) { + this.selectedUser.splice(i, 1) + } + } + this.selectValue = this.selectedUser + .map((item) => { + return item.id + }) + .join(",") + this.selectLabel = this.selectedUser + .map((item) => { + return item[this.obj.name] + }) + .join(",") + this.$emit("select-user", this.selectValue, this.selectLabel, this.selectedUser) + }, + // 澶氶�夋椂鍊� + checkMoreInit() { + if (this.checkedNum > 1 && this.echoName) { + this.selectedUser = [] + this.selectLabel = this.echoName + let arr = this.echoName.split(",") + let arr2 = this.echoValue.split(",") + for (let i = 0; i < arr.length; i++) { + let item = { id: arr2[i] } + item[this.obj.name] = arr[i] + this.selectedUser.push(item) + } + } else { + if (this.echoName) { + this.selectedUser = [] + this.selectLabel = this.echoName ? this.echoName : "" + let item = { id: this.echoValue } + item[this.obj.name] = this.echoName + this.selectedUser.push(item) + this.selectValue = this.echoValue ? this.echoValue : this.echoName ? this.echoName : "" + } else { + this.selectedUser = [] + this.selectLabel = "" + this.selectValue = "" + } + } + }, + // 缁撴潫閫夋嫨銆佸叧闂脊绐� + endSelect(event) { + this.isEndSelect && event.stopPropagation() + }, + // 鍙樻洿閫夋嫨鐘舵�� + changeSelectStatus(status, value) { + this.isEndSelect = status + // 褰搒tatus涓簍rue鏃讹紝dialog鎵撳紑锛屽垵濮嬪寲page + if (status) { + this.keyword = "" + if (value != "clear") { + this.updateSearchList(true) + } + } + }, + selectClear() { + if (this.checkedNum > 1) { + this.selectValue = [] + this.selectLabel = [] + this.selectedUser = [] + this.$emit("select-user", this.selectValue) + } else { + this.isEndSelect = true + // 璧嬪�糴l-select缁勪欢鍊� + this.selectValue = "" + this.selectLabel = "" + // 鍛婄煡鐖剁粍浠舵墍閫夌敤鎴锋暟鎹� + this.selectedUser = "" + this.$emit("select-user", this.selectedUser) + } + this.changeSelectStatus(true, "clear") + } + } +} +</script> + +<style lang="scss"> +.user-simple-search-input-popper { + max-width: 630px; + .el-select-dropdown__wrap { + min-width: 509px; + width: 100%; + min-height: 370px; + + .el-select-dropdown__list { + width: 100%; + height: 350px; + padding: 0; + + & > .el-select-dropdown__item { + width: 100%; + height: 350px; + background-color: rgba(255, 255, 255, 1); + padding: 0; + + & > .container { + width: 96%; + height: 100%; + padding: 2%; + + .search { + margin-bottom: 5px; + + & > .el-input { + & > input { + width: 100%; + height: 40px; + background: rgba(255, 255, 255, 1); + border-radius: 4px; + font-size: 14px; + + font-weight: 400; + color: rgba(175, 179, 190, 1); + } + + & > .el-input__suffix { + & > .el-input__suffix-inner { + font-size: 19px; + } + + & > .el-icon-circle-close { + display: none; + } + + & > i.el-input__icon.el-input__validateIcon.el-icon-circle-check { + display: none; + } + } + } + } + + .bar { + width: 100%; + height: 40px; + display: flex; + justify-content: space-between; + align-items: center; + + & > .desc { + font-size: 14px; + + font-weight: 400; + color: rgba(102, 102, 102, 1); + } + } + + .list { + width: 100%; + height: calc(100% - 40px); + background: rgba(250, 250, 252, 1); + border: 1px solid rgba(250, 250, 252, 1); + + & > ul { + width: 100%; + overflow-y: auto; + overflow-x: hidden; + height: 100%; + div { + height: 40px; + font-size: 14px; + line-height: 40px; + font-weight: 600; + color: rgba(51, 51, 51, 1); + padding: 0 4px; + // background:#eee; + } + .highlight-color { + background: #eee; + } + } + + & > ul > li { + width: 100%; + height: 40px; + font-size: 14px; + line-height: 40px; + font-weight: 400; + color: rgba(51, 51, 51, 1); + padding: 0 4px; + display: inline-block; + float: left; + &:hover { + background: rgba(255, 255, 255, 1); + } + + &.empty { + width: 100%; + height: calc(100% - 80px); + display: flex; + justify-content: center; + align-items: center; + + &:hover { + background-color: transparent; + } + } + + &.loading { + width: 100%; + display: flex; + justify-content: center; + align-items: center; + } + + & > .el-row > .el-col { + & > .grid-content { + line-height: 48px; + padding: 0 7px; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + } + + &:nth-of-type(1) > .grid-content { + display: flex; + align-items: center; + justify-content: flex-start; + + & > span.name { + width: calc(100% - 26px - 10px); + margin-left: 10px; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + } + } + } + } + } + .user-text { + display: inline-block; + line-height: 24px; + } + .ico-delete-user { + color: #aaa; + font-weight: normal; + font-size: 16px; + display: none; + line-height: 24px; + padding: 0 4px 0 2px; + vertical-align: middle; + margin-top: -2px; + } + .user-text:hover .ico-delete-user { + display: inline-block; + } + .fs12-tip { + font-size: 12px; + font-weight: normal; + line-height: 16px; + } + .selected-text { + white-space: normal; + line-height: 24px; + } + } + } + } + } +} +</style> diff --git a/src/views/operate/scrap/AddScrapDialog.vue b/src/views/operate/scrap/AddScrapDialog.vue index 3dc7f47..f7a8db1 100644 --- a/src/views/operate/scrap/AddScrapDialog.vue +++ b/src/views/operate/scrap/AddScrapDialog.vue @@ -45,22 +45,16 @@ <el-row> <el-col :span="12"> <el-form-item label="浜у搧" prop="productName"> - <el-select - v-model="editConfig.infomation.productName" - placeholder="璇烽�夋嫨" - size="mini" - style="width: 90%" + <SimpleSearchInput + :echoValue="editConfig.infomation.productName" + :echoName="editConfig.infomation.productName" + checkedNum="1" + :clearable="true" + @select-user="selProductChange" :disabled="!showFooter" - @change="selProductChange" + style="width: 90%" > - <el-option - v-for="item in productOptions" - :key="item.id" - :label="item.name" - :value="{ value: item.id, label: item.name, unit: item.unit }" - > - </el-option> - </el-select> + </SimpleSearchInput> </el-form-item> </el-col> <el-col :span="12"> @@ -85,7 +79,7 @@ :min="0" :precision="2" :controls="false" - style="width: 85%" + style="width: 90%" :disabled="!showFooter" ></el-input-number> <span>{{ " " + unit }}</span> @@ -132,6 +126,7 @@ import { getProductList } from "@/api/product/product" import { getLocationList } from "@/api/overview/overview" import { addDisuse, finishDisuse } from "@/api/operate/scrap" +import SimpleSearchInput from "@/components/makepager/SimpleSearchInput" export default { name: "AddScrapDialog", props: { @@ -146,7 +141,7 @@ } } }, - components: {}, + components: { SimpleSearchInput }, computed: {}, data() { return { @@ -154,7 +149,7 @@ editConfig: this.editCommonConfig, rules: { // 浜у搧锛屾暟閲忓繀濉� - productName: [{ required: true, message: "璇烽�夋嫨浜у搧", trigger: "change" }], + productName: [{ required: true, validator: this.validatorProduct, trigger: "change" }], amount: [{ required: true, message: "璇疯緭鍏ユ暟閲�", trigger: "blur" }], fromLocationId: [{ required: true, message: "璇烽�夋嫨婧愪綅缃�", trigger: "change" }], toLocationId: [{ required: true, message: "璇烽�夋嫨鎶ュ簾浣嶇疆", trigger: "change" }], @@ -212,7 +207,7 @@ }, // 璁剧疆鍒犻櫎/鎵撳嵃/缂栬緫鏄惁鏄剧ず setBottonView() { - if (this.editConfig.title === "鏂板缓"||this.editConfig.title==="缂栬緫") { + if (this.editConfig.title === "鏂板缓" || this.editConfig.title === "缂栬緫") { this.showButton = false this.showEdit = false this.showFooter = true @@ -272,8 +267,9 @@ // 閫夋嫨浜у搧 selProductChange(val) { this.unit = val.unit - this.productName = val.label - this.productId = val.value + this.productName = val.name + this.productId = val.id + this.editConfig.infomation.productName = val.name }, // 楠岃瘉 async validateClick() { @@ -285,6 +281,14 @@ this.$parent.getData() } }) + }, + // 浜у搧鍗曠嫭鏍¢獙 + validatorProduct(rule, value, callback) { + if (this.editConfig.infomation.productName && this.editConfig.infomation.productName.length > 0) { + callback() + } else { + callback(new Error("璇烽�夋嫨浜у搧")) + } } } } diff --git a/src/views/overview/index.vue b/src/views/overview/index.vue index 6cf6cf0..0985bf7 100644 --- a/src/views/overview/index.vue +++ b/src/views/overview/index.vue @@ -20,17 +20,24 @@ <div class="label"> <span style="cursor: pointer">{{ item.name }}</span> </div> - <div class="set">...</div> + <el-dropdown class="set" placement="bottom" trigger="click" @command="handleCommand"> + <div @click.stop="moreClick()">...</div> + <el-dropdown-menu slot="dropdown"> + <el-dropdown-item :command="{ command: '鍏ㄩ儴', item }">鍏ㄩ儴</el-dropdown-item> + <el-dropdown-item :command="{ command: '灏辩华', item }">灏辩华</el-dropdown-item> + <el-dropdown-item :command="{ command: '瀹屾垚', item }">瀹屾垚</el-dropdown-item> + </el-dropdown-menu> + </el-dropdown> </div> <div class="bottom"> <div class="left"> - <div class="left_view"> + <div class="left_view" @click.stop="statusClick(item, '灏辩华')"> <span>{{ item.readyCount }}</span> <span style="margin-left: 5px">灏辩华</span> </div> </div> <div class="right"> - <div class="right_status"> + <div class="right_status" @click.stop="statusClick(item, '瀹屾垚')"> <span style="cursor: pointer">{{ item.finishCount + " 瀹屾垚" }}</span> </div> <!-- <div class="right_status" style="margin-top: 5px"> @@ -79,11 +86,11 @@ this.keyword = val this.getData() }, - labelClick(item) { + labelClick(item, status) { console.log(item) this.$router.push({ name: "overviewList", - params: { name: item.name, workType: item.baseOperationType, id: item.id } + params: { name: item.name, workType: item.baseOperationType, id: item.id, status: status } }) }, async getData() { @@ -103,6 +110,21 @@ this.pagerOptions.totalCount = res.data.total } }) + }, + handleCommand(val) { + console.log(val) + if (val.command === "鍏ㄩ儴") { + this.labelClick(val.item, "") + } else { + this.labelClick(val.item, val.command) + } + }, + // 鏇村 + moreClick() {}, + // 鐘舵�� + statusClick(item, status) { + console.log(item) + this.labelClick(item, status) } } } @@ -143,7 +165,7 @@ margin-left: auto; margin-right: 20px; font-size: 20px; - cursor: no-drop; + // cursor: no-drop; color: #000; transform: rotate(-90deg); -moz-transform: rotate(-90deg); @@ -153,6 +175,7 @@ .bottom { display: flex; font-size: 13px; + margin-top: 30px; .left { width: 50%; // background: #1d80e2; -- Gitblit v1.8.0