| | |
| | | :product-table-list="tableList" |
| | | @inputContent="inputContent" |
| | | @tableRowClick="tableRowClick" |
| | | @selLocationClick="selLocationClick" |
| | | @selProductClick="selProductClick" |
| | | > |
| | | <template slot="tableButton"> |
| | | <el-table-column label="操作" width="90" fixed="right" align="center"> |
| | | <template slot-scope="scope"> |
| | | <el-button v-if="scope.row.isEdit" @click.stop="delClick(scope)" type="text" size="small" |
| | | >删除</el-button |
| | | > |
| | | </template> |
| | | </el-table-column> |
| | | </template> |
| | | </CommonFormTableView> |
| | | </div> |
| | | <div class="btn-pager"> |
| | |
| | | <script> |
| | | import CommonFormTableView from "@/components/makepager/CommonFormTableView" |
| | | import pageMixin from "@/components/makepager/pager/mixin/pageMixin" |
| | | import { getLocationList } from "@/api/warehouseManage/warehouse" |
| | | import { |
| | | getListingRulesList, |
| | | addListingRules, |
| | | updateListingRules, |
| | | deleteListingRules |
| | | } from "@/api/warehouseManage/listingRules" |
| | | export default { |
| | | name: "listingRules", |
| | | props: {}, |
| | |
| | | searchOptions: [], |
| | | countId: 0, |
| | | isNoProduct: true, // 添加明细行时是否有产品未选择 |
| | | isRowClick: false |
| | | isRowClick: false, |
| | | areaId: 0, |
| | | productId: 0, |
| | | subLocationId: 0, |
| | | currentRowId: 0 |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | methods: { |
| | | setTable() { |
| | | this.tableList = { |
| | | tableData: this.tableData, |
| | | tableData: [], |
| | | selectBox: true, |
| | | tableColumn: [ |
| | | { label: "当产品到达", prop: "location", location: true }, |
| | | { label: "当产品到达", prop: "areaName", location: true }, |
| | | { label: "产品", prop: "productName", product: true }, |
| | | // { label: "产品类别", prop: "productCategory", productCategory: true }, |
| | | { label: "存储到子位置", prop: "subLocation", location: true }, |
| | | { label: "公司", prop: "companyName", company: true } |
| | | { label: "产品类别", prop: "productCategory" }, |
| | | { label: "存储到子位置", prop: "subLocation", location: true } |
| | | // { label: "公司", prop: "companyName", company: true } |
| | | ] |
| | | } |
| | | }, |
| | | // 请求数据 |
| | | async getData() { |
| | | await getListingRulesList({ |
| | | // keyword: this.keyword, |
| | | page: this.pagerOptions.currPage, |
| | | pageSize: this.pagerOptions.pageSize |
| | | }).then((res) => { |
| | | if (res.code === 200) { |
| | | const list = res.data.map((item) => { |
| | | return { |
| | | ...item, |
| | | areaName: item.area.jointName, |
| | | subLocation: item.location.jointName, |
| | | productName: item.product.name, |
| | | productCategory: item.productCategory.name, |
| | | isSet: false, |
| | | isEdit: true |
| | | } |
| | | }) |
| | | this.tableList.tableData = list || [] |
| | | this.tableData = list || [] |
| | | this.pagerOptions.totalCount = res.total |
| | | } |
| | | }) |
| | | }, |
| | | // 操作输入 |
| | | inputContent(val, prop, row) { |
| | |
| | | this.addTitle = "保存" |
| | | this.showDiscard = true |
| | | this.isRowClick = false |
| | | this.currentRowId = 0 |
| | | this.countId++ |
| | | this.tableData.push({ |
| | | countId: this.countId, |
| | | areaId: 0, |
| | | areaName: "", |
| | | locationId: 0, |
| | | productId: "", |
| | | location: 0, |
| | | subLocation: "", |
| | | productName: "", |
| | | companyName: "", |
| | | isSet: true, |
| | | isEdit: false |
| | | }) |
| | | } else if (this.isNoProduct && this.addTitle === "保存") { |
| | | this.addTitle = "新建" |
| | | this.showDiscard = false |
| | | this.tableData.map((item) => { |
| | | item.isEdit = true |
| | | console.log(item) |
| | | if (typeof item.location === "object") { |
| | | item.location = item.location.name |
| | | } |
| | | if (typeof item.subLocation === "object") { |
| | | item.location = item.subLocation.name |
| | | } |
| | | }) |
| | | this.areaId = 0 |
| | | this.subLocationId = 0 |
| | | this.productCategoryId = 0 |
| | | this.productId = 0 |
| | | } else { |
| | | if (this.areaId === 0) { |
| | | this.$message.error("请选择当前产品到达位置") |
| | | } else if (this.productId === 0) { |
| | | this.$message.error("请选择产品") |
| | | } else if (this.subLocationId === 0) { |
| | | this.$message.error("请选择存储到子位置") |
| | | } else { |
| | | this.addTitle = "新建" |
| | | this.showDiscard = false |
| | | this.tableData.map((item) => { |
| | | item.isEdit = true |
| | | console.log(item) |
| | | if (typeof item.location === "object") { |
| | | item.location = item.location.name |
| | | } |
| | | if (typeof item.subLocation === "object") { |
| | | item.location = item.subLocation.name |
| | | } |
| | | }) |
| | | let requestUrl = this.currentRowId === 0 ? addListingRules : updateListingRules |
| | | requestUrl({ |
| | | id: this.currentRowId, |
| | | areaId: this.areaId, |
| | | locationId: this.subLocationId, |
| | | productCategoryId: this.productCategoryId, |
| | | productId: this.productId |
| | | }).then((res) => { |
| | | console.log(res) |
| | | if (res.code === 200) { |
| | | let tipStr = this.currentRowId === 0 ? "添加成功" : "修改成功" |
| | | this.$message.success(tipStr) |
| | | this.getData() |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | // 是否选择产品 |
| | |
| | | }, |
| | | // 行点击 |
| | | tableRowClick(row, rowIndex) { |
| | | console.log(row, rowIndex) |
| | | this.addTitle = "保存" |
| | | this.showDiscard = true |
| | | this.isRowClick = true |
| | | console.log("11111") |
| | | this.isSel() |
| | | if (!this.isNoProduct) { |
| | | this.tableData.splice(this.tableData.length - 1, 1) |
| | | if (!this.isNoProduct && this.currentRowId === 0) { |
| | | this.$message.error("请完成当前新建或取消新建") |
| | | } else { |
| | | this.currentRowId = row.id |
| | | 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 |
| | | } 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 |
| | | } else { |
| | | item.isEdit = true |
| | | } |
| | | }) |
| | | }, |
| | | // 请求数据 |
| | | async getData() { |
| | | await getLocationList({ |
| | | keyword: this.keyword, |
| | | page: this.pagerOptions.currPage, |
| | | pageSize: this.pagerOptions.pageSize |
| | | }).then((res) => { |
| | | if (res.code === 200) { |
| | | const list = res.data ? res.data : [] |
| | | this.tableList.tableInfomation = list |
| | | this.pagerOptions.totalCount = res.total |
| | | } |
| | | }) |
| | | }, |
| | | // 搜索 |
| | | getList(val) { |
| | |
| | | } |
| | | 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.productId = item.value |
| | | this.productCategoryId = item.categoryId |
| | | }, |
| | | // 删除 |
| | | async delClick(scope) { |
| | | console.log(scope) |
| | | await deleteListingRules(scope.row.id).then((res) => { |
| | | if (res.code === 200) { |
| | | this.$message.success("删除成功") |
| | | this.getData() |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |