index.vue 18 KB

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