details.vue 12 KB

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