瀏覽代碼

opc优化

hfxc226 2 年之前
父節點
當前提交
932580812f
共有 2 個文件被更改,包括 77 次插入2 次删除
  1. 26 0
      src/api/remote/opc.js
  2. 51 2
      src/views/remote/opc/modules/BaseForm.vue

+ 26 - 0
src/api/remote/opc.js

@@ -49,6 +49,32 @@ export function updateRemoteOpc (parameter) {
   })
 }
 
+/**
+ * update func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function addRemoteOpcGroup (parameter) {
+  return axios({
+    url: '/remote/opcs/group/add/' + parameter,
+    method: 'PUT'
+  })
+}
+
+/**
+ * update func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function delRemoteOpcGroup (parameter) {
+  return axios({
+    url: '/remote/opcs/group/del/' + parameter,
+    method: 'PUT'
+  })
+}
+
 /**
  * fetch single func
  * parameter: { }

+ 51 - 2
src/views/remote/opc/modules/BaseForm.vue

@@ -75,8 +75,10 @@
           >
             <a-input
               disabled
-              style="width: 100%"
+              style="width: 60%"
               v-decorator="['positionNum', {rules: [{required: false, message: '点位不能为空'}]}]"/>
+            <a-button type="primary" style="width: 20%" @click="handleAddGroup">采集</a-button>
+            <a-button type="default" style="width: 20%" @click="handleDelGroup">终止</a-button>
           </a-form-item>
         </row-item>
         <row-item>
@@ -387,7 +389,14 @@
 
 <script>
 import pick from 'lodash.pick'
-import { addRemoteOpc, updateRemoteOpc, fetchRemoteOpcByPositionNumAndLine } from '@/api/remote/opc'
+import {
+  addRemoteOpc,
+  addRemoteOpcGroup,
+  delRemoteOpcGroup,
+  updateRemoteOpc,
+  fetchRemoteOpcByPositionNumAndLine,
+  fetchRemoteOpc
+} from '@/api/remote/opc'
 import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
 import { getSbPositionTree } from '@/api/sb/position'
 import ColorModal from './ColorModal'
@@ -488,6 +497,46 @@ export default {
         ])))
       })
     },
+    handleAddGroup () {
+      const { form: { getFieldValue } } = this
+      const id = getFieldValue('id')
+      if (id == null || id === '') {
+        this.$message.error('请先保存点位信息')
+        return
+      }
+      fetchRemoteOpc({ id: id }).then(res => {
+        if (res.data.positionNum == null || res.data.positionNum === '') {
+          this.$message.error('请设置点位')
+          return
+        }
+        addRemoteOpcGroup(res.data.positionNum)
+          .then((res) => {
+            this.$message.info(res.data)
+          }).catch(() => {
+            this.confirmLoading = false
+          })
+      })
+    },
+    handleDelGroup () {
+      const { form: { getFieldValue } } = this
+      const id = getFieldValue('id')
+      if (id == null || id === '') {
+        this.$message.error('请先保存点位信息')
+        return
+      }
+      fetchRemoteOpc({ id: id }).then(res => {
+        if (res.data.positionNum == null || res.data.positionNum === '') {
+          this.$message.error('请设置点位')
+          return
+        }
+        delRemoteOpcGroup(res.data.positionNum)
+          .then((res) => {
+            this.$message.info(res.data)
+          }).catch(() => {
+            this.confirmLoading = false
+          })
+      })
+    },
     save () {
       const { form: { validateFieldsAndScroll } } = this
       this.confirmLoading = true