index.vue 11 KB

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