allocation.vue 6.8 KB

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