index.vue 12 KB

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