|
@@ -0,0 +1,794 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-dialog
|
|
|
+ :title="dataItemDialogTitle"
|
|
|
+ width="80%"
|
|
|
+ top="10vh"
|
|
|
+ class="cy-custom-dialog"
|
|
|
+ center
|
|
|
+ v-dialog-drag-and-zoom
|
|
|
+ v-if="dataItemDialogVisible"
|
|
|
+ :before-close="itemDialogClose"
|
|
|
+ :visible.sync="dataItemDialogVisible"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :append-to-body="true">
|
|
|
+ <el-form label-width='100px' style="display: flex;">
|
|
|
+ <el-form-item label='数据源:' style="margin-bottom: 0px; width: 300px;">
|
|
|
+ <el-select v-model="groupBasicForm.dataSourceId" disabled>
|
|
|
+ <el-option
|
|
|
+ v-for="dict in dataSourceList"
|
|
|
+ :key="dict.id"
|
|
|
+ :label="dict.dataSourceName"
|
|
|
+ :value="dict.id"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="itemDataStep == 2" label='数据项:' style="margin-bottom: 0px; width: 300px;">
|
|
|
+ <el-input placeholder="请输入数据项名称进行过滤" style=""
|
|
|
+ @input="chooseItemChangeEvent" v-model="filterChooseItemText"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div v-if="itemDataStep == 1" style="display: flex; height: calc(100% - 36px); overflow: auto;">
|
|
|
+ <!-- 数据项 -->
|
|
|
+ <div class="cy-transform-data">
|
|
|
+ <el-divider content-position="left">数据项</el-divider>
|
|
|
+ <div class="cy-line" style="padding-bottom: 10px;">
|
|
|
+ <div style="height: 35px;">
|
|
|
+ <el-input placeholder="输入关键字进行过滤" v-model="filterItemData" size="mini"
|
|
|
+ prefix-icon="el-icon-search"></el-input>
|
|
|
+ </div>
|
|
|
+ <div style="height: calc(100% - 35px); overflow: auto;">
|
|
|
+ <div :style="hasLeavesFlag == 1 ? 'height: 40%; overflow: auto;' : 'height: 100%; overflow: auto;'">
|
|
|
+ <el-tree class="cy-item-tree"
|
|
|
+ ref="itemTree"
|
|
|
+ :indent="10"
|
|
|
+ :load="loadGroupDataItemNode"
|
|
|
+ :props="groupProps"
|
|
|
+ lazy
|
|
|
+ node-key="id"
|
|
|
+ :filter-node-method="filterItemEvent"
|
|
|
+ @node-click="handleItemNodeClick"
|
|
|
+ :show-checkbox="hasLeavesFlag == 1 ? false : true"
|
|
|
+ :check-on-click-node="true"
|
|
|
+ :highlight-current="true"
|
|
|
+ :default-expand-all="itemDataExpandAll">
|
|
|
+ <span class="custom-tree-node" slot-scope="{ node, data }">
|
|
|
+ <svg-icon v-if="data.isLeaf" icon-class="file-bg"/>
|
|
|
+ <svg-icon v-else-if="node.expanded" icon-class="folder-open" style="width: 1.2em;"/>
|
|
|
+ <svg-icon v-else icon-class="folder"/>
|
|
|
+ <span :title='node.label || "-"' style="margin-left: 2px;">{{ node.label }}</span>
|
|
|
+ </span>
|
|
|
+ </el-tree>
|
|
|
+ </div>
|
|
|
+ <div v-if="hasLeavesFlag == 1" style="height: 60%; overflow: auto;">
|
|
|
+ <el-divider content-position="left" style="margin-bottom: 15px!important;">
|
|
|
+ <i class="el-icon-collection-tag"></i>
|
|
|
+ <span>(共{{ leavesList.length }}项)</span>
|
|
|
+ </el-divider>
|
|
|
+ <el-input placeholder="输入关键字进行过滤"
|
|
|
+ style="margin-top: -10px;width: calc(100% - 60px);" size="mini"
|
|
|
+ @input="itemChangeEvent" v-model="filterItemText"></el-input>
|
|
|
+ <el-checkbox v-model="isSelectAllItemData" @change="handleCheckAllChange"
|
|
|
+ style="margin-left: 5px;">全选</el-checkbox>
|
|
|
+ <div class="cy-leaves-div">
|
|
|
+ <el-checkbox-group v-model="leavesChooseList" @change="handleCheckedCitiesChange">
|
|
|
+ <el-checkbox v-for="leaves in leavesList" :label="leaves">{{ leaves.itemName }}</el-checkbox>
|
|
|
+ </el-checkbox-group>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 操作按钮 -->
|
|
|
+ <div class="cy-transform-btn">
|
|
|
+ <el-row>
|
|
|
+ <el-button size="mini" @click="addCheckNodesBtnEvent">添加 >></el-button>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-button size="mini" @click="removeCheckNodesBtnEvent"><< 移除</el-button>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-button size="mini" @click="removeAllCheckNodesBtnEvent">全部移除</el-button>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ <!-- 已选择数据项 -->
|
|
|
+ <div class="cy-transform-data">
|
|
|
+ <el-divider content-position="left">已选择数据项({{ chooseItemDataListByTree.length }})</el-divider>
|
|
|
+ <div class="cy-line">
|
|
|
+ <div style="height: 100%; overflow: auto;">
|
|
|
+ <el-checkbox v-model="isSelectAllItem" @change="selectAllItem" style="margin-left: 24px;">全选</el-checkbox>
|
|
|
+ <el-tree :data="chooseItemDataListByTree"
|
|
|
+ ref="chooseItemTree"
|
|
|
+ :indent="0"
|
|
|
+ node-key="id"
|
|
|
+ show-checkbox
|
|
|
+ :check-on-click-node="true"
|
|
|
+ :highlight-current="true"
|
|
|
+ :default-expand-all="true"
|
|
|
+ @check-change="handleItemCheckChange">
|
|
|
+ <span class="custom-tree-node" slot-scope="{ node, data }">
|
|
|
+ <svg-icon v-if="!data.children" icon-class="file-bg"/>
|
|
|
+ <svg-icon v-else-if="node.expanded" icon-class="folder-open"/>
|
|
|
+ <svg-icon v-else icon-class="folder"/>
|
|
|
+ <span :title='node.label || data.itemName' style="margin-left: 2px;">{{ node.label || data.itemName }}</span>
|
|
|
+ </span>
|
|
|
+ </el-tree>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-if="itemDataStep == 2" style="overflow: auto; height: calc(100% - 40px);">
|
|
|
+ <el-button size="mini"
|
|
|
+ @click="multipleSetting"
|
|
|
+ style="position: absolute; right: 30px; top: 80px;">批量设置表达式</el-button>
|
|
|
+ <el-button size="mini"
|
|
|
+ @click="multipleSettingEventReport"
|
|
|
+ style="position: absolute; right: 160px; top: 80px; display: none;">批量配置事件驱动</el-button>
|
|
|
+ <el-table
|
|
|
+ ref="multipleTable"
|
|
|
+ :data="chooseItemDataList"
|
|
|
+ :key="bomCheckKey"
|
|
|
+ border
|
|
|
+ @selection-change="selectionLineChangeHandle"
|
|
|
+ @sort-change="sortChange"
|
|
|
+ :stripe="true"
|
|
|
+ :header-cell-style="{background: '#E8E8E8'}"
|
|
|
+ style="width: 100%; margin-top: 10px;">
|
|
|
+ <el-table-column
|
|
|
+ type="selection"
|
|
|
+ width="55">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ sortable="custom"
|
|
|
+ label="数据项名称"
|
|
|
+ prop="itemName">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ sortable="custom"
|
|
|
+ label="四则运算表达式"
|
|
|
+ prop="rule.operationRule"
|
|
|
+ width="300">
|
|
|
+ </el-table-column>
|
|
|
+ <!-- <el-table-column-->
|
|
|
+ <!-- align="center"-->
|
|
|
+ <!-- label="事件报表"-->
|
|
|
+ <!-- prop="tableReportName"-->
|
|
|
+ <!-- width="300">-->
|
|
|
+ <!-- </el-table-column>-->
|
|
|
+ <el-table-column label="操作" align="center" width="300">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ @click="handleChoose(scope.$index, scope.row)">选择表达式</el-button>
|
|
|
+ <!-- <el-button-->
|
|
|
+ <!-- size="mini"-->
|
|
|
+ <!-- @click="handleReportEventConfig(scope.$index, scope.row)">事件驱动配置</el-button>-->
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ <span slot='footer'>
|
|
|
+ <el-button type="primary" v-if="itemDataStep == 1" @click="itemDialogSave1">下一步</el-button>
|
|
|
+ <el-button type="primary" v-if="itemDataStep == 2" @click="itemDialogSave2">确定</el-button>
|
|
|
+ <el-button @click="itemDialogClose">取消</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ title="选择四则运算表达式"
|
|
|
+ width="500px"
|
|
|
+ top="10vh"
|
|
|
+ center
|
|
|
+ v-dialog-drag
|
|
|
+ v-if="dialogDataModelVisible"
|
|
|
+ :before-close="dialogDataModelClose"
|
|
|
+ :visible.sync="dialogDataModelVisible"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :append-to-body="true">
|
|
|
+ <el-select v-model="chooseDataModel" filterable clearable placeholder="请选择表达式" style="width: 100%;">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in this.dataModelList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.title"
|
|
|
+ :value="item.id">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <div style="width: 100%; text-align: center; margin-top: 20px;">
|
|
|
+ <el-button type="primary" @click="saveDataModelEvent">确定</el-button>
|
|
|
+ <el-button @click="dialogDataModelClose">取消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ customCompare,
|
|
|
+ extractDataItemValues,
|
|
|
+ showAlertMsgWin,
|
|
|
+ showAlertWin,
|
|
|
+ showLoading,
|
|
|
+ traverseNode,
|
|
|
+ traverseVisible
|
|
|
+} from "@/utils/cqcy";
|
|
|
+import {
|
|
|
+ getAllDataModel,
|
|
|
+ getAllDataSource,
|
|
|
+ getAllItemGroup,
|
|
|
+ getNextAllItem,
|
|
|
+ getTableItemGroupById
|
|
|
+} from "@/api/datasource";
|
|
|
+import {v4 as uuidv4} from "uuid";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "DataSourceItem",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ dataItemDialogTitle: '选择数据项',
|
|
|
+ dataItemDialogVisible: false,
|
|
|
+ dialogDataModelVisible: false,
|
|
|
+ dataSourceList: [],
|
|
|
+ itemDataStep: 1,
|
|
|
+ filterChooseItemText: '',
|
|
|
+ filterItemData: '',
|
|
|
+ filterItemText: '',
|
|
|
+ itemDataExpandAll: false,
|
|
|
+ isSelectAllItemData: false,
|
|
|
+ isSelectAllItem: false,
|
|
|
+ chooseDataModel: null,
|
|
|
+ dataModelList: [],
|
|
|
+ leavesList: [],
|
|
|
+ leavesListF: [],
|
|
|
+ leavesChooseList: [],
|
|
|
+ itemDataListByTree: [],
|
|
|
+ chooseItemDataList: [],
|
|
|
+ chooseItemDataListF: [],
|
|
|
+ chooseItemDataListByTree: [],
|
|
|
+ dataLineListSelections: [],
|
|
|
+ tempItemList: [],
|
|
|
+ bomCheckKey: 0,
|
|
|
+ groupProps: {
|
|
|
+ isLeaf: 'leaf'
|
|
|
+ },
|
|
|
+ groupBasicForm: {
|
|
|
+ groupId: null,
|
|
|
+ dataSourceId: null,
|
|
|
+ itemList: []
|
|
|
+ },
|
|
|
+ // 驱动数据返回类型:0 通用 1 WINCC
|
|
|
+ hasLeavesFlag: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ props: ['chooseGroup'],
|
|
|
+ watch: {
|
|
|
+ filterItemData(val) {
|
|
|
+ this.$refs.itemTree.filter(val)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ /** 显示弹窗 */
|
|
|
+ show() {
|
|
|
+ this.groupBasicForm.dataSourceId = this.chooseGroup.dataSourceId
|
|
|
+ this.getDataSourceList()
|
|
|
+ },
|
|
|
+ /** 自定义排序 */
|
|
|
+ sortChange({ prop, order }) {
|
|
|
+ this.chooseItemDataList.sort(customCompare(prop, order))
|
|
|
+ },
|
|
|
+ /** 动态搜索事件 */
|
|
|
+ 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
|
|
|
+ },
|
|
|
+ /** 动态过滤事件 */
|
|
|
+ filterItemEvent(value, data) {
|
|
|
+ if (!value) return true
|
|
|
+ return data.label.indexOf(value) !== -1
|
|
|
+ },
|
|
|
+ /** 数据多选事件 */
|
|
|
+ selectionLineChangeHandle (val) {
|
|
|
+ this.dataLineListSelections = val
|
|
|
+ },
|
|
|
+ /** 数据项全选事件 */
|
|
|
+ selectAllItem() {
|
|
|
+ const data = traverseNode(this.$refs.chooseItemTree.store.root.childNodes)
|
|
|
+ if (this.isSelectAllItem) {
|
|
|
+ let arr = traverseVisible(data)
|
|
|
+ let ids = Array.from(arr, ({ id }) => id)
|
|
|
+ this.$refs.chooseItemTree.setCheckedKeys(ids)
|
|
|
+ } else {
|
|
|
+ this.$refs.chooseItemTree.setCheckedNodes([])
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /** 全选事件 */
|
|
|
+ handleCheckAllChange(val) {
|
|
|
+ this.leavesChooseList = val ? this.leavesList : []
|
|
|
+ },
|
|
|
+ /** 全选事件 */
|
|
|
+ handleCheckedCitiesChange(value) {
|
|
|
+ let checkedCount = value.length
|
|
|
+ this.isSelectAllItemData = checkedCount === this.leavesList.length
|
|
|
+ },
|
|
|
+ /** 选择数据模型 */
|
|
|
+ handleChoose(index, row) {
|
|
|
+ // if (this.dataLineListSelections.length > 1) {
|
|
|
+ // this.$message({
|
|
|
+ // message: '请选择一项数据项',
|
|
|
+ // type: 'warning'
|
|
|
+ // })
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ this.chooseDataItemIndex = row.itemName
|
|
|
+ this.chooseDataModel = row.dataModelId
|
|
|
+ this.dialogDataModelVisible = true
|
|
|
+ },
|
|
|
+ /**数据项单项选择判断 */
|
|
|
+ handleItemCheckChange(data, checked, indeterminate) {
|
|
|
+ const tdata = traverseNode(this.$refs.chooseItemTree.store.root.childNodes)
|
|
|
+ let arr = traverseVisible(tdata)
|
|
|
+ if (arr.length == this.$refs.chooseItemTree.getCheckedNodes().length) {
|
|
|
+ this.isSelectAllItem = true
|
|
|
+ } else {
|
|
|
+ this.isSelectAllItem = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /** 批量选择数据模型 */
|
|
|
+ multipleSetting() {
|
|
|
+ if (this.dataLineListSelections.length == 0) {
|
|
|
+ showAlertMsgWin(this, null, '请至少选择一项数据项!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.chooseDataItemIndex = '-1'
|
|
|
+ this.chooseDataModel = null
|
|
|
+ this.dialogDataModelVisible = true
|
|
|
+ },
|
|
|
+ /** 批量配置事件驱动 */
|
|
|
+ multipleSettingEventReport() {
|
|
|
+ if (this.dataLineListSelections.length == 0) {
|
|
|
+ showAlertMsgWin(this, null, '请至少选择一项数据项!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.chooseDataItemIndex = '-1'
|
|
|
+ this.dialogReportEventConfigVisible = true
|
|
|
+ },
|
|
|
+ /** 数据项搜索条件 */
|
|
|
+ itemChangeEvent(value) {
|
|
|
+ let arr = JSON.parse(JSON.stringify(this.leavesListF))
|
|
|
+ if (!value || !value.trim()) {
|
|
|
+ this.leavesList = arr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let filterList = arr.filter(v => {
|
|
|
+ return v.itemName.indexOf(value) !== -1
|
|
|
+ })
|
|
|
+ this.leavesList = filterList
|
|
|
+ },
|
|
|
+ /** 懒加载数据组数据项查询 */
|
|
|
+ loadGroupDataItemNode(node, resolve) {
|
|
|
+ if (node.level === 0) {
|
|
|
+ this.getDataItemByDataSource()
|
|
|
+ // return resolve(this.itemDataListByTree)
|
|
|
+ }
|
|
|
+ let itemNames = []
|
|
|
+ extractDataItemValues(node, itemNames)
|
|
|
+ let itemName = itemNames.reverse().join('!@')
|
|
|
+ let dataSourceId = this.chooseGroup.dataSourceId
|
|
|
+ getNextAllItem(dataSourceId, itemName).then(res => {
|
|
|
+ if (!res.data) {
|
|
|
+ resolve([])
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let datas = res.data.label
|
|
|
+ let leaves = res.data.leaves
|
|
|
+ let leaveList = []
|
|
|
+ if (leaves && leaves.length > 0) {
|
|
|
+ leaves.forEach((t) => {
|
|
|
+ leaveList.push(t)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.filterItemText = ''
|
|
|
+ this.leavesList = leaveList
|
|
|
+ this.leavesListF = JSON.parse(JSON.stringify(this.leavesList))
|
|
|
+ let dataList = []
|
|
|
+ if (datas && datas.length > 0) {
|
|
|
+ datas.forEach((t) => {
|
|
|
+ dataList.push({
|
|
|
+ 'dataSourceId': dataSourceId,
|
|
|
+ 'label': t.itemName,
|
|
|
+ 'leaf': false,
|
|
|
+ 'children': []
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ resolve(dataList)
|
|
|
+ }).catch((e) => {
|
|
|
+ resolve([])
|
|
|
+ showAlertWin(this, null, e)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 数据项点击事件 */
|
|
|
+ handleItemNodeClick(data, node, target) {
|
|
|
+ if (this.hasLeavesFlag !== 1) return
|
|
|
+ this.isSelectAllItemData = false
|
|
|
+ const loading = showLoading(this, '加载中,请稍候···')
|
|
|
+ let itemNames = []
|
|
|
+ extractDataItemValues(node, itemNames)
|
|
|
+ let itemName = itemNames.reverse().join('!@')
|
|
|
+ let dataSourceId = node.data.dataSourceId
|
|
|
+ getNextAllItem(dataSourceId, itemName).then(res => {
|
|
|
+ loading.close()
|
|
|
+ let data = res.data
|
|
|
+
|
|
|
+ let leaves = []
|
|
|
+ if (data.leaves && data.leaves.length > 0) {
|
|
|
+ data.leaves.forEach((t) => {
|
|
|
+ leaves.push(t)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.filterItemText = ''
|
|
|
+ this.leavesList = leaves
|
|
|
+ this.leavesListF = JSON.parse(JSON.stringify(this.leavesList))
|
|
|
+ }).catch((e) => {
|
|
|
+ loading.close()
|
|
|
+ this.leavesList = []
|
|
|
+ this.leavesListF = JSON.parse(JSON.stringify(this.leavesList))
|
|
|
+ showAlertWin(this, null, e)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 根据数据源选择数据项 */
|
|
|
+ getDataItemByDataSource() {
|
|
|
+ let id = this.groupBasicForm.dataSourceId
|
|
|
+ if (!id) {
|
|
|
+ showAlertMsgWin(this, null, '请选择数据源!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.isSelectAllItem = false
|
|
|
+ this.dataLineListSelections = []
|
|
|
+ this.leavesList = []
|
|
|
+ this.leavesChooseList = []
|
|
|
+ this.itemDataStep = 1
|
|
|
+ this.tempItemList = JSON.parse(JSON.stringify(this.groupBasicForm.itemList))
|
|
|
+
|
|
|
+ if (this.tempItemList && this.tempItemList.length > 0) {
|
|
|
+ this.chooseItemDataListByTree = this.tempItemList
|
|
|
+ }
|
|
|
+ const loading = showLoading(this, '加载中,请稍候···')
|
|
|
+ getNextAllItem(id, null).then(res => {
|
|
|
+ loading.close()
|
|
|
+ let data = res.data
|
|
|
+
|
|
|
+ let leaves = []
|
|
|
+ if (data.leaves && data.leaves.length > 0) {
|
|
|
+ data.leaves.forEach((t) => {
|
|
|
+ leaves.push(t)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.leavesList = leaves
|
|
|
+ this.leavesListF = JSON.parse(JSON.stringify(this.leavesList))
|
|
|
+ let items = []
|
|
|
+ if (data.label && data.label.length > 0) {
|
|
|
+ data.label.forEach((t) => {
|
|
|
+ items.push({
|
|
|
+ 'dataSourceId': id,
|
|
|
+ 'label': t.itemName,
|
|
|
+ 'leaf': false,
|
|
|
+ 'children': []
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ // 区分驱动返回数据类型
|
|
|
+ this.hasLeavesFlag = 1
|
|
|
+ this.itemDataListByTree = items
|
|
|
+ this.itemDataListByTreeF = JSON.parse(JSON.stringify(this.itemDataListByTree))
|
|
|
+ })
|
|
|
+ }).catch((e) => {
|
|
|
+ loading.close()
|
|
|
+ showAlertWin(this, null, e)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 获取右侧数据源类型列表 */
|
|
|
+ getDataSourceList() {
|
|
|
+ getAllDataSource().then(res => {
|
|
|
+ this.dataSourceList = res.data
|
|
|
+ this.dataItemDialogVisible = true
|
|
|
+ // this.getDataItemByDataSource()
|
|
|
+ }).catch((e) => {
|
|
|
+ showAlertWin(this, null, e)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 添加数据项 */
|
|
|
+ addCheckNodesBtnEvent() {
|
|
|
+ // 根据当前选择节点拼接为:XXXX.XXXX.XXX
|
|
|
+ let chooseChannelNameList = []
|
|
|
+ // WinCC数据项处理
|
|
|
+ if (this.hasLeavesFlag === 1) {
|
|
|
+ if (this.leavesChooseList.length == 0) {
|
|
|
+ showAlertMsgWin(this, null, '请选择数据项!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for (let i = 0; i < this.leavesChooseList.length; i ++) {
|
|
|
+ let temp = {
|
|
|
+ 'id': uuidv4(),
|
|
|
+ 'nodeIdentifier': null,
|
|
|
+ 'dataType': null,
|
|
|
+ 'label': this.leavesChooseList[i].fullPath,
|
|
|
+ 'nodeIndex': this.leavesChooseList[i].nodeIndex,
|
|
|
+ 'itemName': this.leavesChooseList[i].itemName,
|
|
|
+ 'itemReadName': this.leavesChooseList[i].itemReadName
|
|
|
+ }
|
|
|
+ chooseChannelNameList.push(temp)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 通用数据项处理
|
|
|
+ else {
|
|
|
+ let checkedNodes = this.$refs.itemTree.getCheckedNodes(false, true)
|
|
|
+ if (checkedNodes.length == 0) {
|
|
|
+ showAlertMsgWin(this, null, '请选择数据项!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for (let i in checkedNodes) {
|
|
|
+ let checkedNode = checkedNodes[i]
|
|
|
+ if (!checkedNode.isLeaf) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ const nodeId = checkedNode.$treeNodeId;
|
|
|
+ let channelName = this.treeFindPath(this.itemDataListByTree, data => data.$treeNodeId === nodeId, "label")
|
|
|
+ let temp = {
|
|
|
+ 'id': uuidv4(),
|
|
|
+ 'label': channelName.join('.'),
|
|
|
+ 'nodeIdentifier': checkedNode.nodeIdentifier,
|
|
|
+ 'nodeIndex': checkedNode.nodeIndex,
|
|
|
+ 'dataType': checkedNode.dataType,
|
|
|
+ 'itemReadName': checkedNode.itemReadName
|
|
|
+ }
|
|
|
+ chooseChannelNameList.push(temp)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (chooseChannelNameList.length == 0) {
|
|
|
+ showAlertMsgWin(this, null, '请选择子数据项!')
|
|
|
+ }
|
|
|
+ // 去重
|
|
|
+ let arr = JSON.parse(JSON.stringify(this.chooseItemDataListByTree))
|
|
|
+ if (arr.length == 0) {
|
|
|
+ arr = chooseChannelNameList
|
|
|
+ } else {
|
|
|
+ for (let i in chooseChannelNameList) {
|
|
|
+ let flag = false
|
|
|
+ for (let j in arr) {
|
|
|
+ let tName = arr[j].label ? arr[j].label : arr[j].itemName
|
|
|
+ if (chooseChannelNameList[i].label == tName) {
|
|
|
+ flag = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!flag) {
|
|
|
+ arr.push(chooseChannelNameList[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.chooseItemDataListByTree = arr
|
|
|
+ this.isSelectAllItem = false
|
|
|
+ this.leavesChooseList = []
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isSelectAllItemData = false
|
|
|
+ this.$refs.itemTree.setCheckedKeys([])
|
|
|
+ this.$refs.chooseItemTree.setCheckedNodes([])
|
|
|
+ }, 100)
|
|
|
+ },
|
|
|
+ /** 移除数据项 */
|
|
|
+ removeCheckNodesBtnEvent() {
|
|
|
+ let checkedNodes = this.$refs.chooseItemTree.getCheckedNodes(false, true)
|
|
|
+ if (checkedNodes.length == 0) {
|
|
|
+ showAlertMsgWin(this, null, '请选择数据项!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 移除当前选择项
|
|
|
+ for (let i in checkedNodes) {
|
|
|
+ let index = this.chooseItemDataListByTree.indexOf(checkedNodes[i])
|
|
|
+ if (index >= 0) {
|
|
|
+ this.chooseItemDataListByTree.splice(index, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 重置选择
|
|
|
+ this.isSelectAllItem = false
|
|
|
+ this.$refs.itemTree.setCheckedKeys([])
|
|
|
+ this.$refs.chooseItemTree.setCheckedKeys([])
|
|
|
+ },
|
|
|
+ /** 移除全部数据项 */
|
|
|
+ removeAllCheckNodesBtnEvent() {
|
|
|
+ if (this.chooseItemDataListByTree.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.isSelectAllItem = false
|
|
|
+ this.chooseItemDataListByTree = []
|
|
|
+ this.$refs.itemTree.setCheckedKeys([])
|
|
|
+ },
|
|
|
+ /** 选择数据项弹出层保存事件:第一步 */
|
|
|
+ itemDialogSave1() {
|
|
|
+ if (this.chooseItemDataListByTree.length == 0) {
|
|
|
+ showAlertMsgWin(this, null, '请选择数据项!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.dataItemDialogTitle = '数据项表达式设置'
|
|
|
+ let itemList = []
|
|
|
+ // let itemNameList = this.chooseItemDataListByTree.map(map => { return map.label })
|
|
|
+ for (let i in this.chooseItemDataListByTree) {
|
|
|
+ let temp = this.chooseItemDataListByTree[i]
|
|
|
+ let m = (temp.eventMode || temp.eventMode == 0) ? String(temp.eventMode) : ''
|
|
|
+ itemList.push({
|
|
|
+ 'tableReportId': temp.tableReportId,
|
|
|
+ 'eventMode': m,
|
|
|
+ 'eventValue': temp.eventValue,
|
|
|
+ 'dataModelId': temp.dataModelId,
|
|
|
+ 'itemName': temp.label ? temp.label : temp.itemName,
|
|
|
+ 'nodeIdentifier': temp.nodeIdentifier,
|
|
|
+ 'nodeIndex': temp.nodeIndex,
|
|
|
+ 'dataType': temp.dataType,
|
|
|
+ 'describe': temp.describe,
|
|
|
+ 'itemReadName': temp.itemReadName
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // this.chooseItemDataList = this.chooseItemDataListByTree
|
|
|
+ this.itemDataStep = 2
|
|
|
+ this.getAllDataModel(itemList)
|
|
|
+ },
|
|
|
+ /** 选择数据项弹出层保存事件:第二步 */
|
|
|
+ itemDialogSave2() {
|
|
|
+ this.filterChooseItemText = ''
|
|
|
+ this.chooseItemChangeEvent()
|
|
|
+ this.itemDataStep = 1
|
|
|
+ this.filterItemData = ''
|
|
|
+ this.dataLineListSelections = []
|
|
|
+ this.chooseItemDataListByTree = []
|
|
|
+ this.dataItemDialogVisible = false
|
|
|
+ this.$emit('update-message', JSON.parse(JSON.stringify(this.chooseItemDataList)))
|
|
|
+ this.data = Object.assign({}, this.data);
|
|
|
+ },
|
|
|
+ /** 查询所有数据模型 */
|
|
|
+ getAllDataModel(itemList) {
|
|
|
+ this.dataModelList = []
|
|
|
+ let loading = showLoading(this, '数据加载中,请稍候···')
|
|
|
+ let params = {
|
|
|
+ 'page': 1,
|
|
|
+ 'limit': 1000
|
|
|
+ }
|
|
|
+ getAllDataModel(params).then(res => {
|
|
|
+ loading.close()
|
|
|
+ this.itemDataStep = 2
|
|
|
+ if (!res.data) {
|
|
|
+ this.chooseItemDataList = itemList
|
|
|
+ this.chooseItemDataListF = JSON.parse(JSON.stringify(this.chooseItemDataList))
|
|
|
+ // this.getEventReportList(itemList)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let dataModelList = res.data.dataModelList
|
|
|
+ for (let i in itemList) {
|
|
|
+ for (let j in dataModelList) {
|
|
|
+ if (itemList[i].dataModelId == dataModelList[j].id) {
|
|
|
+ itemList[i].rule = dataModelList[j]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let i = 0; i < dataModelList.length; i ++) {
|
|
|
+ dataModelList[i].title = dataModelList[i].remark
|
|
|
+ ? ('【' + dataModelList[i].remark + '】' + dataModelList[i].operationRule)
|
|
|
+ : dataModelList[i].operationRule
|
|
|
+ this.dataModelList.push(dataModelList[i])
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.chooseItemDataList = JSON.parse(JSON.stringify(itemList))
|
|
|
+ for (let i in this.chooseItemDataList) {
|
|
|
+ let temp = this.chooseItemDataList[i]
|
|
|
+ if (!temp.rule) {
|
|
|
+ temp.rule = {
|
|
|
+ 'operationRule': '默认值'
|
|
|
+ }
|
|
|
+ temp.dataModelId = null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.bomCheckKey = new Date().getTime()
|
|
|
+ this.chooseItemDataListF = JSON.parse(JSON.stringify(this.chooseItemDataList))
|
|
|
+ // this.getEventReportList(this.chooseItemDataList)
|
|
|
+ })
|
|
|
+ }).catch((e) => {
|
|
|
+ loading.close()
|
|
|
+ showAlertWin(this, null, e)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 保存数据模型事件 */
|
|
|
+ saveDataModelEvent() {
|
|
|
+ // if (!this.chooseDataModel) {
|
|
|
+ // this.$message({
|
|
|
+ // message: '请选择表达式!',
|
|
|
+ // type: 'warning'
|
|
|
+ // })
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ let item = {
|
|
|
+ 'operationRule': '默认值'
|
|
|
+ }
|
|
|
+ for (let i in this.dataModelList) {
|
|
|
+ if (this.chooseDataModel == this.dataModelList[i].id) {
|
|
|
+ item = this.dataModelList[i]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let tempArr = JSON.parse(JSON.stringify(this.chooseItemDataListF))
|
|
|
+ // 批量选择
|
|
|
+ if (this.chooseDataItemIndex == '-1' && this.dataLineListSelections.length > 0) {
|
|
|
+ this.dataLineListSelections.forEach((selection) => {
|
|
|
+ tempArr.forEach((itemData) => {
|
|
|
+ if (itemData.itemName === selection.itemName) {
|
|
|
+ // this.$nextTick(() => {
|
|
|
+ itemData.rule = item
|
|
|
+ itemData.dataModelId = item.id
|
|
|
+ // })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ tempArr.forEach((itemData) => {
|
|
|
+ if (itemData.itemName === this.chooseDataItemIndex) {
|
|
|
+ itemData.rule = item
|
|
|
+ itemData.dataModelId = item.id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.filterChooseItemText = ''
|
|
|
+ this.chooseItemDataList = tempArr
|
|
|
+ this.chooseItemDataListF = JSON.parse(JSON.stringify(this.chooseItemDataList))
|
|
|
+ this.bomCheckKey = new Date().getTime()
|
|
|
+ this.dataLineListSelections = []
|
|
|
+ this.dialogDataModelVisible = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 四则运算弹出层关闭事件 */
|
|
|
+ dialogDataModelClose(done) {
|
|
|
+ if (typeof(done) === 'function') {
|
|
|
+ done()
|
|
|
+ } else {
|
|
|
+ this.dialogDataModelVisible = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /** 选择数据项弹出层关闭事件 */
|
|
|
+ itemDialogClose(done) {
|
|
|
+ if ((!this.groupBasicForm.id && !this.chooseItemDataView) || !this.chooseItemDataView) {
|
|
|
+ this.chooseItemDataListByTree = []
|
|
|
+ }
|
|
|
+ if (this.groupBasicForm.id && this.groupBasicForm.dataSourceId == this.updateGroupData.dataSourceId) {
|
|
|
+ this.chooseItemDataListByTree = this.tempItemList
|
|
|
+ this.groupBasicForm.itemList = this.tempItemList
|
|
|
+ }
|
|
|
+ this.filterChooseItemText = ''
|
|
|
+ this.filterItemData = ''
|
|
|
+ this.itemDataListByTree = []
|
|
|
+ this.itemDataListByTreeF = []
|
|
|
+ this.dataLineListSelections = []
|
|
|
+
|
|
|
+ // 修改数据组的时候点击关闭时重新加载
|
|
|
+ if (this.groupDialogTitle == '修改数据组') {
|
|
|
+ this.updateGroupItem()
|
|
|
+ }
|
|
|
+ if (typeof(done) === 'function') {
|
|
|
+ done()
|
|
|
+ } else {
|
|
|
+ this.dataItemDialogVisible = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|