index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <view class="content-box">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" background-color="#F7F9FA" color="#000"
  4. @clickLeft="back" right-icon="scan" @clickRight="HandlScanCode">
  5. </uni-nav-bar>
  6. <view class="list_box">
  7. <u-list @scrolltolower="scrolltolower">
  8. <view class="card_box" v-for="(item, index) in List" :key="index">
  9. <workOrderBom :item='item' v-if='item' @handleScan='handleWordScan'></workOrderBom>
  10. <turnoverBom v-if='item.turnover.length != 0' :list='item.turnover' :wordItem='item' pattern='job'>
  11. </turnoverBom>
  12. <view class="operate_box rx-sc">
  13. <u-button size="small" class="u-reset-button" type="success" @click="handAdd">手动添加</u-button>
  14. </view>
  15. <sampleBom :item='item.quality' v-if='item.quality' :isDetails='false' :turnoverList='item.turnover'
  16. :paramList='paramList' @showReuseTurnover='showReuseTurnover = true'></sampleBom>
  17. <reuseTurnoverBom v-if='showReuseTurnover' :list='item.turnover' :wordItem='item'
  18. :sampleList='item.quality && item.quality.sampleList' :reuseNum='item.quality.reuseNum'>
  19. </reuseTurnoverBom>
  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 {
  30. workorderList,
  31. scanLedger,
  32. sampleTurnoverReview,
  33. paramByTaskId
  34. } from '@/api/pda/workOrder.js'
  35. import workOrderBom from '../../feeding/components/workOrderBom.vue'
  36. import sampleBom from '../components/sampleBom.vue'
  37. import turnoverBom from '../components/turnoverBom.vue'
  38. import reuseTurnoverBom from '../components/reuseTurnoverBom.vue'
  39. import {
  40. batchSave
  41. } from '@/api/pda/feeding.js'
  42. export default {
  43. components: {
  44. workOrderBom,
  45. sampleBom,
  46. turnoverBom,
  47. reuseTurnoverBom
  48. },
  49. data() {
  50. return {
  51. title: null,
  52. id: null,
  53. taskId: null,
  54. List: [],
  55. count: 0,
  56. isLastJob: true,
  57. paramList: [],
  58. showReuseTurnover: false
  59. }
  60. },
  61. onLoad(options) {
  62. this.title = options.taskName ? options.taskName : '质检'
  63. this.id = options.workOrderId
  64. this.taskId = options.taskId
  65. this.getList()
  66. },
  67. onShow() {
  68. uni.$off("setSelectList");
  69. uni.$on("setSelectList", (selectList, id) => {
  70. let turnover = [] //周转车
  71. selectList.forEach(f => {
  72. if (f.rootCategoryLevelId == 7) {
  73. // turnover = turnover.concat(f)
  74. turnover = [f]
  75. }
  76. })
  77. this.$set(this.List[0], 'turnover', turnover)
  78. this.$forceUpdate()
  79. });
  80. },
  81. methods: {
  82. getList() {
  83. workorderList({
  84. ids: [this.id],
  85. taskId: this.taskId
  86. }).then(res => {
  87. this.List = res.map(m => {
  88. m.workOrderId = m.id
  89. if (m.quality) {
  90. m.quality['sampleList'] = []
  91. m['reuseTurnover'] = [],
  92. m.quality['reuseNum'] = 0
  93. } else {
  94. this.isLastJob = false
  95. }
  96. if (Object.prototype.hasOwnProperty.call(m, 'turnover')) {
  97. m['turnover'] = []
  98. this.getSampleTurnover()
  99. }
  100. this.getParam(res[0].currentTaskDiagram.sourceTaskId)
  101. m.feedType = 2
  102. delete m.id
  103. return {
  104. ...m
  105. }
  106. })
  107. })
  108. },
  109. getParam(sourceTaskId) {
  110. paramByTaskId(sourceTaskId).then(res => {
  111. this.paramList = res
  112. })
  113. },
  114. getSampleTurnover() {
  115. let param = {
  116. workOrderId: this.id,
  117. taskId: this.taskId
  118. }
  119. sampleTurnoverReview(param).then(res => {
  120. this.List[0].turnover = res
  121. })
  122. },
  123. scrolltolower() { },
  124. handleWordScan() {
  125. uni.showToast({
  126. icon: 'none',
  127. title: '不支持换工单'
  128. })
  129. },
  130. // 相机扫码
  131. HandlScanCode() {
  132. uni.scanCode({
  133. success: (res) => {
  134. this.scanItAllData(res.result)
  135. }
  136. })
  137. },
  138. scanItAllData(result) {
  139. scanLedger(result).then(res => {
  140. if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  141. let isFals = this.List[0].turnover.some(m => m.code == result)
  142. if (isFals) {
  143. uni.showToast({
  144. title: '周转车已存在',
  145. icon: 'none'
  146. })
  147. return false
  148. }
  149. this.List[0].turnover.push(res[0])
  150. this.$forceUpdate()
  151. }
  152. })
  153. },
  154. save() {
  155. if (!this.isLastJob) {
  156. uni.showToast({
  157. icon: 'none',
  158. title: '上道工序暂未报工'
  159. })
  160. return false
  161. }
  162. if (this.List[0].quality.sampleNum != this.List[0].quality.sampleList.length) {
  163. uni.showToast({
  164. icon: 'none',
  165. title: '处置数量和取样数量对应不上'
  166. })
  167. return false
  168. }
  169. batchSave(this.List).then(res => {
  170. uni.navigateBack()
  171. })
  172. },
  173. handAdd() {
  174. let param = {
  175. turnover: this.List[0].turnover
  176. }
  177. const storageKey = Date.now() + "";
  178. uni.setStorageSync(storageKey, param || {});
  179. uni.navigateTo({
  180. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job&taskId=${this.taskId}`
  181. })
  182. },
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .content-box {
  188. height: 100vh;
  189. overflow: hidden;
  190. display: flex;
  191. flex-direction: column;
  192. }
  193. .list_box {
  194. flex: 1;
  195. overflow: hidden;
  196. padding: 4rpx 0;
  197. .u-list {
  198. height: 100% !important;
  199. }
  200. .card_box {
  201. padding: 16rpx;
  202. }
  203. }
  204. .bottom-wrapper {
  205. .btn_box {
  206. width: 750rpx;
  207. height: 88rpx;
  208. line-height: 88rpx;
  209. background: $theme-color;
  210. text-align: center;
  211. font-size: 36rpx;
  212. font-style: normal;
  213. font-weight: 400;
  214. color: #fff;
  215. }
  216. }
  217. .operate_box {
  218. padding: 10rpx 160rpx;
  219. /deep/ .u-button {
  220. width: 160rpx;
  221. }
  222. }
  223. </style>