index.vue 6.9 KB

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