index.vue 10 KB

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