yangfeng
2023-11-03 27876781629d64545777c069ed60717b34f46b2c
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
<template>
  <div class="rightContent">
    <div class="top">
      <SearchCommonView
        :add-title="'新建'"
        :placeholder="'请输入单号'"
        :amount-view="false"
        :search-task-map="searchTaskMap"
        @addCommonClick="addBtnClick"
        @searchClick="getList"
        @delSelectClick="delSelectClick"
      />
    </div>
    <div class="list-view">
      <div class="table">
        <TableCommonView ref="tableListRef" :table-list="tableList" :show-checkcol="false">
          <template slot="tableButton">
            <el-table-column label="操作" width="120" fixed="right">
              <template slot-scope="scope">
                <el-button @click="tableRowClick(scope.row, 'edit')" type="text" size="small">编辑</el-button>
                <el-button type="text" size="small" @click="tableRowClick(scope.row, 'look')">查看</el-button>
              </template>
            </el-table-column>
          </template>
        </TableCommonView>
      </div>
      <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
      </div>
    </div>
    <!-- 新建/编辑 -->
    <AddDialog
      v-if="editConfig.visible"
      @refresh="refresh"
      :positionList="tableList.tableInfomation"
      :edit-common-config="editConfig"
    />
  </div>
</template>
 
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getLocationList } from "@/api/warehouseManage/warehouse"
import AddDialog from "@/views/warehouseManage/position/AddDialog"
import { getDataByType } from "@/api/data"
export default {
  name: "WarehouseView",
  props: {},
  components: { AddDialog },
  mixins: [pageMixin],
  computed: {},
  data() {
    return {
      tableList: {},
      searchOptions: [],
      editConfig: {
        visible: false,
        title: "新建",
        infomation: {}
      },
      positionTypeList: getDataByType("positionType"),
      searchTaskMap: [],
      type: 3
    }
  },
  created() {
    this.setTable()
    this.searchTaskMap = [{ id: "3", title: "内部位置" }]
    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) {
      console.log(showcol)
      let tableColumn = [
        {
          label: "位置",
          prop: "jointName",
          isShowColumn: true,
          default: true
        },
        {
          label: "位置类型",
          prop: "type",
          isShowColumn: true,
          default: true,
          conversion: true,
          getStatus: this.getTypesList
        }
      ]
      return tableColumn
    },
    getTypesList(val) {
      let string = "--"
      if (val) {
        for (let i in this.positionTypeList) {
          if (this.positionTypeList[i].id == val) {
            return this.positionTypeList[i].name
          }
        }
      }
      return string
    },
    selTableCol(val) {
      this.showcol = val
      this.tableList.tableColumn = this.setTableColumn(val)
    },
    // 请求数据
    async getData() {
      await getLocationList({
        type: this.type,
        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
        }
      })
    },
    refresh() {
      this.pagerOptions.currPage = 1
      this.getData()
    },
    // 搜索
    getList(val) {
      this.keyword = val
      this.pagerOptions.currPage = 1
      this.getData()
    },
    // 行点击
    tableRowClick(row, val) {
      this.editConfig.title = val == "look" ? "查看" : "编辑"
      this.editConfig.infomation = { ...row }
      this.editConfig.infomation.parentId = this.editConfig.infomation.parentId
        ? Number(this.editConfig.infomation.parentId)
        : null
      this.editConfig.visible = true
    },
    // 新建
    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 = "新建"
    },
    // 删除位置
    delSelectClick() {
      this.type = 0
      this.getData()
    }
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped></style>