details.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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="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(!Object.prototype.hasOwnProperty.call(m, 'product')) {
  153. m.product = '{}'
  154. }
  155. console.log(m)
  156. delete m.id
  157. if (this.taskId) {
  158. m.taskId = this.taskId
  159. m.taskName = this.taskName
  160. }
  161. return {
  162. ...m
  163. }
  164. })
  165. })
  166. },
  167. handleScan(id, type) {
  168. console.log(id)
  169. console.log(type)
  170. // this.scanData('SCJHGD20240117002', type, id)
  171. // return false
  172. let _this = this
  173. uni.scanCode({
  174. success: function(res) {
  175. _this.scanData(res.result, type, id)
  176. }
  177. })
  178. },
  179. scanData(result, type, id) {
  180. if (type == 'wordOrder') {
  181. let isFals = this.List.some(m => m.code == result)
  182. if (isFals) {
  183. uni.showToast({
  184. title: '工单已存在',
  185. icon: 'none'
  186. })
  187. return false
  188. }
  189. getByCode(result).then(res => {
  190. let _arr = this.List
  191. _arr.forEach((e, index) => {
  192. if (e.workOrderId == id && res) {
  193. _arr[index] = res
  194. }
  195. })
  196. this.List = _arr
  197. this.$forceUpdate()
  198. })
  199. }
  200. },
  201. scanIt(id) {
  202. console.log(id)
  203. let _this = this
  204. uni.scanCode({
  205. success: function(res) {
  206. _this.scanItData(res.result, id)
  207. console.log(res.result, id)
  208. }
  209. })
  210. },
  211. scanItData(result, id) {
  212. scanLedger(result).then(res => {
  213. console.log(res)
  214. let _arr = []
  215. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  216. _arr = this.List
  217. _arr.forEach((e, index) => {
  218. if (e.workOrderId == id) {
  219. _arr[index].equipmentList = res
  220. }
  221. })
  222. this.List = _arr
  223. this.$forceUpdate()
  224. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  225. _arr = this.List
  226. _arr.forEach((e, index) => {
  227. if (e.workOrderId == id) {
  228. _arr[index].modelList = res
  229. }
  230. })
  231. this.List = _arr
  232. this.$forceUpdate()
  233. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) { // 物料
  234. _arr = this.List
  235. _arr.forEach((e, index) => {
  236. if (e.workOrderId == id) {
  237. _arr[index].instanceList = _arr[index].instanceList.concat(res)
  238. }
  239. })
  240. this.List = _arr
  241. this.$forceUpdate()
  242. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 11) { // 干燥区
  243. _arr = this.List
  244. _arr.forEach((e, index) => {
  245. if (e.workOrderId == id) {
  246. let isFals = _arr[index].aridRegionList.some(m => m.code == res[0]
  247. .aridRegionList[0].code)
  248. if (isFals) {
  249. uni.showToast({
  250. title: '干燥区已存在',
  251. icon: 'none'
  252. })
  253. return false
  254. }
  255. let _obj = res[0].aridRegionList[0]
  256. if (_obj.status == 0) {
  257. _obj['name'] = res[0].name
  258. _obj['region'] = res[0].extInfo.region
  259. _arr[index].aridRegionList = _arr[index].aridRegionList.concat(res[0]
  260. .aridRegionList)
  261. } else {
  262. uni.showToast({
  263. title: '干燥区已占用',
  264. icon: 'none'
  265. })
  266. }
  267. }
  268. })
  269. this.List = _arr
  270. this.$forceUpdate()
  271. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  272. let isFals = _arr[index].turnover.some(m => m.code == res[0].code)
  273. if (isFals) {
  274. uni.showToast({
  275. title: '周转车已存在',
  276. icon: 'none'
  277. })
  278. return false
  279. }
  280. }
  281. })
  282. },
  283. // 全部扫一扫
  284. handlScanCode() {
  285. let _this = this
  286. uni.scanCode({
  287. success: function(res) {
  288. _this.scanItAllData(res.result)
  289. }
  290. })
  291. },
  292. scanItAllData(result) {
  293. scanLedger(result).then(res => {
  294. let _arr = []
  295. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  296. _arr = this.List
  297. _arr.forEach((e, index) => {
  298. res['extInfo'].fixCode = res.fixCode
  299. e.equipmentList = res
  300. })
  301. this.List = _arr
  302. this.$forceUpdate()
  303. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  304. _arr = this.List
  305. _arr.forEach((e, index) => {
  306. e.modelList = res
  307. })
  308. this.List = _arr
  309. this.$forceUpdate()
  310. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) {
  311. _arr = this.List
  312. _arr.forEach((e, index) => {
  313. e.instanceList = e.instanceList.concat(res)
  314. })
  315. this.List = _arr
  316. this.$forceUpdate()
  317. }
  318. })
  319. },
  320. handAdd(id) {
  321. const storageKey = Date.now() + "";
  322. uni.setStorageSync(storageKey, this.List || []);
  323. uni.navigateTo({
  324. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed&taskId=${this.taskId}`
  325. })
  326. },
  327. handOutbound(id) {
  328. const storageKey = Date.now() + "";
  329. uni.setStorageSync(storageKey, this.List || []);
  330. uni.navigateTo({
  331. url: `/pages/pda/feeding/outbound/index?id=${id}&storageKey=${storageKey}taskId=${this.taskId}`
  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. </style>