Blame view

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

    <!-- table区域-begin -->
    <div>
11
     <a-table
李泰瑜 authored
12
13
14
15
        ref="table"
        size="middle"
        bordered
        rowKey="id"
16
        class="j-table-force-nowrap"
李泰瑜 authored
17
18
19
20
21
22
23
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
易文鹏 authored
24
25
26
27
28
29
        <span slot="inventoryStatus_dictText" slot-scope="inventoryStatus_dictText">
          <a-tag :key="inventoryStatus_dictText" :color="getStatusColor(inventoryStatus_dictText)">
            {{ inventoryStatus_dictText }}
          </a-tag>
        </span>
李泰瑜 authored
30
        <span slot="companyCode" slot-scope="companyCode">
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
          this.queryParam['zoneCode'] = val.split("_")[0];
          this.queryParam['materialCode'] = val.split("_")[1];
          this.loadData(1)
李泰瑜 authored
78
79
80
81
82
83
        }
      }
    }
  },
  data() {
    return {
84
85
      description: '库存物料汇总详情页面',
李泰瑜 authored
86
87
      disableMixinCreated: true,
      companyList: [],
88
      zoneList: [],
李泰瑜 authored
89
90
91
      // 表头
      columns: [
        {
周峰 authored
92
          title: this.$t('inventory.inventoryDetailId'),
93
          align: 'center',
94
          dataIndex: 'id',
95
96
          // fixed: 'left',
          // width: 100,
李泰瑜 authored
97
98
        },
        {
周峰 authored
99
          title: this.$t('inventory.companyName'),
100
101
          align: 'center',
李泰瑜 authored
102
103
          dataIndex: 'companyCode',
          key: 'companyCode',
104
105
          scopedSlots: { customRender: 'companyCode' }
李泰瑜 authored
106
107
        },
        {
周峰 authored
108
          title: this.$t('inventory.zone'),
109
110
111
112
113
          align: 'center',
          dataIndex: 'zoneCode',
          key: 'zoneCode',
          scopedSlots: { customRender: 'zoneCode' }
李泰瑜 authored
114
115
        },
        {
周峰 authored
116
          title: this.$t('inventory.locationCode'),
117
118
          align: 'center',
          dataIndex: 'locationCode'
李泰瑜 authored
119
120
        },
        {
周峰 authored
121
          title: this.$t('inventory.containerCode'),
李泰瑜 authored
122
          align: "center",
123
          dataIndex: 'containerCode'
李泰瑜 authored
124
125
        },
        {
周峰 authored
126
          title: this.$t('inventory.serialNumber'),
127
128
129
130
          align: 'center',
          dataIndex: 'sn'
        },
        {
周峰 authored
131
          title: this.$t('inventory.materialCode'),
132
          align: 'center',
李泰瑜 authored
133
134
135
          dataIndex: 'materialCode'
        },
        {
周峰 authored
136
          title: this.$t('inventory.materialName'),
137
          align: 'center',
李泰瑜 authored
138
139
140
          dataIndex: 'materialName'
        },
        {
周峰 authored
141
          title: this.$t('inventory.materialUnit'),
142
          align: 'center',
李泰瑜 authored
143
144
145
          dataIndex: 'materialUnit'
        },
        {
周峰 authored
146
          title: this.$t('inventory.qty'),
147
          align: 'center',
李泰瑜 authored
148
149
150
          dataIndex: 'qty'
        },
        {
周峰 authored
151
          title: this.$t('inventory.taskLockQty'),
152
          align: 'center',
李泰瑜 authored
153
154
155
          dataIndex: 'taskQty'
        },
        {
周峰 authored
156
          title: this.$t('inventory.inventoryStatus'),
157
          align: 'center',
李泰瑜 authored
158
          dataIndex: 'inventoryStatus_dictText',
易文鹏 authored
159
          scopedSlots: {customRender: 'inventoryStatus_dictText'}
李泰瑜 authored
160
161
        },
        {
周峰 authored
162
          title: this.$t('inventory.containerStatus'),
163
164
165
166
          align: 'center',
          dataIndex: 'containerStatus_dictText'
        },
        {
周峰 authored
167
          title: this.$t('inventory.batch'),
李泰瑜 authored
168
169
170
171
          align: "center",
          dataIndex: 'batch'
        },
        {
周峰 authored
172
          title: this.$t('inventory.inboundDate'),
李泰瑜 authored
173
174
175
176
          align: "center",
          dataIndex: 'receiptDate'
        },
        {
周峰 authored
177
          title: this.$t('inventory.inventoryAge'),
178
          align: 'center',
李泰瑜 authored
179
180
181
          dataIndex: 'inventoryAge'
        },
        {
182
          title: this.$t('system.createBy'),
183
          align: 'center',
李泰瑜 authored
184
185
186
          dataIndex: 'createBy'
        },
        {
187
          title: this.$t('system.createTime'),
188
          align: 'center',
李泰瑜 authored
189
190
191
          dataIndex: 'createTime'
        },
        {
192
          title: this.$t('system.updater'),
193
          align: 'center',
李泰瑜 authored
194
195
196
          dataIndex: 'updateBy'
        },
        {
197
          title: this.$t('system.updateTime'),
198
199
          align: 'center',
          dataIndex: 'updateTime'
200
        }
李泰瑜 authored
201
202
      ],
      url: {
203
204
205
        list: '/InventoryMaterialSummary/inventoryMaterialSummary/inventoryMaterialSummaryChild',
        exportXlsUrl: '/InventoryMaterialSummary/inventoryMaterialSummary/exportXls',
        importExcelUrl: 'InventoryMaterialSummary/inventoryMaterialSummary/importExcel'
李泰瑜 authored
206
207
      },
      dictOptions: {
208
        containerStatus: []
李泰瑜 authored
209
210
211
212
213
214
215
216
      }
    }
  },
  created() {
    this.loadFrom();
  },
  computed: {
    importExcelUrl() {
217
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`
李泰瑜 authored
218
219
220
    }
  },
  methods: {
易文鹏 authored
221
222
223
224
225
226
    getStatusColor(status) {
      const colors = {
        '良品': 'green',
        '报废品': 'purple',
        '待确认	': 'grey',
        '次品': 'red',
227
        default: 'blue'
易文鹏 authored
228
229
230
      };
      return colors[status] || colors.default;
    },
李泰瑜 authored
231
    loadFrom() {
232
233
      getCompanyList().then(res => {
李泰瑜 authored
234
235
236
        if (res.success) {
          this.companyList = res.result
        }
237
238
239
240
241
242
      })
      getZoneList().then(res => {
        if (res.success) {
          this.zoneList = res.result
        }
      })
李泰瑜 authored
243
244
    },
    solutionCompany(value) {
245
246
247
248
      let actions = []
      Object.keys(this.companyList).some(key => {
        if (this.companyList[key].code === '' + value) {
李泰瑜 authored
249
250
251
252
253
254
          actions.push(this.companyList[key].name)
          return true
        }
      })
      return actions.join('')
    },
255
256
257
258
259
260
261
262
263
264
    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
265
266
267
268
269
270
271
272
273
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    }
  }
}
</script>
<style scoped>
274
@import '~@assets/less/common.less';
李泰瑜 authored
275
</style>