index.vue 6.0 KB

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