details.vue 4.6 KB

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