details.vue 7.4 KB

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