index.vue 12 KB

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