Blame view

ant-design-vue-jeecg/src/views/system/inventory/InventoryDetailList.vue 9.26 KB
1
2
3
4
<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">
    <!-- 操作按钮区域 -->
    <div class="table-operator" v-if="mainId">
易文鹏 authored
5
      <a-button v-has="'inventoryDetail:add'" @click="handleAdd" type="primary" icon="plus">新增</a-button>
6
      <a-button v-has="'inventoryDetail:export'" type="primary" icon="download" @click="handleExportXls('库存详情')">导出</a-button>
7
      <a-upload
易文鹏 authored
8
        v-has="'inventoryDetail:import'"
9
10
11
12
13
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
14
15
        @change="handleImportExcel"
      >
肖超群 authored
16
        <a-button type="primary" icon="import">导入</a-button>
17
18
19
20
21
22
23
24
25
26
      </a-upload>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
27
        class="j-table-force-nowrap"
28
        :scroll="{ x: true }"
29
30
31
32
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
33
34
        @change="handleTableChange"
      >
易文鹏 authored
35
36
37
38
39
40
         <span slot="inventoryStatus_dictText" slot-scope="inventoryStatus_dictText">
          <a-tag :key="inventoryStatus_dictText" :color="getStatusColor(inventoryStatus_dictText)">
            {{ inventoryStatus_dictText }}
          </a-tag>
        </span>
肖超群 authored
41
42
43
44
45
46
        <span slot="containerStatus_dictText" slot-scope="containerStatus_dictText">
            <a-tag :key="containerStatus_dictText" :color="getStatusColor(containerStatus_dictText)">
              {{ containerStatus_dictText }}
            </a-tag>
        </span>
47
48
49
        <span slot="enable_dictText" slot-scope="enable_dictText">
          <a-tag :key="enable_dictText" :color="getStatusColor(enable_dictText)">
            {{ enable_dictText }}
肖超群 authored
50
51
52
53
          </a-tag>
        </span>
54
        <span slot="companyCode" slot-scope="companyCode">
55
          <a-tag :key="companyCode" color="blue">
56
57
58
59
            {{ solutionCompany(companyCode) }}
          </a-tag>
        </span>
60
61
62
63
64
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
65
66
67
68
69
70
71
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt=""
            style="max-width:80px;font-size: 12px;font-style: italic;"
          />
72
73
74
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
75
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
76
77
78
79
80
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
81
          <a v-has="'inventoryDetail:edit'" @click="handleEdit(record)">编辑<a-divider type="vertical"/></a>
82
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
肖超群 authored
83
            <a v-has="'inventoryDetail:delete'">删除</a>
84
85
86
87
88
89
90
91
92
93
          </a-popconfirm>
        </span>
      </a-table>
    </div>

    <inventoryDetail-modal ref="modalForm" @ok="modalFormOk" :mainId="mainId"></inventoryDetail-modal>
  </a-card>
</template>

<script>
易文鹏 authored
94
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
肖超群 authored
95
import InventoryDetailModal from './modules/InventoryDetailModal'
易文鹏 authored
96
import {getCompanyList, getZoneList} from '@/api/api'
97
肖超群 authored
98
export default {
99
  name: 'InventoryDetailList',
肖超群 authored
100
  mixins: [JeecgListMixin],
易文鹏 authored
101
  components: {InventoryDetailModal},
肖超群 authored
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
  props: {
    mainId: {
      type: String,
      default: '',
      required: false
    }
  },
  watch: {
    mainId: {
      immediate: true,
      handler(val) {
        if (!this.mainId) {
          this.clearList()
        } else {
          this.queryParam['inventoryHeaderId'] = val
117
          this.loadData(1)
118
119
        }
      }
肖超群 authored
120
121
122
123
124
125
126
127
128
129
130
    }
  },
  data() {
    return {
      description: '库存表管理页面',
      disableMixinCreated: true,
      companyList: [],
      // 表头
      columns: [
        {
          title: '库存详情ID',
131
          align: 'center',
132
          dataIndex: 'id',
133
134
          // fixed: "left",
          // width: 100,
肖超群 authored
135
136
137
        },
        {
          title: '货主',
138
          align: 'center',
肖超群 authored
139
140
          dataIndex: 'companyCode',
          key: 'companyCode',
易文鹏 authored
141
          scopedSlots: {customRender: 'companyCode'}
肖超群 authored
142
        },
易文鹏 authored
143
144
145
146
147
        // {
        //   title: '库区',
        //   align: "center",
        //   dataIndex: 'zoneCode'
        // },
肖超群 authored
148
149
        {
          title: '容器编码',
150
          align: 'center',
肖超群 authored
151
152
153
          dataIndex: 'containerCode'
        },
        {
154
155
156
157
158
159
          title: '容器状态',
          align: "center",
          dataIndex: 'containerStatus_dictText',
          scopedSlots: {customRender: 'containerStatus_dictText'}
        },
        {
肖超群 authored
160
          title: '库位编码',
161
          align: 'center',
肖超群 authored
162
163
164
165
          dataIndex: 'locationCode'
        },
        {
          title: '物料编码',
166
          align: 'center',
肖超群 authored
167
168
169
170
          dataIndex: 'materialCode'
        },
        {
          title: '物料名称',
171
          align: 'center',
肖超群 authored
172
173
174
175
          dataIndex: 'materialName'
        },
        {
          title: '物料规格',
176
          align: 'center',
肖超群 authored
177
178
179
180
          dataIndex: 'materialSpec'
        },
        {
          title: '物料单位',
181
          align: 'center',
肖超群 authored
182
183
184
185
          dataIndex: 'materialUnit'
        },
        {
          title: '数量',
186
          align: 'center',
肖超群 authored
187
188
189
190
          dataIndex: 'qty'
        },
        {
          title: '任务锁定数量',
191
          align: 'center',
肖超群 authored
192
193
194
          dataIndex: 'taskQty'
        },
        {
195
196
197
198
199
200
201
202
          title: '托盘填充度',
          align: 'center',
          dataIndex: 'fillDensity',
          customRender: text => {
            return text == null ? '' : text + '%'
          }
        },
        {
肖超群 authored
203
          title: '库存状态',
204
          align: 'center',
易文鹏 authored
205
206
          dataIndex: 'inventoryStatus_dictText',
          scopedSlots: {customRender: 'inventoryStatus_dictText'}
肖超群 authored
207
208
        },
        {
209
          title: '可用状态',
肖超群 authored
210
          align: 'center',
211
212
          dataIndex: 'enable_dictText',
          scopedSlots: {customRender: 'enable_dictText'}
肖超群 authored
213
214
        },
        {
肖超群 authored
215
          title: '批次',
216
          align: 'center',
肖超群 authored
217
218
          dataIndex: 'batch'
        },
肖超群 authored
219
220
221
222
223
        {
          title: '序列号',
          align: "center",
          dataIndex: 'sn'
        },
肖超群 authored
224
225
        {
          title: '入库日期',
226
          align: 'center',
肖超群 authored
227
228
229
230
          dataIndex: 'receiptDate'
        },
        {
          title: '库龄(天)',
231
          align: 'center',
肖超群 authored
232
233
234
235
          dataIndex: 'inventoryAge'
        },
        {
          title: '创建人',
236
          align: 'center',
肖超群 authored
237
238
239
240
          dataIndex: 'createBy'
        },
        {
          title: '创建日期',
241
          align: 'center',
肖超群 authored
242
243
244
245
          dataIndex: 'createTime'
        },
        {
          title: '更新人',
246
          align: 'center',
肖超群 authored
247
248
249
250
          dataIndex: 'updateBy'
        },
        {
          title: '更新日期',
251
          align: 'center',
肖超群 authored
252
253
          dataIndex: 'updateTime'
        },
254
255
256
257
258
259
260
261
        // {
        //   title: '操作',
        //   dataIndex: 'action',
        //   align: 'center',
        //   fixed: 'right',
        //   width: 147,
        //   scopedSlots: {customRender: 'action'}
        // }
肖超群 authored
262
263
      ],
      url: {
264
265
266
267
268
        list: '/inventory/inventoryHeader/listInventoryDetailByMainId',
        delete: '/inventory/inventoryHeader/deleteInventoryDetail',
        deleteBatch: '/inventory/inventoryHeader/deleteBatchInventoryDetail',
        exportXlsUrl: '/inventory/inventoryHeader/exportInventoryDetail',
        importUrl: '/inventory/inventoryHeader/importInventoryDetail'
肖超群 authored
269
270
      },
      dictOptions: {
271
        containerStatus: []
272
      }
肖超群 authored
273
274
275
    }
  },
  created() {
276
    this.loadFrom()
肖超群 authored
277
278
279
  },
  computed: {
    importExcelUrl() {
280
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`
肖超群 authored
281
282
283
    }
  },
  methods: {
易文鹏 authored
284
285
286
287
288
289
    getStatusColor(status) {
      const colors = {
        '良品': 'green',
        '报废品': 'purple',
        '待确认	': 'grey',
        '次品': 'red',
谭毅彬 authored
290
        '锁定': 'red',
肖超群 authored
291
        "冻结": "red",
292
        default: 'blue'
易文鹏 authored
293
294
295
      };
      return colors[status] || colors.default;
    },
肖超群 authored
296
    loadFrom() {
易文鹏 authored
297
298
299
300
301
      // getZoneList().then((res) => {
      //   if (res.success) {
      //     this.zoneList = res.result
      //   }
      // });
302
      getCompanyList().then(res => {
肖超群 authored
303
304
305
        if (res.success) {
          this.companyList = res.result
        }
306
      })
307
    },
易文鹏 authored
308
309
310
311
312
313
314
315
316
317
    // solutionZoneCode(value) {
    //   var actions = []
    //   Object.keys(this.zoneList).some((key) => {
    //     if (this.zoneList[key].code == ('' + value)) {
    //       actions.push(this.zoneList[key].name)
    //       return true
    //     }
    //   })
    //   return actions.join('')
    // },
肖超群 authored
318
319
    solutionCompany(value) {
      var actions = []
320
321
      Object.keys(this.companyList).some(key => {
        if (this.companyList[key].code == '' + value) {
肖超群 authored
322
323
324
325
326
          actions.push(this.companyList[key].name)
          return true
        }
      })
      return actions.join('')
327
    },
肖超群 authored
328
329
330
331
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
332
333
    }
  }
肖超群 authored
334
}
335
336
</script>
<style scoped>
337
@import '~@assets/less/common.less';
338
</style>