allocation.vue 6.2 KB

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