yangfeng
2023-10-19 4d339741f0702a93127af2f4dc04f07a65ec7cde
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<template>
  <div class="rightContent">
    <div class="label-fixed-element">
      <span>{{ params.name }}</span>
    </div>
    <div class="top">
      <SearchCommonView
        :add-title="'新建'"
        :placeholder="'请输入单号/来源单据'"
        :amount-view="false"
        @addCommonClick="addBtnClick"
        @searchClick="getList"
      />
    </div>
    <div class="list-view">
      <div class="table">
        <TableCommonView ref="tableListRef" :table-list="tableList" @selTableCol="selTableCol">
          <template slot="tableButton">
            <el-table-column label="操作" width="100">
              <template slot-scope="scope">
                <el-button @click="tableRowClick(scope.row, '查看')" type="text" size="small">查看</el-button>
                <el-button
                  v-if="scope.row.status !== 4"
                  @click="tableRowClick(scope.row, '编辑')"
                  type="text"
                  size="small"
                  >编辑</el-button
                >
              </template>
            </el-table-column>
          </template>
        </TableCommonView>
      </div>
      <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
      </div>
    </div>
    <!-- 新建/编辑 -->
    <AddOverviewDialog
      v-if="editConfig.visible"
      :work-type="workType"
      :edit-common-config="editConfig"
      :add-name="this.$route.params.name"
      :display-edit="displayEdit"
    />
  </div>
</template>
 
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getOperation } from "@/api/overview/overview"
// import DetailProduct from "@/views/productManage/product/DetailProduct"
import AddOverviewDialog from "@/views/overview/AddOverviewDialog"
 
export default {
  name: "OverviewListView",
  props: {},
  components: { AddOverviewDialog },
  mixins: [pageMixin],
  computed: {},
  data() {
    return {
      tableList: {},
      showcol: ["仓库位置", "调出位置", "调入位置", "联系人", "日期", "来源单据", "状态"],
      searchOptions: [],
      commonDetail: {
        visible: false,
        title: "新建",
        infomation: {}
      },
      editConfig: {
        visible: false,
        title: "新建",
        infomation: {}
      },
      workType: this.$route.params.workType,
      keyword: "",
      params: {},
      displayEdit: false,
      formLabel: "",
      toLabel: ""
    }
  },
  created() {
    console.log(this.workType)
    this.setFormToLabel()
    this.setTable()
    var paramsData = sessionStorage.getItem("paramsData")
    let params = {}
    if (paramsData) {
      params = JSON.parse(sessionStorage.getItem("paramsData"))
    } else {
      params = this.$route.params
      sessionStorage.setItem("paramsData", JSON.stringify(params))
    }
    this.params = params
    this.getData()
    // console.log(this.$route.params.workType)
  },
  // 页面销毁之前
  beforeDestroy() {
    sessionStorage.removeItem("paramsData")
  },
  methods: {
    setFormToLabel() {
      if (this.workType === 1) {
        this.formLabel = "供应商位置"
        this.toLabel = "仓库位置"
      } else if (this.workType === 2) {
        this.formLabel = "仓库位置"
        this.toLabel = "客户位置"
      } else {
        this.formLabel = "调出位置"
        this.toLabel = "调入位置"
      }
    },
    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: "number",
          isShowColumn: true,
          default: true
        },
        {
          label: this.formLabel,
          prop: "from",
          isShowColumn: showcol.includes(this.formLabel),
          default: false
        },
        {
          label: this.toLabel,
          prop: "to",
          isShowColumn: showcol.includes(this.toLabel),
          default: false
        },
        {
          label: "联系人",
          prop: "companyName",
          isShowColumn: showcol.includes("联系人"),
          default: false
        },
        {
          label: "负责人",
          prop: "contacterName",
          isShowColumn: showcol.includes("负责人"),
          default: false
        },
        {
          label: "日期",
          prop: "operationDate",
          isShowColumn: showcol.includes("日期"),
          default: false,
          date: true
        },
        // {
        //   label: "产品可用性",
        //   prop: "status",
        //   isShowColumn: showcol.includes("产品可用性"),
        //   default: false
        // },
        // {
        //   label: "截止日期",
        //   prop: "faultTime",
        //   isShowColumn: showcol.includes("截止日期"),
        //   default: false
        // },
        // {
        //   label: "实际日期",
        //   prop: "shopName",
        //   isShowColumn: showcol.includes("实际日期"),
        //   default: false
        // },
        {
          label: "来源单据",
          prop: "sourceNumber",
          isShowColumn: showcol.includes("来源单据"),
          default: false
        },
        // {
        //   label: "欠单",
        //   prop: "status",
        //   isShowColumn: showcol.includes("欠单"),
        //   default: false
        // },
        {
          label: "入库类型",
          prop: "operationTypeName",
          isShowColumn: showcol.includes("入库类型"),
          default: false
        },
        {
          label: "状态",
          prop: "status",
          width: 120,
          isShowColumn: showcol.includes("状态"),
          default: false,
          status: true,
          isCallMethod: true,
          getCallMethod: this.getStatus
        }
      ]
      return tableColumn
    },
    selTableCol(val) {
      this.showcol = val
      this.tableList.tableColumn = this.setTableColumn(val)
    },
    // 请求数据
    async getData() {
      await getOperation({
        number: this.keyword,
        operationTypeId: this.params.id,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      }).then((res) => {
        console.log(res.data)
        if (res.code === 200) {
          const list = res.data.map((item) => {
            return {
              ...item,
              from: item.fromLocation.name,
              to: item.toLocation.name
            }
          })
          this.tableList.tableInfomation = list || []
          this.pagerOptions.totalCount = res.total
        }
      })
    },
    // 搜索
    getList(val) {
      console.log(val)
      this.keyword = val
      this.pagerOptions.currPage = 1
      this.getData()
    },
    // 查看 编辑
    tableRowClick(row, val) {
      console.log(row)
      this.editConfig.visible = true
      this.editConfig.title = val
      this.editConfig.operationTypeId = this.$route.params.id
      this.editConfig.infomation = { ...row }
    },
    // 新建
    addBtnClick() {
      this.editConfig.visible = true
      this.editConfig.title = "新建"
      this.editConfig.operationTypeId = this.$route.params.id
      this.editConfig.infomation = {}
    },
    // 状态
    getStatus(val) {
      return val === 1 ? "草稿" : val === 3 ? "就绪" : "完成"
    }
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.label-fixed-element {
  background: #e6ecf2;
  position: fixed;
  font-size: 14px;
  width: calc(100% - 530px);
  height: 45px;
  line-height: 45px;
  font-size: 18px;
  font-weight: 700;
  color: #171718;
  margin-top: -60px;
  margin-left: -5px;
}
</style>