TblDepotInForm.vue
12.0 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<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="storageLocation">
<a-input v-model="model.storageLocation" 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="onClick(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="measurementUnit">
<a-input v-model="model.measurementUnit" placeholder="请输入单位" disabled></a-input>
</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">
<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-col :span="24">
<a-form-model-item label="到货厂家" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="supplierName">
<a-input v-model="model.supplierName" placeholder="请输入到货厂家"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="合格证" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
<!-- <a-input v-model="model.certificate" placeholder="请输入合格证"></a-input> -->
<j-upload v-model="model.certificate" ></j-upload>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
<a-input v-model="model.remark" placeholder="请输入备注"></a-input>
</a-form-model-item>
</a-col>
<!-- <a-col :span="24">
<a-form-model-item label="选择机器人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="robotName">
<a-select size="small" v-model="model.robotName" placeholder="请选择机器人" allowClear>
<a-select-option v-for="(item,index) in robotOptions" :key="index" :value="item.id">{{ item.value }}</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="选择目标点位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pointId">
<a-select size="small" v-model="model.pointId" placeholder="请选择目标点位" allowClear>
<a-select-option v-for="(item,index) in pointOptions" :key="index" :value="item.pointId">{{ item.pointName }}</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="选择机器人任务流" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="templateId">
<a-select size="small" v-model="model.templateId" placeholder="请选择机器人任务流" allowClear style="width: 100%">
<a-select-option v-for="(item,index) in templateIdOptions" :key="index" :value="item.id">{{ item.value }}</a-select-option>
</a-select>
</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'
import {getRobotPoints} from '@/api/RobotPoints'
export default {
name: 'TblDepotInForm',
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: '请输入采购性质!' }],
operTime: [{ required: true, message: '请输入入库时间!' }],
operNumber: [{ required: true, message: '请输入数量!' }],
robotName: [{ required: true, message: '请选择机器人!' }],
pointId: [{ required: true, message: '请选择目标点位!' }],
templateId: [{ required: true, message: '请选择机器人任务!' }],
},
robotOptions:[
{id:"SCWM00JS48YF01635",value:"开放收物上舱"},
{id:"SCSK08C0450100861",value:"送物上舱"}
],
pointOptions:[],
templateIdOptions:[
{id:"dock_cabin_to_move_and_lift_down",value:"调度底盘去某个上仓举起并移动到另外点位放下"},
{id:"docking_cabin_and_docking_down",value:"调度底盘移动上舱举起并移动到另外一个舱位放下"},
{id:"docking_cabin_and_move_target",value:"调度底盘移动上舱举起并移动到目标点"},
{id:"move_target_and_lift_down",value:"托举上舱移动到目的地并且放下上舱"},
{id:"dock_cabin_and_move_target_with_wait_action",value:"让某舱到某目的地"}
],
url: {
add: '/depot/tblDepot/add',
edit: '/depot/tblDepot/edit',
queryById: '/depot/tblDepot/queryById',
queryMaterial: '/depot/tblDepot/queryMaterialByPartNum',
queryPartNumber: '/depot/tblDepot/queryPartNumber',
// queryRobotPoints: '/robotPoints/tblRobotPoints/queryList'
},
}
},
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))
// this.getRobotPoints()
},
methods: {
getRobotPoints(){
var that = this;
getRobotPoints().then((res)=>{
console.log('res===',res)
if(res.success){
this.pointOptions = res.result
}
});
},
onClick(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'
}
console.log(this.model)
// return
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)
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
}
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.meterialType = res.result.meterialType
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>