| | |
| | | <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.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> |
| | |
| | | <!-- 产品 --> |
| | | <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" |
| | | style="width: 80%" |
| | | clearable |
| | | @clear="setValueNull(scope.row[item.prop])" |
| | | @change=" |
| | | (val) => { |
| | | selProductClick(val) |
| | |
| | | }" |
| | | > |
| | | </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="请选择" |
| | |
| | | }" |
| | | > |
| | | </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> |
| | | <!-- 用户 --> |
| | |
| | | { id: 2, name: "打" } |
| | | ], |
| | | selLocationOptions: [], // 位置 |
| | | selSonLocationOptions:[], //子位置 |
| | | companyOptions: [], // 公司 |
| | | selRouteOptions: [{ id: 1, name: "制造" }], // 路线 |
| | | locacionName: "", |
| | | locacionId: 0, |
| | | productName: "", |
| | | productId: "" |
| | | productId: "", |
| | | initialPosition:"" |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | } |
| | | }) |
| | | }, |
| | | async handleSelectClient(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("产品类型选中") |
| | | } |
| | | this.$emit("selProductClick",value,item) |
| | | }, |
| | | 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({ |
| | |
| | | if (res.code === 200) { |
| | | const list = res.data ? res.data : [] |
| | | this.selLocationOptions = list.locationList |
| | | this.selSonLocationOptions=list.locationList |
| | | this.productNameOptions = list.productList |
| | | } |
| | | }) |
| | |
| | | // 位置 |
| | | 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 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") |
| | | // } |
| | | } |
| | | }) |
| | | }, |
| | |
| | | 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) { |
| | |
| | | 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) |
| | |
| | | }) |
| | | } |
| | | this.$emit("selLocationClick", item, prop) |
| | | }, |
| | | // 选择子位置 |
| | | selSonLocationClick(item){ |
| | | this.$emit("selSonLocationClick",item) |
| | | }, |
| | | // 获取在库与预测数量 |
| | | getAmountAndPrediction(item, val, ite) { |
| | |
| | | font-size: 13px; |
| | | cursor: pointer; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | ::v-deep { |
| | | .el-autocomplete{ |
| | | height:28px; |
| | | .el-input{ |
| | | height:28px ; |
| | | .el-input__inner{ |
| | | height: 28px; |
| | | } |
| | | } |
| | | } |
| | | .el-form-item__label { |
| | | display: none; |
| | | } |
| | |
| | | height: 35px; |
| | | text-align: center; |
| | | } |
| | | ::v-deep .el-table__body-wrapper{ |
| | | height: unset !important; |
| | | } |
| | | </style> |
| | |
| | | <div class="list-view"> |
| | | <div class="table"> |
| | | <CommonFormTableView |
| | | ref="tableRef" |
| | | :islistingrules="true" |
| | | :product-table-list="tableList" |
| | | @inputContent="inputContent" |
| | | @tableRowClick="tableRowClick" |
| | | @selLocationClick="selLocationClick" |
| | | @selSonLocationClick="selSonLocationClick" |
| | | @querySearchData="querySearchData" |
| | | @selProductClick="selProductClick" |
| | | @selProductTypeClick="selProductTypeClick" |
| | | > |
| | | <!-- |
| | | @selProductTypeClick="selProductTypeClick" |
| | | --> |
| | | <template slot="tableButton"> |
| | | <el-table-column label="操作" width="90" align="center"> |
| | | <template slot-scope="scope"> |
| | |
| | | addTitle: "新建", |
| | | showDiscard: false, |
| | | tableList: {}, |
| | | tableData: [ |
| | | { |
| | | location: "HC/销售区", |
| | | productName: "夏季真丝吊带裙", |
| | | amount: "0.00", |
| | | unit: "件", |
| | | count: "0.00", |
| | | date: "2023-12-31", |
| | | user: "管理员", |
| | | isSet: true, |
| | | isEdit: true |
| | | }, |
| | | { |
| | | location: "HM/销售区", |
| | | productName: "夏季真丝吊带裙", |
| | | productCategory: "", |
| | | subLocation: "A区", |
| | | companyName: "贝思科", |
| | | isSet: true, |
| | | isEdit: true |
| | | } |
| | | ], |
| | | searchOptions: [], |
| | | countId: 0, |
| | | isNoProduct: true, // 添加明细行时是否有产品未选择 |
| | |
| | | RuleType: 0, |
| | | queryProductId: null, |
| | | categoryId: null, |
| | | searchTaskMap: [] |
| | | searchTaskMap: [], |
| | | isCreate:false, |
| | | thatRow:{}, |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | { label: "当产品到达", prop: "areaName", location: true }, |
| | | { label: "产品", prop: "productName", product: true }, |
| | | { label: "产品类别", prop: "productCategory", productType: true }, |
| | | { label: "存储到子位置", prop: "subLocation", location: true } |
| | | { label: "存储到子位置", prop: "subLocation", sonLocation: true } |
| | | // { label: "公司", prop: "companyName", company: true } |
| | | ] |
| | | ], |
| | | rowClickIndex:-1 |
| | | } |
| | | }, |
| | | // 请求数据 |
| | |
| | | const list = res.data.map((item) => { |
| | | return { |
| | | ...item, |
| | | areaName: { label: item.area.jointName, value: item.area.id }, |
| | | areaName: { label: item.location.jointName, value: item.location.id }, |
| | | subLocation: { label: item.location.jointName, value: item.location.id }, |
| | | productName: item.product.name, |
| | | productCategory: item.productCategory.name, |
| | |
| | | }, |
| | | // 新增 |
| | | addProductClick() { |
| | | this.isCreate=true |
| | | this.tableList.tableColumn[1].product = true |
| | | this.tableList.tableColumn[2].productType = true |
| | | console.log(this.tableData) |
| | |
| | | subLocation: "", |
| | | productName: "", |
| | | companyName: "", |
| | | productCategory:"", |
| | | isSet: true, |
| | | isEdit: false, |
| | | isOrder: true |
| | |
| | | } else { |
| | | if (this.areaId === 0) { |
| | | this.$message.error("请选择当前产品到达位置") |
| | | } else if (this.productId === 0 && this.productCategoryId === "") { |
| | | } else if (this.productId === 0 && this.productCategoryId === 0) { |
| | | this.$message.error("请选择产品或产品类别") |
| | | } else if (this.subLocationId === 0) { |
| | | this.$message.error("请选择存储到子位置") |
| | |
| | | id: this.currentRowId, |
| | | areaId: this.areaId, |
| | | locationId: this.subLocationId, |
| | | productCategoryId: this.productCategoryId || "", |
| | | productId: this.productId || "" |
| | | productCategoryId: this.productCategoryId, |
| | | productId: this.productId |
| | | }).then((res) => { |
| | | console.log(res) |
| | | if (res.code === 200) { |
| | | this.getData() |
| | | let tipStr = this.currentRowId === 0 ? "添加成功" : "修改成功" |
| | | this.$message.success(tipStr) |
| | | this.isCreate=false |
| | | } |
| | | }) |
| | | } |
| | |
| | | }, |
| | | // 取消 |
| | | discardBtnClick() { |
| | | this.getData() |
| | | this.isCreate=false |
| | | this.tableList.tableColumn[1].product = true |
| | | this.tableList.tableColumn[2].productType = true |
| | | if (this.isRowClick) { |
| | | this.tableData.map((item) => { |
| | | item.isEdit = true |
| | | }) |
| | | } else { |
| | | this.tableData.splice(0, 1) |
| | | } |
| | | this.addTitle = "新建" |
| | | this.showDiscard = false |
| | | }, |
| | |
| | | }, |
| | | // 行点击 |
| | | tableRowClick(row, rowIndex) { |
| | | this.thatRow=row |
| | | this.tableList.rowClickIndex=rowIndex |
| | | this.rowIndex = rowIndex |
| | | this.isSel() |
| | | if (!this.isNoProduct && this.currentRowId === 0) { |
| | | this.$message.error("请完成当前新建或取消新建") |
| | | } else { |
| | | this.tableList.tableColumn[2].productType = true |
| | | this.currentRowId = row.id |
| | | }else { |
| | | this.currentRowId = row.id||0 |
| | | this.addTitle = "保存" |
| | | this.showDiscard = true |
| | | this.isRowClick = true |
| | | if (!this.isNoProduct) { |
| | | this.tableData.splice(this.tableData.length - 1, 1) |
| | | this.tableData.map((item, index) => { |
| | | if (index === rowIndex) { |
| | | item.isEdit = false |
| | | item.isOrder = true |
| | | } else { |
| | | item.isEdit = true |
| | | } |
| | | }) |
| | | this.areaId = row.areaId |
| | | this.subLocationId = row.locationId |
| | | this.productCategoryId = row.productCategoryId |
| | | this.productId = row.productId |
| | | } |
| | | this.tableData.map((item, index) => { |
| | | if (index === rowIndex) { |
| | | item.isEdit = false |
| | | item.isOrder = true |
| | | } else { |
| | | item.isEdit = true |
| | | } |
| | | }) |
| | | this.areaId = row.areaId |
| | | this.subLocationId = row.locationId |
| | | this.productCategoryId = row.productCategoryId |
| | | this.productId = row.productId |
| | | if ( |
| | | this.tableList.tableData[rowIndex].productName === "" || |
| | | this.tableList.tableData[rowIndex].productName === " " |
| | | ) { |
| | | this.tableList.tableColumn[1].product = false |
| | | this.tableList.tableColumn[2].productType = true |
| | | } else { |
| | | } |
| | | }, |
| | | querySearchData(queryString,results,value){ |
| | | if(this.isCreate){ |
| | | if(queryString===''){ |
| | | this.tableList.tableColumn[1].product = true |
| | | this.tableList.tableColumn[2].productType = false |
| | | this.tableList.tableColumn[2].productType = true |
| | | }else{ |
| | | if(value==="product"){ |
| | | this.tableList.tableColumn[2].productType = false |
| | | if(results.length!==0){ |
| | | this.productId=results[0].id |
| | | }else{ |
| | | this.productId=0 |
| | | } |
| | | }else if(value==="productType"){ |
| | | this.tableList.tableColumn[1].product = false |
| | | if(results.length!==0){ |
| | | this.productCategoryId=results[0].id |
| | | }else{ |
| | | this.productCategoryId=0 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | this.editConfig.visible = true |
| | | this.editConfig.title = "新建" |
| | | }, |
| | | // 选择位置方法 |
| | | // 选择起始位置方法 |
| | | selLocationClick(item, prop) { |
| | | console.log(item, prop) |
| | | if (prop === "areaName") { |
| | | this.areaId = item.value |
| | | } else if (prop === "subLocation") { |
| | | this.subLocationId = item.value |
| | | } |
| | | }, |
| | | // 选中产品方法 |
| | | selProductClick(item) { |
| | | console.log(item, "产品") |
| | | this.RuleType = 1 |
| | | this.tableList.tableColumn[2].productType = false |
| | | this.productId = item.value |
| | | this.productCategoryId = item.categoryId |
| | | // 选择子位置方法 |
| | | selSonLocationClick(item) { |
| | | this.subLocationId = item.value |
| | | }, |
| | | // 选中产品类型方法 |
| | | selProductTypeClick(item) { |
| | | this.RuleType = 2 |
| | | if (this.currentRowId === 0) { |
| | | this.productCategoryId = item.value |
| | | } else { |
| | | // 选中产品方法 |
| | | selProductClick(value,item){ |
| | | if(value==="product"){ |
| | | this.RuleType = 1 |
| | | this.tableList.tableColumn[2].productType = false |
| | | this.productId=item.id |
| | | this.productCategoryId=item.categoryId |
| | | }else if(value==="productType"){ |
| | | this.productCategoryId=item.id |
| | | this.RuleType = 2 |
| | | this.tableList.tableColumn[1].product = false |
| | | this.tableList.tableData[this.rowIndex].productName = " " |
| | | this.productId = "" |
| | | this.productCategoryId = this.tableList.tableData[this.rowIndex].productCategoryId |
| | | } |
| | | }, |
| | | // 删除 |
| | |
| | | }, |
| | | watch: { |
| | | rowIndex(newVal) { |
| | | if (this.tableList.tableData[newVal].productName === " ") { |
| | | this.tableList.tableColumn[1].product = false |
| | | this.tableList.tableColumn[2].productType = true |
| | | } else { |
| | | this.tableList.tableColumn[1].product = true |
| | | this.tableList.tableColumn[2].productType = false |
| | | if(this.isCreate){ |
| | | if(newVal===0){ |
| | | this.tableList.tableColumn[1].product = true |
| | | this.tableList.tableColumn[2].productType = true |
| | | }else{ |
| | | this.$message.error("请完成当前新建或取消新建") |
| | | this.tableList.tableColumn[1].product = false |
| | | this.tableList.tableColumn[2].productType = false |
| | | } |
| | | }else{ |
| | | if ( |
| | | this.tableList.tableData[newVal].productName === "" |
| | | ) { |
| | | this.tableList.tableColumn[1].product = false |
| | | this.tableList.tableColumn[2].productType = true |
| | | } else { |
| | | this.tableList.tableColumn[1].product = true |
| | | this.tableList.tableColumn[2].productType = false |
| | | } |
| | | } |
| | | this.$refs.tableRef.getProductCategoryList() |
| | | } |
| | | } |
| | | } |