details.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <template>
  2. <view class="content-box">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" background-color="#F7F9FA"
  4. color="#000" @clickLeft="back" right-icon="scan" @clickRight="handlScanCode"></uni-nav-bar>
  5. <view class="list_box">
  6. <u-list @scrolltolower="scrolltolower">
  7. <view v-for="(item,index) in List" :key="index" class="card_box">
  8. <workOrderBom :item='item' @handleScan='handleScan'></workOrderBom>
  9. <paramBom v-if='item.paramDetailList.length != 0' :list='item.paramDetailList'></paramBom>
  10. <deviceBom v-if='item.equipmentList.length != 0' :workOrderId='item.workOrderId'
  11. :list='item.equipmentList' @scanIt='scanIt'></deviceBom>
  12. <productsBom v-if="item.product != null && item.product != '{}'" :productsObj="item.product">
  13. </productsBom>
  14. <modelBom v-if='item.modelList.length != 0' :workOrderId='item.workOrderId' :list='item.modelList'
  15. @scanIt='scanIt'>
  16. </modelBom>
  17. <instanceBom v-if='item.instanceList.length != 0' :workOrderId='item.workOrderId'
  18. :list='item.instanceList' :equipmentList="item.equipmentList"
  19. :currentTaskDiagram="item.currentTaskDiagram"></instanceBom>
  20. <semiProductBom v-if='item.semiProductList.length != 0' :workOrderId='item.workOrderId'
  21. :list='item.semiProductList' :equipmentList="item.equipmentList"
  22. :currentTaskDiagram="item.currentTaskDiagram"></semiProductBom>
  23. <turnoverBom v-if='item.turnover.length != 0' :list='item.turnover' :wordItem='item' pattern='feed'
  24. @handleScan='handleScan' @handleDel='handleDel'></turnoverBom>
  25. <aridRegion v-if='item.aridRegionList.length != 0' :list='item.aridRegionList'
  26. @handleScan='handleScan'></aridRegion>
  27. <palletBom v-if='item.palletList.length != 0' :palletList='item.palletList'></palletBom>
  28. <revolvingDiskBom v-if="item.revolvingDiskList.length != 0"
  29. :revolvingDiskList="item.revolvingDiskList"></revolvingDiskBom>
  30. <packingBom v-if='item.packingList.length != 0' :list='item.packingList'></packingBom>
  31. <view class='flex_btn' @click="openDetails(item.workOrderId)">出库单</view>
  32. <view class="operate_box ">
  33. <u-button size="small" class="u-reset-button" type="success"
  34. @click="handAdd(item.workOrderId)">手动添加</u-button>
  35. <u-button size="small" class="u-reset-button" type="success"
  36. @click="scanIt(item.workOrderId)">扫一扫</u-button>
  37. </view>
  38. </view>
  39. </u-list>
  40. </view>
  41. <view class="bottom-wrapper">
  42. <view class="btn_box" @click="save">一键投料</view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import workOrderBom from './components/workOrderBom.vue'
  48. import deviceBom from './components/deviceBom.vue'
  49. import modelBom from './components/modelBom.vue'
  50. import instanceBom from './components/instanceBom.vue'
  51. import semiProductBom from './components/semiProductBom'
  52. import aridRegion from './components/aridRegion'
  53. import paramBom from './components/paramBom.vue'
  54. import turnoverBom from '../jobBooking/components/turnoverBom.vue'
  55. import packingBom from './components/packingBom.vue'
  56. import productsBom from './components/productsBom.vue'
  57. import palletBom from './components/palletBom'
  58. import revolvingDiskBom from './components/revolvingDiskBom'
  59. import {
  60. workorderList,
  61. getByCode,
  62. scanLedger
  63. } from '@/api/pda/workOrder.js'
  64. import {
  65. batchSave
  66. } from '@/api/pda/feeding.js'
  67. export default {
  68. components: {
  69. workOrderBom,
  70. deviceBom,
  71. modelBom,
  72. instanceBom,
  73. semiProductBom,
  74. aridRegion,
  75. paramBom,
  76. turnoverBom,
  77. packingBom,
  78. productsBom,
  79. palletBom,
  80. revolvingDiskBom,
  81. },
  82. data() {
  83. return {
  84. title: '',
  85. idsList: [],
  86. List: [],
  87. taskId: null,
  88. clientEnvironmentId: null,
  89. }
  90. },
  91. onLoad(options) {
  92. this.title = options.taskName ? options.taskName + '-投料' : '投料'
  93. let queryArray = decodeURIComponent(options.arr);
  94. this.idsList = JSON.parse(queryArray);
  95. this.taskId = options.taskId
  96. this.taskName = options.taskName
  97. this.getList()
  98. this.clientEnvironmentId = uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo").clientEnvironmentId
  99. },
  100. onShow() {
  101. uni.$off("setSelectList");
  102. uni.$on("setSelectList", (selectList, id) => {
  103. this.List.forEach(m => {
  104. if (m.workOrderId == id) {
  105. let modelList = [] // 模具
  106. let instanceList = [] // 投料
  107. let aridRegionList = [] // 干燥区
  108. let equipmentList = [] // 生产设备
  109. let palletList = [] // 舟皿
  110. let revolvingDiskList = [] // 周转盘
  111. let semiProductList = [] // 半成品
  112. selectList.forEach(f => {
  113. if (f.rootCategoryLevelId == 4) {
  114. equipmentList = equipmentList.concat(f)
  115. }
  116. if (f.rootCategoryLevelId == 5) {
  117. modelList = modelList.concat(f)
  118. } else if (f.rootCategoryLevelId == 1) {
  119. instanceList = instanceList.concat(f)
  120. }
  121. else if (f.rootCategoryLevelId == 11) {
  122. aridRegionList = aridRegionList.concat(f)
  123. } else if (f.rootCategoryLevelId == 8) {
  124. palletList = palletList.concat(f)
  125. } else if (f.rootCategoryLevelId == 26) {
  126. revolvingDiskList = revolvingDiskList.concat(f)
  127. } else if (f.rootCategoryLevelId == 23 || f.rootCategoryLevelId == 2) {
  128. semiProductList = semiProductList.concat(f)
  129. }
  130. })
  131. this.$set(m, 'modelList', modelList)
  132. this.$set(m, 'instanceList', instanceList)
  133. this.$set(m, 'aridRegionList', aridRegionList)
  134. this.$set(m, 'equipmentList', equipmentList)
  135. this.$set(m, 'palletList', palletList)
  136. this.$set(m, 'revolvingDiskList', revolvingDiskList)
  137. this.$set(m, 'semiProductList', semiProductList)
  138. }
  139. })
  140. });
  141. },
  142. methods: {
  143. scrolltolower() {},
  144. save() {
  145. if (this.clientEnvironmentId == 3) {
  146. this.List.forEach(e => {
  147. if (e.equipmentList.length == 1 && e.instanceList.length > 0) {
  148. e.instanceList.forEach(o => {
  149. if (o.rootCategoryLevelId == 1 && o.isConsumable == 0) {
  150. o['deviceName'] = e.equipmentList[0].name
  151. o['deviceId'] = e.equipmentList[0].id
  152. o['workstationName'] = e.equipmentList[0].workstationName
  153. }
  154. })
  155. }
  156. if (e.equipmentList.length == 1 && e.semiProductList.length > 0) {
  157. e.semiProductList.forEach(o => {
  158. if (o.rootCategoryLevelId == 23 && o.isConsumable == 0) {
  159. o['deviceName'] = e.equipmentList[0].name
  160. o['deviceId'] = e.equipmentList[0].id
  161. o['workstationName'] = e.equipmentList[0].workstationName
  162. }
  163. })
  164. }
  165. })
  166. }
  167. this.List.forEach(f => {
  168. f.instanceList.forEach(e => {
  169. if (Object.prototype.hasOwnProperty.call(e, 'type')) {
  170. e.extInfo['type'] = e.type
  171. }
  172. e.extInfo['isConsumable'] = e.isConsumable
  173. })
  174. })
  175. batchSave(this.List).then(res => {
  176. uni.redirectTo({
  177. url: `/pages/pda/feeding/index/index?feedStatus=1`,
  178. });
  179. })
  180. },
  181. getList() {
  182. workorderList({
  183. ids: this.idsList,
  184. taskId: this.taskId
  185. }).then(res => {
  186. this.List = res.map(m => {
  187. m.workOrderId = m.id
  188. m.instanceList = [] // 物料
  189. m.equipmentList = [] // 设备
  190. m.modelList = [] // 模具
  191. m.aridRegionList = [] // 干燥区
  192. m.packingList = [] // 包装
  193. m.palletList = [] // 舟皿
  194. m.revolvingDiskList = [] // 周转盘
  195. m.semiProductList = [] //半成品
  196. if (m.pickOutInList.length > 0) {
  197. m.pickOutInList.forEach(f => {
  198. if (f.rootCategoryLevelId == 1) {
  199. m.instanceList.push(f)
  200. } else if (f.rootCategoryLevelId == 4) {
  201. m.modelList.push(f)
  202. } else if (f.rootCategoryLevelId == 5) {
  203. m.modelList.push(f)
  204. } else if (f.rootCategoryLevelId == 11) {
  205. m.aridRegionList.push(f)
  206. } else if (f.rootCategoryLevelId == 13) {
  207. m.packingList.push(f)
  208. } else if (f.rootCategoryLevelId == 8) {
  209. m.palletList.push(f)
  210. } else if (f.rootCategoryLevelId == 26) {
  211. m.revolvingDiskList.push(f)
  212. } else if (f.rootCategoryLevelId == 23 || f.rootCategoryLevelId == 2) {
  213. m.semiProductList.push(f)
  214. }
  215. })
  216. }
  217. // 处理字段
  218. m.quality == '' ? m.quality = {} : ''
  219. if (!Object.prototype.hasOwnProperty.call(m, 'product')) {
  220. m.product = '{}'
  221. }
  222. console.log(m)
  223. delete m.id
  224. if (this.taskId) {
  225. m.taskId = this.taskId
  226. m.taskName = this.taskName
  227. }
  228. return {
  229. ...m
  230. }
  231. })
  232. })
  233. },
  234. handleScan(id, type) {
  235. console.log(id)
  236. console.log(type)
  237. // this.scanData('SCJHGD20240117002', type, id)
  238. // return false
  239. let _this = this
  240. uni.scanCode({
  241. success: function(res) {
  242. _this.scanData(res.result, type, id)
  243. }
  244. })
  245. },
  246. scanData(result, type, id) {
  247. if (type == 'wordOrder') {
  248. let isFals = this.List.some(m => m.code == result)
  249. if (isFals) {
  250. uni.showToast({
  251. title: '工单已存在',
  252. icon: 'none'
  253. })
  254. return false
  255. }
  256. getByCode(result).then(res => {
  257. let _arr = this.List
  258. _arr.forEach((e, index) => {
  259. if (e.workOrderId == id && res) {
  260. _arr[index] = res
  261. }
  262. })
  263. this.List = _arr
  264. this.$forceUpdate()
  265. })
  266. }
  267. },
  268. scanIt(id) {
  269. console.log(id)
  270. let _this = this
  271. uni.scanCode({
  272. success: function(res) {
  273. _this.scanItData(res.result, id)
  274. console.log(res.result, id)
  275. }
  276. })
  277. },
  278. scanItData(result, id) {
  279. scanLedger(result).then(res => {
  280. console.log(res)
  281. let _arr = []
  282. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  283. _arr = this.List
  284. _arr.forEach((e, index) => {
  285. if (e.workOrderId == id) {
  286. _arr[index].equipmentList = _arr[index].equipmentList.concat(res)
  287. }
  288. })
  289. this.List = _arr
  290. this.$forceUpdate()
  291. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  292. _arr = this.List
  293. _arr.forEach((e, index) => {
  294. if (e.workOrderId == id) {
  295. _arr[index].modelList = res
  296. }
  297. })
  298. this.List = _arr
  299. this.$forceUpdate()
  300. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) { // 物料
  301. _arr = this.List
  302. _arr.forEach((e, index) => {
  303. if (e.workOrderId == id) {
  304. _arr[index].instanceList = _arr[index].instanceList.concat(res)
  305. }
  306. })
  307. this.List = _arr
  308. this.$forceUpdate()
  309. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 11) { // 干燥区
  310. _arr = this.List
  311. _arr.forEach((e, index) => {
  312. if (e.workOrderId == id) {
  313. let isFals = _arr[index].aridRegionList.some(m => m.code == res[0]
  314. .aridRegionList[0].code)
  315. if (isFals) {
  316. uni.showToast({
  317. title: '干燥区已存在',
  318. icon: 'none'
  319. })
  320. return false
  321. }
  322. let _obj = res[0].aridRegionList[0]
  323. if (_obj.status == 0) {
  324. _obj['name'] = res[0].name
  325. _obj['region'] = res[0].extInfo.region
  326. _arr[index].aridRegionList = _arr[index].aridRegionList.concat(res[0]
  327. .aridRegionList)
  328. } else {
  329. uni.showToast({
  330. title: '干燥区已占用',
  331. icon: 'none'
  332. })
  333. }
  334. }
  335. })
  336. this.List = _arr
  337. this.$forceUpdate()
  338. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  339. let isFals = _arr[index].turnover.some(m => m.code == res[0].code)
  340. if (isFals) {
  341. uni.showToast({
  342. title: '周转车已存在',
  343. icon: 'none'
  344. })
  345. return false
  346. }
  347. }
  348. })
  349. },
  350. // 全部扫一扫
  351. handlScanCode() {
  352. let _this = this
  353. uni.scanCode({
  354. success: function(res) {
  355. _this.scanItAllData(res.result)
  356. }
  357. })
  358. },
  359. scanItAllData(result) {
  360. scanLedger(result).then(res => {
  361. let _arr = []
  362. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  363. _arr = this.List
  364. _arr.forEach((e, index) => {
  365. res['extInfo'].fixCode = res.fixCode
  366. e.equipmentList = e.equipmentList.concat(res)
  367. })
  368. this.List = _arr
  369. this.$forceUpdate()
  370. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  371. _arr = this.List
  372. _arr.forEach((e, index) => {
  373. e.modelList = res
  374. })
  375. this.List = _arr
  376. this.$forceUpdate()
  377. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) {
  378. _arr = this.List
  379. _arr.forEach((e, index) => {
  380. e.instanceList = e.instanceList.concat(res)
  381. })
  382. this.List = _arr
  383. this.$forceUpdate()
  384. }
  385. })
  386. },
  387. handAdd(id) {
  388. const storageKey = Date.now() + "";
  389. uni.setStorageSync(storageKey, this.List || []);
  390. uni.navigateTo({
  391. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed&taskId=${this.taskId}`
  392. })
  393. },
  394. openDetails(id) {
  395. const storageKey = Date.now() + "";
  396. uni.setStorageSync(storageKey, this.List || []);
  397. let url = `/pages/pda/feeding/single?id=${id}&taskId=${this.taskId}&storageKey=${storageKey}`
  398. uni.navigateTo({
  399. url
  400. })
  401. },
  402. },
  403. }
  404. </script>
  405. <style lang="scss" scoped>
  406. .content-box {
  407. height: 100vh;
  408. overflow: hidden;
  409. display: flex;
  410. flex-direction: column;
  411. }
  412. .list_box {
  413. flex: 1;
  414. overflow: hidden;
  415. padding: 4rpx 0;
  416. .u-list {
  417. height: 100% !important;
  418. }
  419. .card_box {
  420. padding: 16rpx;
  421. }
  422. }
  423. .bottom-wrapper {
  424. .btn_box {
  425. width: 750rpx;
  426. height: 88rpx;
  427. line-height: 88rpx;
  428. background: $theme-color;
  429. text-align: center;
  430. font-size: 36rpx;
  431. font-style: normal;
  432. font-weight: 400;
  433. color: #fff;
  434. }
  435. }
  436. .operate_box {
  437. position: fixed;
  438. right: 0;
  439. top: 400rpx;
  440. /deep/ .u-button {
  441. margin-top: 20rpx;
  442. width: 150rpx;
  443. border-radius: 22rpx 0 0 22rpx;
  444. opacity: 0.6;
  445. }
  446. }
  447. .flex_btn {
  448. position: fixed;
  449. right: 0;
  450. bottom: 160rpx;
  451. width: 140rpx;
  452. height: 66rpx;
  453. line-height: 66rpx;
  454. border-radius: 22rpx 0 0 22rpx;
  455. background: $theme-color;
  456. text-align: center;
  457. font-size: 22rpx;
  458. font-style: normal;
  459. font-weight: 400;
  460. color: #fff;
  461. opacity: 0.6;
  462. }
  463. </style>