index.vue 14 KB

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