<template>
|
<div class="rightContent">
|
<div class="top">
|
<SearchCommonView
|
:add-title="addTitle"
|
:show-discard="showDiscard"
|
:show-apply="true"
|
:placeholder="'请输入位置/产品'"
|
:amount-view="false"
|
@addCommonClick="addProductClick"
|
@searchClick="getList"
|
@discardBtnClick="discardBtnClick"
|
@applyBtnClick="applyBtnClick"
|
/>
|
</div>
|
<div class="list-view">
|
<div class="table">
|
<CommonFormTableView
|
:isinventory="true"
|
:product-table-list="tableList"
|
@inputContent="inputContent"
|
@tableRowClick="tableRowClick"
|
>
|
<template slot="tableButton">
|
<el-table-column label="操作" width="180" fixed="right" align="center">
|
<template slot-scope="scope">
|
<span @click="handleHistoryClick(scope.row)">
|
<i class="el-icon-refresh-left"></i>
|
<span>历史</span>
|
</span>
|
<span v-if="scope.row.isSet" @click="handleSetClick(scope)" class="margin_left_5px">
|
<i class="el-icon-setting"></i>
|
<span>设置</span>
|
</span>
|
<template v-else>
|
<span @click="handleUseClick(scope)" class="margin_left_5px">
|
<i class="el-icon-document"></i>
|
<span>应用</span>
|
</span>
|
<span @click="handleCleanupClick(scope)" class="margin_left_5px">
|
<i class="el-icon-delete"></i>
|
<span>清除</span>
|
</span>
|
</template>
|
</template>
|
</el-table-column>
|
</template>
|
</CommonFormTableView>
|
</div>
|
<div class="btn-pager">
|
<PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import CommonFormTableView from "@/components/makepager/CommonFormTableView"
|
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
|
import { getLocationList } from "@/api/warehouseManage/warehouse"
|
export default {
|
name: "InventoryAdjustment",
|
props: {},
|
components: { CommonFormTableView },
|
mixins: [pageMixin],
|
computed: {},
|
data() {
|
return {
|
addTitle: "新建",
|
showDiscard: false,
|
tableList: {},
|
tableData: [
|
{
|
location: "HC/销售区",
|
productName: "夏季真丝吊带裙",
|
amount: "0.00",
|
unit: "件",
|
count: "0.00",
|
date: "2023-12-31",
|
user: "管理员",
|
isSet: true,
|
isEdit: true
|
}
|
],
|
searchOptions: [],
|
countId: 0,
|
isNoProduct: true, // 添加明细行时是否有产品未选择
|
isRowClick: false
|
}
|
},
|
created() {
|
this.setTable()
|
this.getData()
|
},
|
methods: {
|
setTable() {
|
this.tableList = {
|
tableData: this.tableData,
|
selectBox: true,
|
tableColumn: [
|
{ label: "位置", prop: "location", location: true },
|
{ label: "产品", prop: "productName", product: true },
|
{ label: "在库数量", prop: "amount" },
|
{ label: "计量单位", prop: "unit" },
|
{ label: "计数的数量", prop: "count", inputFloat: true },
|
{ label: "差异", prop: "difference" },
|
{ label: "日期", prop: "date", date: true },
|
{ label: "用户", prop: "user", user: true }
|
]
|
}
|
},
|
// 操作输入
|
inputContent(val, prop, row) {
|
this.countId = row.countId
|
this.tableData.map((item) => {
|
if (item.countId === row.countId) {
|
item[prop] = val
|
}
|
})
|
},
|
// 新增
|
addProductClick() {
|
console.log(this.tableData)
|
this.isSel()
|
if (this.isNoProduct && this.addTitle === "新建") {
|
this.addTitle = "保存"
|
this.showDiscard = true
|
this.isRowClick = false
|
this.countId++
|
this.tableData.push({
|
countId: this.countId,
|
productId: "",
|
amount: 0,
|
unit: "",
|
productName: "",
|
count: "0.00",
|
isSet: true,
|
isEdit: false
|
})
|
} else if (this.isNoProduct && this.addTitle === "保存") {
|
this.addTitle = "新建"
|
this.showDiscard = false
|
}
|
},
|
// 是否选择产品
|
isSel() {
|
for (let i = 0; i < this.tableData.length; i++) {
|
if (this.tableData[i].productName.length === 0) {
|
this.isNoProduct = false
|
break
|
} else {
|
this.isNoProduct = true
|
}
|
}
|
},
|
// 取消
|
discardBtnClick() {
|
if (this.isRowClick) {
|
this.tableData.map((item) => {
|
item.isEdit = true
|
})
|
} else {
|
this.tableData.splice(this.tableData.length - 1, 1)
|
}
|
this.addTitle = "新建"
|
this.showDiscard = false
|
},
|
// 应用全部
|
applyBtnClick() {
|
console.log("应用全部")
|
},
|
// 历史
|
handleHistoryClick(row) {
|
this.isSel()
|
console.log(row)
|
if (this.isNoProduct) {
|
console.log("历史")
|
this.$router.push({
|
name: "inventoryAdjustmentHistory",
|
params: { id: row.id }
|
})
|
}
|
},
|
// 设置
|
handleSetClick(scope) {
|
this.isSel()
|
if (this.isNoProduct) {
|
scope.row.isSet = !scope.row.isSet
|
}
|
},
|
// 应用
|
handleUseClick(scope) {
|
scope.row.isSet = !scope.row.isSet
|
},
|
// 清除
|
handleCleanupClick(scope) {
|
scope.row.isSet = !scope.row.isSet
|
},
|
// 行点击
|
tableRowClick(row, rowIndex) {
|
console.log(row, rowIndex)
|
this.addTitle = "保存"
|
this.showDiscard = true
|
this.isRowClick = true
|
this.isSel()
|
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
|
}
|
})
|
},
|
// 请求数据
|
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.keyword = val
|
this.pagerOptions.currPage = 1
|
this.getData()
|
},
|
// 新建
|
addBtnClick() {
|
this.editConfig.infomation = {
|
name: "",
|
parentId: null,
|
type: 3,
|
isScrapLocation: null,
|
isReturnLocation: null,
|
replenishLocation: null,
|
countFrequency: 0,
|
recentlyCount: "",
|
nextCount: "",
|
notes: ""
|
}
|
this.editConfig.visible = true
|
this.editConfig.title = "新建"
|
}
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped></style>
|