index.vue 5.6 KB

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