index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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" 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. @handleScan='handleScan'>
  12. </turnoverBom>
  13. <view class="operate_box rx-sc">
  14. <u-button size="small" class="u-reset-button" type="success" @click="handAdd">手动添加</u-button>
  15. </view>
  16. <sampleBom :item='item.quality' v-if='item.quality' :isDetails='false'
  17. :turnoverList='item.turnover'></sampleBom>
  18. <reuseTurnoverBom v-if='item.quality.showReuseTurnover' :list='item.turnover' :wordItem='item'
  19. :reuseNum='item.quality.reuseNum'>
  20. </reuseTurnoverBom>
  21. </view>
  22. </u-list>
  23. </view>
  24. <view class="bottom-wrapper">
  25. <view class="btn_box" @click="save">一键报工</view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. workorderList,
  33. scanLedger,
  34. sampleTurnoverReview
  35. } from '@/api/pda/workOrder.js'
  36. import workOrderBom from '../../feeding/components/workOrderBom.vue'
  37. import sampleBom from '../components/sampleBom.vue'
  38. import turnoverBom from '../components/turnoverBom.vue'
  39. import reuseTurnoverBom from '../components/reuseTurnoverBom.vue'
  40. import {
  41. batchSave
  42. } from '@/api/pda/feeding.js'
  43. export default {
  44. components: {
  45. workOrderBom,
  46. sampleBom,
  47. turnoverBom,
  48. reuseTurnoverBom
  49. },
  50. data() {
  51. return {
  52. title: null,
  53. id: null,
  54. taskId: null,
  55. List: [],
  56. count: 0,
  57. isLastJob: true
  58. }
  59. },
  60. onLoad(options) {
  61. this.title = options.taskName ? options.taskName : '质检'
  62. this.id = options.workOrderId
  63. this.taskId = options.taskId
  64. this.getList()
  65. },
  66. onShow() {
  67. uni.$off("setSelectList");
  68. uni.$on("setSelectList", (selectList, id) => {
  69. let turnover = [] //周转车
  70. selectList.forEach(f => {
  71. if (f.rootCategoryLevelId == 7) {
  72. turnover = turnover.concat(f)
  73. }
  74. })
  75. this.$set(this.List[0], 'turnover', turnover)
  76. this.$forceUpdate()
  77. });
  78. },
  79. methods: {
  80. getList() {
  81. workorderList({
  82. ids: [this.id],
  83. taskId: this.taskId
  84. }).then(res => {
  85. this.List = res.map(m => {
  86. m.workOrderId = m.id
  87. if (m.quality) {
  88. m.quality['sampleList'] = []
  89. m['reuseTurnover'] = [],
  90. m.quality['showReuseTurnover'] = false,
  91. m.quality['reuseNum'] = 0
  92. } else {
  93. this.isLastJob = false
  94. }
  95. if (Object.prototype.hasOwnProperty.call(m, 'turnover')) {
  96. m['turnover'] = []
  97. this.getSampleTurnover()
  98. }
  99. m.feedType = 2
  100. delete m.id
  101. return {
  102. ...m
  103. }
  104. })
  105. })
  106. },
  107. getSampleTurnover() {
  108. let param = {
  109. workOrderId: this.id,
  110. taskId: this.taskId
  111. }
  112. sampleTurnoverReview(param).then(res => {
  113. this.List[0].turnover = res
  114. })
  115. },
  116. scrolltolower() {},
  117. handleWordScan() {
  118. uni.showToast({
  119. icon: 'none',
  120. title: '不支持换工单'
  121. })
  122. },
  123. // 相机扫码
  124. HandlScanCode() {
  125. let _this = this
  126. uni.scanCode({
  127. success: function(res) {
  128. _this.scanItAllData(res.result)
  129. }
  130. })
  131. },
  132. scanItAllData(result) {
  133. scanLedger(result).then(res => {
  134. if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  135. let isFals = this.List[0].turnover.some(m => m.code == result)
  136. if (isFals) {
  137. uni.showToast({
  138. title: '周转车已存在',
  139. icon: 'none'
  140. })
  141. return false
  142. }
  143. this.List[0].turnover.push(res[0])
  144. this.$forceUpdate()
  145. }
  146. })
  147. },
  148. save() {
  149. if (!this.isLastJob) {
  150. uni.showToast({
  151. icon: 'none',
  152. title: '上道工序暂未报工'
  153. })
  154. return false
  155. }
  156. this.count = 0;
  157. this.List[0].quality.sampleList.forEach(e => {
  158. if (Number(e.num) > 0 && Number(e.num) != NaN) {
  159. this.count += Number(e.num);
  160. }
  161. })
  162. if (this.List[0].quality.sampleNum != this.count) {
  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>