index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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) {
  107. this.isLastJob = false
  108. }
  109. if (m.normalQuality == null || m.workOrderType == 2) {
  110. this.$set(m, 'normalQuality', {})
  111. m.normalQuality.quantity = 0
  112. m.normalQuality.inspectionId = this.inspectionId
  113. m.normalQuality.inspectionName = this.inspectionName
  114. }
  115. m.lastObj = {
  116. formedNum: m.formedNumLast,
  117. taskNameLast: m.taskNameLast,
  118. unit: m.unit
  119. }
  120. m.feedType = 3
  121. console.log(333, m)
  122. delete m.id
  123. if (this.taskId) {
  124. m.taskId = this.taskId
  125. }
  126. return {
  127. ...m
  128. }
  129. })
  130. })
  131. },
  132. getLastTree() {
  133. getLastTreeByPid(this.inspectionId).then(res => {
  134. this.inspectionList = res
  135. this.inspectionList.push({
  136. id: -1,
  137. name: '废品总数量'
  138. })
  139. this.getGualityReview()
  140. })
  141. },
  142. getGualityReview() {
  143. let param = {
  144. inspectionId: this.inspectionId,
  145. workOrderId: this.id,
  146. taskId: this.taskId,
  147. }
  148. qualityReview(param).then(res => {
  149. if (res && res.extInfo && res.extInfo.inspectionList) {
  150. this.inspectionList = res.extInfo.inspectionList
  151. }
  152. })
  153. },
  154. scrolltolower() {},
  155. handleWordScan() {
  156. uni.showToast({
  157. icon: 'none',
  158. title: '不支持换工单'
  159. })
  160. },
  161. scanIt(id) {
  162. uni.scanCode({
  163. success: (res) => {
  164. this.scanItData(res.result, id)
  165. }
  166. })
  167. },
  168. scanItData(result, id) {
  169. scanLedger(result).then(res => {
  170. let _arr = []
  171. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  172. _arr = this.List
  173. _arr.forEach((e, index) => {
  174. if (e.workOrderId == id) {
  175. _arr[index].equipmentList = res
  176. }
  177. })
  178. this.List = _arr
  179. this.$forceUpdate()
  180. }
  181. if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  182. _arr = this.List
  183. _arr.forEach((e, index) => {
  184. if (e.workOrderId == id) {
  185. _arr[index].turnover = res
  186. }
  187. })
  188. this.List = _arr
  189. this.$forceUpdate()
  190. }
  191. })
  192. },
  193. save() {
  194. if (!this.isLastJob) {
  195. uni.showToast({
  196. icon: 'none',
  197. title: '上道工序暂未报工'
  198. })
  199. return false
  200. }
  201. if (this.List[0].normalQuality.quantity < 0) {
  202. uni.showToast({
  203. icon: 'none',
  204. title: '废品数量小于0'
  205. })
  206. return false
  207. }
  208. if (this.List[0].normalQuality.formedNum - this.List[0].normalQuality.quantity < 0) {
  209. uni.showToast({
  210. icon: 'none',
  211. title: '废品数量不能大于合格数量'
  212. })
  213. return false
  214. }
  215. this.List[0].normalQuality.inspectionList = this.inspectionList
  216. let _arr = JSON.parse(JSON.stringify(this.List))
  217. _arr.forEach(e => {
  218. e.turnover.forEach((o) => {
  219. o.extInfo.positionList.forEach(f => {
  220. f.quantity = f.quantity - Number(f.sampleNum)
  221. f.sampleNum = 0
  222. })
  223. })
  224. })
  225. batchSave(_arr).then(res => {
  226. uni.navigateBack()
  227. })
  228. },
  229. handAdd(id) {
  230. console.log(id)
  231. const storageKey = Date.now() + "";
  232. uni.setStorageSync(storageKey, this.List || []);
  233. uni.navigateTo({
  234. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=zdy&taskId=${this.taskId}&classIds=[4,7]`
  235. })
  236. },
  237. }
  238. }
  239. </script>
  240. <style lang="scss" scoped>
  241. .content-box {
  242. height: 100vh;
  243. overflow: hidden;
  244. display: flex;
  245. flex-direction: column;
  246. }
  247. .list_box {
  248. flex: 1;
  249. overflow: hidden;
  250. padding: 4rpx 0;
  251. .u-list {
  252. height: 100% !important;
  253. }
  254. .card_box {
  255. padding: 16rpx 24rpx;
  256. }
  257. }
  258. .bottom-wrapper {
  259. .btn_box {
  260. width: 750rpx;
  261. height: 88rpx;
  262. line-height: 88rpx;
  263. background: $theme-color;
  264. text-align: center;
  265. font-size: 36rpx;
  266. font-style: normal;
  267. font-weight: 400;
  268. color: #fff;
  269. }
  270. }
  271. .operate_box {
  272. padding: 10rpx 160rpx;
  273. /deep/ .u-button {
  274. width: 160rpx;
  275. }
  276. }
  277. </style>