allocation.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view>
  3. <view style="position: fixed;z-index: 100;">
  4. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="设备分配"></uni-nav-bar>
  5. </view>
  6. <view class="utabs">
  7. <view style="width: 95%;margin: 0 auto;">
  8. <u-tabs :list="list" :is-scroll="true" :current="current" @change="change" item-width="140" font-size="24" gutter="20"
  9. bar-width="60" active-color="#42b983"></u-tabs>
  10. </view>
  11. </view>
  12. <view class="ass_list">
  13. <checkbox-group class="che_group" @change="checkboxchange">
  14. <label class="equipment" v-for="(items,indexs) in assignments.children" :key="items.id">
  15. <view class="equipment_top">
  16. <image :src="assignments.src" mode="" class="equipment_top_img"></image>
  17. <span class="equipment_top_name">{{assignments.type_name}}</span>
  18. <checkbox :value="String(items.type_name)" :checked="items.check" class="ucheckbox" color="#42b983" />
  19. </view>
  20. <view class="equipment_bot">
  21. <p class="equipment_bot_id">设备ID:{{items.id}}</p>
  22. <p class="equipment_bot_name">设备名称:{{items.type_name}}</p>
  23. <view class="equipment_state">在线</view>
  24. </view>
  25. </label>
  26. </checkbox-group>
  27. </view>
  28. <view class="allocbtn">
  29. <button @click="cancel" class="cancel">取消分配</button>
  30. <button @click="canfirm" class="canfirm">确定分配</button>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. search: '',
  39. checken: false,
  40. assignment: [],
  41. assignments: [],
  42. list: [],
  43. current: 0,
  44. assignment_items: [],
  45. images: [{
  46. path: "../../static/image/fourMoodBase/测报灯.png",
  47. id: 3
  48. }, {
  49. path: "../../static/image/fourMoodBase/环境监测.png",
  50. id: 5
  51. }, {
  52. path: "../../static/image/fourMoodBase/监控.png",
  53. id: 6
  54. }, {
  55. path: "../../static/image/fourMoodBase/孢子仪.png",
  56. id: 7
  57. }],
  58. src: '',
  59. obj: {},
  60. addtype:[]
  61. }
  62. },
  63. methods: {
  64. async getFourbase() { //基地列表
  65. const res = await this.$myRequest({
  66. url: '/api/api_gateway?method=base.bases.base_equip',
  67. })
  68. this.assignment = res.data
  69. for (var i = 0; i < this.assignment.length; i++) {
  70. let obj = {}
  71. obj.name = this.assignment[i].type_name
  72. this.list.push(obj)
  73. if (this.assignment[i].id == this.images[i].id) {
  74. this.assignment[i].src = this.images[i].path
  75. }
  76. }
  77. this.assignments = this.assignment[this.current]
  78. for (let i = 0; i < this.assignments.children.length; i++) {
  79. this.assignments.children[i].check = false
  80. for(let j = 0;j<this.addtype.length;j++){
  81. if(this.assignments.children[i].type_name == this.addtype[j]){
  82. this.assignments.children[i].check = true
  83. }
  84. }
  85. }
  86. },
  87. forchange(obj) {
  88. for (let i = 0; i < this.assignments.children.length; i++) {
  89. this.assignments.children[i].check = false
  90. }
  91. for (let key in obj) {
  92. for (let i = 0; i < key.length; i++) {
  93. for (let j = 0; j < this.assignments.children.length; j++) {
  94. if (Number(obj[key][i]) == this.assignments.children[j].type_name) {
  95. this.assignments.children[j].check = true
  96. }
  97. }
  98. }
  99. }
  100. this.$forceUpdate()
  101. },
  102. change(index) {
  103. this.current = index
  104. this.assignments = this.assignment[index]
  105. this.forchange(this.obj)
  106. console.log(this.obj)
  107. },
  108. checkboxchange(e, items) {
  109. console.log(e.detail.value)
  110. this.obj[this.assignments.type_name] = e.detail.value
  111. this.forchange(this.obj)
  112. },
  113. clickLeft() {
  114. uni.navigateBack({
  115. delta: 1
  116. })
  117. },
  118. cancel() {
  119. this.clickLeft()
  120. },
  121. canfirm() {
  122. localStorage.setItem("id",JSON.stringify(this.obj))
  123. uni.navigateBack({
  124. delta:1
  125. })
  126. },
  127. },
  128. onLoad(option) {
  129. console.log(option)
  130. if(option.type){
  131. this.addtype = option.type.split("#")
  132. console.log(this.addtype)
  133. }
  134. this.getFourbase()
  135. },
  136. }
  137. </script>
  138. <style lang="scss">
  139. .utabs {
  140. width: 100%;
  141. position: fixed;
  142. top: 44px;
  143. z-index: 100;
  144. }
  145. .bases_search {
  146. width: 100%;
  147. position: fixed;
  148. top: 84px;
  149. z-index: 100;
  150. background-color: #FFFFFF;
  151. height: 80rpx;
  152. padding-top: 20rpx;
  153. .bases_search_text {
  154. width: 90%;
  155. margin: 0 auto;
  156. background-color: #F8F8F8;
  157. height: 60rpx;
  158. border-radius: 30rpx;
  159. display: flex;
  160. line-height: 60rpx;
  161. .search {
  162. padding: 0 20rpx;
  163. font-size: 34rpx;
  164. }
  165. input {
  166. width: 80%;
  167. margin-top: 10rpx;
  168. font-size: 28rpx;
  169. }
  170. }
  171. }
  172. .ass_list {
  173. position: absolute;
  174. top: 84px;
  175. width: 100%;
  176. margin-bottom: 40px;
  177. .che_group {
  178. display: flex;
  179. flex-direction: column;
  180. width: 90%;
  181. margin: 0 auto;
  182. }
  183. .equipment {
  184. width: 90%;
  185. margin: 20rpx auto;
  186. box-shadow: 0 0 10rpx #bcb9ca;
  187. padding: 20rpx 30rpx;
  188. .equipment_top {
  189. height: 60rpx;
  190. width: 100%;
  191. border-bottom: 1px solid #dfe5ec;
  192. position: relative;
  193. .equipment_top_img {
  194. width: 40rpx;
  195. height: 40rpx;
  196. position: absolute;
  197. }
  198. .equipment_top_name {
  199. font-size: 24rpx;
  200. margin-left: 60rpx;
  201. }
  202. .ucheckbox {
  203. float: right;
  204. margin: 0rpx -4rpx;
  205. transform: scale(0.7);
  206. }
  207. }
  208. .equipment_bot {
  209. padding: 30rpx 0;
  210. position: relative;
  211. .equipment_bot_id {
  212. font-weight: 700;
  213. font-size: 15px;
  214. margin-bottom: 16rpx;
  215. }
  216. .equipment_bot_name {
  217. font-size: 10px;
  218. }
  219. .equipment_state {
  220. position: absolute;
  221. top: 20rpx;
  222. right: 0;
  223. width: 100rpx;
  224. height: 100rpx;
  225. text-align: center;
  226. line-height: 100rpx;
  227. color: #42b983;
  228. }
  229. }
  230. }
  231. }
  232. .allocbtn {
  233. width: 100%;
  234. position: fixed;
  235. bottom: 0;
  236. z-index: 100;
  237. display: flex;
  238. button {
  239. width: 50%;
  240. font-size: 24rpx;
  241. height: 80rpx;
  242. line-height: 80rpx;
  243. border-radius: 0;
  244. }
  245. .cancel {
  246. background-color: #C8C7CC;
  247. color: #555555;
  248. }
  249. .canfirm {
  250. color: white;
  251. background-color: #42b983;
  252. }
  253. }
  254. </style>