index.vue 5.9 KB

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