details.vue 10 KB

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