details.vue 5.2 KB

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