index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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">
  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. <deviceBom v-if='item.equipmentList.length != 0' :workOrderId='item.workOrderId'
  11. :list='item.equipmentList' @scanIt='scanIt'></deviceBom>
  12. <turnoverBom v-if='item.turnover.length != 0' :list='item.turnover' :wordItem='item' pattern='job'>
  13. </turnoverBom>
  14. <view class="operate_box rx-sc">
  15. <u-button size="small" class="u-reset-button" type="success"
  16. @click="handAdd(item.workOrderId)">手动添加</u-button>
  17. <u-button size="small" class="u-reset-button" type="success"
  18. @click="scanIt(item.workOrderId)">扫一扫</u-button>
  19. </view>
  20. <diagramLast :item='item.lastObj' v-if='item && item.workOrderType != 2'></diagramLast>
  21. <inspectionBom v-if='inspectionList.length' :inspectionList='inspectionList'
  22. :normalQuality='item.normalQuality'></inspectionBom>
  23. </view>
  24. </u-list>
  25. </view>
  26. <view class="bottom-wrapper">
  27. <view class="btn_box" @click="save">确认</view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import {
  33. workorderList,
  34. getLastTreeByPid,
  35. scanLedger,
  36. qualityReview
  37. } from '@/api/pda/workOrder.js'
  38. import {
  39. batchSave
  40. } from '@/api/pda/feeding.js'
  41. import workOrderBom from '../../feeding/components/workOrderBom.vue'
  42. import inspectionBom from '../components/inspectionBom.vue'
  43. import deviceBom from '../../feeding/components/deviceBom.vue'
  44. import diagramLast from '../components/diagramLast.vue'
  45. import turnoverBom from '../../sample/components/turnoverBom.vue'
  46. export default {
  47. components: {
  48. workOrderBom,
  49. inspectionBom,
  50. deviceBom,
  51. diagramLast,
  52. turnoverBom
  53. },
  54. data() {
  55. return {
  56. title: null,
  57. id: null,
  58. taskId: null,
  59. inspectionId: null,
  60. inspectionName: null,
  61. List: [],
  62. inspectionList: [],
  63. isLastJob: true
  64. }
  65. },
  66. onLoad(options) {
  67. this.title = options.taskName ? options.taskName + '-' + options.inspectionName : '质检'
  68. this.inspectionId = options.inspectionId
  69. this.inspectionName = options.inspectionName
  70. this.id = options.workOrderId
  71. this.taskId = options.taskId
  72. this.getList()
  73. this.getLastTree()
  74. },
  75. onShow() {
  76. uni.$off("setSelectList");
  77. uni.$on("setSelectList", (selectList, id) => {
  78. this.List.forEach(m => {
  79. if (m.workOrderId == id) {
  80. let equipmentList = [] // 生产设备
  81. let turnover = []
  82. selectList.forEach(f => {
  83. if (f.rootCategoryLevelId == 4) {
  84. equipmentList = equipmentList.concat(f)
  85. }
  86. if (f.rootCategoryLevelId == 7) {
  87. turnover = turnover.concat(f)
  88. }
  89. })
  90. this.$set(m, 'equipmentList', equipmentList)
  91. this.$set(m, 'turnover', turnover)
  92. }
  93. })
  94. })
  95. },
  96. methods: {
  97. getList() {
  98. workorderList({
  99. ids: [this.id],
  100. taskId: this.taskId,
  101. }).then(res => {
  102. this.List = res.map(m => {
  103. m.workOrderId = m.id
  104. m.equipmentList = [] // 设备
  105. m.turnover = [] // 周转车
  106. if (m.normalQuality != null || m.workOrderType == 2) {
  107. this.$set(m, 'normalQuality', {})
  108. m.normalQuality.quantity = 0
  109. m.normalQuality.inspectionId = this.inspectionId
  110. m.normalQuality.inspectionName = this.inspectionName
  111. } else {
  112. this.isLastJob = false
  113. }
  114. m.lastObj = {
  115. formedNum: m.formedNumLast,
  116. taskNameLast: m.taskNameLast,
  117. unit: m.unit
  118. }
  119. m.feedType = 3
  120. delete m.id
  121. if (this.taskId) {
  122. m.taskId = this.taskId
  123. }
  124. return {
  125. ...m
  126. }
  127. })
  128. })
  129. },
  130. getLastTree() {
  131. getLastTreeByPid(this.inspectionId).then(res => {
  132. this.inspectionList = res
  133. this.inspectionList.push({
  134. id: -1,
  135. name: '废品总数量'
  136. })
  137. this.getGualityReview()
  138. })
  139. },
  140. getGualityReview() {
  141. let param = {
  142. inspectionId: this.inspectionId,
  143. workOrderId: this.id,
  144. taskId: this.taskId,
  145. }
  146. qualityReview(param).then(res => {
  147. if (res && res.extInfo && res.extInfo.inspectionList) {
  148. this.inspectionList = res.extInfo.inspectionList
  149. }
  150. })
  151. },
  152. scrolltolower() {},
  153. handleWordScan() {
  154. uni.showToast({
  155. icon: 'none',
  156. title: '不支持换工单'
  157. })
  158. },
  159. scanIt(id) {
  160. uni.scanCode({
  161. success: (res) => {
  162. this.scanItData(res.result, id)
  163. }
  164. })
  165. },
  166. scanItData(result, id) {
  167. scanLedger(result).then(res => {
  168. let _arr = []
  169. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  170. _arr = this.List
  171. _arr.forEach((e, index) => {
  172. if (e.workOrderId == id) {
  173. _arr[index].equipmentList = res
  174. }
  175. })
  176. this.List = _arr
  177. this.$forceUpdate()
  178. }
  179. if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  180. _arr = this.List
  181. _arr.forEach((e, index) => {
  182. if (e.workOrderId == id) {
  183. _arr[index].turnover = res
  184. }
  185. })
  186. this.List = _arr
  187. this.$forceUpdate()
  188. }
  189. })
  190. },
  191. save() {
  192. if (!this.isLastJob) {
  193. uni.showToast({
  194. icon: 'none',
  195. title: '上道工序暂未报工'
  196. })
  197. return false
  198. }
  199. if (this.List[0].normalQuality.quantity < 0) {
  200. uni.showToast({
  201. icon: 'none',
  202. title: '废品数量小于0'
  203. })
  204. return false
  205. }
  206. if (this.List[0].normalQuality.formedNum - this.List[0].normalQuality.quantity < 0) {
  207. uni.showToast({
  208. icon: 'none',
  209. title: '废品数量不能大于合格数量'
  210. })
  211. return false
  212. }
  213. this.List[0].normalQuality.inspectionList = this.inspectionList
  214. let _arr = JSON.parse(JSON.stringify(this.List))
  215. _arr.forEach(e => {
  216. e.turnover.forEach((o) => {
  217. o.extInfo.positionList.forEach(f => {
  218. f.quantity = f.quantity - Number(f.sampleNum)
  219. f.sampleNum = 0
  220. })
  221. })
  222. })
  223. batchSave(_arr).then(res => {
  224. uni.navigateBack()
  225. })
  226. },
  227. handAdd(id) {
  228. console.log(id)
  229. const storageKey = Date.now() + "";
  230. uni.setStorageSync(storageKey, this.List || []);
  231. uni.navigateTo({
  232. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=zdy&taskId=${this.taskId}&classIds=[4,7]`
  233. })
  234. },
  235. }
  236. }
  237. </script>
  238. <style lang="scss" scoped>
  239. .content-box {
  240. height: 100vh;
  241. overflow: hidden;
  242. display: flex;
  243. flex-direction: column;
  244. }
  245. .list_box {
  246. flex: 1;
  247. overflow: hidden;
  248. padding: 4rpx 0;
  249. .u-list {
  250. height: 100% !important;
  251. }
  252. .card_box {
  253. padding: 16rpx 24rpx;
  254. }
  255. }
  256. .bottom-wrapper {
  257. .btn_box {
  258. width: 750rpx;
  259. height: 88rpx;
  260. line-height: 88rpx;
  261. background: $theme-color;
  262. text-align: center;
  263. font-size: 36rpx;
  264. font-style: normal;
  265. font-weight: 400;
  266. color: #fff;
  267. }
  268. }
  269. .operate_box {
  270. padding: 10rpx 160rpx;
  271. /deep/ .u-button {
  272. width: 160rpx;
  273. }
  274. }
  275. </style>