index.vue 16 KB

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