index.vue 5.8 KB

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