index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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' :sampleList='item.quality && item.quality.sampleList'
  18. :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. let _arr = []
  156. _arr = JSON.parse(JSON.stringify(this.List))
  157. _arr.forEach(f => {
  158. f.turnover.forEach(o => {
  159. o.extInfo.positionList.forEach(r => {
  160. r.sampleNum = 0
  161. r.reuseNum = 0
  162. })
  163. })
  164. f.reuseTurnover.forEach(o => {
  165. o.extInfo.positionList.forEach(r => {
  166. r.sampleNum = 0
  167. r.reuseNum = 0
  168. })
  169. })
  170. })
  171. if (!this.isLastJob) {
  172. uni.showToast({
  173. icon: 'none',
  174. title: '上道工序暂未报工'
  175. })
  176. return false
  177. }
  178. if (this.List[0].quality.sampleNum != this.List[0].quality.sampleList.length) {
  179. uni.showToast({
  180. icon: 'none',
  181. title: '处置数量和取样数量对应不上'
  182. })
  183. return false
  184. }
  185. batchSave(this.List).then(res => {
  186. uni.navigateBack()
  187. })
  188. },
  189. handAdd() {
  190. let param = {
  191. turnover: this.List[0].turnover
  192. }
  193. const storageKey = Date.now() + "";
  194. uni.setStorageSync(storageKey, param || {});
  195. uni.navigateTo({
  196. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job&taskId=${this.taskId}`
  197. })
  198. },
  199. }
  200. }
  201. </script>
  202. <style lang="scss" scoped>
  203. .content-box {
  204. height: 100vh;
  205. overflow: hidden;
  206. display: flex;
  207. flex-direction: column;
  208. }
  209. .list_box {
  210. flex: 1;
  211. overflow: hidden;
  212. padding: 4rpx 0;
  213. .u-list {
  214. height: 100% !important;
  215. }
  216. .card_box {
  217. padding: 16rpx;
  218. }
  219. }
  220. .bottom-wrapper {
  221. .btn_box {
  222. width: 750rpx;
  223. height: 88rpx;
  224. line-height: 88rpx;
  225. background: $theme-color;
  226. text-align: center;
  227. font-size: 36rpx;
  228. font-style: normal;
  229. font-weight: 400;
  230. color: #fff;
  231. }
  232. }
  233. .operate_box {
  234. padding: 10rpx 160rpx;
  235. /deep/ .u-button {
  236. width: 160rpx;
  237. }
  238. }
  239. </style>