zuozhengqing
2024-04-10 62d36f52a6058e0483feceb8819475b31bc1f102
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<template>
  <div class="rightContent">
    <div class="top">
      <SearchCommonView :show-add="false" :placeholder="'请输入单号'" :amount-view="false" @searchClick="getList" />
    </div>
    <div class="list-view">
      <div class="table">
        <TableCommonView ref="tableListRef" :table-list="tableList" @selTableCol="selTableCol"></TableCommonView>
      </div>
      <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
      </div>
    </div>
  </div>
</template>
 
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { historyInventoryAdjustment } from "@/api/operate/inventoryAdjustment"
 
export default {
  name: "InventoryAdjustmentHistory",
  props: {},
  components: {},
  mixins: [pageMixin],
  computed: {},
  data() {
    return {
      tableList: {},
      showcol: ["状态"],
      searchOptions: [],
      keyword: "",
      locationId: 0,
      productId: "",
      baseOperationType: ""
    }
  },
  created() {
    this.setTable()
    this.locationId = this.$route.params.locationId
    this.productId = this.$route.params.productId
    this.baseOperationType = this.$route.params.baseOperationType
    this.getData()
  },
  methods: {
    setTable() {
      this.tableList = {
        tableInfomation: [],
        selectBox: false,
        selectIndex: true,
        showcol: this.showcol,
        allcol: [],
        tableColumn: this.setTableColumn(this.showcol)
      }
      let allcol = []
      for (let i = 0; i < this.tableList.tableColumn.length; i++) {
        if (!this.tableList.tableColumn[i].default) {
          const label = this.tableList.tableColumn[i].label
          allcol.push(label)
        }
      }
      this.tableList.allcol = allcol
    },
    setTableColumn(showcol) {
      let tableColumn = [
        {
          label: "日期",
          prop: "operationDate",
          isShowColumn: true,
          default: true
        },
        {
          label: "单号",
          prop: "number",
          isShowColumn: true,
          default: true
        },
        {
          label: "产品",
          prop: "productName",
          isShowColumn: true,
          default: true
        },
        {
          label: "从",
          prop: "from",
          isShowColumn: true,
          default: true
        },
        {
          label: "至",
          prop: "to",
          isShowColumn: true,
          default: true
        },
        {
          label: "数量",
          prop: "amount",
          isShowColumn: true,
          default: true
        },
        {
          label: "单位",
          prop: "unit",
          isShowColumn: true,
          default: true
        },
        {
          label: "状态",
          prop: "status",
          width: 120,
          isShowColumn: showcol.includes("状态"),
          default: false,
          status: true,
          isCallMethod: true,
          getCallMethod: this.getStatus
        },
        {
          label: "完成者",
          prop: "user",
          isShowColumn: showcol.includes("完成者"),
          default: false
        }
      ]
      return tableColumn
    },
    selTableCol(val) {
      this.showcol = val
      this.tableList.tableColumn = this.setTableColumn(val)
    },
    // 请求数据
    async getData() {
      await historyInventoryAdjustment({
        baseOperationType: this.baseOperationType,
        locationId: this.locationId,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize,
        productId: this.productId
      }).then((res) => {
        if (res.code === 200) {
          const list = res.data.map((item) => {
            let product = item.details[0].product
            return {
              ...item,
              from: item.details[0].fromLocation.jointName?item.details[0].fromLocation.jointName:"",
              to: item.details[0].toLocation.jointName?item.details[0].toLocation.jointName:"",
              productName: product.name,
              amount: item.details[0].amount,
              unit: product.unit
            }
          })
          this.tableList.tableInfomation = list || []
          this.pagerOptions.totalCount = res.total
        }
      })
    },
    // 搜索
    getList(val) {
      console.log(val)
      this.keyword = val
      this.pagerOptions.currPage = 1
      this.getData()
    },
    // 状态
    getStatus(val) {
      return val === 1 ? "草稿" : val === 3 ? "就绪" : "完成"
    }
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped></style>