details.vue 9.1 KB

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