details.vue 10 KB

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