index.vue 6.3 KB

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