allocation.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. console.log(this.assignments.children[i].check)
  84. }
  85. }
  86. }
  87. },
  88. forchange(obj) {
  89. for (let i = 0; i < this.assignments.children.length; i++) {
  90. this.assignments.children[i].check = false
  91. }
  92. for (let i = 0; i < this.assignments.children.length; i++) {
  93. // this.assignments.children[i].check = false
  94. for(let j = 0;j<this.addtype.length;j++){
  95. if(this.assignments.children[i].type_name == this.addtype[j]){
  96. this.assignments.children[i].check = true
  97. console.log(this.assignments.children[i].check)
  98. }
  99. }
  100. }
  101. for (let key in obj) {
  102. for (let i = 0; i < key.length; i++) {
  103. for (let j = 0; j < this.assignments.children.length; j++) {
  104. if (Number(obj[key][i]) == this.assignments.children[j].type_name) {
  105. this.assignments.children[j].check = true
  106. }
  107. }
  108. }
  109. }
  110. this.$forceUpdate()
  111. },
  112. change(index) {
  113. this.current = index
  114. this.assignments = this.assignment[index]
  115. this.forchange(this.obj)
  116. console.log(this.obj)
  117. },
  118. checkboxchange(e, items) {
  119. console.log(e.detail.value)
  120. this.obj[this.assignments.type_name] = e.detail.value
  121. this.forchange(this.obj)
  122. },
  123. clickLeft() {
  124. uni.navigateBack({
  125. delta: 1
  126. })
  127. },
  128. cancel() {
  129. this.clickLeft()
  130. },
  131. canfirm() {
  132. localStorage.setItem("id",JSON.stringify(this.obj))
  133. uni.navigateBack({
  134. delta:1
  135. })
  136. },
  137. },
  138. onLoad(option) {
  139. console.log(option)
  140. if(option.type){
  141. this.addtype = option.type.split("#")
  142. console.log(this.addtype)
  143. }
  144. this.getFourbase()
  145. },
  146. }
  147. </script>
  148. <style lang="scss">
  149. .utabs {
  150. width: 100%;
  151. position: fixed;
  152. top: 44px;
  153. z-index: 100;
  154. }
  155. .bases_search {
  156. width: 100%;
  157. position: fixed;
  158. top: 84px;
  159. z-index: 100;
  160. background-color: #FFFFFF;
  161. height: 80rpx;
  162. padding-top: 20rpx;
  163. .bases_search_text {
  164. width: 90%;
  165. margin: 0 auto;
  166. background-color: #F8F8F8;
  167. height: 60rpx;
  168. border-radius: 30rpx;
  169. display: flex;
  170. line-height: 60rpx;
  171. .search {
  172. padding: 0 20rpx;
  173. font-size: 34rpx;
  174. }
  175. input {
  176. width: 80%;
  177. margin-top: 10rpx;
  178. font-size: 28rpx;
  179. }
  180. }
  181. }
  182. .ass_list {
  183. position: absolute;
  184. top: 84px;
  185. width: 100%;
  186. margin-bottom: 40px;
  187. .che_group {
  188. display: flex;
  189. flex-direction: column;
  190. width: 90%;
  191. margin: 0 auto;
  192. }
  193. .equipment {
  194. width: 90%;
  195. margin: 20rpx auto;
  196. box-shadow: 0 0 10rpx #bcb9ca;
  197. padding: 20rpx 30rpx;
  198. .equipment_top {
  199. height: 60rpx;
  200. width: 100%;
  201. border-bottom: 1px solid #dfe5ec;
  202. position: relative;
  203. .equipment_top_img {
  204. width: 40rpx;
  205. height: 40rpx;
  206. position: absolute;
  207. }
  208. .equipment_top_name {
  209. font-size: 24rpx;
  210. margin-left: 60rpx;
  211. }
  212. .ucheckbox {
  213. float: right;
  214. margin: 0rpx -4rpx;
  215. transform: scale(0.7);
  216. }
  217. }
  218. .equipment_bot {
  219. padding: 30rpx 0;
  220. position: relative;
  221. .equipment_bot_id {
  222. font-weight: 700;
  223. font-size: 15px;
  224. margin-bottom: 16rpx;
  225. }
  226. .equipment_bot_name {
  227. font-size: 10px;
  228. }
  229. .equipment_state {
  230. position: absolute;
  231. top: 20rpx;
  232. right: 0;
  233. width: 100rpx;
  234. height: 100rpx;
  235. text-align: center;
  236. line-height: 100rpx;
  237. color: #42b983;
  238. }
  239. }
  240. }
  241. }
  242. .allocbtn {
  243. width: 100%;
  244. position: fixed;
  245. bottom: 0;
  246. z-index: 100;
  247. display: flex;
  248. button {
  249. width: 50%;
  250. font-size: 24rpx;
  251. height: 80rpx;
  252. line-height: 80rpx;
  253. border-radius: 0;
  254. }
  255. .cancel {
  256. background-color: #C8C7CC;
  257. color: #555555;
  258. }
  259. .canfirm {
  260. color: white;
  261. background-color: #42b983;
  262. }
  263. }
  264. </style>