allocation.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. if(option.type!=''){
  130. this.addtype = option.type.split("#")
  131. console.log(this.addtype)
  132. }
  133. this.getFourbase()
  134. },
  135. }
  136. </script>
  137. <style lang="scss">
  138. .utabs {
  139. width: 100%;
  140. position: fixed;
  141. top: 44px;
  142. z-index: 100;
  143. }
  144. .bases_search {
  145. width: 100%;
  146. position: fixed;
  147. top: 84px;
  148. z-index: 100;
  149. background-color: #FFFFFF;
  150. height: 80rpx;
  151. padding-top: 20rpx;
  152. .bases_search_text {
  153. width: 90%;
  154. margin: 0 auto;
  155. background-color: #F8F8F8;
  156. height: 60rpx;
  157. border-radius: 30rpx;
  158. display: flex;
  159. line-height: 60rpx;
  160. .search {
  161. padding: 0 20rpx;
  162. font-size: 34rpx;
  163. }
  164. input {
  165. width: 80%;
  166. margin-top: 10rpx;
  167. font-size: 28rpx;
  168. }
  169. }
  170. }
  171. .ass_list {
  172. position: absolute;
  173. top: 84px;
  174. width: 100%;
  175. margin-bottom: 40px;
  176. .che_group {
  177. display: flex;
  178. flex-direction: column;
  179. width: 90%;
  180. margin: 0 auto;
  181. }
  182. .equipment {
  183. width: 90%;
  184. margin: 20rpx auto;
  185. box-shadow: 0 0 10rpx #bcb9ca;
  186. padding: 20rpx 30rpx;
  187. .equipment_top {
  188. height: 60rpx;
  189. width: 100%;
  190. border-bottom: 1px solid #dfe5ec;
  191. position: relative;
  192. .equipment_top_img {
  193. width: 40rpx;
  194. height: 40rpx;
  195. position: absolute;
  196. }
  197. .equipment_top_name {
  198. font-size: 24rpx;
  199. margin-left: 60rpx;
  200. }
  201. .ucheckbox {
  202. float: right;
  203. margin: 0rpx -4rpx;
  204. transform: scale(0.7);
  205. }
  206. }
  207. .equipment_bot {
  208. padding: 30rpx 0;
  209. position: relative;
  210. .equipment_bot_id {
  211. font-weight: 700;
  212. font-size: 15px;
  213. margin-bottom: 16rpx;
  214. }
  215. .equipment_bot_name {
  216. font-size: 10px;
  217. }
  218. .equipment_state {
  219. position: absolute;
  220. top: 20rpx;
  221. right: 0;
  222. width: 100rpx;
  223. height: 100rpx;
  224. text-align: center;
  225. line-height: 100rpx;
  226. color: #42b983;
  227. }
  228. }
  229. }
  230. }
  231. .allocbtn {
  232. width: 100%;
  233. position: fixed;
  234. bottom: 0;
  235. z-index: 100;
  236. display: flex;
  237. button {
  238. width: 50%;
  239. font-size: 24rpx;
  240. height: 80rpx;
  241. line-height: 80rpx;
  242. border-radius: 0;
  243. }
  244. .cancel {
  245. background-color: #C8C7CC;
  246. color: #555555;
  247. }
  248. .canfirm {
  249. color: white;
  250. background-color: #42b983;
  251. }
  252. }
  253. </style>