details.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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 模具
  139. // this.scanItData('M001', id)
  140. // return false
  141. let _this = this
  142. uni.scanCode({
  143. success: function(res) {
  144. _this.scanItData(res.result, id)
  145. console.log(res.result, id)
  146. }
  147. })
  148. },
  149. scanItData(result, id) {
  150. scanLedger(result).then(res => {
  151. let _arr = []
  152. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  153. _arr = this.List
  154. _arr.forEach((e, index) => {
  155. if (e.workOrderId == id) {
  156. _arr[index].equipmentList = res
  157. }
  158. })
  159. this.List = _arr
  160. this.$forceUpdate()
  161. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) {
  162. _arr = this.List
  163. _arr.forEach((e, index) => {
  164. if (e.workOrderId == id) {
  165. _arr[index].modelList = res
  166. }
  167. })
  168. this.List = _arr
  169. console.log(this.List)
  170. this.$forceUpdate()
  171. }
  172. })
  173. },
  174. handAdd(id, list) {
  175. const storageKey = Date.now() + "";
  176. uni.setStorageSync(storageKey, list || []);
  177. uni.navigateTo({
  178. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed`
  179. })
  180. },
  181. },
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. .content-box {
  186. height: 100vh;
  187. overflow: hidden;
  188. display: flex;
  189. flex-direction: column;
  190. }
  191. .list_box {
  192. flex: 1;
  193. overflow: hidden;
  194. padding: 4rpx 0;
  195. .u-list {
  196. height: 100% !important;
  197. }
  198. .card_box {
  199. padding: 16rpx 24rpx;
  200. }
  201. }
  202. .bottom-wrapper {
  203. .btn_box {
  204. width: 750rpx;
  205. height: 88rpx;
  206. line-height: 88rpx;
  207. background: $theme-color;
  208. text-align: center;
  209. font-size: 36rpx;
  210. font-style: normal;
  211. font-weight: 400;
  212. color: #fff;
  213. }
  214. }
  215. .operate_box {
  216. padding: 10rpx 160rpx;
  217. /deep/ .u-button {
  218. width: 160rpx;
  219. }
  220. }
  221. </style>