index.vue 13 KB

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