importBom.vue
5.48 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
<template>
<a-modal
:title="title"
:width="800"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭"
wrapClassName="ant-modal-cust-warp"
style="top:5%;height: 85%;overflow-y: hidden">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="节点编码">
<a-input v-decorator="['no']" :disabled="true" />
<a-input v-decorator="['uuid']" :disabled="true" />
<a-input v-decorator="['cno']" style="display:none"/>
<a-input v-decorator="['js']" style="display:none"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="项目名称">
<a-input placeholder="请输入项目名称" :disabled="roleDisabled" v-decorator.trim="[ 'projectName', validatorRules.projectName]" />
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="生产令号">
<j-search-select-tag placeholder="请选择生产令号" v-decorator="['orderNo', { rules: [{ required: true, message: '请输入生产令号!' }] }]" :dictOptions="searchOptions">
</j-search-select-tag>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="bom套数">
<a-input placeholder="请输入正整数" :disabled="roleDisabled" v-decorator.trim="['multiple',validatorRules.multiple]" />
</a-form-item>
<p style="margin-left: 85px;color: red" >注:输入正整数套数相乘,负整数套数相除</p>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
import { importBom,checkName,getWorkOrderList } from '@api/api'
import JDictSelectTag from '/src/components/dict/JDictSelectTag'
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
export default {
name: 'importBom',
props:['pro_no','pno_no',"js","uuid"],
components: {
JDictSelectTag,
JSearchSelectTag
},
data () {
return {
title:"操作",
visible: false,
roleDisabled: false,
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
form: this.$form.createForm(this),
searchOptions:[],
validatorRules:{
roleType:{
type: [
{ required: true, message: '请输入编码!' },
{ min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur' }
]},
projectName:{
rules: [{
required: true, message: '请输入项目名称!'
},{
validator: this.validateName,
}]
},multiple:{
rules: [
{validator: this.validateDigits},
]
}
},
}
},
created () {
this.getWorkOrder();
},
methods: {
add () {
if(this.pro_no==''){
const that = this;
that.$message.warning("请至少勾选一条列表");
}else{
this.edit({});
}
},
edit (record) {
this.form.resetFields();
this.model = Object.assign({}, record);
this.visible = true;
//编辑页面禁止修改角色编码
if(this.model.id){
this.roleDisabled = true;
}else{
this.roleDisabled = false;
}
this.$nextTick(() => {
this.form.setFieldsValue({
projectName: this.model.projectName,
orderNo: this.model.orderNo,
no:this.pro_no,
cno:this.pno_no,
js:this.js,
uuid:this.uuid,
multiple:'1'
})
})
},
close () {
this.$emit('close');
this.visible = false;
},
getWorkOrder(){
var params ='';
getWorkOrderList(params).then((res) => {
this.searchOptions=res.result
})
},
handleOk () {
const that = this;
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true;
values.projectName = (values.projectName || '').trim()
values.orderNo = (values.orderNo || '').trim()
values.no = (values.no || '').trim()
//values.multiple = (values.multiple || '').trim()
let formData = Object.assign(this.model, values);
let obj;
obj=importBom(formData);
obj.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();
})
}
})
},
handleCancel () {
this.close()
},
validateName(rule, value, callback){
var params = {
projectName: value,
};
checkName(params).then((res) => {
if (res.success) {
callback()
} else {
callback("项目名称已存在!")
}
})
},
validateDigits(rule, value, callback){
//if(!(/(^[1-9]\d-*$)/.test(value))){
var reg=/-?[1-9]\d*/;
if(!reg.test(value)){
callback("输入整数!")
}else{
callback()
}
},
}
}
</script>
<style scoped>
</style>