details.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. selectList.forEach(f => {
  84. if (f.rootCategoryLevelId == 5) {
  85. modelList = modelList.concat(f)
  86. } else if (f.rootCategoryLevelId == 1) {
  87. instanceList = instanceList.concat(f)
  88. } else if (f.rootCategoryLevelId == 11) {
  89. aridRegionList = aridRegionList.concat(f)
  90. }
  91. })
  92. this.$set(m, 'modelList', modelList)
  93. this.$set(m, 'instanceList', instanceList)
  94. this.$set(m, 'aridRegionList', aridRegionList)
  95. }
  96. })
  97. });
  98. },
  99. methods: {
  100. scrolltolower() {},
  101. save() {
  102. let bol
  103. this.List.forEach(e => {
  104. if (e.aridRegionList && e.aridRegionList.length > 0) {
  105. bol = e.aridRegionList.every(v => v.occupationTime)
  106. } else {
  107. bol = true
  108. }
  109. })
  110. if (!bol) {
  111. uni.showToast({
  112. title: '请输入干燥时间',
  113. icon: 'none'
  114. })
  115. return false
  116. }
  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(this.idsList).then(res => {
  125. this.List = res.map(m => {
  126. m.workOrderId = m.id
  127. m.equipmentList = [] // 设备
  128. m.modelList = [] // 模具
  129. m.instanceList = [] // 投料
  130. m.turnover = [] // 周转车
  131. m.aridRegionList = [] // 干燥区
  132. delete m.id
  133. if (this.taskId) {
  134. m.taskId = this.taskId
  135. m.taskName = this.taskName
  136. }
  137. return {
  138. ...m
  139. }
  140. })
  141. })
  142. },
  143. handleScan(id, type) {
  144. console.log(id)
  145. console.log(type)
  146. // this.scanData('SCJHGD20240117002', type, id)
  147. // return false
  148. let _this = this
  149. uni.scanCode({
  150. success: function(res) {
  151. _this.scanData(res.result, type, id)
  152. }
  153. })
  154. },
  155. scanData(result, type, id) {
  156. if (type == 'wordOrder') {
  157. let isFals = this.List.some(m => m.code == result)
  158. if (isFals) {
  159. uni.showToast({
  160. title: '工单已存在',
  161. icon: 'none'
  162. })
  163. return false
  164. }
  165. getByCode(result).then(res => {
  166. let _arr = this.List
  167. _arr.forEach((e, index) => {
  168. if (e.workOrderId == id && res) {
  169. _arr[index] = res
  170. }
  171. })
  172. this.List = _arr
  173. this.$forceUpdate()
  174. })
  175. }
  176. },
  177. scanIt(id) {
  178. console.log(id)
  179. // CX-EQ-YLSJL-008 设备
  180. // M001 M002 模具
  181. // S310000552731 物料
  182. // 干燥区
  183. // w0300000003140004 周转车
  184. this.scanItData('w0300000003140004', id)
  185. return false
  186. let _this = this
  187. uni.scanCode({
  188. success: function(res) {
  189. _this.scanItData(res.result, id)
  190. console.log(res.result, id)
  191. }
  192. })
  193. },
  194. scanItData(result, id) {
  195. scanLedger(result).then(res => {
  196. console.log(res)
  197. let _arr = []
  198. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  199. _arr = this.List
  200. _arr.forEach((e, index) => {
  201. if (e.workOrderId == id) {
  202. _arr[index].equipmentList = res
  203. }
  204. })
  205. this.List = _arr
  206. this.$forceUpdate()
  207. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  208. _arr = this.List
  209. _arr.forEach((e, index) => {
  210. if (e.workOrderId == id) {
  211. _arr[index].modelList = res
  212. }
  213. })
  214. this.List = _arr
  215. this.$forceUpdate()
  216. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) { // 物料
  217. _arr = this.List
  218. _arr.forEach((e, index) => {
  219. if (e.workOrderId == id) {
  220. _arr[index].instanceList = _arr[index].instanceList.concat(res)
  221. }
  222. })
  223. this.List = _arr
  224. this.$forceUpdate()
  225. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 11) { // 干燥区
  226. _arr = this.List
  227. _arr.forEach((e, index) => {
  228. if (e.workOrderId == id) {
  229. let isFals = _arr[index].aridRegionList.some(m => m.code == res[0]
  230. .aridRegionList[0].code)
  231. if (isFals) {
  232. uni.showToast({
  233. title: '干燥区已存在',
  234. icon: 'none'
  235. })
  236. return false
  237. }
  238. let _obj = res[0].aridRegionList[0]
  239. if (_obj.status == 0) {
  240. _obj['name'] = res[0].name
  241. _obj['region'] = res[0].extInfo.region
  242. _arr[index].aridRegionList = _arr[index].aridRegionList.concat(res[0]
  243. .aridRegionList)
  244. } else {
  245. uni.showToast({
  246. title: '干燥区已占用',
  247. icon: 'none'
  248. })
  249. }
  250. }
  251. })
  252. this.List = _arr
  253. this.$forceUpdate()
  254. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  255. _arr = this.List
  256. _arr.forEach((e, index) => {
  257. if (e.workOrderId == id) {
  258. console.log(res)
  259. let isFals = _arr[index].turnover.some(m => m.code == res[0].code)
  260. if (isFals) {
  261. uni.showToast({
  262. title: '周转车已存在',
  263. icon: 'none'
  264. })
  265. return false
  266. }
  267. _arr[index].turnover = _arr[index].turnover.concat(res)
  268. }
  269. })
  270. this.List = _arr
  271. this.$forceUpdate()
  272. }
  273. })
  274. },
  275. // 全部扫一扫
  276. handlScanCode() {
  277. // CX-EQ-YLSJL-008 设备
  278. // M001 M002 模具
  279. // S310000552731 物料
  280. // w0300000003140004 周转车
  281. // this.scanItAllData('w0300000003140004')
  282. // return false
  283. let _this = this
  284. uni.scanCode({
  285. success: function(res) {
  286. _this.scanItAllData(res.result)
  287. }
  288. })
  289. },
  290. scanItAllData(result) {
  291. scanLedger(result).then(res => {
  292. let _arr = []
  293. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  294. _arr = this.List
  295. _arr.forEach((e, index) => {
  296. res['extInfo'].fixCode = res.fixCode
  297. e.equipmentList = res
  298. })
  299. this.List = _arr
  300. this.$forceUpdate()
  301. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  302. _arr = this.List
  303. _arr.forEach((e, index) => {
  304. e.modelList = res
  305. })
  306. this.List = _arr
  307. this.$forceUpdate()
  308. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) {
  309. _arr = this.List
  310. _arr.forEach((e, index) => {
  311. e.instanceList = e.instanceList.concat(res)
  312. })
  313. this.List = _arr
  314. this.$forceUpdate()
  315. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  316. _arr = this.List
  317. _arr.forEach((e, index) => {
  318. e.turnover = e.turnover.concat(res)
  319. })
  320. this.List = _arr
  321. this.$forceUpdate()
  322. }
  323. })
  324. },
  325. handAdd(id) {
  326. const storageKey = Date.now() + "";
  327. uni.setStorageSync(storageKey, this.List || []);
  328. uni.navigateTo({
  329. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed`
  330. })
  331. },
  332. },
  333. }
  334. </script>
  335. <style lang="scss" scoped>
  336. .content-box {
  337. height: 100vh;
  338. overflow: hidden;
  339. display: flex;
  340. flex-direction: column;
  341. }
  342. .list_box {
  343. flex: 1;
  344. overflow: hidden;
  345. padding: 4rpx 0;
  346. .u-list {
  347. height: 100% !important;
  348. }
  349. .card_box {
  350. padding: 16rpx 24rpx;
  351. }
  352. }
  353. .bottom-wrapper {
  354. .btn_box {
  355. width: 750rpx;
  356. height: 88rpx;
  357. line-height: 88rpx;
  358. background: $theme-color;
  359. text-align: center;
  360. font-size: 36rpx;
  361. font-style: normal;
  362. font-weight: 400;
  363. color: #fff;
  364. }
  365. }
  366. .operate_box {
  367. padding: 10rpx 160rpx;
  368. /deep/ .u-button {
  369. width: 160rpx;
  370. }
  371. }
  372. </style>