index.vue 7.6 KB

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