index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div id="dynamicdata">
  3. <!-- tab分页 -->
  4. <el-row class="top-tab">
  5. <el-tabs v-model="curType" type='card'>
  6. <el-tab-pane v-for="(item) in typeList" :key="item.Name" :label="item.Name+'('+item.Sum+'/'+item.Rcount+')'" :name="item.Name">
  7. </el-tab-pane>
  8. </el-tabs>
  9. <div class="pos-right">
  10. <span style="margin-right:10px;" v-show="lastUpdateTime">最后配置完成时间:{{lastUpdateTime}}</span>
  11. <span v-if="tipsType==2" class="tips">
  12. 原始点位变化,部分标识受到影响,请重新执行对应规则
  13. <i class="el-icon-right"></i>
  14. </span>
  15. <span v-if="tipsType==3" class="tips">
  16. 对应规则有更新,记得执行哦
  17. <i class="el-icon-right"></i>
  18. </span>
  19. <span v-if="tipsType==0" class="tips">规则执行中。。。</span>
  20. <el-tooltip class="item" effect="dark" :content="'按对应规则自动设定实例动态参数信息点'" placement="left">
  21. <el-badge :is-dot="tipsType==2||tipsType==3" class="item">
  22. <el-button size="small" type="primary" @click="showSelectAll" icon="el-icon-refresh" style="float:right;" :disabled="isPending">配置
  23. </el-button>
  24. <!-- @contextmenu.native.prevent="show" -->
  25. </el-badge>
  26. </el-tooltip>
  27. </div>
  28. </el-row>
  29. <!-- 设备 -->
  30. <equipRules v-if="curType=='设备'" ref="equip" :typeName="curType" @refresh="refreshTabs" :isPending="isPending"></equipRules>
  31. <!-- 部件 -->
  32. <partsRules v-else-if="curType=='部件'" ref="parts" :typeName="curType" @refresh="refreshTabs" :isPending="isPending"></partsRules>
  33. <!-- 系统 -->
  34. <systemRules v-else-if="curType=='系统'" ref="system" :typeName="curType" @refresh="refreshTabs" :isPending="isPending"></systemRules>
  35. <!-- 空间 -->
  36. <spaceRules v-else-if="curType=='空间'" ref="space" :typeName="curType" @refresh="refreshTabs" :isPending="isPending"></spaceRules>
  37. <!-- 应用规则弹窗 -->
  38. <apply-rules-dialog ref="apply" @refresh="getExecuteFeedback" @cancel="cancelApply" @clash="getClash"></apply-rules-dialog>
  39. <!-- 冲突日志 -->
  40. <applyLog ref="applyLog"></applyLog>
  41. <!-- 规则更新提示 -->
  42. <el-dialog title="提示" :visible.sync="ruleDialogShow" width="25%" @close="rulesClose">
  43. <span>{{tipCon}}</span>
  44. <span slot="footer" class="dialog-footer">
  45. <el-button size="small" @click="rulesClose">稍后处理</el-button>
  46. <el-button size="small" type="primary" @click="apply(false)">现在执行</el-button>
  47. </span>
  48. </el-dialog>
  49. <!-- 选择增量 or 全量 执行 -->
  50. <el-dialog title="提示" :visible.sync="allApplyDialog" width="30%" @close="allApplyClose">
  51. <div id="applySelect">
  52. <el-radio v-model="force" :label="false">增量执行:只设定对应规则or原始点位有变化的实例动态参数信息点</el-radio>
  53. <p style="color:#999;">因自动判断是否变化,可能更新不够完整,但速度比较快</p>
  54. <p>
  55. <span class="el-dropdown-link" @click="allApplyFlag=true">
  56. 我要全量执行<i class="el-icon-arrow-down el-icon--right"></i>
  57. </span>
  58. </p>
  59. <div v-show="allApplyFlag">
  60. <el-radio v-model="force" :label="true">全量执行:按对应规则重新设定所有实例动态参数信息点</el-radio>
  61. <p style="color:#ff0000;">全量执行时间较长,且执行过程中相关功能不可操作</p>
  62. </div>
  63. </div>
  64. <span slot="footer" class="dialog-footer">
  65. <el-button size="small" @click="allApplyClose">取消</el-button>
  66. <el-button size="small" type="primary" @click="apply">确认</el-button>
  67. </span>
  68. </el-dialog>
  69. </div>
  70. </template>
  71. <script>
  72. import tools from "@/utils/tools";
  73. import { mapGetters, mapActions } from "vuex";
  74. // import applyRulesDialog from "@/components/point/dynamicdata/applyRulesDialog";
  75. import applyRulesDialog from "@/components/point/dynamicdata/applyRulesDialog-copy";
  76. import applyLog from "@/components/point/dynamicdata/applyLog";
  77. import equipRules from "@/components/point/dynamicdata/equipRules";
  78. import partsRules from "@/components/point/dynamicdata/partsRules";
  79. import systemRules from "@/components/point/dynamicdata/systemRules";
  80. import spaceRules from "@/components/point/dynamicdata/spaceRules";
  81. import {
  82. dynamicClashConfirm,
  83. dynamicPromptmessage,
  84. dynamicPointTypeList,
  85. dynamicExecuteFeedback
  86. } from "@/api/scan/request";
  87. export default {
  88. computed: {
  89. ...mapGetters("layout", ["projectId"])
  90. },
  91. data() {
  92. return {
  93. curType: "", //当前所在tab页
  94. typeList: [], //tab页list
  95. lastUpdateTime: "", //最后更新时间
  96. tipsType: 1, //提示信息种类
  97. ruleDialogShow: false, //规则提示执行弹窗
  98. tipCon: '', //配置按钮提示文字-规则提示执行弹窗文字
  99. allApplyDialog: false, //全量执行弹窗
  100. allApplyFlag: false, //全量执行flag
  101. force: false, //默认增量执行 ----- false - 增量 true - 全量执行
  102. isPending: false, //是否执行中:执行中禁用所有功能 true即为执行中
  103. missionID: '', //任务id
  104. hasClash: false, //默认不含冲突
  105. };
  106. },
  107. components: {
  108. applyRulesDialog,
  109. applyLog,
  110. equipRules,
  111. partsRules,
  112. systemRules,
  113. spaceRules
  114. },
  115. created() {
  116. let typeName = this.$route.query.typeName;
  117. if (typeName) {
  118. this.curType = typeName
  119. }
  120. this.init();
  121. },
  122. mounted() { },
  123. methods: {
  124. //获取查询条件-提示信息
  125. init() {
  126. let param = { Related: true };
  127. //对象类型
  128. this.getTypeNames();
  129. //获取 任务列表
  130. this.getMissionList();
  131. },
  132. //查询任务列表
  133. getMissionList() {
  134. dynamicExecuteFeedback({ Id: null }, res => {
  135. let missionList = res.Content
  136. missionList.map(mission => {
  137. if ('Success/Fail'.indexOf(mission.Completed) > -1) {
  138. } else {
  139. this.missionID = mission.Id
  140. }
  141. })
  142. if (this.missionID) {
  143. this.isPending = true;
  144. this.tipsType = 0;
  145. this.getExecuteFeedback(this.missionID)
  146. } else {
  147. this.isPending = false;
  148. this.getPrompt()
  149. }
  150. })
  151. },
  152. //获取提示消息
  153. getPrompt() {
  154. dynamicPromptmessage({}, res => {
  155. if (res.Result == "success") {
  156. if (res.Content.length) {
  157. for (let i = 0; i < res.Content.length; i++) {
  158. if (res.Content[i].Type == "最后一次执行时间") {
  159. this.tipsType = this.tipsType > 1 ? this.tipsType : 1;
  160. this.lastUpdateTime = res.Content[i].Content.substr(0, res.Content[i].Content.lastIndexOf('.'));
  161. }
  162. if (res.Content[i].Type == "原始点位增删") {
  163. this.tipsType = 2;
  164. this.tipCon = "原始点位变化,部分标识受到影响,请重新执行对应规则";
  165. this.ruleDialogShow = true;
  166. }
  167. if (res.Content[i].Type == "未执行对应规则") {
  168. this.tipsType = 3;
  169. this.tipCon = "对应规则更新,是否现在执行?";
  170. this.ruleDialogShow = true;
  171. }
  172. }
  173. } else {
  174. this.tipsType = 1;
  175. this.tipCon = '';
  176. this.lastUpdateTime = ''
  177. }
  178. }
  179. });
  180. },
  181. //获取tab页
  182. getTypeNames() {
  183. let param = { Related: true };
  184. //对象类型
  185. dynamicPointTypeList(param, res => {
  186. if (res.Result == "success") {
  187. this.typeList = res.Content;
  188. if (this.typeList.length) {
  189. //记录上次操作的tab页
  190. this.curType =
  191. this.curType != 0 ? this.curType : this.typeList[0].Name;
  192. } else {
  193. this.tableData = [];
  194. }
  195. }
  196. });
  197. },
  198. //显示选择增量or增量执行
  199. showSelectAll() {
  200. this.allApplyDialog = true;
  201. this.force = false;
  202. this.allApplyFlag = false;
  203. },
  204. //执行对应结果
  205. apply() {
  206. this.ruleDialogShow = false;
  207. this.tipsType = 0;
  208. this.isPending = true;
  209. this.allApplyClose()
  210. this.$refs.apply.showDialog(this.force);
  211. },
  212. //规则执行弹窗
  213. rulesClose() {
  214. this.ruleDialogShow = false;
  215. },
  216. //关闭选择全量-增量弹窗
  217. allApplyClose() {
  218. this.allApplyDialog = false;
  219. this.force = false;
  220. },
  221. //刷新列表
  222. refreshTabs(val) {
  223. this.curType = val;
  224. this.getTypeNames()
  225. },
  226. // show() {
  227. // console.log('右键事件')
  228. // },
  229. //获取执行反馈
  230. getExecuteFeedback(missionID) {
  231. let param = {
  232. Id: missionID
  233. }
  234. setTimeout(() => {
  235. dynamicExecuteFeedback(param, res => {
  236. this.allApplyClose()
  237. let response = res.Content[0]
  238. if ('Success/Fail'.indexOf(response.Completed) > -1) {
  239. setTimeout(() => {
  240. this.isPending = false;
  241. this.getPrompt()
  242. this.$refs.apply.getPromptobjs()
  243. if (this.hasClash) {
  244. this.$refs.applyLog.showDialog(missionID)
  245. }
  246. }, 2000)
  247. } else {
  248. this.isPending = true;
  249. this.tipsType = 0;
  250. setTimeout(() => {
  251. this.getExecuteFeedback(missionID)
  252. }, 2000)
  253. }
  254. })
  255. }, 2000)
  256. },
  257. //取消执行
  258. cancelApply(x) {
  259. this.isPending = false;
  260. this.tipsType = 1;
  261. },
  262. //接收是否有冲突
  263. getClash(length) {
  264. this.hasClash = !!length
  265. }
  266. },
  267. watch: {
  268. projectId() {
  269. this.init();
  270. }
  271. }
  272. };
  273. </script>
  274. <style lang="scss" scoped>
  275. #dynamicdata {
  276. overflow: hidden;
  277. height: 100%;
  278. background-color: #fff;
  279. padding: 10px;
  280. position: relative;
  281. /deep/ .top-tab {
  282. position: relative;
  283. height: 54px;
  284. .pos-right {
  285. position: absolute;
  286. right: 0;
  287. top: 0;
  288. .tips {
  289. color: red;
  290. position: absolute;
  291. right: 73px;
  292. width: 390px;
  293. text-align: right;
  294. padding-right: 10px;
  295. background-color: #fff;
  296. }
  297. }
  298. /deep/ .el-tabs__item.is-top {
  299. border-top: 2px solid transparent;
  300. &.is-active {
  301. border-top: 2px solid #409eff;
  302. }
  303. }
  304. }
  305. #applySelect {
  306. /deep/ .el-radio__input.is-checked + .el-radio__label {
  307. color: #000;
  308. }
  309. p {
  310. font-size: 12px;
  311. padding-left: 24px;
  312. }
  313. }
  314. }
  315. </style>