index.vue 11 KB

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