index.vue 10 KB

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