houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <el-dialog
3     :title="!dataForm.id ? '新增' : '修改'"
4     :close-on-click-modal="false"
5     :width="dialogWidth"
6     :visible.sync="visible">
7     <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">
8       <el-divider content-position="left">模型信息</el-divider>
9       <el-row :gutter="20">
10         <el-col :span="12">
11           <el-form-item label="模型名称" prop="modelname">
12             <el-input v-model="dataForm.modelname" placeholder="模型名称" maxlength="50" clearable></el-input>
13           </el-form-item>
14         </el-col>
15       </el-row>
16       <el-row :gutter="20">
17         <el-col :span="12">
18           <el-form-item label="调度类型" prop="scheduleid">
19             <el-select v-model="dataForm.scheduleid" placeholder="请选择">
20               <el-option
21                 v-for="item in scheduleList"
22                 :key="item.id"
23                 :label="item.name"
24                 :value="item.id">
25               </el-option>
26             </el-select>
27           </el-form-item>
28         </el-col>
29       </el-row>
30       <el-row :gutter="20">
31         <el-col :span="24">
32           <el-form-item label="类名" prop="classname">
33             <el-input v-model="dataForm.classname" placeholder="类名" maxlength="32" clearable ></el-input>
34           </el-form-item>
35         </el-col>
36       </el-row>
37       <el-row :gutter="20">
38         <el-col :span="12">
39           <el-form-item label="方法名" prop="methodname">
40             <el-input v-model="dataForm.methodname" placeholder="方法名" maxlength="32" clearable ></el-input>
41           </el-form-item>
42         </el-col>
43         <el-col :span="12">
44           <el-form-item label="模型路径" prop="modelpath">
45             <el-input v-model="dataForm.modelpath" placeholder="模型路径" maxlength="32" clearable ></el-input>
46           </el-form-item>
47         </el-col>
48       </el-row>
49       <el-row :gutter="20">
50         <el-col :span="12">
51           <el-form-item label="端口长度" prop="portlength">
52             <el-input v-model="dataForm.portlength" placeholder="端口长度" maxlength="32" clearable ></el-input>
53           </el-form-item>
54         </el-col>
55         <el-col :span="12">
56           <el-form-item label="模型状态" prop="modelstatus">
57             <el-input v-model="dataForm.modelstatus" placeholder="模型状态" maxlength="32" clearable ></el-input>
58           </el-form-item>
59         </el-col>
60       </el-row>
61       <el-row :gutter="20">
62         <el-col :span="24">
63           <el-table
64             :data="dataForm.stScheduleParamSettingList"
65             border
66             style="width: 100%">
67             <el-table-column
68               prop=""
69               label="键"
70               align="center">
71               <template slot-scope="scope">
72                 <el-input size="mini" v-model="scope.row.key" maxlength="256" clearable style="width:100%;hight:100%"></el-input>
73               </template>
74             </el-table-column>
75             <el-table-column
76               prop=""
77               label="名称"
78               align="center">
79               <template slot-scope="scope">
80                 <el-input size="mini" v-model="scope.row.name" maxlength="256" clearable style="width:100%;hight:100%"></el-input>
81               </template>
82             </el-table-column>
83             <el-table-column
84               prop=""
85               label="类型"
86               align="center">
87               <template slot-scope="scope">
88                 <el-input size="mini" v-model="scope.row.valuetype" maxlength="256" clearable style="width:100%;hight:100%"></el-input>
89               </template>
90             </el-table-column>
91             <el-table-column
92               prop=""
93               label="值"
94               align="center">
95               <template slot-scope="scope">
96                 <el-input size="mini" v-model="scope.row.value" maxlength="256" clearable style="width:100%;hight:100%"></el-input>
97               </template>
98             </el-table-column>
99             <el-table-column
100               prop=""
101               label="操作"
102               width="100"
103               align="center">
104               <template slot-scope="scope">
105                 <el-button
106                   @click.native.prevent="addRow(scope.$index, dataForm.stScheduleParamSettingList)"
107                   type="text"
108                   size="small">
109                   添加
110                 </el-button>
111                 <el-button
112                   @click.native.prevent="deleteRow(scope.$index, dataForm.stScheduleParamSettingList)"
113                   type="text"
114                   size="small">
115                   删除
116                 </el-button>
117               </template>
118             </el-table-column>
119           </el-table>
120         </el-col>
121       </el-row>
122       <el-divider content-position="left">输入参数</el-divider>
123       <el-row :gutter="20">
124         <el-col :span="24">
125           <el-table
126             :data="dataForm.stScheduleParamList"
127             border
128             style="width: 100%">
129             <el-table-column
130               prop=""
131               label="端口"
132               width="100"
133               align="center">
134               <template slot-scope="scope">
135                 <el-input size="mini" v-model="scope.row.modelparamportorder" maxlength="5" clearable style="width:100%;hight:100%"></el-input>
136               </template>
137             </el-table-column>
138             <el-table-column
139               prop=""
140               label="序号"
141               width="100"
142               align="center">
143               <template slot-scope="scope">
144                 <el-input size="mini" v-model="scope.row.modelparamorder" maxlength="5" clearable style="width:100%;hight:100%"></el-input>
145               </template>
146             </el-table-column>
147             <el-table-column
148               prop=""
149               label="类型"
150               width="150"
151               align="center">
152               <template slot-scope="scope">
153                 <el-select size="mini" v-model="scope.row.modelparamtype" @change="changeModelparamtype(value, scope.row)" placeholder="请选择">
154                   <el-option
155                     v-for="item in modelparamtypeList"
156                     :key="item"
157                     :label="item"
158                     :value="item">
159                   </el-option>
160                 </el-select>
161               </template>
162             </el-table-column>
163             <el-table-column
164               prop=""
165               label="参数名称"
166               align="center">
167               <template slot-scope="scope">
168                 <el-select
169                   size="mini"
170                   v-model="scope.row.modelparamid"
171                   filterable
172                   @change="changeModelparam(scope.row)"
173                   placeholder="请选择">
174                   <el-option
175                     v-for="(item, index) in modelparamList"
176                     :key="index"
177                     :label="item.name"
178                     :value="item.id"
179                     :disabled="!(item.type === scope.row.modelparamtype)">
180                   </el-option>
181                 </el-select>
182               </template>
183             </el-table-column>
184             <el-table-column
185               prop=""
186               label="参数长度"
187               width="120"
188               align="center">
189               <template slot-scope="scope">
190                 <el-input size="mini" v-model="scope.row.datalength" maxlength="50" clearable style="width:100%;hight:100%"></el-input>
191               </template>
192             </el-table-column>
193             <el-table-column
194               prop=""
195               label="操作"
196               width="100"
197               align="center">
198               <template slot-scope="scope">
199                 <el-button
200                   @click.native.prevent="addRow(scope.$index, dataForm.stScheduleParamList)"
201                   type="text"
202                   size="small">
203                   添加
204                 </el-button>
205                 <el-button
206                   @click.native.prevent="deleteRow(scope.$index, dataForm.stScheduleParamList)"
207                   type="text"
208                   size="small">
209                   删除
210                 </el-button>
211               </template>
212             </el-table-column>
213           </el-table>
214         </el-col>
215       </el-row>
216       <el-divider content-position="left">用户参数</el-divider>
217       <el-row :gutter="20">
218         <el-col :span="24">
219           <el-table
220             :data="dataForm.stScheduleModelUserParamList"
221             border
222             style="width: 100%">
223             <el-table-column
224               prop=""
225               label="用户"
226               align="center">
227               <template slot-scope="scope">
228                 <el-select size="mini" v-model="scope.row.userid" placeholder="请选择">
229                   <el-option
230                     v-for="item in scheduleUserList"
231                     :key="item.id"
232                     :label="item.name"
233                     :value="item.id">
234                   </el-option>
235                 </el-select>
236               </template>
237             </el-table-column>
238             <el-table-column
239               prop=""
240               label="能源类型"
241               align="center">
242               <template slot-scope="scope">
243                 <el-select size="mini" v-model="scope.row.energytypeid" placeholder="请选择">
244                   <el-option
245                     v-for="item in scheduleEnergyTypeList"
246                     :key="item.id"
247                     :label="item.name"
248                     :value="item.id">
249                   </el-option>
250                 </el-select>
251               </template>
252             </el-table-column>
253             <el-table-column
254               prop=""
255               label="是否调整"
256               width="100"
257               align="center">
258               <template slot-scope="scope">
259                 <el-input size="mini" v-model="scope.row.isadjust" maxlength="5" clearable style="width:100%;hight:100%"></el-input>
260               </template>
261             </el-table-column>
262             <el-table-column
263               prop=""
264               label="调整上限"
265               width="100"
266               align="center">
267               <template slot-scope="scope">
268                 <el-input size="mini" v-model="scope.row.upadjlimit" maxlength="5" clearable style="width:100%;hight:100%"></el-input>
269               </template>
270             </el-table-column>
271             <el-table-column
272               prop=""
273               label="调整下限"
274               width="100"
275               align="center">
276               <template slot-scope="scope">
277                 <el-input size="mini" v-model="scope.row.downadjlimit" maxlength="5" clearable style="width:100%;hight:100%"></el-input>
278               </template>
279             </el-table-column>
280             <el-table-column
281               prop=""
282               label="调整排序"
283               width="100"
284               align="center">
285               <template slot-scope="scope">
286                 <el-input size="mini" v-model="scope.row.adjorder" maxlength="5" clearable style="width:100%;hight:100%"></el-input>
287               </template>
288             </el-table-column>
289             <el-table-column
290               prop=""
291               label="操作"
292               width="100"
293               align="center">
294               <template slot-scope="scope">
295                 <el-button
296                   @click.native.prevent="addRow(scope.$index, dataForm.stScheduleModelUserParamList)"
297                   type="text"
298                   size="small">
299                   添加
300                 </el-button>
301                 <el-button
302                   @click.native.prevent="deleteRow(scope.$index, dataForm.stScheduleModelUserParamList)"
303                   type="text"
304                   size="small">
305                   删除
306                 </el-button>
307               </template>
308             </el-table-column>
309           </el-table>
310         </el-col>
311       </el-row>
312     </el-form>
313     <span slot="footer" class="dialog-footer">
314       <el-button :loading="loading" @click="visible = false">取消</el-button>
315       <el-button :loading="loading" type="primary" @click="dataFormSubmit()">确定</el-button>
316     </span>
317   </el-dialog>
318 </template>
319
320 <script>
321   import { isPositiveInteger } from '@/utils/validate'
322   export default {
323     data () {
324       var validatePositiveInteger = (rule, value, callback) => {
325         if (value && !isPositiveInteger(value)) {
326           callback(new Error('应该为整数'))
327         } else {
328           callback()
329         }
330       }
331       return {
332         loading: true,
333         dialogWidth: 0,
334         visible: false,
335         noDisabled: false,
336         pointLoading: false,
337         roleList: [],
338         pointList: [],
339         pointMap: {},
340         modelparamtypeList: ['常量点', '测量点', '洗选日计划', '装车日计划', '检修计划'],
341         modelparamList: [],
342         modelparamMap: {},
343         scheduleList: [],
344         scheduleObjectList: [],
345         scheduleUserList: [],
346         scheduleEnergyTypeList: [],
347         fileList: [],
348         operatorList: ['+', '-'],
349         isList: [
350           {
351             code: 0,
352             name: '否'
353           },
354           {
355             code: 1,
356             name: '是'
357           }],
358         replaceModelOnly: 0,
359         dataForm: {
360           id: 0,
361           modelname: '',
362           scheduleid: '',
363           objectid: '',
364           classname: '',
365           methodname: '',
366           modelpath: '',
367           portlength: '',
368           modelstatus: '',
369           stScheduleParamSettingList: [],
370           stScheduleParamList: [],
371           stScheduleModelUserParamList: []
372         },
373         dataRule: {
374           'modelname': [
375             { required: true, message: '模型名称不能为空', trigger: 'blur' }
376           ],
377           'scheduleid': [
378             { required: true, message: '调度不能为空', trigger: 'blur' }
379           ],
380           'objectid': [
381             { required: true, message: '调度对象不能为空', trigger: 'blur' }
382           ],
383           'methodname': [
384             { required: true, message: '方法名不能为空', trigger: 'blur' }
385           ],
386           'modelstatus': [
387             { required: true, message: '模型状态不能为空', trigger: 'blur' }
388           ],
389           'portlength': [
390             { validator: validatePositiveInteger, trigger: 'blur' }
391           ]
392         }
393       }
394     },
395     created () {
396       this.setDialogWidth()
397     },
398     mounted () {
399       window.onresize = () => {
400         return (() => {
401           this.setDialogWidth()
402         })()
403       }
404     },
405     methods: {
406       setDialogWidth () {
407         let val = document.body.clientWidth
408         const def = 1300 // 默认宽度
409         if (val < def) {
410           this.dialogWidth = '80%'
411         } else {
412           this.dialogWidth = '60%'
413         }
414       },
415       init (id) {
416         this.getScheduleList()
417         // this.getScheduleObjectList()
418         this.getModelparamList()
419         this.getScheduleUserList()
420         this.getScheduleEnergyTypeList()
421         this.dataForm.id = id || 0
422         this.loading = true
423         this.visible = true
424         this.$nextTick(() => {
425           this.$refs['dataForm'].resetFields()
426           this.setDefaultFields()
427         })
428         if (id) {
429           this.$http({
430             url: `/iailab-ntt-model/mcs/schedule-model/info/${this.dataForm.id}`,
431             method: 'get',
432             params: this.$http.adornParams()
433           }).then(({data}) => {
434             this.expressionList = []
435             if (data && data.code === 0) {
436               this.dataForm.modelname = data.scheduleMode.modelname
437               this.dataForm.scheduleid = data.scheduleMode.scheduleid
438               this.dataForm.objectid = data.scheduleMode.objectid
439               this.dataForm.classname = data.scheduleMode.classname
440               this.dataForm.methodname = data.scheduleMode.methodname
441               this.dataForm.modelpath = data.scheduleMode.modelpath
442               this.dataForm.portlength = data.scheduleMode.portlength
443               this.dataForm.modelstatus = data.scheduleMode.modelstatus
444               this.dataForm.stScheduleParamSettingList = data.scheduleMode.stScheduleParamSettingList || []
445               this.dataForm.stScheduleParamList = data.scheduleMode.stScheduleParamList || []
446               this.loading = false
447             }
448           })
449         } else {
450           this.loading = false
451         }
452       },
453       setDefaultFields () {
454         this.dataForm.stScheduleParamSettingList = [{
455           key: '',
456           value: '',
457           valuetype: '',
458           name: ''
459         }]
460         this.dataForm.stScheduleParamList = [{
461           modelparamportorder: '1',
462           modelparamorder: '1',
463           modelparamtype: '',
464           modelparamid: '',
465           datalength: ''
466         }]
467         this.dataForm.stScheduleModelUserParamList = [{
468           userid: '',
469           energytypeid: '',
470           isadjust: '',
471           upadjlimit: '',
472           downadjlimit: '',
473           adjorder: ''
474         }]
475       },
476       changeModelparam (row) {
477         row.modelparamname = this.modelparamMap[row.modelparamid]
478       },
479       deleteRow (index, rows) {
480         if (!rows || rows.length === 1) {
481           this.$message({
482             message: '不能全部删除!',
483             type: 'error',
484             duration: 1500
485           })
486           return
487         }
488         rows.splice(index, 1)
489         this.orderRow(rows)
490       },
491       addRow (index, rows) {
492         let row = JSON.parse(JSON.stringify(rows[index]))
493         rows.splice(index, 0, row)
494         this.orderRow(rows)
495       },
496       changeModelparamtype (value, row) {
497         row.modelparamid = ''
498       },
499       changeOutputPoint (value) {
500         this.dataForm.mmItemOutput.tagname = this.pointMap[value]
501       },
502       orderRow (rows) {
503         let modelparamorder = 0
504         let modelparamportorder = 0
505         rows.forEach(function (value) {
506           if (value.modelparamportorder !== modelparamportorder) {
507             modelparamportorder = value.modelparamportorder
508             modelparamorder = 1
509           }
510           value.modelparamorder = modelparamorder
511           modelparamorder++
512         })
513       },
514       // 获取调度集合
515       getScheduleList () {
516         this.scheduleList = []
517         this.$http({
518           url: '/iailab-ntt-model/mcs/schedule/list',
519           method: 'get',
520           params: this.$http.adornParams({
521             'page': 1,
522             'limit': 500
523           })
524         }).then(({data}) => {
525           if (data && data.code === 0) {
526             data.page.list.forEach(function (value) {
527               this.scheduleList.push({
528                 id: value.id,
529                 name: value.name
530               })
531             }, this)
532           }
533         })
534       },
535       // 获取调度用户
536       getScheduleUserList () {
537         this.scheduleUserList = []
538         this.$http({
539           url: '/iailab-ntt-model/mcs/schedule-user/list',
540           method: 'get',
541           params: this.$http.adornParams({
542             'page': 1,
543             'limit': 500
544           })
545         }).then(({data}) => {
546           if (data && data.code === 0) {
547             data.page.list.forEach(function (value) {
548               this.scheduleUserList.push({
549                 id: value.id,
550                 name: value.username
551               })
552             }, this)
553           }
554         })
555       },
556       // 获取能源类型
557       getScheduleEnergyTypeList () {
558         this.scheduleEnergyTypeList = []
559         this.$http({
560           url: '/iailab-ntt-model/mcs/schedule-energy-type/list',
561           method: 'get',
562           params: this.$http.adornParams({
563             'page': 1,
564             'limit': 500
565           })
566         }).then(({data}) => {
567           if (data && data.code === 0) {
568             data.page.list.forEach(function (value) {
569               this.scheduleEnergyTypeList.push({
570                 id: value.id,
571                 name: value.energytypename
572               })
573             }, this)
574           }
575         })
576       },
577       // 获取调度对象
578       getScheduleObjectList () {
579         this.scheduleObjectList = []
580         this.$http({
581           url: '/iailab-ntt-model/mcs/schedule-object/list',
582           method: 'get',
583           params: this.$http.adornParams({
584             'page': 1,
585             'limit': 500
586           })
587         }).then(({data}) => {
588           if (data && data.code === 0) {
589             data.page.list.forEach(function (value) {
590               this.scheduleObjectList.push({
591                 id: value.id,
592                 name: value.name
593               })
594             }, this)
595           }
596         })
597       },
598       // 获取模型参数
599       getModelparamList () {
600         this.modelparamList = []
601         this.$http({
602           url: '/iailab-ntt-model/mcs/data-point/list/all',
603           method: 'get',
604           params: this.$http.adornParams({
605             'pointtypename': 'CONSTANT'
606           })
607         }).then(({data}) => {
608           if (data && data.code === 0) {
609             data.data.forEach(function (value) {
610               this.modelparamList.push({
611                 id: value.id,
612                 name: value.mkbmName + ':' + value.cdmc,
613                 type: '常量点'
614               })
615               this.modelparamMap[value.id] = value.mkbmName + ':' + value.cdmc
616             }, this)
617           }
618         })
619         this.$http({
620           url: '/iailab-ntt-model/mcs/data-point/list/all',
621           method: 'get',
622           params: this.$http.adornParams({
623             'pointtypename': 'MEASURE POINT'
624           })
625         }).then(({data}) => {
626           if (data && data.code === 0) {
627             data.data.forEach(function (value) {
628               this.modelparamList.push({
629                 id: value.id,
630                 name: value.mkbmName + ':' + value.cdmc,
631                 type: '测量点'
632               })
633               this.modelparamMap[value.id] = value.mkbmName + ':' + value.cdmc
634             }, this)
635           }
636         })
637         this.$http({
638           url: '/iailab-ntt-model/mcs/work-process/list/all',
639           method: 'get',
640           params: this.$http.adornParams({
641             'page': 1,
642             'limit': 1000,
643             'processType': '洗选日计划'
644           })
645         }).then(({data}) => {
646           if (data && data.code === 0) {
647             data.data.forEach(function (value) {
648               this.modelparamList.push({
649                 id: value.id,
650                 code: value.code,
651                 name: value.aliasName,
652                 type: '洗选日计划'
653               })
654               this.modelparamMap[value.id] = value.aliasName
655             }, this)
656           }
657         })
658         this.$http({
659           url: '/iailab-ntt-model/mcs/work-process/list/all',
660           method: 'get',
661           params: this.$http.adornParams({
662             'page': 1,
663             'limit': 1000,
664             'processType': '装车日计划'
665           })
666         }).then(({data}) => {
667           if (data && data.code === 0) {
668             data.data.forEach(function (value) {
669               this.modelparamList.push({
670                 id: value.id,
671                 code: value.code,
672                 name: value.aliasName,
673                 type: '装车日计划'
674               })
675               this.modelparamMap[value.id] = value.aliasName
676             }, this)
677           }
678         })
679         this.$http({
680           url: '/iailab-ntt-model/mcs/work-process/list/all',
681           method: 'get',
682           params: this.$http.adornParams({
683             'page': 1,
684             'limit': 1000,
685             'processType': '检修计划'
686           })
687         }).then(({data}) => {
688           if (data && data.code === 0) {
689             data.data.forEach(function (value) {
690               this.modelparamList.push({
691                 id: value.id,
692                 code: value.code,
693                 name: value.aliasName,
694                 type: '检修计划'
695               })
696               this.modelparamMap[value.id] = value.aliasName
697             }, this)
698           }
699         })
700       },
701       setReplaceModelOnly (value) {
702         this.replaceModelOnly = value
703       },
704       // 表单提交
705       dataFormSubmit () {
706         this.$refs['dataForm'].validate((valid) => {
707           if (valid) {
708             this.$http({
709               url: `/iailab-ntt-model/mcs/schedule-model/${!this.dataForm.id ? 'save' : 'update'}`,
710               method: 'post',
711               data: this.$http.adornData({
712                 id: this.dataForm.id,
713                 modelname: this.dataForm.modelname,
714                 scheduleid: this.dataForm.scheduleid,
715                 objectid: this.dataForm.objectid,
716                 classname: this.dataForm.classname,
717                 methodname: this.dataForm.methodname,
718                 modelpath: this.dataForm.modelpath,
719                 portlength: this.dataForm.portlength,
720                 modelstatus: this.dataForm.modelstatus,
721                 stScheduleParamSettingList: this.dataForm.stScheduleParamSettingList,
722                 stScheduleParamList: this.dataForm.stScheduleParamList
723               })
724             }).then(({data}) => {
725               if (data && data.code === 0) {
726                 this.$message({
727                   message: '操作成功',
728                   type: 'success',
729                   duration: 1500,
730                   onClose: () => {
731                     this.visible = false
732                     this.$emit('refreshDataList')
733                   }
734                 })
735               } else {
736                 this.$message.error(data.msg)
737               }
738             })
739           }
740         })
741       }
742     }
743   }
744 </script>
745
746 <style>
747   .el-select {
748     width: 100%
749   }
750 </style>