index.vue 6.4 KB

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