index.vue 8.4 KB

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