details.vue 11 KB

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