index.vue 5.7 KB

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