|
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
11
|
cancelText="关闭"
>
|
|
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'
|
|
56
|
|
|
57
|
export default {
|
谭毅彬
authored
|
58
|
name: 'ReceiptDetailModal',
|
|
59
60
61
62
63
64
65
66
67
68
|
components: {},
props: {
mainId: {
type: String,
required: false,
default: ''
}
},
data() {
return {
|
谭毅彬
authored
|
69
|
title: '操作',
|
|
70
71
72
73
74
75
|
width: 800,
visible: false,
materialList: {},
querySource: {},
model: {},
labelCol: {
|
谭毅彬
authored
|
76
77
|
xs: { span: 24 },
sm: { span: 5 }
|
|
78
79
|
},
wrapperCol: {
|
谭毅彬
authored
|
80
81
|
xs: { span: 24 },
sm: { span: 16 }
|
|
82
83
84
|
},
confirmLoading: false,
validatorRules: {
|
谭毅彬
authored
|
85
86
87
|
materialCode: [{ required: true, message: '请输入物料编码!' }],
qty: [{ required: true, message: '请输入单据数量!' }],
inventoryStatus: [{ required: true, message: '请输入库存状态!' }]
|
|
88
89
|
},
url: {
|
谭毅彬
authored
|
90
91
|
add: '/receipt/receiptHeader/addReceiptDetail',
edit: '/receipt/receiptHeader/editReceiptDetail'
|
|
92
|
}
|
|
93
94
95
|
}
},
created() {
|
|
96
|
//备份model原始值
|
谭毅彬
authored
|
97
98
|
this.modelDefault = JSON.parse(JSON.stringify(this.model))
this.searchMaterial()
|
|
99
100
101
|
},
methods: {
add() {
|
谭毅彬
authored
|
102
103
|
let record = { inventoryStatus: 'good' }
this.edit(record)
|
|
104
|
},
|
|
105
|
edit(record) {
|
谭毅彬
authored
|
106
107
|
this.model = Object.assign({}, record)
this.visible = true
|
|
108
109
|
},
close() {
|
谭毅彬
authored
|
110
111
112
|
this.$emit('close')
this.visible = false
this.$refs.form.clearValidate()
|
|
113
114
|
},
searchMaterial() {
|
谭毅彬
authored
|
115
116
117
118
|
const that = this
that.querySource.materialCode = that.model.materialCode
searchMaterialByCode(that.querySource).then(res => {
that.materialList = res.result
|
|
119
120
121
|
})
},
handleOk() {
|
谭毅彬
authored
|
122
|
const that = this
|
|
123
124
125
|
// 触发表单验证
this.$refs.form.validate(valid => {
if (valid) {
|
谭毅彬
authored
|
126
127
128
|
that.confirmLoading = true
let httpurl = ''
let method = ''
|
|
129
|
if (!this.model.id) {
|
谭毅彬
authored
|
130
131
|
httpurl += this.url.add
method = 'post'
|
|
132
|
} else {
|
谭毅彬
authored
|
133
134
|
httpurl += this.url.edit
method = 'put'
|
|
135
|
}
|
|
136
|
this.model['receiptId'] = this.mainId
|
谭毅彬
authored
|
137
138
139
140
141
142
143
144
145
146
147
148
149
|
httpAction(httpurl, this.model, method)
.then(res => {
if (res.success) {
that.$message.success(res.message)
that.$emit('ok')
} else {
that.$message.warning(res.message)
}
})
.finally(() => {
that.confirmLoading = false
that.close()
})
|
|
150
151
152
153
154
155
156
|
} else {
return false
}
})
},
handleCancel() {
this.close()
|
谭毅彬
authored
|
157
|
}
|
|
158
|
}
|
|
159
|
}
|
|
160
|
</script>
|