applyRulesDialog.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <el-dialog title="提示" :visible.sync="dialogVisible" width="60%" @close="handleClose" id="applyRules">
  3. <span>对应规则有冲突,请处理</span>
  4. <el-tabs v-model="activeName" @tab-click="handleClick">
  5. <el-tab-pane label="人工填写过表号功能号" name="first"></el-tab-pane>
  6. <!-- <el-tab-pane label="多个标识对应同一个信息点" name="second"></el-tab-pane> -->
  7. </el-tabs>
  8. <el-table :data="tableData" style="width: 100%;max-height:400px;min-height:200px;" height="calc(100% - 160px)" @expand-change="expandRow"
  9. ref="expandTable">
  10. <el-table-column type="expand" class-name="bgf5">
  11. <template slot-scope="scope">
  12. <el-row>
  13. <el-col :span="12">
  14. <p>{{scope.row.BuildLocalName}}-{{scope.row.FloorLocalName}}</p>
  15. <p>{{scope.row.RoomLocalName}}</p>
  16. <p>{{scope.row.SubTypeName}}</p>
  17. </el-col>
  18. <el-col :span="6">
  19. <p>{{scope.row.OldMsg.Description}}</p>
  20. <p>
  21. {{scope.row.OldMsg.EquipmentMark}}
  22. {{scope.row.OldMsg.KeyEquipmentType}}
  23. {{scope.row.OldMsg.KeyEquipmentParameter}}
  24. </p>
  25. <p>{{scope.row.OldMsg.LocationFlag&&scope.row.OldMsg.LocationFlag.toString()}}</p>
  26. </el-col>
  27. <el-col :span="6">
  28. <p>{{scope.row.NewMsg.Description}}</p>
  29. <p>
  30. {{scope.row.NewMsg.EquipmentMark}}
  31. {{scope.row.NewMsg.KeyEquipmentType}}
  32. {{scope.row.NewMsg.KeyEquipmentParameter}}
  33. </p>
  34. <p>{{scope.row.NewMsg.LocationFlag&&scope.row.NewMsg.LocationFlag.toString()}}</p>
  35. </el-col>
  36. </el-row>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="设备实例本地名(本地编码)" class-name="bgf5" align="center">
  40. <template slot-scope="scope">
  41. {{scope.row.ObjectLocalName}}({{scope.row.ObjectLocalCode}})
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="信息点" prop="InfomationPoint" align="center"></el-table-column>
  45. <el-table-column label="原值" prop="Old" align="center">
  46. <template slot-scope="scope">
  47. <el-radio v-model="scope.row.checked" label="Old">{{scope.row.Old}}</el-radio>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="新值" prop="New" align="center">
  51. <template slot-scope="scope">
  52. <el-radio v-model="scope.row.checked" label="New">{{scope.row.New}}</el-radio>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <span slot="footer" class="dialog-footer">
  57. <span style="font-size:12px;color:red;" v-show="finished">请处理所有冲突</span>
  58. <el-button size="small" @click="handleClose">取消</el-button>
  59. <el-button size="small" type="primary" @click="userSelected">使用选择的表号功能号</el-button>
  60. </span>
  61. </el-dialog>
  62. </template>
  63. <script>
  64. import {
  65. dynamicPromptobjs, //提示冲突
  66. dynamicClashConfirm, //冲突选择确认
  67. dynamicQueryPoint, //查点位
  68. dynamicExecute, //执行规则
  69. } from "@/api/scan/request";
  70. import Vue from 'vue'
  71. export default {
  72. data() {
  73. return {
  74. dialogVisible: false, //弹窗显示与隐藏
  75. tableData: [],
  76. activeName: "first", //当前所在tab页
  77. finished: false, //未处理所有冲突提示文字
  78. force: false, //请求冲突-默认false
  79. };
  80. },
  81. methods: {
  82. showDialog(force) {
  83. this.force = force
  84. if (this.tableData.length) {
  85. this.dialogVisible = true;
  86. } else {
  87. this.rulesConfirm()
  88. }
  89. },
  90. handleClick() { },
  91. handleClose() {
  92. this.dialogVisible = false;
  93. this.$emit('cancel')
  94. },
  95. //检查是否处理完所有冲突
  96. userSelected() {
  97. let flag = true;
  98. this.tableData.map(t => {
  99. if (!t.checked) {
  100. flag = false;
  101. }
  102. })
  103. this.finished = !flag;
  104. flag && this.confirmClash()
  105. },
  106. //查询是否有冲突
  107. getPromptobjs() {
  108. let param = {
  109. Force: this.force
  110. }
  111. dynamicPromptobjs(param, res => {
  112. this.tableData = res.Content.map((item) => {
  113. item.OldMsg = {}
  114. item.NewMsg = {}
  115. return item
  116. });
  117. })
  118. },
  119. //展开行
  120. expandRow(row) {
  121. let index = this.tableData.indexOf(row);
  122. if (row.OldMsg.TypeCode || row.NewMsg.TypeCode) return;
  123. let param1 = {
  124. Filters: `MeterFuncid='${row.Old}'`,
  125. PageNumber: 1,
  126. PageSize: 50
  127. }
  128. let param2 = {
  129. Filters: `MeterFuncid='${row.New}'`,
  130. PageNumber: 1,
  131. PageSize: 50
  132. }
  133. dynamicQueryPoint(param1, res => {
  134. row.OldMsg = res.Content[0]
  135. this.tableData[index] = row
  136. })
  137. dynamicQueryPoint(param2, res => {
  138. row.NewMsg = res.Content[0]
  139. this.tableData[index] = row
  140. })
  141. },
  142. //确认冲突
  143. confirmClash() {
  144. // let selectedRows = this.tableData.filter(item => {
  145. // return item.checked == 'Old'
  146. // })
  147. let selectedRows = this.tableData;
  148. let param = [];
  149. selectedRows.map(t => {
  150. let tempObj = {
  151. Objs: [t],
  152. Points: [t]
  153. }
  154. param.push(tempObj)
  155. })
  156. dynamicClashConfirm(param, res => {
  157. this.rulesConfirm();
  158. })
  159. },
  160. //执行规则
  161. rulesConfirm() {
  162. let param = {
  163. Force: this.force
  164. }
  165. dynamicExecute(param, res => {
  166. this.$message.success('执行成功');
  167. this.dialogVisible = false;
  168. this.tableData = []
  169. let missionID = res.Content[0].Id
  170. this.$emit('refresh', missionID)
  171. })
  172. }
  173. },
  174. mounted() { },
  175. created() {
  176. this.getPromptobjs()
  177. }
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. #applyRules {
  182. /deep/ td.bgf5 {
  183. background-color: #f5f7fa;
  184. }
  185. td p {
  186. text-align: center;
  187. }
  188. }
  189. </style>