details.vue 5.2 KB

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