|
1
2
3
4
5
6
7
8
9
|
<template>
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
|
谭毅彬
authored
|
10
|
:cancelText="$t('button.close')"
|
谭毅彬
authored
|
11
|
>
|
|
12
13
14
|
<a-spin :spinning="confirmLoading">
<a-form-model ref="form" :model="model" :rules="validatorRules">
<a-row>
|
谭毅彬
authored
|
15
16
17
18
19
20
21
22
23
24
25
|
<a-col :span="24">
<a-form-model-item label="物料" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialCode">
<j-search-select-tag
v-model="model.materialCode"
dict="material,name,code"
placeholder="请选择物料编码"
:pageSize="10"
:async="true"
/>
</a-form-model-item>
</a-col>
|
|
26
27
|
<a-col :span="24">
<a-form-model-item label="单据数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qty">
|
谭毅彬
authored
|
28
|
<a-input-number v-model="model.qty" placeholder="请输入单据数量" style="width: 100%" />
|
|
29
30
31
32
|
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="库存状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inventoryStatus">
|
谭毅彬
authored
|
33
34
35
36
37
38
|
<j-dict-select-tag
type="list"
v-model="model.inventoryStatus"
dictCode="inventory_status"
placeholder="请选择库存状态"
/>
|
|
39
40
41
42
|
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="批次" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="batch">
|
|
43
|
<a-input v-model="model.batch" placeholder="请输入批次"></a-input>
|
|
44
45
46
47
48
49
50
51
52
|
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
</a-spin>
</j-modal>
</template>
<script>
|
谭毅彬
authored
|
53
54
55
|
import { httpAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
import { searchMaterialByCode } from '@/api/api'
|
谭毅彬
authored
|
56
|
import { translateResultMessage } from '@/api/api'
|
|
57
|
|
|
58
|
export default {
|
谭毅彬
authored
|
59
|
name: 'ReceiptDetailModal',
|
|
60
61
62
63
64
65
66
67
68
69
|
components: {},
props: {
mainId: {
type: String,
required: false,
default: ''
}
},
data() {
return {
|
谭毅彬
authored
|
70
|
title: this.$t('system.options'),
|
|
71
72
73
74
75
76
|
width: 800,
visible: false,
materialList: {},
querySource: {},
model: {},
labelCol: {
|
谭毅彬
authored
|
77
78
|
xs: { span: 24 },
sm: { span: 5 }
|
|
79
80
|
},
wrapperCol: {
|
谭毅彬
authored
|
81
82
|
xs: { span: 24 },
sm: { span: 16 }
|
|
83
84
85
|
},
confirmLoading: false,
validatorRules: {
|
谭毅彬
authored
|
86
87
88
|
materialCode: [{ required: true, message: '请输入物料编码!' }],
qty: [{ required: true, message: '请输入单据数量!' }],
inventoryStatus: [{ required: true, message: '请输入库存状态!' }]
|
|
89
90
|
},
url: {
|
谭毅彬
authored
|
91
92
|
add: '/receipt/receiptHeader/addReceiptDetail',
edit: '/receipt/receiptHeader/editReceiptDetail'
|
|
93
|
}
|
|
94
95
96
|
}
},
created() {
|
|
97
|
//备份model原始值
|
谭毅彬
authored
|
98
99
|
this.modelDefault = JSON.parse(JSON.stringify(this.model))
this.searchMaterial()
|
|
100
101
102
|
},
methods: {
add() {
|
谭毅彬
authored
|
103
104
|
let record = { inventoryStatus: 'good' }
this.edit(record)
|
|
105
|
},
|
|
106
|
edit(record) {
|
谭毅彬
authored
|
107
108
|
this.model = Object.assign({}, record)
this.visible = true
|
|
109
110
|
},
close() {
|
谭毅彬
authored
|
111
112
113
|
this.$emit('close')
this.visible = false
this.$refs.form.clearValidate()
|
|
114
115
|
},
searchMaterial() {
|
谭毅彬
authored
|
116
117
118
119
|
const that = this
that.querySource.materialCode = that.model.materialCode
searchMaterialByCode(that.querySource).then(res => {
that.materialList = res.result
|
|
120
121
122
|
})
},
handleOk() {
|
谭毅彬
authored
|
123
|
const that = this
|
|
124
125
126
|
// 触发表单验证
this.$refs.form.validate(valid => {
if (valid) {
|
谭毅彬
authored
|
127
128
129
|
that.confirmLoading = true
let httpurl = ''
let method = ''
|
|
130
|
if (!this.model.id) {
|
谭毅彬
authored
|
131
132
|
httpurl += this.url.add
method = 'post'
|
|
133
|
} else {
|
谭毅彬
authored
|
134
135
|
httpurl += this.url.edit
method = 'put'
|
|
136
|
}
|
|
137
|
this.model['receiptId'] = this.mainId
|
谭毅彬
authored
|
138
139
140
|
httpAction(httpurl, this.model, method)
.then(res => {
if (res.success) {
|
谭毅彬
authored
|
141
|
that.$message.success(translateResultMessage(res, res.message))
|
谭毅彬
authored
|
142
143
|
that.$emit('ok')
} else {
|
谭毅彬
authored
|
144
|
that.$message.warning(translateResultMessage(res, res.message))
|
谭毅彬
authored
|
145
146
147
148
149
150
|
}
})
.finally(() => {
that.confirmLoading = false
that.close()
})
|
|
151
152
153
154
155
156
157
|
} else {
return false
}
})
},
handleCancel() {
this.close()
|
谭毅彬
authored
|
158
|
}
|
|
159
|
}
|
|
160
|
}
|
|
161
|
</script>
|