allocation.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 40px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="设备分配"></uni-nav-bar>
  7. </view>
  8. <view class="utabs">
  9. <view style="width: 95%;margin: 0 auto;">
  10. <u-tabs :list="list" :is-scroll="true" :current="current" @change="change" item-width="140" font-size="24" gutter="20"
  11. bar-width="60" active-color="#42b983"></u-tabs>
  12. </view>
  13. </view>
  14. <view class="ass_list">
  15. <checkbox-group class="che_group" @change="checkboxchange">
  16. <label class="equipment" v-for="(items,indexs) in assignments.children" :key="items.id">
  17. <view class="equipment_top">
  18. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+assignments.src" mode="" class="equipment_top_img"></image>
  19. <span class="equipment_top_name">{{assignments.type_name}}</span>
  20. <checkbox :value="String(items.type_name)" :checked="items.check" class="ucheckbox" color="#42b983" />
  21. </view>
  22. <view class="equipment_bot">
  23. <p class="equipment_bot_id">设备ID:{{items.id}}</p>
  24. <p class="equipment_bot_name">设备名称:{{items.type_name}}</p>
  25. <view class="equipment_state">在线</view>
  26. </view>
  27. </label>
  28. </checkbox-group>
  29. </view>
  30. <view class="allocbtn">
  31. <button @click="cancel" class="cancel">取消分配</button>
  32. <button @click="canfirm" class="canfirm">确定分配</button>
  33. </view>
  34. </view>
  35. <view class="top" v-if="isTop" @click="top">
  36. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  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_items: [],
  51. images: [{
  52. path: "/image/fourMoodBase/1.png",
  53. id: 3
  54. }, {
  55. path: "/image/fourMoodBase/5.png",
  56. id: 5
  57. }, {
  58. path: "/image/fourMoodBase/2.png",
  59. id: 6
  60. }, {
  61. path: "/image/fourMoodBase/4.png",
  62. id: 7
  63. },
  64. {
  65. path: "/image/fourMoodBase/10.png",
  66. id: 10
  67. }
  68. ],
  69. src: '',
  70. obj: {},
  71. isTop: false,
  72. base_id: "",
  73. baseidarr: ""
  74. }
  75. },
  76. methods: {
  77. async ybase() { //获取基地设备
  78. const res = await this.$myRequest({
  79. url: '/api/api_gateway?method=base.bases.base_map_list',
  80. data: {
  81. base_id: this.base_id
  82. }
  83. })
  84. this.baseidarr = res
  85. console.log(res)
  86. this.getFourbase()
  87. },
  88. async getFourbase() { //基地列表
  89. const res = await this.$myRequest({
  90. url: '/api/api_gateway?method=base.bases.base_equip',
  91. })
  92. this.assignment = res.data
  93. for (var i = 0; i < this.assignment.length; i++) {
  94. let obj = {}
  95. obj.name = this.assignment[i].type_name
  96. this.list.push(obj)
  97. for (var j = 0; j < this.images.length; j++) {
  98. if (this.assignment[i].id == this.images[j].id) {
  99. this.assignment[i].src = this.images[j].path
  100. }
  101. }
  102. }
  103. this.assignments = this.assignment[this.current]
  104. for (let i = 0; i < this.assignments.children.length; i++) {
  105. this.assignments.children[i].check = false
  106. for (let j = 0; j < this.baseidarr.length; j++) {
  107. if (this.assignments.children[i].type_name == this.baseidarr[j].device_id) {
  108. this.assignments.children[i].check = true
  109. console.log(this.assignments.children[i].check)
  110. }
  111. }
  112. }
  113. },
  114. forchange(obj) {
  115. for (let i = 0; i < this.assignments.children.length; i++) {
  116. this.assignments.children[i].check = false
  117. for (let key in obj) {
  118. if(key==this.list[this.current].name){
  119. for(let j = 0; j < obj[key].length; j++){
  120. if(this.assignments.children[i].type_name == obj[key][j]){
  121. this.assignments.children[i].check = true
  122. }
  123. }
  124. }
  125. }
  126. }
  127. },
  128. change(index) {
  129. this.current = index
  130. this.assignments = this.assignment[index]
  131. console.log(this.obj)
  132. this.forchange(this.obj)
  133. },
  134. checkboxchange(e, items) {
  135. this.obj[this.assignments.type_name] = JSON.parse(JSON.stringify(e.detail.value))
  136. console.log(this.obj)
  137. },
  138. clickLeft() {
  139. uni.navigateBack({
  140. delta: 1
  141. })
  142. },
  143. cancel() {
  144. this.clickLeft()
  145. },
  146. canfirm() {
  147. uni.setStorage({
  148. key:"typeid",
  149. data:JSON.stringify(this.obj),
  150. success:()=>{
  151. uni.navigateBack({
  152. delta:1
  153. })
  154. }
  155. })
  156. },
  157. top() {
  158. uni.pageScrollTo({
  159. scrollTop: 0,
  160. duration: 500
  161. })
  162. }
  163. },
  164. onLoad(option) {
  165. this.base_id = option.base_id
  166. this.ybase()
  167. },
  168. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  169. if (e.scrollTop > 200) { //距离大于200时显示
  170. this.isTop = true
  171. } else { //距离小于200时隐藏
  172. this.isTop = false
  173. }
  174. },
  175. }
  176. </script>
  177. <style lang="scss">
  178. .utabs {
  179. width: 100%;
  180. position: fixed;
  181. top: 88px;
  182. z-index: 100;
  183. }
  184. .bases_search {
  185. width: 100%;
  186. position: fixed;
  187. top: 84px;
  188. z-index: 100;
  189. background-color: #FFFFFF;
  190. height: 80rpx;
  191. padding-top: 20rpx;
  192. .bases_search_text {
  193. width: 90%;
  194. margin: 0 auto;
  195. background-color: #F8F8F8;
  196. height: 60rpx;
  197. border-radius: 30rpx;
  198. display: flex;
  199. line-height: 60rpx;
  200. .search {
  201. padding: 0 20rpx;
  202. font-size: 34rpx;
  203. }
  204. input {
  205. width: 80%;
  206. margin-top: 10rpx;
  207. font-size: 28rpx;
  208. }
  209. }
  210. }
  211. .ass_list {
  212. position: absolute;
  213. top: 84px;
  214. width: 100%;
  215. margin-bottom: 40px;
  216. .che_group {
  217. display: flex;
  218. flex-direction: column;
  219. width: 90%;
  220. margin: 0 auto;
  221. }
  222. .equipment {
  223. width: 90%;
  224. margin: 20rpx auto;
  225. box-shadow: 0 0 10rpx #bcb9ca;
  226. padding: 20rpx 30rpx;
  227. .equipment_top {
  228. height: 60rpx;
  229. width: 100%;
  230. border-bottom: 1px solid #dfe5ec;
  231. position: relative;
  232. .equipment_top_img {
  233. width: 40rpx;
  234. height: 40rpx;
  235. position: absolute;
  236. }
  237. .equipment_top_name {
  238. font-size: 24rpx;
  239. margin-left: 60rpx;
  240. }
  241. .ucheckbox {
  242. float: right;
  243. margin: 0rpx -4rpx;
  244. transform: scale(0.7);
  245. }
  246. }
  247. .equipment_bot {
  248. padding: 30rpx 0;
  249. position: relative;
  250. .equipment_bot_id {
  251. font-weight: 700;
  252. font-size: 15px;
  253. margin-bottom: 16rpx;
  254. }
  255. .equipment_bot_name {
  256. font-size: 24rpx;
  257. }
  258. .equipment_state {
  259. position: absolute;
  260. top: 20rpx;
  261. right: 0;
  262. width: 100rpx;
  263. height: 100rpx;
  264. text-align: center;
  265. line-height: 100rpx;
  266. color: #42b983;
  267. }
  268. }
  269. }
  270. }
  271. .allocbtn {
  272. width: 100%;
  273. position: fixed;
  274. bottom: 0;
  275. z-index: 100;
  276. display: flex;
  277. button {
  278. width: 50%;
  279. font-size: 24rpx;
  280. height: 80rpx;
  281. line-height: 80rpx;
  282. border-radius: 0;
  283. }
  284. .cancel {
  285. background-color: #C8C7CC;
  286. color: #555555;
  287. }
  288. .canfirm {
  289. color: white;
  290. background-color: #42b983;
  291. }
  292. }
  293. .top {
  294. position: fixed;
  295. right: 30px;
  296. bottom: 100px;
  297. z-index: 100;
  298. image {
  299. width: 100rpx;
  300. height: 100rpx;
  301. }
  302. }
  303. </style>