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