details.vue 13 KB

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