index.vue 5.0 KB

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