PlanRulesDialog.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <ele-modal
  3. :title="title"
  4. :visible.sync="visible"
  5. :close-on-click-modal="false"
  6. @close="handleClose"
  7. resizable
  8. maxable
  9. width="80%"
  10. append-to-body
  11. >
  12. <div v-if="rulesInfo">
  13. {{ JSON.stringify(planDevices) }}
  14. </div>
  15. <template v-slot:footer>
  16. <div class="footer-box">
  17. <div class="txt-tip">
  18. <span class="active">
  19. {{ rulesInfo ? rulesInfo.planDevices.length : 0 }}
  20. </span>
  21. 条记录,当前位于第
  22. <span class="active">{{ activeIndex + 1 }}</span
  23. >条
  24. </div>
  25. <el-button
  26. type="primary"
  27. icon="el-icon-arrow-left"
  28. size="mini"
  29. :disabled="activeIndex === 0"
  30. @click="activeIndex--"
  31. >
  32. 上一页
  33. </el-button>
  34. <el-button
  35. type="primary"
  36. size="mini"
  37. :disabled="activeIndex === rulesInfo.planDevices.length - 1"
  38. @click="activeIndex++"
  39. >
  40. 下一页
  41. <i class="el-icon-arrow-right el-icon--right"></i>
  42. </el-button>
  43. <el-button @click="handleClose" size="mini">关 闭</el-button>
  44. </div>
  45. </template>
  46. </ele-modal>
  47. </template>
  48. <script>
  49. import dictMixins from '@/mixins/dictMixins';
  50. export default {
  51. mixins: [dictMixins],
  52. data() {
  53. return {
  54. visible: false,
  55. title: '巡点检',
  56. // 规则信息
  57. rulesInfo: null,
  58. // 当前项
  59. activeIndex: 0
  60. };
  61. },
  62. computed: {
  63. // 当前设备信息
  64. planDevices() {
  65. if (this.rulesInfo && this.rulesInfo.planDevices) {
  66. return this.rulesInfo.planDevices[this.activeIndex];
  67. }
  68. return null;
  69. }
  70. },
  71. methods: {
  72. // 外部调用,打开弹窗
  73. open(data, title = '') {
  74. if (title) {
  75. this.title = title;
  76. }
  77. this.rulesInfo = data;
  78. console.log('this.rulesInfo', this.rulesInfo);
  79. this.visible = true;
  80. },
  81. // 关闭时清理表单
  82. handleClose() {
  83. this.$nextTick(() => {
  84. this.visible = false;
  85. });
  86. }
  87. }
  88. };
  89. </script>
  90. <style scoped lang="scss">
  91. .txt-tip {
  92. .active {
  93. color: #409eff;
  94. font-weight: bold;
  95. }
  96. }
  97. .footer-box {
  98. display: flex;
  99. align-items: center;
  100. justify-content: flex-end;
  101. gap: 15px;
  102. }
  103. </style>