index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <view class="content-box">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="搜索" @clickLeft="back">
  4. <!--右菜单-->
  5. <template slot="right">
  6. <u-button type="success" size="small" class="u-reset-button" @click="openTreePicker"
  7. text="选择分类"></u-button>
  8. </template>
  9. </uni-nav-bar>
  10. <view class="top-wrapper">
  11. <view class="searchBox rx-bc">
  12. <input v-model="keyWord" placeholder="请输入关键字搜索" class="searchInput" />
  13. <view>
  14. <u-button @click="getList" type="success" size="small" class="u-reset-button" text="搜索">
  15. </u-button>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="list_box">
  20. <u-list>
  21. <checkbox-group v-for="(item, index) in list" :key="index" @change="e => selectVal(e, item, index)">
  22. <label class="listBox rx-bs">
  23. <view class="listBox-sel">
  24. <checkbox :value="item.code" color="#fff" :disabled="item.disabled"
  25. :checked="item.checked" />
  26. </view>
  27. <view class="listBox-con">
  28. <view class="listBox-top rx-bc">
  29. <view> {{ item.assetName }}</view>
  30. <view class="code">{{ item.assetCode}}</view>
  31. </view>
  32. <view class="listBox-bottom rx">
  33. <view v-for="(itm, index) in tableH(item.rootCategoryLevelId)" :key="index"
  34. class="items">
  35. {{ itm.label }}:{{ item[itm.prop] }}
  36. </view>
  37. </view>
  38. </view>
  39. </label>
  40. </checkbox-group>
  41. <u-empty v-if='list.length == 0' style='margin-top: 20vh;' iconSize='150' textSize='32' text='暂无数据'>
  42. </u-empty>
  43. </u-list>
  44. </view>
  45. <view class="bottom-wrapper rx-bc">
  46. <view>
  47. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  48. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
  49. </checkbox>
  50. </view>
  51. <view>
  52. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen">
  53. <view class="selBtn"> 选择( {{ checkListLen }} ) </view>
  54. </u-button>
  55. </view>
  56. </view>
  57. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类"
  58. :localdata="classificationList" valueKey="id" textKey="name" childrenKey="children" />
  59. </view>
  60. </template>
  61. <script>
  62. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  63. import {
  64. tableHeader
  65. } from '../../common.js'
  66. import {
  67. treeByPid,
  68. pageeLedgerMain
  69. } from '@/api/pda/workOrder.js'
  70. export default {
  71. components: {
  72. baTreePicker
  73. },
  74. data() {
  75. return {
  76. keyWord: null,
  77. categoryLevelId: null,
  78. classificationList: [],
  79. treePickerShow: false,
  80. list: [],
  81. seletedAll: false, //全选状态
  82. memoList: []
  83. }
  84. },
  85. //选择的列表长度
  86. computed: {
  87. checkListLen() {
  88. return this.memoList.length
  89. }
  90. },
  91. onLoad(option) {
  92. this.getTreeList()
  93. },
  94. methods: {
  95. _seletedAll() {
  96. if (!this.seletedAll) {
  97. this.seletedAll = true
  98. this.list.map(item => {
  99. this.$set(item, 'checked', true)
  100. const idx = this.memoList.findIndex(itm => itm.id === item.id)
  101. if (idx === -1) {
  102. this.memoList.push(item)
  103. }
  104. })
  105. } else {
  106. this.seletedAll = false
  107. this.list.map(item => {
  108. this.$set(item, 'checked', false)
  109. const idx = this.memoList.findIndex(itm => itm.id === item.id)
  110. if (idx > -1) {
  111. this.memoList.splice(idx, 1)
  112. }
  113. })
  114. }
  115. },
  116. openTreePicker() {
  117. this.$refs.treePicker._show()
  118. },
  119. tableH(type) {
  120. return tableHeader(type)
  121. },
  122. getTreeList() {
  123. let params = {
  124. ids: [1, 5, 7, 8, 10, 14, ]
  125. }
  126. treeByPid(params).then(res => {
  127. this.classificationList = res
  128. this.confirm([res[0].id], res[0].name)
  129. })
  130. },
  131. confirm(id, name) {
  132. this.categoryLevelId = id
  133. this.getList()
  134. },
  135. getList() {
  136. let param = {
  137. categoryLevelId: this.categoryLevelId,
  138. keyWord: this.keyWord,
  139. pageNum: 1,
  140. size: -1
  141. }
  142. this.list = []
  143. pageeLedgerMain(param).then(res => {
  144. this.list.push(
  145. ...res.list.map(i => {
  146. const checked =
  147. this.memoList.findIndex(itm => itm.id === i.id) > -1
  148. return {
  149. checked,
  150. ...i
  151. }
  152. })
  153. )
  154. })
  155. },
  156. //勾选
  157. selectVal(e, val, index) {
  158. this.list[index].checked = !this.list[index].checked
  159. this.seletedAll = !this.list.some(item => !item.checked)
  160. const idx = this.memoList.findIndex(
  161. item => item.id === this.list[index].id
  162. )
  163. if (this.list[index].checked) {
  164. if (idx === -1) {
  165. this.memoList.push(this.list[index])
  166. }
  167. } else {
  168. if (idx > -1) {
  169. this.memoList.splice(idx, 1)
  170. }
  171. }
  172. }
  173. }
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. .content-box {
  178. height: 100vh;
  179. overflow: hidden;
  180. display: flex;
  181. flex-direction: column;
  182. background-color: $page-bg;
  183. }
  184. .searchBox {
  185. background-color: #dedede;
  186. height: 90rpx;
  187. padding: 0 20rpx;
  188. input {
  189. height: 70rpx;
  190. width: 540rpx;
  191. background: #f9f9f9 !important;
  192. padding-left: 10rpx;
  193. border-radius: 5rpx;
  194. }
  195. }
  196. .list_box {
  197. flex: 1;
  198. overflow: hidden;
  199. padding: 6rpx 0;
  200. .u-list {
  201. height: 100% !important;
  202. }
  203. }
  204. .bottom-wrapper {
  205. height: 80rpx;
  206. background: #fff;
  207. padding: 0 32rpx;
  208. /deep/ .uni-checkbox-input-checked {
  209. background-color: $theme-color !important;
  210. border-color: $theme-color !important;
  211. }
  212. }
  213. .listBox {
  214. padding: 4rpx 24rpx;
  215. background: #fff;
  216. /deep/ .uni-checkbox-input-checked {
  217. background-color: $theme-color !important;
  218. border-color: $theme-color !important;
  219. }
  220. .listBox-con {
  221. width: 650rpx;
  222. font-weight: 400;
  223. }
  224. .listBox-top {
  225. margin-top: 6rpx;
  226. color: #090A0A;
  227. font-size: 28rpx;
  228. font-style: normal;
  229. }
  230. .listBox-bottom {
  231. color: #090A0A;
  232. font-size: 24rpx;
  233. font-style: normal;
  234. flex-wrap: wrap;
  235. .items {
  236. width: 50%;
  237. margin-top: 6rpx;
  238. }
  239. }
  240. }
  241. </style>