details.vue 4.6 KB

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