Browse Source

王帅-主属性

ws 1 năm trước cách đây
mục cha
commit
7c56bb308f

+ 1 - 1
chuanyi-admin/src/api/system/driver.js

@@ -17,7 +17,7 @@ export function getAllDataSourceDriver() {
  */
 export function getOpcDaDriverEnum() {
   return request({
-    url: '/dataSource/getOpcDaDriverEnum',
+    url: '/dataSource/getAllDataSouceCls',
     method: 'get'
   })
 }

+ 78 - 6
chuanyi-admin/src/views/system/driver/index.vue

@@ -38,7 +38,7 @@
       <el-form ref="driverForm" :model="driverForm" :rules="rules" label-width="140px">
         <el-row style="margin-bottom: 5px">
           <el-col>
-            <el-form-item label="驱动:" prop="driver">
+            <el-form-item label="驱动:" prop="driver" class="required-label">
               <el-select
                 v-if="driverForm.id"
                 v-model="driverForm.driver"
@@ -53,8 +53,8 @@
               </el-select>
             </el-form-item>
           </el-col>
-          <el-col :span="12">
-            <el-form-item label="数据项名称:" prop="items" class="cy-item-name">
+          <el-col>
+            <el-form-item label="主属性:" prop="items" class="cy-item-name required-label">
               <el-tag
                 v-for="tag in dynamicTags"
                 :key="tag.itemName"
@@ -76,6 +76,29 @@
               <el-button v-else class="button-new-tag" size="small" @click="showInput">+ 添加</el-button>
             </el-form-item>
           </el-col>
+          <el-col :span="12" style="margin-top: 50px;">
+            <el-form-item label="附属属性:" prop="itemsSub" class="cy-item-name">
+              <el-tag
+                v-for="tag in dynamicTagsSub"
+                :key="tag.itemName"
+                closable
+                :disable-transitions="false"
+                @close="handleTagCloseSub(tag)"
+              >
+                {{ tag.itemName }}
+              </el-tag>
+              <el-input
+                v-if="inputVisibleSub"
+                ref="saveTagInput"
+                v-model="inputValueSub"
+                class="input-new-tag"
+                size="small"
+                @keyup.enter.native="handleInputConfirmSub"
+                @blur="handleInputConfirmSub"
+              />
+              <el-button v-else class="button-new-tag" size="small" @click="showInputSub">+ 添加</el-button>
+            </el-form-item>
+          </el-col>
         </el-row>
       </el-form>
       <div slot="footer" class="dialog-footer" style="margin-top: 20px;">
@@ -113,7 +136,10 @@ export default {
       open: false,
       inputVisible: false,
       inputValue: '',
+      inputVisibleSub: false,
+      inputValueSub: '',
       dynamicTags: [],
+      dynamicTagsSub: [],
       driverForm: {
         id: null,
         driver: null,
@@ -182,7 +208,19 @@ export default {
               'value': data.clsId
             }
           }
-          this.dynamicTags = data.driverBasicItemList
+          const tag = []
+          const tagSub = []
+          if (data.driverBasicItemList && data.driverBasicItemList.length > 0) {
+            data.driverBasicItemList.forEach(item => {
+              if (item.itemType === 1) {
+                tag.push(item)
+              } else {
+                tagSub.push(item)
+              }
+            })
+          }
+          this.dynamicTags = tag
+          this.dynamicTagsSub = tagSub
         })
       })
     },
@@ -218,9 +256,20 @@ export default {
         params.driverBasicItemList.push({
           id: tag.id,
           driverId: tag.driverId,
-          itemName: tag.itemName
+          itemName: tag.itemName,
+          itemType: 1
         })
       })
+      if (this.dynamicTagsSub && this.dynamicTagsSub.length > 0) {
+        this.dynamicTagsSub.forEach((tag) => {
+          params.driverBasicItemList.push({
+            id: tag.id,
+            driverId: tag.driverId,
+            itemName: tag.itemName,
+            itemType: 0
+          })
+        })
+      }
       if (this.driverForm.id) {
         params.id = this.driverForm.id
         updateDataSourceDriver(params).then((response) => {
@@ -265,6 +314,9 @@ export default {
     handleTagClose(tag) {
       this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1)
     },
+    handleTagCloseSub(tag) {
+      this.dynamicTagsSub.splice(this.dynamicTagsSub.indexOf(tag), 1)
+    },
     /** 显示数据项输入框 */
     showInput() {
       this.inputVisible = true
@@ -272,6 +324,12 @@ export default {
         this.$refs.saveTagInput.$refs.input.focus()
       })
     },
+    showInputSub() {
+      this.inputVisibleSub = true
+      this.$nextTick(_ => {
+        this.$refs.saveTagInput.$refs.input.focus()
+      })
+    },
     /** 数据项输入完成事件 */
     handleInputConfirm() {
       const inputValue = this.inputValue
@@ -286,9 +344,23 @@ export default {
       this.inputVisible = false
       this.inputValue = ''
     },
+    handleInputConfirmSub() {
+      const inputValue = this.inputValueSub
+      if (inputValue) {
+        const isInArray = this.dynamicTagsSub.some(item => item.itemName === inputValue)
+        if (!isInArray) {
+          this.dynamicTagsSub.push({
+            itemName: inputValue
+          })
+        }
+      }
+      this.inputVisibleSub = false
+      this.inputValueSub = ''
+    },
     /** 表单重置 */
     reset() {
       this.dynamicTags = []
+      this.dynamicTagsSub = []
       this.driverForm = {
         id: null,
         driver: null,
@@ -308,7 +380,7 @@ export default {
 </script>
 
 <style rel="stylesheet/scss" lang="scss">
- .el-form-item__label::before {
+ .required-label>label::before {
   content: "*";
   color: #ff4949;
   margin-right: 4px;

+ 1 - 1
cqcy-ei/cqcy-ei-da/src/main/resources/mapper/DataSourceDao.xml

@@ -19,7 +19,7 @@
 
     <sql id="driverBasicItem">
         id
-        , driver_id, item_name
+        , driver_id, item_name, item_type
     </sql>
 
     <insert id="addDataSource">