index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template>
  2. <div class="cqcy-content" v-if="chooseGroupId">
  3. <div style="margin-bottom: 10px;">
  4. <span style="color: #474646; font-size: 14px;">数据组:</span>
  5. <el-select v-model="chooseGroupId" disabled size="mini">
  6. <el-option v-for="dict in groupDataList" :key="dict.id" :label="dict.groupName" :value="dict.id"></el-option>
  7. </el-select>
  8. <span style="margin-left: 20px; color: #474646; font-size: 14px;">数据项名称:</span>
  9. <el-input placeholder="请输入数据项名称" size="mini" style="width: 200px;" @input="itemChangeEvent" v-model="filterItemText"
  10. prefix-icon="el-icon-search">
  11. </el-input>
  12. <el-checkbox v-model="groupRunStatus" size="mini" style="margin-left: 20px;" @change="groupRunCheckboxEvent"
  13. title="固定每5秒刷新一次数据">实时数据</el-checkbox>
  14. <el-button type="danger" v-show="!groupRunStatus" icon="el-icon-delete" size="mini" @click="multipleDelItemEvent"
  15. style="float: right;">批量删除</el-button>
  16. <el-button type="primary" v-show="!groupRunStatus" icon="el-icon-s-tools" size="mini"
  17. @click="multipleModelItemEvent" style="float: right; margin-right: 15px;">批量设置表达式</el-button>
  18. <el-button type="primary" v-show="!groupRunStatus" icon="el-icon-plus" size="mini" @click="addGroupItemEvent"
  19. style="float: right; margin-right: 5px;">添加数据项</el-button>
  20. </div>
  21. <u-table class="cy-group-items" row-key="label" use-virtual :height="uTableHeight" :data="itemDataList"
  22. @selection-change="selectionLineChangeHandle" @sort-change="sortChange" :big-data-checkbox="true"
  23. showBodyOverflow="title" showHeaderOverflow="title" border>
  24. <u-table-column type="selection" width="55" align="center" />
  25. <u-table-column type="index" label="序号" width="60" fixed align="center" />
  26. <u-table-column label="数据项名称" prop="itemName" sortable="custom" align="center" />
  27. <template v-if="groupRunStatus">
  28. <u-table-column prop="dataType" sortable="custom" label="数据项类型" align="center" width="120">
  29. </u-table-column>
  30. <u-table-column prop="operationRule" sortable="custom" label="表达式" align="center" width="150">
  31. <template slot-scope="scope">
  32. {{ scope.row.operationRule ? scope.row.operationRule : '默认值' }}
  33. </template>
  34. </u-table-column>
  35. <u-table-column prop="quality" sortable="custom" label="质量" align="center" width="60">
  36. </u-table-column>
  37. <u-table-column prop="dataOrgValue" sortable="custom" label="原始数据值" align="center" width="120">
  38. <template slot-scope="scope">
  39. {{ (scope.row.dataOrgValue != null
  40. && scope.row.dataOrgValue != 'undefined'
  41. && scope.row.dataOrgValue != 'null') ? scope.row.dataOrgValue : '' }}
  42. </template>
  43. </u-table-column>
  44. <u-table-column prop="dataValue" sortable="custom" label="计算值" align="center" width="100">
  45. <template slot-scope="scope">
  46. {{ (scope.row.dataValue != null
  47. && scope.row.dataValue != 'undefined'
  48. && scope.row.dataValue != 'null') ? scope.row.dataValue : '' }}
  49. </template>
  50. </u-table-column>
  51. <u-table-column prop="dataSourceName" sortable="custom" label="数据源名称" align="center" width="180">
  52. </u-table-column>
  53. <u-table-column prop="createTime" sortable label="取值时间" align="center" width="180">
  54. </u-table-column>
  55. </template>
  56. <template v-else>
  57. <u-table-column prop="describe" sortable="custom" label="别名" align="center" width="150">
  58. <template slot-scope="scope" v-if="scope.row.describe">
  59. <!-- <el-tag type="primary" disable-transitions>{{ scope.row.describe }}</el-tag>-->
  60. <span>{{ scope.row.describe }}</span>
  61. </template>
  62. </u-table-column>
  63. <u-table-column prop="dataSourceName" sortable="custom" label="数据源名称" align="center" width="180">
  64. </u-table-column>
  65. <u-table-column prop="operationRule" sortable="custom" label="表达式" align="center" width="200">
  66. <template slot-scope="scope">
  67. {{ scope.row.operationRule ? scope.row.operationRule : '默认值' }}
  68. </template>
  69. </u-table-column>
  70. <u-table-column label="操作" align="center" width="180">
  71. <template slot-scope="scope">
  72. <el-button type="text" size="small" icon="el-icon-edit" @click="handleClickByEdit(scope.row)">编辑</el-button>
  73. <el-button type="text" size="small" icon="el-icon-delete" style="color: red;"
  74. @click="handleClickByDel(scope.row)">删除</el-button>
  75. </template>
  76. </u-table-column>
  77. </template>
  78. </u-table>
  79. <!-- 修改数据项基础信息 -->
  80. <el-dialog title="修改数据项" width="600px" top="10vh" center v-dialog-drag v-if="dialogItemVisible"
  81. :before-close="dialogClose" :visible.sync="dialogItemVisible" :close-on-click-modal="false" :append-to-body="true">
  82. <el-form ref="itemForm" :model="itemForm" label-width="150px">
  83. <el-form-item label="ID" prop="id" style="display: none;">
  84. <el-input v-model='itemForm.id' type="text" auto-complete="off"></el-input>
  85. </el-form-item>
  86. <el-form-item label="数据模型:" prop="dataModelId">
  87. <el-select v-model="itemForm.dataModelId" filterable clearable placeholder="请选择表达式" style="width: 100%;">
  88. <el-option v-for="(item, index) in this.dataModelList" :key="index" :label="item.title" :value="item.id">
  89. </el-option>
  90. </el-select>
  91. </el-form-item>
  92. <el-form-item label="数据项描述信息:" prop="describe">
  93. <el-input v-model.trim='itemForm.describe' type="text" auto-complete="off" show-word-limit maxlength="20"
  94. placeholder="请输入描述信息"></el-input>
  95. </el-form-item>
  96. <!-- <el-divider content-position="left" class="cy-divider">事件报表配置(以下任意一项配置为空都将会无效)</el-divider>-->
  97. <!-- <el-form-item label="事件驱动产生条件:" prop="eventMode">-->
  98. <!-- <el-radio-group v-model="itemForm.eventMode">-->
  99. <!-- <el-radio label="0">大于</el-radio>-->
  100. <!-- <el-radio label="1">小于</el-radio>-->
  101. <!-- <el-radio label="2">布尔类型</el-radio>-->
  102. <!-- </el-radio-group>-->
  103. <!-- </el-form-item>-->
  104. <!-- <el-form-item label="阈值:" prop="eventValue">-->
  105. <!-- <el-input v-model="itemForm.eventValue" placeholder="请输入阈值" maxlength="8">-->
  106. <!-- </el-input>-->
  107. <!-- </el-form-item>-->
  108. <!-- <el-form-item label="事件驱动报表:" prop="tableReportId">-->
  109. <!-- <el-select v-model="itemForm.tableReportId" filterable clearable-->
  110. <!-- placeholder="请选择事件驱动报表" style="width: 100%;">-->
  111. <!-- <el-option-->
  112. <!-- v-for="(item, index) in this.eventReportList"-->
  113. <!-- :key="index"-->
  114. <!-- :label="item.reportTableName"-->
  115. <!-- :value="item.id">-->
  116. <!-- </el-option>-->
  117. <!-- </el-select>-->
  118. <!-- </el-form-item>-->
  119. </el-form>
  120. <span slot='footer'>
  121. <el-button type="primary" @click="editConfirmEvent" style="margin-top: 20px;">确定</el-button>
  122. <el-button @click="dialogClose" style="margin-top: 20px;">取消</el-button>
  123. </span>
  124. </el-dialog>
  125. <el-dialog title="选择表达式" width="500px" top="10vh" center v-dialog-drag v-if="dialogDataModelVisible"
  126. :before-close="dialogDataModelClose" :visible.sync="dialogDataModelVisible" :close-on-click-modal="false"
  127. :append-to-body="true">
  128. <el-select v-model="chooseDataModel" filterable clearable placeholder="请选择表达式" style="width: 100%;">
  129. <el-option v-for="(item, index) in this.dataModelList" :key="index" :label="item.title" :value="item.id">
  130. </el-option>
  131. </el-select>
  132. <div style="width: 100%; text-align: center; margin-top: 20px;">
  133. <el-button type="primary" @click="saveDataModelEvent">确定</el-button>
  134. <el-button @click="dialogDataModelClose">取消</el-button>
  135. </div>
  136. </el-dialog>
  137. <!-- 选择数据项 -->
  138. <data-source-item ref="dataSourceItem" @update-message="updateDataItemEmit"
  139. :chooseGroup="chooseGroup"></data-source-item>
  140. </div>
  141. </template>
  142. <script>
  143. import {
  144. addItemList,
  145. batchSetExpresses,
  146. deleteItemByIdList,
  147. getAllDataModel,
  148. getItemById,
  149. getItemGroupById,
  150. getItemValueById,
  151. updateItem
  152. } from "@/api/datasource";
  153. import { customCompare, showAlertMsgWin, showAlertWin, showConfirmWin, showLoading } from "@/utils/cqcy";
  154. import cqcyCode from "@/utils/cqcyCode";
  155. import DataSourceItem from "@/components/CustomDialog/DataSourceItem.vue";
  156. export default {
  157. name: "index",
  158. components: {
  159. DataSourceItem
  160. },
  161. data() {
  162. return {
  163. dialogItemVisible: false,
  164. dialogDataModelVisible: false,
  165. itemDataList: [],
  166. itemDataListF: [],
  167. groupDataList: [],
  168. dataModelList: [],
  169. chooseDataModel: null,
  170. selectionItems: [],
  171. eventReportList: [],
  172. chooseGroup: null,
  173. chooseGroupId: null,
  174. groupRunStatus: false,
  175. timeInterval: null,
  176. filterItemText: '',
  177. uTableHeight: 500,
  178. itemForm: {
  179. id: null,
  180. dataModelId: null,
  181. // eventMode: null,
  182. // eventValue: null,
  183. // tableReportId: null,
  184. describe: ''
  185. }
  186. }
  187. },
  188. watch: {
  189. '$route'(to, from) {
  190. this.readParams()
  191. },
  192. '$route.query.t': {
  193. handler(o, n) {
  194. }
  195. },
  196. deep: true
  197. },
  198. created() {
  199. this.readParams()
  200. },
  201. beforeDestroy() {
  202. if (this.timeInterval) {
  203. clearInterval(this.timeInterval)
  204. this.timeInterval = null
  205. }
  206. // sessionStorage.removeItem('GROUP_ID')
  207. },
  208. methods: {
  209. sortChange({ prop, order }) {
  210. this.itemDataList.sort(customCompare(prop, order))
  211. },
  212. itemChangeEvent(value) {
  213. let arr = JSON.parse(JSON.stringify(this.itemDataListF))
  214. if (!value || !value.trim()) {
  215. this.itemDataList = arr
  216. return
  217. }
  218. let filterList = arr.filter(v => {
  219. return v.itemName.indexOf(value) !== -1
  220. })
  221. this.itemDataList = filterList
  222. },
  223. /** 读取参数 */
  224. readParams() {
  225. this.filterItemText = ''
  226. // let groupListStorage = sessionStorage.getItem('GROUP_LIST') ? sessionStorage.getItem('GROUP_LIST') : '[]'
  227. // this.groupDataList = JSON.parse(groupListStorage)
  228. let groupId = sessionStorage.getItem('GROUP_ID') ? sessionStorage.getItem('GROUP_ID') : '-1'
  229. this.chooseGroupId = parseInt(groupId)
  230. this.groupRunStatus = false
  231. this.getGroupById(this.chooseGroupId)
  232. // this.getItemValueById()
  233. },
  234. /** 运行状态值 */
  235. groupRunCheckboxEvent(val) {
  236. this.groupRunStatus = val
  237. this.getItemValueById()
  238. },
  239. /** 获取数据项值信息 */
  240. getItemValueById() {
  241. if (!this.groupRunStatus || !this.chooseGroup) {
  242. this.filterItemText = ''
  243. if (this.timeInterval) {
  244. clearInterval(this.timeInterval)
  245. this.timeInterval = null
  246. }
  247. this.getGroupById(this.chooseGroupId)
  248. return
  249. }
  250. getItemValueById(this.chooseGroup.id).then(res => {
  251. // this.filterItemText = ''
  252. let list = res.data
  253. if (!list) return
  254. // 避免布尔类型时页面无法显示数据
  255. for (let i = 0; i < list.length; i++) {
  256. list[i].dataValue += ''
  257. list[i].quality += ''
  258. }
  259. if (this.filterItemText) {
  260. let filterList = list.filter(v => {
  261. return v.itemName.indexOf(this.filterItemText) !== -1
  262. })
  263. this.itemDataList = filterList
  264. } else {
  265. this.itemDataList = list
  266. }
  267. this.itemDataListF = JSON.parse(JSON.stringify(list))
  268. }).catch((e) => {
  269. showAlertWin(this, null, e)
  270. })
  271. let temp = setInterval(() => {
  272. getItemValueById(this.chooseGroup.id).then(res => {
  273. // this.filterItemText = ''
  274. let list = res.data
  275. // 避免布尔类型时页面无法显示数据
  276. for (let i = 0; i < list.length; i++) {
  277. list[i].dataValue += ''
  278. list[i].quality += ''
  279. }
  280. if (this.filterItemText) {
  281. let filterList = list.filter(v => {
  282. return v.itemName.indexOf(this.filterItemText) !== -1
  283. })
  284. this.itemDataList = filterList
  285. } else {
  286. this.itemDataList = list
  287. }
  288. this.itemDataListF = JSON.parse(JSON.stringify(list))
  289. }).catch((e) => {
  290. // showAlertWin(this, e)
  291. })
  292. }, 5 * 1000)
  293. this.timeInterval = temp
  294. },
  295. setRowHeight() {
  296. if ($('.cqcy-content') && $('.cqcy-content')[0]) {
  297. this.uTableHeight = $('.cqcy-content')[0].offsetHeight - 100
  298. }
  299. },
  300. /** 获取组详细信息 */
  301. getGroupById(id) {
  302. this.setRowHeight()
  303. if (this.timeInterval) {
  304. clearInterval(this.timeInterval)
  305. this.timeInterval = null
  306. }
  307. if (!id || id <= 0) {
  308. this.chooseGroupId = null
  309. return
  310. }
  311. this.filterItemText = ''
  312. const loading = showLoading(this, '加载中,请稍候···')
  313. getItemGroupById(id).then(res => {
  314. loading.close()
  315. this.chooseGroup = res.data
  316. this.groupDataList = [{
  317. 'id': this.chooseGroup.id,
  318. 'groupName': this.chooseGroup.groupName
  319. }]
  320. this.setRowHeight()
  321. this.itemDataList = this.chooseGroup.itemList
  322. this.itemDataListF = JSON.parse(JSON.stringify(this.itemDataList))
  323. }).catch((e) => {
  324. loading.close()
  325. showAlertWin(this, null, e)
  326. })
  327. },
  328. /** 查询所有数据模型 */
  329. getAllDataModel(callback) {
  330. let loading = showLoading(this, '数据加载中,请稍候···')
  331. let params = {
  332. 'page': 1,
  333. 'limit': 1000
  334. }
  335. getAllDataModel(params).then(res => {
  336. loading.close()
  337. this.dataModelList = res.data.dataModelList
  338. for (let i = 0; i < this.dataModelList.length; i++) {
  339. this.dataModelList[i].title = this.dataModelList[i].remark
  340. ? ('【' + this.dataModelList[i].remark + '】' + this.dataModelList[i].operationRule)
  341. : this.dataModelList[i].operationRule
  342. }
  343. if (callback) callback(true)
  344. }).catch((e) => {
  345. loading.close()
  346. if (callback) callback(false)
  347. showAlertWin(this, null, e)
  348. })
  349. },
  350. /** 编辑 */
  351. handleClickByEdit(row) {
  352. let _this = this
  353. if (!row || !row.id) {
  354. showAlertMsgWin(_this, null, cqcyCode[201])
  355. return
  356. }
  357. _this.getAllDataModel(status => {
  358. if (!status) return
  359. const loading = showLoading(_this, '加载中,请稍候···')
  360. getItemById(row.id).then(res => {
  361. loading.close()
  362. if (res.data.runState == 1) {
  363. showAlertMsgWin(this, null, '该数据组正在运行中,禁止修改!')
  364. return
  365. }
  366. _this.$nextTick(() => {
  367. _this.itemForm.id = row.id
  368. _this.itemForm.dataModelId = res.data.dataModelId
  369. _this.itemForm.describe = res.data.describe
  370. // _this.itemForm.tableReportId = res.data.tableReportId
  371. // _this.itemForm.eventMode = res.data.eventMode + ''
  372. // _this.itemForm.eventValue = res.data.eventValue
  373. _this.dialogItemVisible = true
  374. })
  375. }).catch((e) => {
  376. loading.close()
  377. showAlertWin(_this, null, e)
  378. })
  379. // let params = {
  380. // 'page': 1,
  381. // 'limit': 1000,
  382. // 'isAutoReport': 3
  383. // }
  384. // getAllReportTable(params).then(res => {
  385. // let eventReportList = res.data.reportTableList
  386. // this.eventReportList = eventReportList
  387. // getItemById(row.id).then(res => {
  388. // loading.close()
  389. // _this.$nextTick(() => {
  390. // _this.itemForm.id = row.id
  391. // _this.itemForm.dataModelId = res.data.dataModelId
  392. // _this.itemForm.describe = res.data.describe
  393. // _this.itemForm.tableReportId = res.data.tableReportId
  394. // _this.itemForm.eventMode = res.data.eventMode + ''
  395. // _this.itemForm.eventValue = res.data.eventValue
  396. // _this.dialogItemVisible = true
  397. // })
  398. // }).catch((e) => {
  399. // loading.close()
  400. // showAlertWin(_this, e)
  401. // })
  402. // }).catch((e) => {
  403. // loading.close()
  404. // showAlertWin(this, e)
  405. // })
  406. })
  407. },
  408. /** 编辑确认事件 */
  409. editConfirmEvent() {
  410. // if (this.itemForm.eventValue) {
  411. // let reg = /^(\-)?\d+(\.\d{1,2})?$/
  412. // if (!reg.test(this.itemForm.eventValue)) {
  413. // this.$message({
  414. // message: '阈值不合法',
  415. // type: 'warning'
  416. // })
  417. // return
  418. // }
  419. // if (this.itemForm.eventMode == '2' && this.itemForm.eventValue != 0 && this.itemForm.eventValue != 1) {
  420. // this.$message({
  421. // message: '布尔类型时阈值只能为0或者1',
  422. // type: 'warning'
  423. // })
  424. // return
  425. // }
  426. // }
  427. const loading = showLoading(this, '加载中,请稍候···')
  428. // 若驱动报表事件任意一项为空,则清空报表事项
  429. // if ((!this.itemForm.eventMode || this.itemForm.eventMode == 'null')
  430. // || (this.itemForm.eventValue == null || this.itemForm.eventValue == '')
  431. // || !this.itemForm.tableReportId) {
  432. // this.itemForm.eventMode = null
  433. // this.itemForm.eventValue = null
  434. // this.itemForm.tableReportId = null
  435. // }
  436. let params = JSON.parse(JSON.stringify(this.itemForm))
  437. updateItem(params).then(res => {
  438. loading.close()
  439. let msg = res.data ? '编辑成功!' : '编辑失败!'
  440. showAlertMsgWin(this, null, msg)
  441. this.dialogItemVisible = false
  442. this.getGroupById(this.chooseGroupId)
  443. }).catch((e) => {
  444. loading.close()
  445. showAlertWin(this, null, e)
  446. })
  447. },
  448. /** 删除数据项 */
  449. delItems(ids) {
  450. if (ids.length === this.itemDataListF.length) {
  451. showAlertMsgWin(this, null, '至少保留一项数据项信息!')
  452. return
  453. }
  454. const loading = showLoading(this, '删除中,请稍候···')
  455. deleteItemByIdList(ids).then(res => {
  456. loading.close()
  457. let msg = res.data ? '删除成功!' : '删除失败!'
  458. showAlertMsgWin(this, null, msg)
  459. this.getGroupById(this.chooseGroupId)
  460. }).catch((e) => {
  461. loading.close()
  462. showAlertWin(this, null, e)
  463. })
  464. },
  465. /** 删除 */
  466. handleClickByDel(row) {
  467. if (!row || !row.id) {
  468. showAlertMsgWin(this, null, cqcyCode[201])
  469. return
  470. }
  471. if (this.chooseGroup && this.chooseGroup.runState == 1) {
  472. showAlertMsgWin(this, null, '该数据组正在运行中,禁止删除!')
  473. return
  474. }
  475. showConfirmWin(this, null, '您确定要删除该数据项吗?', () => {
  476. this.delItems([row.id])
  477. })
  478. },
  479. /** 多选事件 */
  480. selectionLineChangeHandle(val) {
  481. this.selectionItems = val
  482. },
  483. /** 批量设置组数据中数据项表达式 */
  484. multipleModelItemEvent() {
  485. if (!this.selectionItems || this.selectionItems.length == 0) {
  486. showAlertMsgWin(this, null, '请至少选择一项数据!')
  487. return
  488. }
  489. if (this.chooseGroup && this.chooseGroup.runState == 1) {
  490. showAlertMsgWin(this, null, '该数据组正在运行中,禁止修改!')
  491. return
  492. }
  493. this.getAllDataModel(status => {
  494. this.dialogDataModelVisible = true
  495. })
  496. },
  497. /** 添加数据项 */
  498. addGroupItemEvent() {
  499. const loading = showLoading(this, '加载中,请稍候···')
  500. getItemGroupById(this.chooseGroupId).then(res => {
  501. loading.close()
  502. if (res.data.runState == 1) {
  503. showAlertMsgWin(this, null, '该数据组正在运行中,禁止添加数据项!')
  504. } else {
  505. this.$refs.dataSourceItem.groupBasicForm.itemList = res.data.itemList
  506. this.$refs.dataSourceItem.show()
  507. }
  508. }).catch((e) => {
  509. loading.close()
  510. showAlertWin(this, null, e)
  511. })
  512. },
  513. /** 批量设置组数据中数据项表达式 */
  514. saveDataModelEvent() {
  515. // let ids = Array.from(this.selectionItems, ({ id }) => id)
  516. let itemList = []
  517. this.selectionItems.forEach((item) => {
  518. itemList.push({
  519. 'id': item.id,
  520. 'itemGroupId': item.itemGroupId,
  521. 'dataModelId': this.chooseDataModel
  522. })
  523. })
  524. let params = {
  525. 'itemList': itemList
  526. }
  527. const loading = showLoading(this, '设置中,请稍候···')
  528. batchSetExpresses(params).then(res => {
  529. loading.close()
  530. let msg = res.data ? '设置成功!' : '设置失败!'
  531. showAlertMsgWin(this, null, msg)
  532. this.dialogDataModelVisible = false
  533. this.selectionItems = []
  534. this.chooseDataModel = null
  535. this.getGroupById(this.chooseGroupId)
  536. }).catch((e) => {
  537. loading.close()
  538. showAlertWin(this, null, e)
  539. })
  540. },
  541. /** 批量删除组数据中数据项 */
  542. multipleDelItemEvent() {
  543. if (!this.selectionItems || this.selectionItems.length == 0) {
  544. showAlertMsgWin(this, null, '请至少选择一项数据!')
  545. return
  546. }
  547. if (this.chooseGroup && this.chooseGroup.runState == 1) {
  548. showAlertMsgWin(this, null, '该数据组正在运行中,禁止删除!')
  549. return
  550. }
  551. showConfirmWin(this, null, '您确定要删除已选择数据项吗?', () => {
  552. let ids = Array.from(this.selectionItems, ({ id }) => id)
  553. this.delItems(ids)
  554. })
  555. },
  556. /** 更新已选择数据项 */
  557. updateDataItemEmit(items) {
  558. let params = {
  559. 'id': this.chooseGroup.id,
  560. 'itemList': items
  561. }
  562. const loading = showLoading(this, '添加中,请稍候···')
  563. addItemList(params).then(res => {
  564. loading.close()
  565. let msg = res.data ? '设置成功!' : '设置失败!'
  566. showAlertMsgWin(this, null, msg)
  567. this.dialogDataModelVisible = false
  568. this.selectionItems = []
  569. this.chooseDataModel = null
  570. this.getGroupById(this.chooseGroupId)
  571. }).catch((e) => {
  572. loading.close()
  573. showAlertWin(this, null, e)
  574. })
  575. },
  576. /** 弹出层关闭事件 */
  577. dialogClose(done) {
  578. if (this.$refs['itemForm']) {
  579. this.$refs['itemForm'].resetFields()
  580. }
  581. if (typeof (done) === 'function') {
  582. done()
  583. } else {
  584. this.dialogItemVisible = false
  585. }
  586. },
  587. /** 数据模型弹出层关闭事件 */
  588. dialogDataModelClose(done) {
  589. if (typeof (done) === 'function') {
  590. done()
  591. } else {
  592. this.dialogDataModelVisible = false
  593. }
  594. },
  595. }
  596. }
  597. </script>
  598. <style rel="stylesheet/scss" lang="scss">
  599. .el-table--enable-row-hover .el-table__body tr:hover>td {
  600. background-color: transparent !important;
  601. }
  602. .cy-divider {
  603. margin-top: 50px;
  604. .el-divider__text {
  605. font-size: 12px;
  606. color: #5e5e5e;
  607. }
  608. }
  609. .cy-group-items {
  610. margin-top: 10px;
  611. height: calc(100% - 100px);
  612. }
  613. </style>