index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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" right-icon="scan" @clickRight="HandlScanCode">
  5. </uni-nav-bar>
  6. <view class="list_box">
  7. <u-list @scrolltolower="scrolltolower">
  8. <view class="card_box">
  9. <workOrderBom :item='objData' v-if='objData' @handleScan='handleScan'></workOrderBom>
  10. <deviceBom v-if='objData.equipmentList.length != 0' :list='objData.equipmentList'></deviceBom>
  11. <modelBom v-if='objData.modelList.length != 0' :list='objData.modelList'>
  12. </modelBom>
  13. <jobBom :item='objData' :palletList='objData.palletList'></jobBom>
  14. <byProductBom v-if='objData.productRecycleList.length != 0 ' :list='objData.productRecycleList'>
  15. </byProductBom>
  16. <turnoverBom v-if='objData.turnover.length != 0' :list='objData.turnover' :wordItem='objData'
  17. @handleScan='handleScan'>
  18. </turnoverBom>
  19. <aridRegion v-if='objData.aridRegionList.length != 0' :list='objData.aridRegionList'
  20. @handleScan='handleScan' :isType='true'></aridRegion>
  21. <view class="operate_box rx-sc">
  22. <u-button size="small" class="u-reset-button" type="success" @click="handAdd">手动添加</u-button>
  23. </view>
  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. getByIdReport,
  35. getByCodeReport
  36. } from '@/api/pda/jobBooking.js'
  37. import {
  38. scanLedger
  39. } from '@/api/pda/workOrder.js'
  40. import workOrderBom from '../../feeding/components/workOrderBom.vue'
  41. import deviceBom from '../../feeding/components/deviceBom.vue'
  42. import modelBom from '../../feeding/components/modelBom.vue'
  43. import jobBom from '../components/jobBom.vue'
  44. import byProductBom from '../components/byProductBom'
  45. import turnoverBom from '../components/turnoverBom.vue'
  46. import aridRegion from '../../feeding/components/aridRegion.vue'
  47. export default {
  48. components: {
  49. workOrderBom,
  50. deviceBom,
  51. modelBom,
  52. jobBom,
  53. byProductBom,
  54. turnoverBom,
  55. aridRegion
  56. },
  57. data() {
  58. return {
  59. title: '',
  60. objData: {
  61. equipmentList: [],
  62. modelList: [],
  63. turnover: [],
  64. productRecycleList: [],
  65. aridRegionList: [],
  66. palletList: [],
  67. workReportInfo: {
  68. }
  69. },
  70. id: null,
  71. taskId: null,
  72. }
  73. },
  74. onLoad(options) {
  75. this.title = options.taskName ? options.taskName + '-报工' : '报工'
  76. this.id = options.id
  77. this.taskId = options.taskId
  78. this.getList()
  79. },
  80. onShow() {
  81. uni.$off("setSelectList");
  82. uni.$on("setSelectList", (selectList, id) => {
  83. let turnover = []
  84. selectList.forEach(f => {
  85. if (f.rootCategoryLevelId == 7) { // 周转车
  86. turnover = turnover.concat(f)
  87. }
  88. })
  89. this.$set(this.objData, 'turnover', turnover)
  90. this.$forceUpdate()
  91. });
  92. },
  93. methods: {
  94. // 相机扫码
  95. HandlScanCode() {
  96. // CX-EQ-YLSJL-008 设备
  97. // M001 M002 模具
  98. // 周转车 w0300000003140004
  99. this.scanItAllData('M002')
  100. return false
  101. let _this = this
  102. uni.scanCode({
  103. success: function(res) {
  104. _this.scanItAllData(res.result)
  105. }
  106. })
  107. },
  108. scanItAllData(result) {
  109. scanLedger(result).then(res => {
  110. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  111. if (this.objData.equipmentList.length == 0) {
  112. this.objData.equipmentList = res
  113. this.$forceUpdate()
  114. } else {
  115. if (this.objData.equipmentList[0].instanceId != res[0].instanceId) {
  116. uni.showToast({
  117. title: '设备不匹配',
  118. icon: 'none'
  119. })
  120. } else {
  121. uni.showToast({
  122. title: '设备匹配成功',
  123. icon: 'none'
  124. })
  125. }
  126. }
  127. }
  128. if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 磨具
  129. if (this.objData.modelList.length == 0) {
  130. this.objData.modelList = res
  131. this.$forceUpdate()
  132. } else {
  133. if (this.objData.modelList[0].instanceId != res[0].instanceId) {
  134. uni.showToast({
  135. title: '模具不匹配',
  136. icon: 'none'
  137. })
  138. } else {
  139. uni.showToast({
  140. title: '设备匹配成功',
  141. icon: 'none'
  142. })
  143. }
  144. }
  145. } else if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  146. let isFals = this.objData.turnover.some(m => m.code == result)
  147. if (isFals) {
  148. uni.showToast({
  149. title: '周转车已存在',
  150. icon: 'none'
  151. })
  152. return false
  153. }
  154. this.objData.turnover.push(res[0])
  155. this.$forceUpdate()
  156. }
  157. })
  158. },
  159. handleScan(id, type) {
  160. let _this = this
  161. uni.scanCode({
  162. success: function(res) {
  163. _this.scanData(res.result, type, id)
  164. }
  165. })
  166. },
  167. scanData(result, type, id) {
  168. if (type == 'wordOrder') {
  169. getByCodeReport(result, this.taskId).then(res => {
  170. this.objData = res
  171. if (!this.objData.hasOwnProperty('turnover')) {
  172. this.objData['turnover'] = []
  173. }
  174. if (!this.objData.hasOwnProperty('aridRegionList')) {
  175. this.objData['aridRegionList'] = []
  176. }
  177. })
  178. } else if (type == 'turnover') {
  179. let isFals = this.objData.turnover.some(m => m.code == result)
  180. if (isFals) {
  181. uni.showToast({
  182. title: '周转车已存在',
  183. icon: 'none'
  184. })
  185. return false
  186. }
  187. getByCodeReport(result, this.taskId).then(res => {
  188. this.objData.turnover[id] = res
  189. })
  190. }
  191. },
  192. getList() {
  193. getByIdReport(this.id, this.taskId).then(res => {
  194. this.objData = res
  195. if (!this.objData.hasOwnProperty('turnover')) {
  196. this.objData['turnover'] = []
  197. }
  198. if (!this.objData.hasOwnProperty('aridRegionList')) {
  199. this.objData['aridRegionList'] = []
  200. }
  201. this.objData.palletList = [{
  202. categoryLevelId: '',
  203. categoryLevelName: '',
  204. categoryId: '',
  205. rootCategoryLevelId: '',
  206. code: '',
  207. name: '',
  208. specification: '',
  209. brandNum: '',
  210. modelType: '',
  211. quantity: '',
  212. unit: ''
  213. }]
  214. this.objData.workReportInfo = {
  215. formingNum: null,
  216. formingWeight: null,
  217. formedNum: null,
  218. formedWeight: null,
  219. notFormedNum: null,
  220. notFormedWeight: null,
  221. }
  222. this.objData.workReportInfo.formingNum = res.formingNum
  223. this.objData.workReportInfo.formingWeight = res.formingWeight
  224. this.objData.workReportInfo.unit = res.unit
  225. this.objData.workReportInfo.weightUnit = res.weightUnit
  226. })
  227. },
  228. scrolltolower() {},
  229. handAdd() {
  230. const storageKey = Date.now() + "";
  231. uni.setStorageSync(storageKey, this.objData || {});
  232. uni.navigateTo({
  233. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job`
  234. })
  235. },
  236. save() {
  237. console.log(this.objData)
  238. }
  239. }
  240. }
  241. </script>
  242. <style lang="scss" scoped>
  243. .content-box {
  244. height: 100vh;
  245. overflow: hidden;
  246. display: flex;
  247. flex-direction: column;
  248. }
  249. .list_box {
  250. flex: 1;
  251. overflow: hidden;
  252. padding: 4rpx 0;
  253. .u-list {
  254. height: 100% !important;
  255. }
  256. .card_box {
  257. padding: 16rpx 24rpx;
  258. }
  259. }
  260. .bottom-wrapper {
  261. .btn_box {
  262. width: 750rpx;
  263. height: 88rpx;
  264. line-height: 88rpx;
  265. background: $theme-color;
  266. text-align: center;
  267. font-size: 36rpx;
  268. font-style: normal;
  269. font-weight: 400;
  270. color: #fff;
  271. }
  272. }
  273. .operate_box {
  274. padding: 10rpx 160rpx;
  275. /deep/ .u-button {
  276. width: 160rpx;
  277. }
  278. }
  279. </style>