Blame view

ant-design-vue-jeecg/src/views/system/inventory/subTables/InventoryDetailSubTable.vue 6.65 KB
李泰瑜 authored
1
2
3
4
5
6
7
8
9
10
<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">
    <!-- 操作按钮区域 -->
    <div class="table-operator" v-if="mainId">
      <a-button v-has="'inventoryDetail:add'" @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('库存详情')">导出</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
11
     <a-table
李泰瑜 authored
12
13
14
15
16
17
18
19
20
21
22
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
易文鹏 authored
23
24
25
26
27
28
        <span slot="inventoryStatus_dictText" slot-scope="inventoryStatus_dictText">
          <a-tag :key="inventoryStatus_dictText" :color="getStatusColor(inventoryStatus_dictText)">
            {{ inventoryStatus_dictText }}
          </a-tag>
        </span>
李泰瑜 authored
29
        <span slot="companyCode" slot-scope="companyCode">
30
31
          <a-tag :key="companyCode" color="blue">
李泰瑜 authored
32
33
34
35
            {{ solutionCompany(companyCode) }}
          </a-tag>
        </span>
36
37
38
39
40
        <span slot="zoneCode" slot-scope="zoneCode">
          <a-tag :key="zoneCode" color="blue">
            {{ solutionZoneCode(zoneCode) }}
          </a-tag>
        </span>
李泰瑜 authored
41
42
43
44
45
46
47
48
49
      </a-table>
    </div>

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

<script>
50
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
李泰瑜 authored
51
import InventoryDetailModal from '../modules/InventoryDetailModal'
52
53
import { getCompanyList, getZoneList } from '@/api/api'
李泰瑜 authored
54
55

export default {
56
57
  name: 'InventoryDetailSubTable',
李泰瑜 authored
58
  mixins: [JeecgListMixin],
59
60
  components: { InventoryDetailModal },
李泰瑜 authored
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  props: {
    mainId: {
      type: String,
      default: '',
      required: false
    }
  },
  watch: {
    mainId: {
      immediate: true,
      handler(val) {
        if (!this.mainId) {
          this.clearList()
        } else {
75
76
77
78
          this.queryParam['zoneCode'] = val.split("_")[0];
          this.queryParam['materialCode'] = val.split("_")[1];
          this.loadData(1)
李泰瑜 authored
79
80
81
82
83
84
        }
      }
    }
  },
  data() {
    return {
85
86
      description: '库存物料汇总详情页面',
李泰瑜 authored
87
88
      disableMixinCreated: true,
      companyList: [],
89
      zoneList: [],
李泰瑜 authored
90
91
92
93
      // 表头
      columns: [
        {
          title: '库存详情ID',
94
          align: 'center',
95
96
          dataIndex: 'id',
          fixed: 'left',
97
          width: 100,
李泰瑜 authored
98
99
100
        },
        {
          title: '货主',
101
102
          align: 'center',
李泰瑜 authored
103
104
          dataIndex: 'companyCode',
          key: 'companyCode',
105
106
          scopedSlots: { customRender: 'companyCode' }
李泰瑜 authored
107
108
109
        },
        {
          title: '库区',
110
111
112
113
114
          align: 'center',
          dataIndex: 'zoneCode',
          key: 'zoneCode',
          scopedSlots: { customRender: 'zoneCode' }
李泰瑜 authored
115
116
        },
        {
117
118
119
          title: '库位编码',
          align: 'center',
          dataIndex: 'locationCode'
李泰瑜 authored
120
121
        },
        {
122
          title: '容器编码',
李泰瑜 authored
123
          align: "center",
124
          dataIndex: 'containerCode'
李泰瑜 authored
125
126
        },
        {
127
128
129
130
131
          title: '序列号',
          align: 'center',
          dataIndex: 'sn'
        },
        {
李泰瑜 authored
132
          title: '物料编码',
133
          align: 'center',
李泰瑜 authored
134
135
136
137
          dataIndex: 'materialCode'
        },
        {
          title: '物料名称',
138
          align: 'center',
李泰瑜 authored
139
140
141
142
          dataIndex: 'materialName'
        },
        {
          title: '物料单位',
143
          align: 'center',
李泰瑜 authored
144
145
146
147
          dataIndex: 'materialUnit'
        },
        {
          title: '数量',
148
          align: 'center',
李泰瑜 authored
149
150
151
152
          dataIndex: 'qty'
        },
        {
          title: '任务锁定数量',
153
          align: 'center',
李泰瑜 authored
154
155
156
157
          dataIndex: 'taskQty'
        },
        {
          title: '库存状态',
158
          align: 'center',
李泰瑜 authored
159
          dataIndex: 'inventoryStatus_dictText',
易文鹏 authored
160
          scopedSlots: {customRender: 'inventoryStatus_dictText'}
李泰瑜 authored
161
162
        },
        {
163
164
165
166
167
          title: '容器状态',
          align: 'center',
          dataIndex: 'containerStatus_dictText'
        },
        {
李泰瑜 authored
168
169
170
171
172
173
174
175
176
177
178
          title: '批次',
          align: "center",
          dataIndex: 'batch'
        },
        {
          title: '入库日期',
          align: "center",
          dataIndex: 'receiptDate'
        },
        {
          title: '库龄(天)',
179
          align: 'center',
李泰瑜 authored
180
181
182
183
          dataIndex: 'inventoryAge'
        },
        {
          title: '创建人',
184
          align: 'center',
李泰瑜 authored
185
186
187
188
          dataIndex: 'createBy'
        },
        {
          title: '创建日期',
189
          align: 'center',
李泰瑜 authored
190
191
192
193
          dataIndex: 'createTime'
        },
        {
          title: '更新人',
194
          align: 'center',
李泰瑜 authored
195
196
197
198
          dataIndex: 'updateBy'
        },
        {
          title: '更新日期',
199
200
          align: 'center',
          dataIndex: 'updateTime'
201
        }
李泰瑜 authored
202
203
      ],
      url: {
204
205
206
        list: '/InventoryMaterialSummary/inventoryMaterialSummary/inventoryMaterialSummaryChild',
        exportXlsUrl: '/InventoryMaterialSummary/inventoryMaterialSummary/exportXls',
        importExcelUrl: 'InventoryMaterialSummary/inventoryMaterialSummary/importExcel'
李泰瑜 authored
207
208
      },
      dictOptions: {
209
        containerStatus: []
李泰瑜 authored
210
211
212
213
214
215
216
217
      }
    }
  },
  created() {
    this.loadFrom();
  },
  computed: {
    importExcelUrl() {
218
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`
李泰瑜 authored
219
220
221
    }
  },
  methods: {
易文鹏 authored
222
223
224
225
226
227
    getStatusColor(status) {
      const colors = {
        '良品': 'green',
        '报废品': 'purple',
        '待确认	': 'grey',
        '次品': 'red',
228
        default: 'blue'
易文鹏 authored
229
230
231
      };
      return colors[status] || colors.default;
    },
李泰瑜 authored
232
    loadFrom() {
233
234
      getCompanyList().then(res => {
李泰瑜 authored
235
236
237
        if (res.success) {
          this.companyList = res.result
        }
238
239
240
241
242
243
      })
      getZoneList().then(res => {
        if (res.success) {
          this.zoneList = res.result
        }
      })
李泰瑜 authored
244
245
    },
    solutionCompany(value) {
246
247
248
249
      let actions = []
      Object.keys(this.companyList).some(key => {
        if (this.companyList[key].code === '' + value) {
李泰瑜 authored
250
251
252
253
254
255
          actions.push(this.companyList[key].name)
          return true
        }
      })
      return actions.join('')
    },
256
257
258
259
260
261
262
263
264
265
    solutionZoneCode(value) {
      let 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
266
267
268
269
270
271
272
273
274
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    }
  }
}
</script>
<style scoped>
275
@import '~@assets/less/common.less';
李泰瑜 authored
276
</style>