TblDepotOutForm.vue
8.8 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<template>
<a-spin :spinning="confirmLoading">
<j-form-container :disabled="formDisabled">
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
<a-row>
<a-col :span="24">
<a-form-model-item label="领料人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ling">
<a-input v-model="model.ling" placeholder="请输入领料人"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="领料环节" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lingSysOrgCode">
<a-input v-model="model.lingSysOrgCode" placeholder="请输入领料环节"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partNumber">
<a-input v-model="model.partNumber" placeholder="请输入编号" @blur="autoInput" @keyup.enter.native="autoInput"
@input="inputMathen">
</a-input>
<div class="select" v-if="isShow" :style="`height:${menuHeight}`" @mouseenter="flag = true"
@mouseleave="flag = false">
<div v-for="(version, index) in versionList" :key="index" @click.stop="onClickOut(version)">
{{ version }}
</div>
</div>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="品名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productName">
<a-input v-model="model.productName" placeholder="请输入品名" disabled></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="规格" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spec">
<a-input v-model="model.spec" placeholder="请输入规格" disabled></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="型号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="type">
<a-input v-model="model.type" placeholder="请输入型号" disabled></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="采购性质" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="buyingClassify">
<j-dict-select-tag type="radio" v-model="model.buyingClassify" dictCode="buying_classify"
placeholder="请选择采购性质" disabled />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operNumber">
<a-input-number v-model="model.operNumber" :min="0" :max="9999" :precision="0" :formatter="limitNumber"
:parser="limitNumber" placeholder="请输入数量" style="width: 100%" />
</a-form-model-item>
</a-col>
<a-col :span="24" > <!-- v-if="workOrderFlg" -->
<a-form-model-item label="工作令" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="workOrder">
<a-input v-model="model.workOrder" placeholder="请输入工作令"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="出库时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operTime">
<j-date placeholder="请选择出库时间" v-model="model.operTime" style="width: 100%" />
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
</j-form-container>
</a-spin>
</template>
<script>
import { httpAction, getAction, getPartNumber } from '@/api/manage'
import { validateDuplicateValue, formatDate } from '@/utils/util'
export default {
name: 'TblDepotOutForm',
components: {},
props: {
//表单禁用
disabled: {
type: Boolean,
default: false,
required: false,
},
},
data() {
return {
versionList: [],
isShow: false,
flag: false,
model: {
operTime: formatDate(new Date().getTime(), 'yyyy-MM-dd'),
},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
validatorRules: {
partNumber: [{ required: true, message: '请输入零件编号!' }],
productName: [{ required: true, message: '请输入品名!' }],
spec: [{ required: true, message: '请输入规格!' }],
type: [{ required: true, message: '请输入型号!' }],
buyingClassify: [{ required: true, message: '请输入采购性质!' }],
operNumber: [{ required: true, message: '请输入数量!' }],
workOrder: [{ required: true, message: '请输入工作令!' }],
ling:[{ required: true, message: '请输入领料人!' }],
lingSysOrgCode:[{ required: true, message: '请输入领料环节!' }],
},
url: {
add: '/depot/tblDepot/add',
edit: '/depot/tblDepot/edit',
queryById: '/depot/tblDepot/queryById',
queryMaterial: '/depot/tblDepot/queryMaterialByPartNum',
queryPartNumber: '/depot/tblDepot/queryPartNumber'
},
// workOrderFlg: false
}
},
computed: {
formDisabled() {
return this.disabled
},
// 下拉框的高度
menuHeight() {
return this.versionList.length * 50 > 150
? 150 + 'px'
: `${this.versionList.length * 50}px`
},
},
created() {
//备份model原始值
this.modelDefault = JSON.parse(JSON.stringify(this.model))
},
methods: {
onClickOut(val) {
this.model.partNumber = val
this.$emit('partNumber', this.model.partNumber)
this.isShow = false
this.flag = false
this.autoInput();
},
onChange() {
this.$emit('partNumber', this.model.partNumber)
this.isShow = false
},
onBlur() {
this.isShow = this.flag
},
limitNumber(value) {
if (typeof value === 'string') {
return !isNaN(Number(value)) ? value.replace(/\./g, '') : 0
} else if (typeof value === 'number') {
return !isNaN(value) ? String(value).replace(/\./g, '') : 0
} else {
return 0
}
},
add() {
this.edit(this.modelDefault)
},
edit(record) {
this.model = Object.assign({}, record)
this.visible = true
},
submitForm() {
const that = this
// 触发表单验证
this.$refs.form.validate((valid) => {
if (valid) {
that.confirmLoading = true
let httpurl = ''
let method = ''
if (!this.model.id) {
httpurl += this.url.add
method = 'post'
} else {
httpurl += this.url.edit
method = 'put'
}
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
})
}
})
},
async autoInput() {
if (this.isShow) {
// this.isShow = false
return
}
this.confirmLoading = true
const param = { partNum: this.model.partNumber }
let res = await getAction(this.url.queryMaterial, param)
console.log(res)
if (!res.result) {
this.$message.error('编号有误,请重新输入或扫码!')
this.model.productName = ''
this.model.spec = ''
this.model.type = ''
this.model.buyingClassify = ''
this.confirmLoading = false
this.isShow = false;
return
}
// if (res.result.meterialType === '1') {
// this.workOrderFlg = true;
// } else {
// this.workOrderFlg = false;
// }
this.model.productName = res.result.productName
this.model.spec = res.result.spec
this.model.type = res.result.type
this.model.buyingClassify = res.result.buyingClassify
this.model.depotType = '出库'
this.confirmLoading = false
this.isShow = false;
this.$nextTick(() => { })
},
async inputMathen() {
const param = { partNum: this.model.partNumber }
let res = await getPartNumber(this.url.queryPartNumber, param)
this.versionList = res.result;
this.isShow = true;
}
},
}
</script>
<style >
.select {
width: 100%;
position: absolute;
background: #fff;
z-index: 99999;
overflow: auto;
left: 0px;
cursor: pointer;
border: 1px solid #ccc;
padding: 0 10px;
}
</style>