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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
| <!--
| * @Author: 李喆(开发组) lzhe@yxqiche.com
| * @Date: 2025-05-28 12:03:55
| * @LastEditors: gaoshp
| * @LastEditTime: 2025-08-10 13:05:56
| * @FilePath: /mdmweb/src/views/flowmgr/taskassign.vue
| * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
| -->
| <template>
| <basic-container>
| <avue-form ref="form" :option="attachOption" v-model="attachForm" @submit="formSubmit"><!-- -->
| <template #machineCode="{}">
| <el-tree-select ref="tree" filterable v-model="attachForm.machineCode"
| node-key="machineCode"
| :data="treeData" :props="defaultProps">
| </el-tree-select>
| </template>
| <template #drawingNo="{}">
| <el-autocomplete v-model="attachForm.drawingNo"
| :fetch-suggestions="querySearchAsync"
| :trigger-on-focus="false" @select="handleSelect"
| >
| </el-autocomplete>
| </template>
|
| <template #programmer="{}">
| <el-autocomplete ref="autoProgrammer" :disabled="drawingNoMatch" v-model="attachForm.programmer"
| :fetch-suggestions="queryProgrammerAsync"
| :trigger-on-focus="false" @select="handleProgrammerSelect"
| >
| </el-autocomplete>
| </template>
|
| </avue-form>
| </basic-container>
| </template>
|
| <script>
| import {
| getQueryString,
| } from '@/utils/util';
|
| export default {
| watch: {
| 'attachForm.drawingNo': function (val) {
| if(val && this.attachForm.processNo && this.attachForm.processEdition) {
| this.attachForm.title = `${val}-${this.attachForm.processNo}-${this.attachForm.processEdition}-计划任务`;
|
|
| }
| },
| 'attachForm.processNo': function (val) {
| if(val && this.attachForm.drawingNo && this.attachForm.processEdition) {
| //this.attachForm.title = `${val}-${this.attachForm.processNo}-数控程序编制`;
| this.attachForm.title = `${this.attachForm.drawingNo}-${val}-${this.attachForm.processEdition}-计划任务`;
| }
| },
| 'attachForm.processEdition': function (val) {
| if(val && this.attachForm.drawingNo && this.attachForm.processNo ) {
| //this.attachForm.title = `${val}-${this.attachForm.processNo}-数控程序编制`;
| this.attachForm.title = `${this.attachForm.drawingNo}-${this.attachForm.processNo}-${val}-计划任务`;
| }
| },
| },
| data() {
| var that = this;
| return {
| form: {},
|
| treeData: [],
| defaultProps: {
| children: 'children',
| label: 'name',
| disabled: (data) => data.nodeType!=='machine',//仅机床节点可选
| isLeaf: (data) => !data.hasChildren
| },
| timeout:0, //零件号加载的timeout
| drawingNoMatch:true,//零件号是否匹配分工表
| attachOption: {
| labelWidth: 160,
| submitBtn: true,
| emptyBtn: false,
| tip: false,
| column: [
| {
| label: '流程标题',
| prop: 'title',
| type: 'input',
| span: 24,
| disabled:true,
| dataType: 'string'
| },
| {
| label: '零组件号',
| prop: 'drawingNo',
| type: 'input',
| span: 12,
| dataType: 'string',
| blur: (col) => {
| this.handleTrim(col);
|
| },
| rules: [{ required: true, message: '必填', trigger: 'blur' }],
| },
| {
| label: '图纸版次',
| prop: 'drawingNoEdition',
| type: 'input',
| span: 12,
| dataType: 'string',
| rules: [{ required: true, message: '必填', trigger: 'blur' }],
| blur: (col) => {
| this.handleTrim(col)
| },
| },
| {
| label: '产品型号',
| prop: 'productModel',
| type: 'input',
| span: 12,
| dataType: 'string',
| rules: [{ required: true, message: '必填', trigger: 'blur' }],
| blur: (col) => {
| this.handleTrim(col)
| },
| },
| {
| label: '工序号',
| prop: 'processNo',
| type: 'input',
| span: 12,
| step: 1,
| precision: 0,
| dataType: 'string',
| rules: [{ required: true, message: '必填', trigger: 'blur' }],
| blur: (col) => {
| this.handleTrim(col)
| },
| },
| {
| label: '工序名称',
| prop: 'processName',
| type: 'input',
| span: 12,
| dataType: 'string',
| rules: [{ required: true, message: '必填', trigger: 'blur' }],
| blur: (col) => {
| this.handleTrim(col)
| },
| },
| {
| label: '工序版次',
| prop: 'processEdition',
| type: 'input',
| span: 12,
| dataType: 'string',
| rules: [{ required: true, message: '必填', trigger: 'blur' }],
| blur: (col) => {
| this.handleTrim(col)
| },
| },
| {
| label: '批次号',
| prop: 'craftEdition',
| placeholder:'如"2S24001"',
| type: 'input',
| span: 12,
| dataType: 'string',
| maxlength: 10,
| blur: (col) => {
| this.handleTrim(col)
| },
| },
|
| {
| label: '加工机床',
| prop: 'machineCode',
| type: 'select',
| rules: [{ required: true, message: '必填', trigger: 'blur' }],
| span: 12
| },
| {
| label: '计划锁定时间(天)',
| prop: 'planLockDays',
| type: 'number',
| min:0,
| max:30,
| span: 12,
| controls:true,
| dataType: 'number',
| controlsPosition:'right',
| rules: [{ required: true, message: '必填', trigger: 'blur' }],
| },
| {
| label: '计划开工时间',
| prop: 'planStartTime',
| type: 'date',
| format: "YYYY-MM-DD",
| valueFormat: "YYYY-MM-DD",
| span: 12,
| dataType: 'string',
| rules: [{ required: true, message: '必填', trigger: 'blur' }],
| },
| {
| label: '偏离单号',
| prop: 'deviation',
| type: 'input',
| span: 12,
| dataType: 'string',
| class:'input_holder_warn',
| placeholder:'无偏离单任务请留空',
| blur: (col) => {
| this.handleTrim(col)
| },
| // rules: [{ required: true, message: '必填', trigger: 'blur' }],
| },
| {
| label: '主管工艺',
| prop: 'programmer',
| type: 'input',//column 12
| disabled:true,
| span: 12,
| dataType: 'string',
| },
| ],
| },
| attachForm: {planLockDays:7,planStartTime: this.$dayjs().format('YYYY-MM-DD')},//默认7天
| defaultForm: {planLockDays:7,planStartTime: this.$dayjs().format('YYYY-MM-DD')},
| };
| },
| methods: {
| treeLoad () {
| axios({
| url: '/blade-mdm/gkw/node/load-tree',
| method: 'get',
| }).then(
| res => {
| this.treeData = this.filterTreeData(res.data.data);
| var firstIndex = 0;
| res.data.data.forEach((item,index)=> {
| if(item.children.length != 0) {
| firstIndex = index;
| }
| })
| //defaultKeys.push(item.id);
| this.defaultKeys = [res.data.data[firstIndex].id];
| }
| )
| },
| filterTreeData(oriTreeData){
| var roots = [];
| for(var i=0;i<oriTreeData.length;i++){
| roots.push(this.filterTreeNodes(oriTreeData[i]));
| }
| return roots;
| },
| filterTreeNodes(node) {
| // 如果当前节点的nodeType是'machine',则清除其子节点
| if (node.nodeType === 'machine') {
| // 创建一个新对象,复制当前节点的属性,但清除children
| return {
| ...node,
| children: []
| };
| }
|
| // 如果当前节点有子节点,递归处理每个子节点
| if (node.children && node.children.length > 0) {
| return {
| ...node,
| children: node.children.map(child => this.filterTreeNodes(child))
| };
| }
|
| // 如果既不是machine节点也没有子节点,直接返回原节点
| return node;
| },
|
| querySearchAsync(query, cb) {//零组件号搜索建议
| axios({
| url: '/blade-mdm/producedivision/select-data',
| method: 'get',
| params: {drawingNo: query},
| }).then(
| res => {
| if(res.data.code == 200){
| let list = res.data.data;
| for(let i of list){
| i.value = i.ljh;
| }
|
| clearTimeout(this.timeout)
| this.timeout = setTimeout(() => {
| cb(list);
| }, 1000)
|
| }
| },
| error => {
| console.log(error);
| }
| );
|
| },
| handleSelect(item) {
| this.attachForm.productModel = item.cph;
| },
|
| queryProgrammerAsync(query, cb) {//主管工艺搜索建议
| axios({
| url: '/blade-mdm/producedivision/select-programmer',
| method: 'get',
| params: {programmer: query},
| }).then(
| res => {
| if(res.data.code == 200){
| let list = res.data.data;
| for(let i of list){
| i.value = '主管工艺:'+i.programmerName+',校对:'+i.checkerName;
| }
|
| clearTimeout(this.timeout)
| this.timeout = setTimeout(() => {
| cb(list);
| }, 600)
|
| }
| },
| error => {
| console.log(error);
| }
| );
|
| },
| handleProgrammerSelect(item){
| this.attachForm.producePlanId = item.id;
| this.attachForm.planDrawingNo = this.attachForm.drawingNo;//记录此时的零组件号
| console.log('productid',this.attachForm )
|
| },
| handleTrim(col){
| //console.log(col)
| let value = this.attachForm[col.column.prop];
| if (typeof value === 'string') {
| const trimmedValue = value.trim();
| // 只有当值确实发生变化时才更新
| if (trimmedValue !== value) {
| this.attachForm[col.column.prop] = trimmedValue;
| }
| }
| // this.attachForm[col.column.prop]='dddd'
| },
| formSubmit(form, done) {
| var form = { ...form };
| console.log('submit',form);
| if(this.attachForm.planDrawingNo == this.attachForm.drawingNo && this.attachForm.producePlanId){
| //手动指定了人员职责表id,不用继续从服务端验证
| this.startDispatch(form,done);
| }else{
| axios({
| url: '/blade-mdm/producedivision/select-by-drawingno',
| method: 'get',
| params: {drawingNo:this.attachForm.drawingNo},
| }).then(
| res => {
|
| if(res.data.code == 200){
| this.$message({
| type: 'success',
| message: '操作成功!',
| });
|
| this.attachForm.producePlanId = res.data.data.id;
| this.drawingNoMatch = true;
| console.log('planid',this.attachForm.productPlanId)
| this.startDispatch(form,done);
| }else{
| this.drawingNoMatch = false;
|
| this.$alert(res.data.msg+".或者手动选择主管工艺。", '发起任务失败',{type:'error',confirmButtonText:'关闭'});
| }
| done();
| },
| error => {
| console.log(error);
| done();
| }
| );
| }
|
| },
| startDispatch(form,done){
| //验证都通过了,执行启动流程
| axios({
| url: '/blade-mdm/flow/dispatch/start',
| method: 'post',
| data: form,
| }).then(
| res => {
|
| if(res.data.code == 200){
| this.$message({
| type: 'success',
| message: '操作成功!',
| });
| this.$refs.form.resetForm();
| this.attachForm = this.defaultForm;
| this.drawingNoMatch = true;
| }else{
| this.$alert(res.data.msg, '发起任务失败',{type:'error',confirmButtonText:'关闭'});
| }
| done();
| },
| error => {
| window.console.log(error);
| done();
| }
| );
| },
| handleGlobalBlur( {prop, value} ) {
| console.log('prop')
| // 1. 筛选需要处理的字段类型(仅输入类:input/textarea)
| const inputTypes = ["input", "textarea"];
| const currentColumn = this.attachOption.column.find(item => item.prop === prop);
|
| // 2. 若为输入类字段,且值为字符串,执行 trim 处理
| if (currentColumn && inputTypes.includes(currentColumn.type) && typeof value === "string") {
| const trimmedValue = value.trim();
| // 3. 同步处理后的值到表单 model(避免直接修改 prop,通过 $set 确保响应式)
| this.$set(this.attachForm, prop, trimmedValue);
| }
| },
| handleBlur(prop, value) {
| if (typeof value === 'string') {
| const trimmedValue = value.trim();
| // 只有当值确实发生变化时才更新
| if (trimmedValue !== value) {
| this.attachForm[prop] = trimmedValue;
| }
| }
| }
| },
|
| mounted() {
| this.treeLoad();
| },
| };
| </script>
|
| <style lang="scss">
| .input_holder_warn {
| .el-input__inner::placeholder {
| color: rgb(255, 106, 0); /* 设置颜色为红色 */
| font-size: 16px; /* 设置字体大小为16px */
| }
| }
| </style>
|
|