index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view class="">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择设备" @clickLeft="back"></uni-nav-bar>
  4. <uni-data-picker ref="pickerDeptName" :localdata="treeList" @change="handleChange"
  5. :map="{text:'name','value':'id'}" v-show="pickerDeptShow">
  6. </uni-data-picker>
  7. <view v-if="tableList && tableList.length!==0">
  8. <view class="p20">
  9. <radio-group @change="checkboxChange">
  10. <label v-for="(item,idx) in tableList" :key="idx" class="flex mb20 h">
  11. <radio :value="item.assetCode" :checked="item.checked" />
  12. <view class="flex flexBox">
  13. <view class="name">
  14. {{item.assetName}}
  15. </view>
  16. <view class="">
  17. <view class="mb10">{{item.assetCode}}</view>
  18. <view class="col">{{item.classificationInfo}}</view>
  19. </view>
  20. </view>
  21. </label>
  22. </radio-group>
  23. </view>
  24. <view class="footer">
  25. <view class="">
  26. <text class="footer-span-btn" @click="resetEqui">选择设备</text>
  27. <text class="footer-span-btn" @click="submit">确定({{checkListLen}})</text>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="" v-else>
  32. <view class="no_data">
  33. <view class="center">
  34. <uni-icons type="chat-filled" size="36"></uni-icons>
  35. </view>
  36. <view class="center">
  37. 暂无数据
  38. </view>
  39. </view>
  40. <view class="footer footer-right">
  41. <view class="center">
  42. <text class="footer-span-btn" @click="resetEqui">选择设备</text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. get,
  51. postJ,
  52. post
  53. } from "@/utils/api.js"
  54. let [page, size, isEnd] = [1, 10, true];
  55. export default {
  56. data() {
  57. return {
  58. treeList: [],
  59. pickerDeptShow: false,
  60. classificationId: "",
  61. tableList: [],
  62. selectList: []
  63. }
  64. },
  65. computed: {
  66. checkListLen() {
  67. const list = this.tableList.filter((el) => {
  68. if (el.checked) {
  69. return el
  70. }
  71. })
  72. return list.length
  73. }
  74. },
  75. onShow() {
  76. this.getTreeList()
  77. },
  78. onReachBottom() {
  79. if (isEnd) {
  80. return;
  81. }
  82. page++
  83. this.getList()
  84. },
  85. methods: {
  86. submit() {
  87. let list = this.tableList.filter(item => item.checked)
  88. this.$store.dispatch("repair/setSelectEqui", list)
  89. uni.$emit('selectEqui', list);
  90. this.back()
  91. },
  92. resetEqui() {
  93. this.tableList = []
  94. this.pickerDeptShow = true
  95. this.$refs.pickerDeptName.show()
  96. },
  97. checkboxChange(e) {
  98. console.log(e)
  99. this.tableList.forEach(item => {
  100. if (item.assetCode == e.detail.value) {
  101. this.$set(item, 'checked', true)
  102. } else {
  103. this.$set(item, 'checked', false)
  104. }
  105. })
  106. },
  107. handleChange(e) {
  108. let data = e.detail.value[e.detail.value.length - 1]
  109. this.classificationId = data.value
  110. page = 1;
  111. isEnd = true;
  112. this.getList();
  113. },
  114. getList() {
  115. uni.showLoading({
  116. title: "数据加载中"
  117. });
  118. let par = {
  119. assetType: "SHENGCHANSHEBEI",
  120. page,
  121. size
  122. }
  123. par[decodeURIComponent(encodeURIComponent('classificationIds[]'))] = this.classificationId
  124. get(this.apiUrl + '/asset/page', par).then(res => {
  125. // console.log(res)
  126. if (res.success) {
  127. let data = res.data.records;
  128. let pageTotal = res.data.pages;
  129. if (page === 1) {
  130. data.forEach(el => {
  131. el.num = 0
  132. })
  133. this.tableList = data;
  134. } else {
  135. data.forEach(element => {
  136. element.num = 0;
  137. this.tableList.push(element);
  138. });
  139. }
  140. page < pageTotal ? (isEnd = false) : (isEnd = true);
  141. }
  142. uni.hideLoading()
  143. })
  144. },
  145. getTreeList() {
  146. get(this.apiUrl + "/classify/getClassify?id=1").then(res => {
  147. if (res.success) {
  148. this.treeList = res.data[0].children.map(item => {
  149. item.checked = false
  150. return item
  151. })
  152. this.pickerDeptShow = true
  153. this.$refs.pickerDeptName.show()
  154. }
  155. })
  156. },
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. /deep/.uni-data-tree-input {
  162. display: none;
  163. }
  164. .p20 {
  165. padding: 20rpx 20rpx 100rpx;
  166. }
  167. .mb20 {
  168. margin-bottom: 20rpx;
  169. }
  170. .mb10 {
  171. margin-bottom: 10rpx;
  172. }
  173. .flex {
  174. display: flex;
  175. }
  176. .h {
  177. min-height: 80rpx;
  178. align-items: top;
  179. border-bottom: 1px solid #eaeaea;
  180. padding-bottom: 20rpx;
  181. }
  182. .flexBox {
  183. flex: 1;
  184. font-size: $uni-font-size-base;
  185. justify-content: space-between;
  186. margin-left: 10rpx;
  187. .col {
  188. font-size: $uni-font-size-sm;
  189. color: #555;
  190. }
  191. }
  192. .footer {
  193. position: fixed;
  194. display: flex;
  195. justify-content: flex-end;
  196. align-items: center;
  197. bottom: 0;
  198. width: 100%;
  199. height: 90rpx;
  200. text-align: center;
  201. border-top: 1rpx solid #eeecec;
  202. background-color: #FFFFFF;
  203. .bottom {
  204. font-size: $uni-font-size-lg;
  205. margin-left: 20rpx;
  206. .select-all {
  207. color: $j-primary-green;
  208. }
  209. }
  210. .footer-span-btn {
  211. height: 30rpx;
  212. line-height: 30rpx;
  213. font-size: $uni-font-size-lg;
  214. color: #ffffff;
  215. margin-right: 20rpx;
  216. padding: 10rpx 20rpx;
  217. text-align: center;
  218. background-color: $j-primary-green;
  219. border-radius: 40rpx;
  220. }
  221. }
  222. .footer-right {
  223. justify-content: flex-end;
  224. }
  225. .no_data {
  226. position: fixed;
  227. top: 50%;
  228. left: 50%;
  229. transform: translate(-50%, -50%);
  230. .center {
  231. text-align: center;
  232. color: #555;
  233. font-size: $uni-font-size-base;
  234. }
  235. }
  236. </style>