details.vue 10 KB

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