allocation.vue 7.0 KB

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