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. });
  83. },
  84. methods: {
  85. scrolltolower() {},
  86. save() {
  87. let _arr = []
  88. _arr = this.List.map(m => {
  89. return {
  90. ...m
  91. }
  92. })
  93. console.log(_arr)
  94. batchSave(_arr).then(res => {
  95. uni.navigateTo({
  96. url: `/pages/pda/feeding/index/index?feedStatus=1`,
  97. });
  98. })
  99. },
  100. getList() {
  101. workorderList(this.idsList).then(res => {
  102. this.List = res.map(m => {
  103. m.workOrderId = m.id
  104. m.equipmentList = [] // 设备
  105. m.modelList = [] // 模具
  106. m.instanceList = [] // 投料
  107. delete m.id
  108. return {
  109. ...m
  110. }
  111. })
  112. })
  113. },
  114. handleScan(id, type) {
  115. console.log(id)
  116. console.log(type)
  117. // this.scanData('SCJHGD20240117002', type, id)
  118. // return false
  119. let _this = this
  120. uni.scanCode({
  121. success: function(res) {
  122. _this.scanData(res.result, type, id)
  123. }
  124. })
  125. },
  126. scanData(result, type, id) {
  127. if (type == 'wordOrder') {
  128. let isFals = this.List.some(m => m.code == result)
  129. if (isFals) {
  130. uni.showToast({
  131. title: '工单已存在',
  132. icon: 'none'
  133. })
  134. return false
  135. }
  136. getByCode(result).then(res => {
  137. let _arr = this.List
  138. _arr.forEach((e, index) => {
  139. if (e.workOrderId == id && res) {
  140. _arr[index] = res
  141. }
  142. })
  143. this.List = _arr
  144. this.$forceUpdate()
  145. })
  146. }
  147. },
  148. scanIt(id) {
  149. console.log(id)
  150. // CX-EQ-YLSJL-008 设备
  151. // M001 M002 模具
  152. // S310000552731 物料
  153. // this.scanItData('S310000552731', id)
  154. // return false
  155. let _this = this
  156. uni.scanCode({
  157. success: function(res) {
  158. _this.scanItData(res.result, id)
  159. console.log(res.result, id)
  160. }
  161. })
  162. },
  163. scanItData(result, id) {
  164. scanLedger(result).then(res => {
  165. let _arr = []
  166. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  167. _arr = this.List
  168. _arr.forEach((e, index) => {
  169. if (e.workOrderId == id) {
  170. console.log(res.fixCode)
  171. _arr[index].equipmentList = res
  172. }
  173. })
  174. this.List = _arr
  175. this.$forceUpdate()
  176. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  177. _arr = this.List
  178. _arr.forEach((e, index) => {
  179. if (e.workOrderId == id) {
  180. _arr[index].modelList = res
  181. }
  182. })
  183. this.List = _arr
  184. this.$forceUpdate()
  185. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) {
  186. _arr = this.List
  187. _arr.forEach((e, index) => {
  188. if (e.workOrderId == id) {
  189. _arr[index].instanceList = _arr[index].instanceList.concat(res)
  190. }
  191. })
  192. this.List = _arr
  193. this.$forceUpdate()
  194. }
  195. })
  196. },
  197. // 全部扫一扫
  198. handlScanCode() {
  199. // CX-EQ-YLSJL-008 设备
  200. // M001 M002 模具
  201. // S310000552731 物料
  202. // this.scanItAllData('M001')
  203. // return false
  204. let _this = this
  205. uni.scanCode({
  206. success: function(res) {
  207. _this.scanItAllData(res.result)
  208. }
  209. })
  210. },
  211. scanItAllData(result) {
  212. scanLedger(result).then(res => {
  213. let _arr = []
  214. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  215. _arr = this.List
  216. _arr.forEach((e, index) => {
  217. res['extInfo'].fixCode = res.fixCode
  218. e.equipmentList = res
  219. })
  220. this.List = _arr
  221. this.$forceUpdate()
  222. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  223. _arr = this.List
  224. _arr.forEach((e, index) => {
  225. e.modelList = res
  226. })
  227. this.List = _arr
  228. this.$forceUpdate()
  229. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) {
  230. _arr = this.List
  231. _arr.forEach((e, index) => {
  232. e.instanceList = e.instanceList.concat(res)
  233. })
  234. this.List = _arr
  235. this.$forceUpdate()
  236. }
  237. })
  238. },
  239. handAdd(id) {
  240. const storageKey = Date.now() + "";
  241. uni.setStorageSync(storageKey, this.List || []);
  242. uni.navigateTo({
  243. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed`
  244. })
  245. },
  246. },
  247. }
  248. </script>
  249. <style lang="scss" scoped>
  250. .content-box {
  251. height: 100vh;
  252. overflow: hidden;
  253. display: flex;
  254. flex-direction: column;
  255. }
  256. .list_box {
  257. flex: 1;
  258. overflow: hidden;
  259. padding: 4rpx 0;
  260. .u-list {
  261. height: 100% !important;
  262. }
  263. .card_box {
  264. padding: 16rpx 24rpx;
  265. }
  266. }
  267. .bottom-wrapper {
  268. .btn_box {
  269. width: 750rpx;
  270. height: 88rpx;
  271. line-height: 88rpx;
  272. background: $theme-color;
  273. text-align: center;
  274. font-size: 36rpx;
  275. font-style: normal;
  276. font-weight: 400;
  277. color: #fff;
  278. }
  279. }
  280. .operate_box {
  281. padding: 10rpx 160rpx;
  282. /deep/ .u-button {
  283. width: 160rpx;
  284. }
  285. }
  286. </style>