index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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.name }}</view>
  30. <view class="code">{{ item.code}}</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 class="items">
  38. 可用库存:{{ item.availableCountBase }} {{item.unit}}
  39. </view>
  40. </view>
  41. </view>
  42. </label>
  43. </checkbox-group>
  44. <view v-if='list.length == 0' style='margin-top: 20vh;' >
  45. <u-empty iconSize='150' textSize='32' text='暂无数据'>
  46. </u-empty>
  47. </view>
  48. </u-list>
  49. </view>
  50. <view class="bottom-wrapper rx-bc">
  51. <view>
  52. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  53. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
  54. </checkbox>
  55. </view>
  56. <view>
  57. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="jumpAdd">
  58. <view> 选择( {{ checkListLen }} ) </view>
  59. </u-button>
  60. </view>
  61. </view>
  62. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类"
  63. :localdata="classificationList" valueKey="id" textKey="name" childrenKey="children" />
  64. </view>
  65. </template>
  66. <script>
  67. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  68. import {
  69. tableHeader
  70. } from '../../common.js'
  71. import {
  72. treeByPid,
  73. pageeLedgerMain,
  74. assetPage
  75. } from '@/api/pda/workOrder.js'
  76. export default {
  77. components: {
  78. baTreePicker
  79. },
  80. data() {
  81. return {
  82. keyWord: null,
  83. categoryLevelId: null,
  84. classificationList: [],
  85. treePickerShow: false,
  86. list: [],
  87. seletedAll: false, //全选状态
  88. memoList: [],
  89. isType: null,
  90. pid: null, // 上个页面id
  91. storageKey: null
  92. }
  93. },
  94. //选择的列表长度
  95. computed: {
  96. checkListLen() {
  97. return this.memoList.length
  98. }
  99. },
  100. onLoad(option) {
  101. this.pid = option.id
  102. this.isType = option.isType
  103. if (option.storageKey) {
  104. this.storageKey = option.storageKey
  105. this.memoList = (this.storageKey && uni.getStorageSync(this.storageKey)) || []
  106. }
  107. this.getTreeList()
  108. },
  109. onUnload() {
  110. if (this.storageKey) {
  111. uni.removeStorage(this.storageKey)
  112. }
  113. },
  114. methods: {
  115. _seletedAll() {
  116. if (!this.seletedAll) {
  117. this.seletedAll = true
  118. this.list.map(item => {
  119. this.$set(item, 'checked', true)
  120. const idx = this.memoList.findIndex(itm => itm.id === item.id)
  121. if (idx === -1) {
  122. this.memoList.push(item)
  123. }
  124. })
  125. } else {
  126. this.seletedAll = false
  127. this.list.map(item => {
  128. this.$set(item, 'checked', false)
  129. const idx = this.memoList.findIndex(itm => itm.id === item.id)
  130. if (idx > -1) {
  131. this.memoList.splice(idx, 1)
  132. }
  133. })
  134. }
  135. },
  136. openTreePicker() {
  137. this.$refs.treePicker._show()
  138. },
  139. tableH(type) {
  140. return tableHeader(type)
  141. },
  142. getTreeList() {
  143. let params = {
  144. ids: [1, 5, 7, 8, 10, 14]
  145. }
  146. treeByPid(params).then(res => {
  147. this.classificationList = res
  148. this.confirm([res[0].id], res[0].name)
  149. })
  150. },
  151. confirm(id, name) {
  152. this.categoryLevelId = id
  153. this.getList()
  154. },
  155. getList() {
  156. let param = {
  157. categoryLevelId: this.categoryLevelId,
  158. keyWord: this.keyWord,
  159. pageNum: 1,
  160. size: -1,
  161. }
  162. this.list = []
  163. if(this.isType == 'pick') {
  164. param.dimension = 1
  165. pageeLedgerMain(param).then(res => {
  166. this.list.push(
  167. ...res.list.map(i => {
  168. const checked =
  169. this.memoList.findIndex(itm => itm.id === i.id) > -1
  170. const warehouseId = i.pathIds && i.pathIds.split(',')[0]
  171. return {
  172. checked,
  173. warehouseId,
  174. ...i,
  175. instanceId: i.id,
  176. categoryId: i.assetId,
  177. }
  178. })
  179. )
  180. })
  181. } else if(this.isType == 'feed') {
  182. assetPage(param).then(res => {
  183. this.list.push(
  184. ...res.list.map(i => {
  185. const checked =
  186. this.memoList.findIndex(itm => itm.id === i.id) > -1
  187. const warehouseId = i.pathIds && i.pathIds.split(',')[0]
  188. return {
  189. checked,
  190. warehouseId,
  191. ...i,
  192. instanceId: i.id,
  193. categoryId: i.assetId,
  194. }
  195. })
  196. )
  197. })
  198. }
  199. },
  200. //勾选
  201. selectVal(e, val, index) {
  202. this.list[index].checked = !this.list[index].checked
  203. this.seletedAll = !this.list.some(item => !item.checked)
  204. const idx = this.memoList.findIndex(
  205. item => item.id === this.list[index].id
  206. )
  207. if (this.list[index].checked) {
  208. if (idx === -1) {
  209. this.memoList.push(this.list[index])
  210. }
  211. } else {
  212. if (idx > -1) {
  213. this.memoList.splice(idx, 1)
  214. }
  215. }
  216. },
  217. //跳转回添加页面
  218. jumpAdd() {
  219. uni.$emit('setSelectList', this.memoList, this.pid)
  220. uni.navigateBack()
  221. },
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .content-box {
  227. height: 100vh;
  228. overflow: hidden;
  229. display: flex;
  230. flex-direction: column;
  231. background-color: $page-bg;
  232. }
  233. .searchBox {
  234. background-color: #dedede;
  235. height: 90rpx;
  236. padding: 0 20rpx;
  237. input {
  238. height: 70rpx;
  239. width: 540rpx;
  240. background: #f9f9f9 !important;
  241. padding-left: 10rpx;
  242. border-radius: 5rpx;
  243. }
  244. }
  245. .list_box {
  246. flex: 1;
  247. overflow: hidden;
  248. padding: 6rpx 0;
  249. .u-list {
  250. height: 100% !important;
  251. }
  252. }
  253. .bottom-wrapper {
  254. height: 80rpx;
  255. background: #fff;
  256. padding: 0 32rpx;
  257. /deep/ .uni-checkbox-input-checked {
  258. background-color: $theme-color !important;
  259. border-color: $theme-color !important;
  260. }
  261. }
  262. .listBox {
  263. margin-top: 8rpx;
  264. padding: 8rpx 24rpx;
  265. background: #fff;
  266. /deep/ .uni-checkbox-input-checked {
  267. background-color: $theme-color !important;
  268. border-color: $theme-color !important;
  269. }
  270. .listBox-con {
  271. width: 650rpx;
  272. font-weight: 400;
  273. }
  274. .listBox-top {
  275. margin-top: 6rpx;
  276. color: #090A0A;
  277. font-size: 28rpx;
  278. font-style: normal;
  279. }
  280. .listBox-bottom {
  281. color: #090A0A;
  282. font-size: 24rpx;
  283. font-style: normal;
  284. flex-wrap: wrap;
  285. .items {
  286. width: 50%;
  287. margin-top: 8rpx;
  288. }
  289. }
  290. }
  291. </style>