details.vue 5.8 KB

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