index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. let _this = this
  140. uni.scanCode({
  141. success: function(res) {
  142. _this.scanItData(res.result, id)
  143. }
  144. })
  145. },
  146. scanItData(result, id) {
  147. scanLedger(result).then(res => {
  148. console.log(res)
  149. let _arr = []
  150. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  151. _arr = this.List
  152. _arr.forEach((e, index) => {
  153. if (e.workOrderId == id) {
  154. _arr[index].equipmentList = res
  155. }
  156. })
  157. this.List = _arr
  158. this.$forceUpdate()
  159. }
  160. })
  161. },
  162. save() {
  163. if (!this.isLastJob) {
  164. uni.showToast({
  165. icon: 'none',
  166. title: '上道工序暂未报工'
  167. })
  168. return false
  169. }
  170. if (this.List[0].normalQuality.quantity < 0) {
  171. uni.showToast({
  172. icon: 'none',
  173. title: '废品数量小于0'
  174. })
  175. return false
  176. }
  177. if (this.List[0].normalQuality.formedNum - this.List[0].normalQuality.quantity < 0) {
  178. uni.showToast({
  179. icon: 'none',
  180. title: '废品数量不能大于合格数量'
  181. })
  182. return false
  183. }
  184. this.List[0].normalQuality.inspectionList = this.inspectionList
  185. batchSave(this.List).then(res => {
  186. uni.navigateBack()
  187. })
  188. },
  189. handAdd(id) {
  190. console.log(id)
  191. const storageKey = Date.now() + "";
  192. uni.setStorageSync(storageKey, this.List || []);
  193. uni.navigateTo({
  194. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed&taskId=${this.taskId}`
  195. })
  196. },
  197. }
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. .content-box {
  202. height: 100vh;
  203. overflow: hidden;
  204. display: flex;
  205. flex-direction: column;
  206. }
  207. .list_box {
  208. flex: 1;
  209. overflow: hidden;
  210. padding: 4rpx 0;
  211. .u-list {
  212. height: 100% !important;
  213. }
  214. .card_box {
  215. padding: 16rpx 24rpx;
  216. }
  217. }
  218. .bottom-wrapper {
  219. .btn_box {
  220. width: 750rpx;
  221. height: 88rpx;
  222. line-height: 88rpx;
  223. background: $theme-color;
  224. text-align: center;
  225. font-size: 36rpx;
  226. font-style: normal;
  227. font-weight: 400;
  228. color: #fff;
  229. }
  230. }
  231. .operate_box {
  232. padding: 10rpx 160rpx;
  233. /deep/ .u-button {
  234. width: 160rpx;
  235. }
  236. }
  237. </style>