Browse Source

数据组项搜索

FinalYu 2 years ago
parent
commit
cac83f1504

+ 6 - 1
chuanyi_client2/src/api/datasource.js

@@ -234,8 +234,13 @@ export function updateItemDescribe(data) {
  * @returns {AxiosPromise}
  */
 export function getAllDataModel(params) {
+    let uriParams = '/dataModel/getAllDataModel'
+    uriParams += '?page=' + params.page + '&limit=' + params.limit
+    if (params.operationRule) {
+        uriParams += '&operationRule=' + params.operationRule
+    }
     return request({
-        url: '/dataModel/getAllDataModel?page=' + params.page + '&limit=' + params.limit,
+        url: uriParams,
         headers: {
             isToken: true
         },

+ 40 - 12
chuanyi_client2/src/components/HeaderMain/index.vue

@@ -290,7 +290,9 @@
           </div>
         </div>
       </div>
-      <div v-if="itemDataStep == 2">
+      <div v-if="itemDataStep == 2" style="overflow: auto; height: calc(100% - 40px);">
+        <el-input placeholder="请输入数据项名称进行过滤" style="margin-top: 10px;" size="mini"
+                  @input="chooseItemChangeEvent" v-model="filterChooseItemText"></el-input>
         <el-button size="mini"
                    @click="multipleSetting"
                    style="position: absolute; right: 30px; top: 80px;">批量设置表达式</el-button>
@@ -387,6 +389,7 @@ export default {
       dataModelList: [],
       labelPosition: 'top',
       filterItemText: '',
+      filterChooseItemText: '',
       // 组配置右键布局显示状态
       visibleGroupMenu: false,
       visibleReportMenu: false,
@@ -451,6 +454,7 @@ export default {
       filterItemData: '',
       // 已选择的数据项
       chooseItemDataList: [],
+      chooseItemDataListF: [],
       chooseItemDataListByTree: [],
       dataLineListSelections: [],
       chooseItemDataView: false,
@@ -548,6 +552,17 @@ export default {
       })
       this.leavesList = filterList
     },
+    chooseItemChangeEvent(value) {
+      let arr = JSON.parse(JSON.stringify(this.chooseItemDataListF))
+      if (!value || !value.trim()) {
+        this.chooseItemDataList = arr
+        return
+      }
+      let filterList = arr.filter(v => {
+        return v.itemName.indexOf(value) !== -1
+      })
+      this.chooseItemDataList = filterList
+    },
     /** 数据组组配置点击事件 */
     handleNodeClick(data, node, target) {
       this.closeMenu()
@@ -722,6 +737,7 @@ export default {
             callback: action => {
               this.handleCancel()
               this.chooseItemDataList = []
+              this.chooseItemDataListF = []
               this.leavesChooseList = []
               this.chooseItemDataView = false
               // 刷新组列表
@@ -758,6 +774,7 @@ export default {
       }
       const loading = showLoading(this, '加载中,请稍候···')
       this.chooseItemDataList = []
+      this.chooseItemDataListF = []
       getItemGroupById(id).then(res => {
         loading.close()
         this.createGroupEvent()
@@ -792,6 +809,7 @@ export default {
       }
       const loading = showLoading(this, '加载中,请稍候···')
       this.chooseItemDataList = []
+      this.chooseItemDataListF = []
       getItemGroupById(id).then(res => {
         loading.close()
         let item = res.data
@@ -822,6 +840,7 @@ export default {
       }
       this.chooseItemDataListByTree = arr
       this.chooseItemDataList = arr
+      this.chooseItemDataListF = JSON.parse(JSON.stringify(this.chooseItemDataList))
     },
     /** 删除组信息 */
     delGroup() {
@@ -876,6 +895,7 @@ export default {
     dataSourceChange(val) {
       this.chooseItemDataView = false
       this.chooseItemDataList = []
+      this.chooseItemDataListF = []
       this.chooseItemDataListByTree = []
       this.groupBasicForm.itemList = []
 
@@ -1188,6 +1208,7 @@ export default {
         this.itemDataStep = 2
         if (!res.data) {
           this.chooseItemDataList = itemList
+          this.chooseItemDataListF = JSON.parse(JSON.stringify(this.chooseItemDataList))
           return
         }
         let dataModelList = res.data.dataModelList
@@ -1216,6 +1237,7 @@ export default {
             }
           }
           this.bomCheckKey = new Date().getTime()
+          this.chooseItemDataListF = JSON.parse(JSON.stringify(this.chooseItemDataList))
         })
       }).catch((e) => {
         loading.close()
@@ -1236,29 +1258,35 @@ export default {
           item = this.dataModelList[i]
         }
       }
+      let tempArr = JSON.parse(JSON.stringify(this.chooseItemDataListF))
       // 批量选择
-      if (this.chooseDataItemIndex == -1 && this.dataLineListSelections.length > 0) {
+      if (this.chooseDataItemIndex == '-1' && this.dataLineListSelections.length > 0) {
         this.dataLineListSelections.forEach((selection) => {
-          this.chooseItemDataList.forEach((itemData) => {
+          tempArr.forEach((itemData) => {
             if (itemData.itemName === selection.itemName) {
               // this.$nextTick(() => {
                 itemData.rule = item
                 itemData.dataModelId = item.id
-                this.bomCheckKey = new Date().getTime()
               // })
             }
           })
         })
-        this.dataLineListSelections = []
-        this.dialogDataModelVisible = false
-        return
+      } else {
+        tempArr.forEach((itemData) => {
+          if (itemData.itemName === this.chooseDataItemIndex) {
+            itemData.rule = item
+            itemData.dataModelId = item.id
+          }
+        })
       }
       this.$nextTick(() => {
-        this.chooseItemDataList[this.chooseDataItemIndex].rule = item
-        this.chooseItemDataList[this.chooseDataItemIndex].dataModelId = item.id
+        this.filterChooseItemText = ''
+        this.chooseItemDataList = tempArr
+        this.chooseItemDataListF = JSON.parse(JSON.stringify(this.chooseItemDataList))
         this.bomCheckKey = new Date().getTime()
+        this.dataLineListSelections = []
+        this.dialogDataModelVisible = false
       })
-      this.dialogDataModelVisible = false
     },
     selectionLineChangeHandle (val) {
       this.dataLineListSelections = val
@@ -1272,7 +1300,7 @@ export default {
         })
         return
       }
-      this.chooseDataItemIndex = -1
+      this.chooseDataItemIndex = '-1'
       this.chooseDataModel = null
       this.dialogDataModelVisible = true
     },
@@ -1285,7 +1313,7 @@ export default {
       //   })
       //   return
       // }
-      this.chooseDataItemIndex = index
+      this.chooseDataItemIndex = row.itemName
       this.chooseDataModel = null
       this.dialogDataModelVisible = true
     },

+ 17 - 0
chuanyi_client2/src/views/data_model/index.vue

@@ -4,6 +4,14 @@
     <el-button type="primary" class="cy-nav-btn" icon="el-icon-circle-plus-outline" size="mini" @click="handleAdd">新增</el-button>
     <el-divider></el-divider>
     <div class="cy-main">
+      <div style="margin-bottom: 10px;">
+        <el-input placeholder="请输入名称或者四则运算表达式"
+                  v-model="searchTxt"
+                  style="margin-left: 5px; width: 300px;"
+                  prefix-icon="el-icon-search">
+        </el-input>
+        <el-button style="margin-left: 5px;" @click="searchRuleEvent">查询</el-button>
+      </div>
       <el-table
           :data="tableData" border :stripe="true"
           :header-cell-style="{background: '#E8E8E8'}"
@@ -138,6 +146,7 @@ export default {
       tableLimit: 10,
       tableTotal: 0,
       tableData: [],
+      searchTxt: '',
       dataModelForm: {
         id: '',
         mathParameter: 'calcVal',
@@ -308,6 +317,11 @@ export default {
         }
       })
     },
+    /** 搜索 */
+    searchRuleEvent() {
+      this.tablePage = 1
+      this.getAllDataModel()
+    },
     /** 数据条数改变 */
     sizeChangeEvent(val) {
       this.tablePage = 1
@@ -326,6 +340,9 @@ export default {
         'page': this.tablePage,
         'limit': this.tableLimit
       }
+      if (this.searchTxt && this.searchTxt.trim()) {
+        params.operationRule = this.searchTxt
+      }
       getAllDataModel(params).then(res => {
         loading.close()
         if (!res.data) {

+ 51 - 8
chuanyi_client2/src/views/group_item/index.vue

@@ -1,6 +1,7 @@
 <template>
   <div class="cqcy-content" v-if="chooseGroupId">
     <div style="margin-bottom: 10px;">
+      <span style="color: #474646; font-size: 14px;">数据组:</span>
       <el-select v-model="chooseGroupId" disabled size="mini">
         <el-option
             v-for="dict in groupDataList"
@@ -9,6 +10,14 @@
             :value="dict.id"
         ></el-option>
       </el-select>
+      <span style="margin-left: 5px; color: #474646; font-size: 14px;">数据项名称:</span>
+      <el-input placeholder="请输入数据项名称"
+                size="mini"
+                style="width: 200px;"
+                @input="itemChangeEvent"
+                v-model="filterItemText"
+                prefix-icon="el-icon-search">
+      </el-input>
       <el-checkbox v-model="groupRunStatus" size="mini" style="margin-left: 20px;"
                    @change="groupRunCheckboxEvent" title="固定每5秒刷新一次数据">实时数据</el-checkbox>
     </div>
@@ -26,11 +35,24 @@
       <template v-if="groupRunStatus">
         <el-table-column prop="dataType" label="数据项类型" align="center" width="100">
         </el-table-column>
-        <el-table-column prop="dataValue" label="数据项值" align="center" width="120">
+        <el-table-column prop="operationRule" label="表达式" align="center" width="200">
+          <template slot-scope="scope">
+            {{ scope.row.operationRule ? scope.row.operationRule : '默认值' }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="dataOrgValue" label="原始数据值" align="center" width="100">
+          <template slot-scope="scope">
+            {{ scope.row.dataOrgValue ? scope.row.dataOrgValue : '' }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="dataValue" label="数据值" align="center" width="100">
+          <template slot-scope="scope">
+            {{ (scope.row.dataValue && scope.row.dataValue != 'undefined') ? scope.row.dataValue : '' }}
+          </template>
         </el-table-column>
-        <el-table-column prop="dataSourceName" label="数据源名称" align="center" width="200">
+        <el-table-column prop="dataSourceName" label="数据源名称" align="center" width="180">
         </el-table-column>
-        <el-table-column prop="createTime" label="运行时间" align="center" width="120">
+        <el-table-column prop="createTime" label="取值时间" align="center" width="180">
         </el-table-column>
       </template>
       <template v-else>
@@ -40,7 +62,12 @@
             <span>{{ scope.row.describe }}</span>
           </template>
         </el-table-column>
-        <el-table-column prop="dataSourceName" label="数据源名称" align="center" width="200">
+        <el-table-column prop="dataSourceName" label="数据源名称" align="center" width="180">
+        </el-table-column>
+        <el-table-column prop="operationRule" label="表达式" align="center" width="200">
+          <template slot-scope="scope">
+            {{ scope.row.operationRule ? scope.row.operationRule : '默认值' }}
+          </template>
         </el-table-column>
         <el-table-column label="操作" align="center" width="100">
           <template slot-scope="scope">
@@ -63,11 +90,13 @@ export default {
   data() {
     return {
       itemDataList: [],
+      itemDataListF: [],
       groupDataList: [],
       chooseGroup: null,
       chooseGroupId: null,
       groupRunStatus: false,
-      timeInterval: null
+      timeInterval: null,
+      filterItemText: '',
     }
   },
   watch: {
@@ -76,8 +105,6 @@ export default {
     },
     '$route.query.t': {
       handler(o, n) {
-        // console.log(o)
-        // console.log(n)
       }
     },
     deep: true
@@ -89,6 +116,17 @@ export default {
     }
   },
   methods: {
+    itemChangeEvent(value) {
+      let arr = JSON.parse(JSON.stringify(this.itemDataListF))
+      if (!value || !value.trim()) {
+        this.leavesList = arr
+        return
+      }
+      let filterList = arr.filter(v => {
+        return v.itemName.indexOf(value) !== -1
+      })
+      this.itemDataList = filterList
+    },
     /** 读取参数 */
     readParams() {
       // let groupListStorage = sessionStorage.getItem('GROUP_LIST') ? sessionStorage.getItem('GROUP_LIST') : '[]'
@@ -97,7 +135,7 @@ export default {
       this.chooseGroupId = parseInt(groupId)
       this.groupRunStatus = false
       this.getGroupById(this.chooseGroupId)
-      this.getItemValueById()
+      // this.getItemValueById()
     },
     /** 运行状态值 */
     groupRunCheckboxEvent(val) {
@@ -115,20 +153,24 @@ export default {
         return
       }
       getItemValueById(this.chooseGroup.id).then(res => {
+        this.filterItemText = ''
         this.itemDataList = res.data
         // 避免布尔类型时页面无法显示数据
         for (let i = 0; i < this.itemDataList.length; i ++) {
           this.itemDataList[i].dataValue += ''
         }
+        this.itemDataListF = JSON.parse(JSON.stringify(this.itemDataList))
       }).catch((e) => {
       })
       let temp = setInterval(() => {
         getItemValueById(this.chooseGroup.id).then(res => {
+          this.filterItemText = ''
           this.itemDataList = res.data
           // 避免布尔类型时页面无法显示数据
           for (let i = 0; i < this.itemDataList.length; i ++) {
             this.itemDataList[i].dataValue += ''
           }
+          this.itemDataListF = JSON.parse(JSON.stringify(this.itemDataList))
         }).catch((e) => {
         })
       }, 5 * 1000)
@@ -153,6 +195,7 @@ export default {
           'groupName': this.chooseGroup.groupName
         }]
         this.itemDataList = this.chooseGroup.itemList
+        this.itemDataListF = JSON.parse(JSON.stringify(this.itemDataList))
       }).catch((e) => {
         loading.close()
         this.$alert(e, '查询失败!', {