From 2151a84932d1ceb9723f45923b223d147d3bb512 Mon Sep 17 00:00:00 2001
From: gaoshp <291585735@qq.com>
Date: 星期日, 27 十月 2024 14:56:26 +0800
Subject: [PATCH] 过程参数

---
 src/views/console/workstation/CollTable.vue  |  110 +++++++++---------
 src/views/console/workstation/CollDialog.vue |  123 ++++++++++---------
 src/views/mdc/processParam/index.vue         |   24 +--
 src/views/console/workstation/addOptions.js  |   85 ++++++++++++++
 4 files changed, 214 insertions(+), 128 deletions(-)

diff --git a/src/views/console/workstation/CollDialog.vue b/src/views/console/workstation/CollDialog.vue
index 9b84e1c..d734859 100644
--- a/src/views/console/workstation/CollDialog.vue
+++ b/src/views/console/workstation/CollDialog.vue
@@ -38,9 +38,9 @@
 
                 </template>
                 <template #default="scope">
-                    <el-select :disabled="!scope.row.status" v-model="scope.row[item.prop]"
-                        @change="change($event, scope.row, scope.$index, item)" placeholder="" size="small"
-                        v-if="item.type === 'option'">
+                    <el-select :disabled="!scope.row.status || (item.disabledFn && item.disabledFn(scope.row))"
+                        v-model="scope.row[item.prop]" @change="change($event, scope.row, scope.$index, item)"
+                        placeholder="" size="small" v-if="item.type === 'option'">
                         <el-option v-for="item in item.options" :key="item.value || item" :label="(item?.label || item)"
                             :value="(item.value || item)" />
                     </el-select>
@@ -62,9 +62,11 @@
 </template>
 
 <script>
+import addOptions from './addOptions'
 export default {
     name: 'CollDialog',
     emits: ['success', 'closed'],
+    mixins: [addOptions],
     props: {
         option: {
             type: Object
@@ -99,10 +101,12 @@
                 const label = options.find(v => v.value === e).label
                 this.tabledata[index].dpLabel = label
                 this.tabledata[index].dpName = e
+                this.tabledata[index].paramChartType = 'distribute'
             } else if (prop === 'dpCategory' && e === 'Other') {
                 this.tabledata[index].dpLabel = ''
                 this.tabledata[index].dpName = ''
             }
+            // 鐐逛綅鍒嗙被涓洪潪鍏朵粬鏃� 杩囩▼鍙傛暟灞曠ず鏂瑰紡涓哄垎甯冨浘
         },
         changeType(val) {
             if (this.tabledata.length > 0) {
@@ -111,7 +115,7 @@
                 }).then(() => {
                     try {
                         this.cols = JSON.parse(this.typeList.find(v => v.id === val).dpHeadFull)
-                        this.addOptions()
+                        this.addOptions(this.cols)
                         this.tabledata = []
                     } catch (error) {
                         this.cols = []
@@ -122,7 +126,7 @@
             } else {
                 try {
                     this.cols = JSON.parse(this.typeList.find(v => v.id === val).dpHeadFull)
-                    this.addOptions()
+                    this.addOptions(this.cols)
 
                 } catch (error) {
                     this.cols = []
@@ -162,64 +166,64 @@
             })
 
         },
-        addOptions() {
-            if (this.cols.filter(v => v.prop === 'isProcessParam').length === 0) {
-                this.cols.unshift(
-                    {
-                        label: "杩囩▼鍙傛暟",
-                        prop: "isProcessParam",
-                        isRequired: true,
-                        type: 'boolean',
-                    }
-                )
-            }
-            if (this.cols.filter(v => v.prop === 'dpLabel').length === 0) {
-                this.cols.unshift(
-                    {
-                        label: "鏄剧ず鍚嶇О",
-                        prop: "dpLabel",
-                        isRequired: true,
-                    }
-                )
-            }
-            if (this.cols.filter(v => v.prop === 'dpCategory').length === 0) {
-                this.cols.unshift(
-                    {
-                        label: "鐐逛綅鍒嗙被",
-                        prop: "dpCategory",
-                        isRequired: true,
-                        type: 'option',
-                        options: [{
-                            label: '绋嬪簭鍚�',
-                            value: 'ProgName'
-                        }, {
-                            label: '绋嬪簭鍐呭',
-                            value: 'ProgContent'
-                        }, {
-                            label: '鍒�鍏峰彿',
-                            value: 'ToolNo'
-                        }, {
-                            label: '鐘舵��',
-                            value: 'DeviceStatus'
-                        }, {
-                            label: '浜ч噺',
-                            value: 'Output'
-                        }, {
-                            label: '鍛婅',
-                            value: 'Alarm'
-                        }, {
-                            label: '鍏朵粬',
-                            value: 'Other'
-                        }]
-                    }
-                )
-            }
-        },
+        // addOptions() {
+        //     if (this.cols.filter(v => v.prop === 'isProcessParam').length === 0) {
+        //         this.cols.unshift(
+        //             {
+        //                 label: "杩囩▼鍙傛暟",
+        //                 prop: "isProcessParam",
+        //                 isRequired: true,
+        //                 type: 'boolean',
+        //             }
+        //         )
+        //     }
+        //     if (this.cols.filter(v => v.prop === 'dpLabel').length === 0) {
+        //         this.cols.unshift(
+        //             {
+        //                 label: "鏄剧ず鍚嶇О",
+        //                 prop: "dpLabel",
+        //                 isRequired: true,
+        //             }
+        //         )
+        //     }
+        //     if (this.cols.filter(v => v.prop === 'dpCategory').length === 0) {
+        //         this.cols.unshift(
+        //             {
+        //                 label: "鐐逛綅鍒嗙被",
+        //                 prop: "dpCategory",
+        //                 isRequired: true,
+        //                 type: 'option',
+        //                 options: [{
+        //                     label: '绋嬪簭鍚�',
+        //                     value: 'ProgName'
+        //                 }, {
+        //                     label: '绋嬪簭鍐呭',
+        //                     value: 'ProgContent'
+        //                 }, {
+        //                     label: '鍒�鍏峰彿',
+        //                     value: 'ToolNo'
+        //                 }, {
+        //                     label: '鐘舵��',
+        //                     value: 'DeviceStatus'
+        //                 }, {
+        //                     label: '浜ч噺',
+        //                     value: 'Output'
+        //                 }, {
+        //                     label: '鍛婅',
+        //                     value: 'Alarm'
+        //                 }, {
+        //                     label: '鍏朵粬',
+        //                     value: 'Other'
+        //                 }]
+        //             }
+        //         )
+        //     }
+        // },
         getList(params) {
             this.$HTTP.get(`/api/blade-cps/workstation/listDatapointsByWorkstationId`, {}, { params }).then(res => {
                 try {
                     this.cols = JSON.parse(res.data.dpHead)
-                    this.addOptions()
+                    this.addOptions(this.cols)
                 } catch (error) {
                     this.cols = []
                 }
@@ -238,6 +242,7 @@
             })
         },
         table_edit(row) {
+            console.log('bianji', row)
             row.status = '1'
         },
         del(index) {
diff --git a/src/views/console/workstation/CollTable.vue b/src/views/console/workstation/CollTable.vue
index e67ffc6..e7903df 100644
--- a/src/views/console/workstation/CollTable.vue
+++ b/src/views/console/workstation/CollTable.vue
@@ -1,8 +1,8 @@
 <!--
  * @Date: 2024-10-05 09:51:45
  * @LastEditors: gaoshp
- * @LastEditTime: 2024-10-16 23:41:34
- * @FilePath: /avue-data/Users/mache/Documents/demo/cps-web/src/views/console/workstation/CollTable.vue
+ * @LastEditTime: 2024-10-27 14:03:19
+ * @FilePath: /cps-web/src/views/console/workstation/CollTable.vue
 -->
 <template>
     <div>
@@ -35,8 +35,9 @@
 </template>
 
 <script>
-
+import addOptions from './addOptions'
 export default {
+    mixins: [addOptions],
     props: {
         info: {
             type: Object,
@@ -72,57 +73,58 @@
             this.$HTTP.get(`/api/blade-cps/workstation/listDatapointsByWorkstationId`, {}, { params }).then(res => {
                 try {
                     this.cols = JSON.parse(res.data.dpHead)
-                    if (this.cols.filter(v => v.prop === 'isProcessParam').length === 0) {
-                        this.cols.unshift(
-                            {
-                                label: "杩囩▼鍙傛暟",
-                                prop: "isProcessParam",
-                                isRequired: true,
-                                type: 'boolean',
-                            }
-                        )
-                    }
-                    if (this.cols.filter(v => v.prop === 'dpLabel').length === 0) {
-                        this.cols.unshift(
-                            {
-                                label: "鏄剧ず鍚嶇О",
-                                prop: "dpLabel",
-                                isRequired: true,
-                            }
-                        )
-                    }
-                    if (this.cols.filter(v => v.prop === 'dpCategory').length === 0) {
-                        this.cols.unshift(
-                            {
-                                label: "鐐逛綅鍒嗙被",
-                                prop: "dpCategory",
-                                isRequired: true,
-                                type: 'option',
-                                options: [{
-                                    label: '绋嬪簭鍚�',
-                                    value: 'ProgName'
-                                }, {
-                                    label: '绋嬪簭鍐呭',
-                                    value: 'ProgContent'
-                                }, {
-                                    label: '鍒�鍏峰彿',
-                                    value: 'ToolNo'
-                                }, {
-                                    label: '鐘舵��',
-                                    value: 'DeviceStatus'
-                                }, {
-                                    label: '浜ч噺',
-                                    value: 'Output'
-                                }, {
-                                    label: '鍛婅',
-                                    value: 'Alarm'
-                                }, {
-                                    label: '鍏朵粬',
-                                    value: 'Other'
-                                }]
-                            }
-                        )
-                    }
+                    this.addOptions(this.cols)
+                    // if (this.cols.filter(v => v.prop === 'isProcessParam').length === 0) {
+                    //     this.cols.unshift(
+                    //         {
+                    //             label: "杩囩▼鍙傛暟",
+                    //             prop: "isProcessParam",
+                    //             isRequired: true,
+                    //             type: 'boolean',
+                    //         }
+                    //     )
+                    // }
+                    // if (this.cols.filter(v => v.prop === 'dpLabel').length === 0) {
+                    //     this.cols.unshift(
+                    //         {
+                    //             label: "鏄剧ず鍚嶇О",
+                    //             prop: "dpLabel",
+                    //             isRequired: true,
+                    //         }
+                    //     )
+                    // }
+                    // if (this.cols.filter(v => v.prop === 'dpCategory').length === 0) {
+                    //     this.cols.unshift(
+                    //         {
+                    //             label: "鐐逛綅鍒嗙被",
+                    //             prop: "dpCategory",
+                    //             isRequired: true,
+                    //             type: 'option',
+                    //             options: [{
+                    //                 label: '绋嬪簭鍚�',
+                    //                 value: 'ProgName'
+                    //             }, {
+                    //                 label: '绋嬪簭鍐呭',
+                    //                 value: 'ProgContent'
+                    //             }, {
+                    //                 label: '鍒�鍏峰彿',
+                    //                 value: 'ToolNo'
+                    //             }, {
+                    //                 label: '鐘舵��',
+                    //                 value: 'DeviceStatus'
+                    //             }, {
+                    //                 label: '浜ч噺',
+                    //                 value: 'Output'
+                    //             }, {
+                    //                 label: '鍛婅',
+                    //                 value: 'Alarm'
+                    //             }, {
+                    //                 label: '鍏朵粬',
+                    //                 value: 'Other'
+                    //             }]
+                    //         }
+                    //     )
+                    // }
                 } catch (error) {
                     this.cols = []
                 }
diff --git a/src/views/console/workstation/addOptions.js b/src/views/console/workstation/addOptions.js
new file mode 100644
index 0000000..d8f6daa
--- /dev/null
+++ b/src/views/console/workstation/addOptions.js
@@ -0,0 +1,85 @@
+export default {
+    methods: {
+        addOptions(cols) {
+            if (cols.filter(v => v.prop === 'paramChartType').length === 0) {
+                cols.unshift(
+                    {
+                        label: "杩囩▼鍙傛暟灞曠ず鏂瑰紡",
+                        prop: "paramChartType",
+                        isRequired: true,
+                        isRequiredFn: row => {
+                            return row.isProcessParam
+                        },
+                        type: 'option',
+                        options: [{
+                            label: '鏇茬嚎鍥�',
+                            value: 'line'
+                        }, {
+                            label: '鍒嗗竷鍥�',
+                            value: 'distribute'
+                        }],
+                        disabledFn: row => {
+                            console.log(row, '>>>>>>>')
+                            if (row.dpCategory !== "Other") {
+                                return true
+                            } else {
+                                return false
+                            }
+                        }
+                    }
+                )
+            }
+            if (cols.filter(v => v.prop === 'isProcessParam').length === 0) {
+                cols.unshift(
+                    {
+                        label: "杩囩▼鍙傛暟",
+                        prop: "isProcessParam",
+                        isRequired: true,
+                        type: 'boolean',
+                    }
+                )
+            }
+            if (cols.filter(v => v.prop === 'dpLabel').length === 0) {
+                cols.unshift(
+                    {
+                        label: "鏄剧ず鍚嶇О",
+                        prop: "dpLabel",
+                        isRequired: true,
+                    }
+                )
+            }
+            if (cols.filter(v => v.prop === 'dpCategory').length === 0) {
+                cols.unshift(
+                    {
+                        label: "鐐逛綅鍒嗙被",
+                        prop: "dpCategory",
+                        isRequired: true,
+                        type: 'option',
+                        options: [{
+                            label: '绋嬪簭鍚�',
+                            value: 'ProgName'
+                        }, {
+                            label: '绋嬪簭鍐呭',
+                            value: 'ProgContent'
+                        }, {
+                            label: '鍒�鍏峰彿',
+                            value: 'ToolNo'
+                        }, {
+                            label: '鐘舵��',
+                            value: 'DeviceStatus'
+                        }, {
+                            label: '浜ч噺',
+                            value: 'Output'
+                        }, {
+                            label: '鍛婅',
+                            value: 'Alarm'
+                        }, {
+                            label: '鍏朵粬',
+                            value: 'Other'
+                        }]
+                    }
+                )
+            }
+        },
+    }
+}
\ No newline at end of file
diff --git a/src/views/mdc/processParam/index.vue b/src/views/mdc/processParam/index.vue
index 6fab622..1aa5b51 100644
--- a/src/views/mdc/processParam/index.vue
+++ b/src/views/mdc/processParam/index.vue
@@ -1,7 +1,7 @@
 <!--
  * @Date: 2024-04-09 22:11:21
  * @LastEditors: gaoshp
- * @LastEditTime: 2024-10-22 22:30:19
+ * @LastEditTime: 2024-10-27 14:55:20
  * @FilePath: /cps-web/src/views/mdc/processParam/index.vue
  瀹炴椂鐪嬫澘
 -->
@@ -37,7 +37,7 @@
                         </el-row>
                         <TimeLine v-model="timeRange" ref="timeLine"></TimeLine>
                         <el-collapse v-model="activeList">
-                            <el-collapse-item :title="item.description" :name="index" v-for="(item, index) in list"
+                            <el-collapse-item :title="item.deLabel" :name="index" v-for="(item, index) in list"
                                 :key="index">
                                 <div
                                     v-if="(['DeviceStatus', 'ProcessProgram'].includes(item.name) && item?.dayCharts?.series?.length > 1) || (!['DeviceStatus', 'ProcessProgram'].includes(item.name) && item?.dayCharts?.series?.length > 0) && activeList.indexOf(index) > -1">
@@ -179,16 +179,7 @@
             })
         },
         viewData(item) {
-            let data = {
-                FeedOverride: '杩涚粰鍊嶇巼',
-                FeedSpeed: '杩涚粰閫熷害',
-                SpindleOverride: '涓昏酱鍊嶇巼',
-                SpindleSpeed: '涓昏酱杞��',
-                Output: '浜ч噺',
-                ProcessProgram: '绋嬪簭鍚�',
-                DeviceStatus: '璁惧鐘舵��',
-            }
-            this.drawerName = data[item.name]
+            this.drawerName = item.dpLabel
 
             this.$HTTP.post('/api/blade-mdc/process-parameter/item?current=1&size=1500', {
                 endTime: this.timeRange.endTime,
@@ -226,12 +217,14 @@
                 workstationId: this.treeChecked.toString()
             })
             this.list = []
-            this.$HTTP.get('/api/blade-mdc/process-parameter/param', { workstationId: this.treeChecked.toString() }).then(res => {
+            this.$HTTP.get('/api/blade-mdc/process-parameter/params', { workstationId: this.treeChecked.toString() }).then(res => {
                 if (res.code === 200) {
                     console.log('jkjkjkjkj', this.list)
                     this.list = res.data.map(v => {
+                        let name = v.isProcessParam ? 'ProcessProgram' : v.dpName
                         return {
                             ...v,
+                            name: name,
                             height: ['ProcessProgram', 'DeviceStatus'].includes(v.name) ? '100px' : '200px'
                         }
                     })
@@ -245,7 +238,7 @@
             })
         },
         queryChart1(item) {
-            let index = this.list.findIndex(item => item.name === 'DeviceStatus')
+            let index = this.list.findIndex(item => item.dpName === 'DeviceStatus')
             this.list[index] = Object.assign({
                 ...this.list[index],
                 dayCharts: {}
@@ -266,7 +259,8 @@
                     processParameter: item.processParameter
                 }
             }).then(res => {
-                if (['DeviceStatus', 'ProcessProgram'].includes(item.name)) {
+                // if (['DeviceStatus', 'ProcessProgram'].includes(item.name)) {
+                if (item.paramChartType === 'distribute') {
                     this.setDeviceStatusOptions(res.data, item.name)
                 } else {
                     this.setLineOptions(res.data.data, item.name)

--
Gitblit v1.9.3