index.vue 5.1 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" 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. this.scanItAllData('w0300000003574001')
  117. return false
  118. let _this = this
  119. uni.scanCode({
  120. success: function(res) {
  121. _this.scanItAllData(res.result)
  122. }
  123. })
  124. },
  125. scanItAllData(result) {
  126. scanLedger(result).then(res => {
  127. if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  128. let isFals = this.List[0].turnover.some(m => m.code == result)
  129. if (isFals) {
  130. uni.showToast({
  131. title: '周转车已存在',
  132. icon: 'none'
  133. })
  134. return false
  135. }
  136. this.List[0].turnover.push(res[0])
  137. this.$forceUpdate()
  138. }
  139. })
  140. },
  141. save() {
  142. if (!this.isLastJob) {
  143. uni.showToast({
  144. icon: 'none',
  145. title: '上道工序暂未报工'
  146. })
  147. return false
  148. }
  149. this.count = 0;
  150. this.List[0].quality.sampleList.forEach(e => {
  151. if (Number(e.num) > 0 && Number(e.num) != NaN) {
  152. this.count += Number(e.num);
  153. }
  154. })
  155. if (this.List[0].quality.sampleNum != this.count) {
  156. uni.showToast({
  157. icon: 'none',
  158. title: '处置数量和取样数量对应不上'
  159. })
  160. return false
  161. }
  162. batchSave(this.List).then(res => {
  163. uni.navigateBack()
  164. })
  165. },
  166. handAdd() {
  167. let param = {
  168. turnover: this.List[0].turnover
  169. }
  170. const storageKey = Date.now() + "";
  171. uni.setStorageSync(storageKey, param || {});
  172. uni.navigateTo({
  173. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job&taskId=${this.taskId}`
  174. })
  175. },
  176. }
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .content-box {
  181. height: 100vh;
  182. overflow: hidden;
  183. display: flex;
  184. flex-direction: column;
  185. }
  186. .list_box {
  187. flex: 1;
  188. overflow: hidden;
  189. padding: 4rpx 0;
  190. .u-list {
  191. height: 100% !important;
  192. }
  193. .card_box {
  194. padding: 16rpx 24rpx;
  195. }
  196. }
  197. .bottom-wrapper {
  198. .btn_box {
  199. width: 750rpx;
  200. height: 88rpx;
  201. line-height: 88rpx;
  202. background: $theme-color;
  203. text-align: center;
  204. font-size: 36rpx;
  205. font-style: normal;
  206. font-weight: 400;
  207. color: #fff;
  208. }
  209. }
  210. .operate_box {
  211. padding: 10rpx 160rpx;
  212. /deep/ .u-button {
  213. width: 160rpx;
  214. }
  215. }
  216. </style>