index.vue 5.7 KB

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