index.vue 13 KB

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