Explorar el Código

基础库和联锁新增页面(有bug,待改)

yuhan hace 9 meses
padre
commit
a42424049e

+ 73 - 3
src/views/module_interLock/InterlockSummary/modules/InterlockSummaryForm.vue

@@ -5,17 +5,47 @@
         <a-row>
           <a-col :span="12">
             <a-form-model-item label="装置" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockApparatusId">
-              <a-input v-model="model.interlockApparatusId" placeholder="请选择装置"></a-input>
+              <a-select
+                v-model="model.interlockApparatusId"
+                show-search
+                placeholder="请选择装置"
+                @change="handleApparatusChange"
+                >
+                <!-- option-filter-prop="children" -->
+                <!-- :filter-option="filterOption" -->
+                <!-- @focus="handleFocus" -->
+                <!-- @blur="handleBlur" -->
+                <a-select-option v-for="(item) in apparatusData" :key="item.key" :value="item.key">{{ item.title }}</a-select-option>
+              </a-select>
             </a-form-model-item>
           </a-col>
           <a-col :span="12">
             <a-form-model-item label="系统" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockSystemId">
-              <a-input v-model="model.interlockSystemId" placeholder="请选择系统"></a-input>
+              <a-select
+                v-model="model.interlockSystemId"
+                show-search
+                placeholder="请选择系统"
+                @change="handleSystemChange"
+                >
+                <!-- option-filter-prop="children" -->
+                <!-- :filter-option="filterOption" -->
+                <!-- @focus="handleFocus" -->
+                <!-- @blur="handleBlur" -->
+                <a-select-option v-for="(item) in systemData" :key="item.key" :value="item.key">{{ item.title }}</a-select-option>
+              </a-select>
             </a-form-model-item>
           </a-col>
           <a-col :span="12">
             <a-form-model-item label="联锁名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockName">
-              <a-input v-model="model.interlockName" placeholder="请输入联锁名称"  ></a-input>
+              <a-auto-complete
+                v-model="model.interlockName"
+                :data-source="interLockData"
+                placeholder="请输入联锁名称"
+                @search="interLockSearch"
+                />
+                <!-- @select="interLockSelect" -->
+                <!-- @change="onChange" -->
+                <!-- style="width: 200px" -->
             </a-form-model-item>
           </a-col>
           <!-- <a-col :span="24">
@@ -143,11 +173,15 @@
         validatorRules: {
         },
         url: {
+          interLockSelect: '/sys/dict/loadTreeData',
           add: "/summary/interlockSummary/add",
           edit: "/summary/interlockSummary/edit",
           queryById: "/summary/interlockSummary/queryById"
         },
         dianweiOptions: dianweiOptions,
+        apparatusData: [],
+        systemData: [],
+        interLockData: []
       }
     },
     computed: {
@@ -155,11 +189,47 @@
         return this.disabled
       },
     },
+    watch: {
+      'model.interlockName'(val) {
+        console.log('value', val);
+      },
+    },
     created () {
+      this.getData('0', 'apparatusData')
        //备份model原始值
       this.modelDefault = JSON.parse(JSON.stringify(this.model));
     },
     methods: {
+      // 获取装置/系统/联锁数据--默认获取装置数据
+      getData(pid, dataName){
+        let param = {
+          pid: pid,
+          tableName: 'interlock_base',
+          text: 'interlock_name',
+          code: 'id',
+          pidField: 'pid',
+          hasChildField: 'has_child',
+          condition: ''
+        }
+        getAction(this.url.interLockSelect,param).then(res=>{
+          if(res.success){
+            this[dataName] = res.result
+          }
+        })
+      },
+      // 装置选择改变时
+      handleApparatusChange(e){
+        console.log(e)
+        this.getData(e, 'systemData')
+      },
+      // 系统选择改变时
+      handleSystemChange(e){
+        console.log(e)
+        this.getData(e, 'interLockData')
+      },
+      interLockSearch(searchText){
+        this.interLockData = !searchText ? [] : [searchText, searchText.repeat(2), searchText.repeat(3)]
+      },
       displayRender({ labels }) {
         return labels[labels.length - 1];
       },

+ 4 - 4
src/views/module_interLock/baseInterLock/modules/BaseInterLockModal.vue

@@ -21,7 +21,7 @@
         </a-form-model-item>
         <template v-if="model.interlockType !== '0'">
           <a-form-model-item label="父级节点" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pid">
-            <!-- <j-tree-select
+            <j-tree-select
               ref="treeSelect"
               placeholder="请选择父级节点"
               v-model="model.pid"
@@ -31,14 +31,14 @@
               pidValue="0"
               hasChildField="has_child"
               >
-            </j-tree-select> -->
-            <a-tree-select
+            </j-tree-select>
+            <!-- <a-tree-select
               v-model="model.pid"
               style="width: 100%"
               :tree-data="interlockTwoTree"
               placeholder="请选择"
               tree-default-expand-all
-              ></a-tree-select>
+              ></a-tree-select> -->
               <!-- :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" -->
           </a-form-model-item>
         </template>