index.vue 7.7 KB

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