details.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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 != '{}'" :productsObj="item.product"></productsBom>
  13. <modelBom v-if='item.modelList.length != 0' :workOrderId='item.workOrderId' :list='item.modelList'
  14. @scanIt='scanIt'>
  15. </modelBom>
  16. <instanceBom v-if='item.instanceList.length != 0' :workOrderId='item.workOrderId'
  17. :list='item.instanceList'></instanceBom>
  18. <turnoverBom v-if='item.turnover.length != 0' :list='item.turnover' :wordItem='item' pattern='feed'
  19. @handleScan='handleScan' @handleDel='handleDel'></turnoverBom>
  20. <aridRegion v-if='item.aridRegionList.length != 0' :list='item.aridRegionList'
  21. @handleScan='handleScan'></aridRegion>
  22. <packingBom v-if='item.packingList.length != 0' :list='item.packingList'></packingBom>
  23. <view class="operate_box rx-sc">
  24. <!-- <u-button size="small" class="u-reset-button" type="success"
  25. @click="handOutbound(item.workOrderId)">出库单</u-button> -->
  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. batchSave(this.List).then(res => {
  118. uni.navigateTo({
  119. url: `/pages/pda/feeding/index/index?feedStatus=1`,
  120. });
  121. })
  122. },
  123. getList() {
  124. workorderList({
  125. ids: this.idsList,
  126. taskId: this.taskId
  127. }).then(res => {
  128. this.List = res.map(m => {
  129. m.workOrderId = m.id
  130. m.instanceList = [] // 物料
  131. m.equipmentList = [] // 设备
  132. m.modelList = [] // 模具
  133. m.aridRegionList = [] // 干燥区
  134. m.packingList = [] // 包装
  135. if (m.pickOutInList.length > 0) {
  136. m.pickOutInList.forEach(f => {
  137. if (f.rootCategoryLevelId == 1) {
  138. m.instanceList.push(f)
  139. } else if (f.rootCategoryLevelId == 4) {
  140. m.modelList.push(f)
  141. } else if (f.rootCategoryLevelId == 5) {
  142. m.modelList.push(f)
  143. } else if (f.rootCategoryLevelId == 11) {
  144. m.aridRegionList.push(f)
  145. } else if (f.rootCategoryLevelId == 13) {
  146. m.packingList.push(f)
  147. }
  148. })
  149. }
  150. // 处理字段
  151. m.quality == '' ? m.quality = {} : ''
  152. if (m.taskNameLast) {
  153. m.product = {
  154. taskNameLast: m.taskNameLast,
  155. formedWeightLast: m.formedWeightLast,
  156. feedQuantity: m.formedNumLast,
  157. categoryId: m.categoryId,
  158. brandNum: m.brandNo,
  159. modelType: m.model,
  160. unit: m.unit
  161. }
  162. } else {
  163. m.product = {}
  164. }
  165. delete m.id
  166. if (this.taskId) {
  167. m.taskId = this.taskId
  168. m.taskName = this.taskName
  169. }
  170. return {
  171. ...m
  172. }
  173. })
  174. })
  175. },
  176. handleScan(id, type) {
  177. console.log(id)
  178. console.log(type)
  179. // this.scanData('SCJHGD20240117002', type, id)
  180. // return false
  181. let _this = this
  182. uni.scanCode({
  183. success: function(res) {
  184. _this.scanData(res.result, type, id)
  185. }
  186. })
  187. },
  188. scanData(result, type, id) {
  189. if (type == 'wordOrder') {
  190. let isFals = this.List.some(m => m.code == result)
  191. if (isFals) {
  192. uni.showToast({
  193. title: '工单已存在',
  194. icon: 'none'
  195. })
  196. return false
  197. }
  198. getByCode(result).then(res => {
  199. let _arr = this.List
  200. _arr.forEach((e, index) => {
  201. if (e.workOrderId == id && res) {
  202. _arr[index] = res
  203. }
  204. })
  205. this.List = _arr
  206. this.$forceUpdate()
  207. })
  208. }
  209. },
  210. scanIt(id) {
  211. console.log(id)
  212. let _this = this
  213. uni.scanCode({
  214. success: function(res) {
  215. _this.scanItData(res.result, id)
  216. console.log(res.result, id)
  217. }
  218. })
  219. },
  220. scanItData(result, id) {
  221. scanLedger(result).then(res => {
  222. console.log(res)
  223. let _arr = []
  224. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  225. _arr = this.List
  226. _arr.forEach((e, index) => {
  227. if (e.workOrderId == id) {
  228. _arr[index].equipmentList = res
  229. }
  230. })
  231. this.List = _arr
  232. this.$forceUpdate()
  233. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  234. _arr = this.List
  235. _arr.forEach((e, index) => {
  236. if (e.workOrderId == id) {
  237. _arr[index].modelList = res
  238. }
  239. })
  240. this.List = _arr
  241. this.$forceUpdate()
  242. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) { // 物料
  243. _arr = this.List
  244. _arr.forEach((e, index) => {
  245. if (e.workOrderId == id) {
  246. _arr[index].instanceList = _arr[index].instanceList.concat(res)
  247. }
  248. })
  249. this.List = _arr
  250. this.$forceUpdate()
  251. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 11) { // 干燥区
  252. _arr = this.List
  253. _arr.forEach((e, index) => {
  254. if (e.workOrderId == id) {
  255. let isFals = _arr[index].aridRegionList.some(m => m.code == res[0]
  256. .aridRegionList[0].code)
  257. if (isFals) {
  258. uni.showToast({
  259. title: '干燥区已存在',
  260. icon: 'none'
  261. })
  262. return false
  263. }
  264. let _obj = res[0].aridRegionList[0]
  265. if (_obj.status == 0) {
  266. _obj['name'] = res[0].name
  267. _obj['region'] = res[0].extInfo.region
  268. _arr[index].aridRegionList = _arr[index].aridRegionList.concat(res[0]
  269. .aridRegionList)
  270. } else {
  271. uni.showToast({
  272. title: '干燥区已占用',
  273. icon: 'none'
  274. })
  275. }
  276. }
  277. })
  278. this.List = _arr
  279. this.$forceUpdate()
  280. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  281. let isFals = _arr[index].turnover.some(m => m.code == res[0].code)
  282. if (isFals) {
  283. uni.showToast({
  284. title: '周转车已存在',
  285. icon: 'none'
  286. })
  287. return false
  288. }
  289. }
  290. })
  291. },
  292. // 全部扫一扫
  293. handlScanCode() {
  294. let _this = this
  295. uni.scanCode({
  296. success: function(res) {
  297. _this.scanItAllData(res.result)
  298. }
  299. })
  300. },
  301. scanItAllData(result) {
  302. scanLedger(result).then(res => {
  303. let _arr = []
  304. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  305. _arr = this.List
  306. _arr.forEach((e, index) => {
  307. res['extInfo'].fixCode = res.fixCode
  308. e.equipmentList = res
  309. })
  310. this.List = _arr
  311. this.$forceUpdate()
  312. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  313. _arr = this.List
  314. _arr.forEach((e, index) => {
  315. e.modelList = res
  316. })
  317. this.List = _arr
  318. this.$forceUpdate()
  319. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) {
  320. _arr = this.List
  321. _arr.forEach((e, index) => {
  322. e.instanceList = e.instanceList.concat(res)
  323. })
  324. this.List = _arr
  325. this.$forceUpdate()
  326. }
  327. })
  328. },
  329. handAdd(id) {
  330. const storageKey = Date.now() + "";
  331. uni.setStorageSync(storageKey, this.List || []);
  332. uni.navigateTo({
  333. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed&taskId=${this.taskId}`
  334. })
  335. },
  336. handOutbound(id) {
  337. const storageKey = Date.now() + "";
  338. uni.setStorageSync(storageKey, this.List || []);
  339. uni.navigateTo({
  340. url: `/pages/pda/feeding/outbound/index?id=${id}&storageKey=${storageKey}taskId=${this.taskId}`
  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. </style>