MaterialReceiptModal.vue
5.08 KB
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
<template>
<j-modal
:title="title"
:width="1800"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭"
>
<div style="padding: 10px 16px; text-align: left;">
<a-button type="primary" @click="addCommonInput" icon="plus">
添加
</a-button>
</div>
<a-spin :spinning="confirmLoading">
<a-form-model ref="form" :model="model">
<a-row :gutter="24">
<a-col :span="4" v-for="(item, index) in fromPortList" :key="index">
<div style="font-weight:bold; font-size:15px; margin-bottom:16px; text-align:center;">
{{ item.label }}
</div>
<a-row :gutter="8" style="margin-bottom: 12px;">
<a-col :span="8" style="line-height: 32px; text-align: right; padding-right: 8px;">
物料编码
</a-col>
<a-col :span="16">
<j-search-select-tag
v-model="model.list[index].materialCode"
:dictOptions="model.list[index].materialList"
placeholder="请选择物料编码"
@search="(val) => searchMaterial(val, index)"
/>
</a-col>
</a-row>
<a-row
v-for="(boxNo, boxIdx) in model.list[index].boxCount"
:key="boxIdx"
:gutter="8"
style="margin-bottom: 12px;"
>
<a-col :span="8" style="line-height: 32px; text-align: right; padding-right: 8px;">
第{{ boxNo }}箱
</a-col>
<a-col :span="16">
<a-input v-model="model.list[index].boxList[boxIdx]" style="width: 100%;" />
</a-col>
</a-row>
<!-- <a-row v-for="n in 8" :key="`fixed-${n}`" :gutter="8" style="margin-bottom: 12px;">
<a-col :span="8" style="line-height: 32px; text-align: right; padding-right: 8px;">
第{{ n }}箱
</a-col>
<a-col :span="16">
<a-input v-model="model.list[index][`input${n}`]" style="width: 100%;" />
</a-col>
</a-row>
<a-row v-for="(inputKey, inputIdx) in dynamicInputKeys" :key="`dynamic-${inputIdx}`" :gutter="8" style="margin-bottom: 12px;">
<a-col :span="8" style="line-height: 32px; text-align: right; padding-right: 8px;">
第{{ 8 + inputIdx + 1 }}箱
</a-col>
<a-col :span="16">
<a-input v-model="model.list[index][inputKey]" style="width: 100%;" />
</a-col>
</a-row>-->
</a-col>
</a-row>
</a-form-model>
</a-spin>
</j-modal>
</template>
<script>
import {materialReceipt, searchMaterialByCode} from '@/api/api'
export default {
name: 'MaterialReceiptModal',
data() {
return {
title: '辅料入库',
width: 1600,
visible: false,
confirmLoading: false,
fromPortList: [
{ label: '站台一(P31041)', code: 'P31041' },
{ label: '站台二(P31042)', code: 'P31042' },
{ label: '站台三(P31043)', code: 'P31043' },
{ label: '站台四(P31044)', code: 'P31044' },
{ label: '站台五(P31045)', code: 'P31045' },
],
model: { list: [] },
dynamicInputKeys: [],
dynamicIndex: 1,
}
},
created() {
this.initForm()
},
methods: {
searchMaterial(val) {
try {
searchMaterialByCode({ code: val }).then(res => {
const list = res.result.filter(x => x.value === '000006' || x.value === '000002')
this.model.list.forEach((item, i) => {
this.model.list[i].materialList = list
})
})
} catch (err) {
this.model.list.forEach((item, i) => {
this.model.list[i].materialList = []
})
}
},
initForm() {
this.model.list = this.fromPortList.map(() => ({
materialCode: null,
materialList: [],
boxCount: 8,
boxList: ['', '', '', '', '', '', '', ''],
}))
this.searchMaterial()
},
addCommonInput() {
this.model.list.forEach(item => {
item.boxCount += 1
item.boxList.push('')
})
},
edit() {
this.initForm()
this.visible = true
},
close() {
this.$emit('close')
this.visible = false
this.$refs.form && this.$refs.form.clearValidate()
},
handleOk() {
this.confirmLoading = true
const params = this.model.list.map((item, index) => ({
fromPortCode: this.fromPortList[index].code,
materialCode: item.materialCode,
batchList: item.boxList.filter(i => i),
}))
materialReceipt(params).then(res => {
if (res.success) {
this.$message.success('提交成功')
this.$emit('ok')
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.confirmLoading = false
this.close()
})
},
handleCancel() {
this.close()
},
},
}
</script>