Tactics.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view>
  3. <view class="option">
  4. <view class="option_title">
  5. <text style="left: 20rpx;">关联策略</text>
  6. <text style="right: 20rpx;">{{publicName}}</text>
  7. </view>
  8. <radio-group @change="Sight">
  9. <view class="option_name" v-for="(item,index) in option" :key="index">
  10. <view class="option_radio">
  11. <radio :value="item.lightName" :checked="item.lightName === lightName"></radio>
  12. </view>
  13. <view class="option_information">
  14. <view class="tactics_name">
  15. <text style="left: 120rpx;">策略名称:</text>
  16. <text>{{item.lightName}}</text>
  17. </view>
  18. <view class="tactics_detail">
  19. <text style="left: 300rpx;">策略详情:</text>
  20. <text>{{item.combinationStr[0]}}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </radio-group>
  25. <view class="operate">
  26. <button type="primary" @click="send()">确定</button>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import { tactics, changeTactics, light } from '@/pages/api/lighting/lighting.js'
  33. export default {
  34. data() {
  35. return {
  36. option: [],
  37. //被选中的单选框下标
  38. current: 0,
  39. //改变策略的信息
  40. publicName: '',
  41. publicId: 0,
  42. relationType: 0,
  43. lightId: 0,
  44. lightName: '',
  45. }
  46. },
  47. methods: {
  48. Sight(e) {
  49. for (let i = 0; i < this.option.length; i++) {
  50. if (this.option[i].lightName === e.detail.value) {
  51. this.current = i
  52. }
  53. }
  54. },
  55. send() {
  56. const index = this.current
  57. const lightId = this.option[index].lightId
  58. changeTactics(this.publicId,lightId,this.relationType,this.publicName,this.lightName).then(res => {
  59. if(res.code == 200){
  60. console.log(res)
  61. }
  62. })
  63. },
  64. policy(e){
  65. this.publicName = e.publicName
  66. this.publicId = e.publicId
  67. this.relationType = e.relationType
  68. this.lightName = e.lightName
  69. console.log(this.lightName)
  70. // this.index = parseInt(e.index2)
  71. // this.pageSize = parseInt(e.pageSize)
  72. // this.Current = parseInt(e.current)
  73. //获取策略选项列表
  74. tactics().then(res => {
  75. if (res.code == 200) {
  76. this.option = res.data
  77. }
  78. })
  79. }
  80. },
  81. onLoad(e) {
  82. this.policy(e)
  83. }
  84. }
  85. </script>
  86. <style lang="scss">
  87. page {
  88. width: 100%;
  89. height: 100%;
  90. }
  91. .option {
  92. width: 750rpx;
  93. height: 100%;
  94. }
  95. .option_title {
  96. width: 100%;
  97. height: 100rpx;
  98. line-height: 100rpx;
  99. font-size: 36rpx;
  100. border-bottom: 1px solid #dedfe3;
  101. position: relative;
  102. text {
  103. position: absolute;
  104. }
  105. }
  106. .option_name {
  107. width: 100%;
  108. height: 160rpx;
  109. border-bottom: 1px solid #dedfe3;
  110. display: flex;
  111. }
  112. .option_radio {
  113. width: 150rpx;
  114. height: 100%;
  115. display: flex;
  116. align-items: center;
  117. justify-content: center;
  118. }
  119. .option_information {
  120. width: 600rpx;
  121. height: 100%;
  122. }
  123. .tactics_name {
  124. width: 600rpx;
  125. height: 50%;
  126. font-size: 30rpx;
  127. display: flex;
  128. align-items: center;
  129. }
  130. .tactics_detail {
  131. width: 600rpx;
  132. height: 50%;
  133. font-size: 30rpx;
  134. }
  135. .operate {
  136. width: 700rpx;
  137. height: 150rpx;
  138. margin: 50rpx auto;
  139. button {
  140. font-size: 30rpx;
  141. }
  142. }
  143. </style>