index.vue 16 KB

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