save.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <!-- 新建/修改 方案 -->
  2. <template>
  3. <div class="index-container">
  4. <!-- 步骤栏 -->
  5. <steps-bar class-name="steps-bar" :current-step="currentStep" :current-plan-data="currentPlanData" @changeStep="getStep" />
  6. <!-- <steps-bar class-name="steps-bar" :active="currentStep" @changeStep="getStep" /> -->
  7. <!-- 1-检测方案配置表单 -->
  8. <plan-config v-if="mountedFinished" class-name="plan-config" :current-step="currentStep" :current-plan-data="currentPlanData" @updataPlanData="updataCurrentPlanData" @changeStep="getStep" />
  9. <!-- 2-测点导入 -->
  10. <plan-check-point v-if="currentPlanData.id>0 && isMaster104===false" ref="planCheckPoint" class-name="plan-check-point" :current-step="currentStep" :current-plan-data="currentPlanData" @changeStep="getStep" />
  11. <plan-check-point-master104 v-if="currentPlanData.id>0 && isMaster104===true" ref="planCheckPointMaster104" class-name="plan-check-point" :current-step="currentStep" :current-plan-data="currentPlanData" @changeStep="getStep" />
  12. <!-- 3-步骤设置 -->
  13. <plan-steps v-if="currentPlanData.id>0" ref="planSteps" class-name="plan-steps" :current-step="currentStep" :current-plan-data="currentPlanData" @changeStep="getStep" />
  14. <!-- 4-用例设置 -->
  15. <plan-example v-if="currentPlanData.id>0" ref="planExample" class-name="plan-example" :current-step="currentStep" :current-plan-data="currentPlanData" @changeStep="getStep" />
  16. </div>
  17. </template>
  18. <script>
  19. import { mapGetters } from 'vuex'
  20. // 步骤栏
  21. import StepsBar from './components/StepsBar'
  22. // 检测方案配置
  23. import PlanConfig from './components/PlanConfig'
  24. // 测点导入
  25. import PlanCheckPoint from './components/PlanCheckPoint'
  26. // 主站104检测方案-测点导入
  27. import PlanCheckPointMaster104 from './components/PlanCheckPoint_master104'
  28. // 步骤设置
  29. import PlanSteps from './components/PlanSteps'
  30. // 用例设置
  31. import PlanExample from './components/PlanExample'
  32. // 公用接口
  33. import { httpGet } from '@/api/common-action'
  34. export default {
  35. name: 'Plan',
  36. components: {
  37. StepsBar,
  38. PlanConfig,
  39. PlanCheckPoint,
  40. PlanCheckPointMaster104, // 主站104检测时的测点导入组件
  41. PlanSteps,
  42. PlanExample
  43. },
  44. data() {
  45. return {
  46. isMaster104: false, // 是否是主站104检测方案
  47. currentStep: 0,
  48. currentPlanData: {},
  49. mountedFinished: false,
  50. checkSteps: []
  51. // className: 'steps-bar'
  52. }
  53. },
  54. computed: {
  55. ...mapGetters([
  56. 'roles'
  57. ])
  58. },
  59. // watch: {
  60. // currentPlanData(val) {
  61. // console.log(`creat planId changed, planId=`, val)
  62. // this.currentPlanData = val
  63. // },
  64. // deep: true
  65. // },
  66. created() {
  67. },
  68. mounted() {
  69. // console.log(`this.$route.query=${this.$route.query.planId}`)
  70. // console.log('this.$route.query=', this.$route.query)
  71. this.$nextTick(() => {
  72. this.initFunctions()
  73. })
  74. },
  75. methods: {
  76. // 初始化
  77. async initFunctions() {
  78. // 获取planId
  79. // 乘以1强制转换成数字型
  80. this.currentPlanData.id = this.$route.query.planId * 1
  81. if (this.currentPlanData.id) {
  82. // 通过planId 获取 方案配置 数据
  83. const res = await httpGet(`/test/suite/${this.currentPlanData.id}`)
  84. // console.log('save initFunctions httpGet res=', res)
  85. if (res.productType === 'IEC104') {
  86. this.isMaster104 = true
  87. } else {
  88. this.isMaster104 = false
  89. }
  90. this.currentPlanData = res
  91. // if (res.productType === 'LOW_POWER' || res.protocolValue === 'MICRO_POWER') {
  92. // this.className = 'one-steps-bar'
  93. // }
  94. }
  95. // 加载完成再加载 PlanConfig 否则 currentPlanData 可能会传不成功
  96. this.mountedFinished = true
  97. },
  98. // 操作步骤变更
  99. getStep(changeStep, currentPlanData) {
  100. // console.log('getStep changeStep=', changeStep)
  101. // console.log('getStep currentPlanData=', currentPlanData)
  102. this.currentStep = changeStep
  103. // console.log('currentStep=', this.currentStep)
  104. if (currentPlanData) {
  105. this.currentPlanData = currentPlanData
  106. }
  107. if (this.currentStep === 1) {
  108. // 当前方案是否是主站104方案
  109. if (this.isMaster104) {
  110. this.$refs.planCheckPointMaster104.getPlanCheckPoint()
  111. } else {
  112. this.$refs.planCheckPoint.getPlanCheckPoint()
  113. }
  114. } else if (this.currentStep === 2) {
  115. this.$refs.planSteps.getPlanSteps()
  116. } else if (this.currentStep === 3) {
  117. this.$refs.planExample.getPlanExamples()
  118. // this.$refs.planExample.tableLayout()
  119. }
  120. // this.$refs.planCheckPoint.tableLayout()
  121. // this.$refs.planSteps.tableLayout()
  122. // this.$refs.planExample.tableLayout()
  123. },
  124. // currentPlanData变更
  125. updataCurrentPlanData(val) {
  126. // console.log('newVal = ', val)
  127. this.$set(this.currentPlanData, 'productType', val)
  128. }
  129. }
  130. }
  131. </script>
  132. <!-- 公用样式 -->
  133. <style lang="scss">
  134. // 底部按钮
  135. .bottom-button {
  136. display: flex;
  137. justify-content: center;
  138. padding-bottom: 20px;
  139. .cancel-plan {
  140. padding-right: 20px;
  141. }
  142. }
  143. // 按钮公用样式
  144. .dark-button {
  145. background-color: #00706B;
  146. border: 1px #00706B solid;
  147. color: #fff;
  148. }
  149. .light-button {
  150. color: #00706B;
  151. border: 1px #00706B solid;
  152. }
  153. </style>
  154. <!-- 专用样式 -->
  155. <style lang="scss" scoped>
  156. .index-container {
  157. min-height: calc(100vh - 120px);
  158. border: 1px #CCC solid;
  159. margin: 30px 30px 0px 30px;
  160. }
  161. </style>