details.vue 11 KB

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