index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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'></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' @handleDel='handleDel'>
  18. </turnoverBom>
  19. <aridRegion v-if='objData.aridRegionList.length != 0' :list='objData.aridRegionList'
  20. @handleScan='handleScan' @handleDel='handleDel'></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. },
  67. id: null,
  68. taskId: null,
  69. }
  70. },
  71. onLoad(options) {
  72. this.title = options.taskName ? options.taskName + '-报工' : '报工'
  73. this.id = options.id
  74. this.taskId = options.taskId
  75. this.getList()
  76. },
  77. onShow() {
  78. uni.$off("setSelectList");
  79. uni.$on("setSelectList", (selectList, id) => {
  80. let turnover = []
  81. selectList.forEach(f => {
  82. if (f.rootCategoryLevelId == 7) { // 周转车
  83. turnover = turnover.concat(f)
  84. }
  85. })
  86. this.$set(this.objData, 'turnover', turnover)
  87. this.$forceUpdate()
  88. });
  89. },
  90. methods: {
  91. // 相机扫码
  92. HandlScanCode() {
  93. // CX-EQ-YLSJL-008 设备
  94. // M001 M002 模具
  95. // 周转车 w0300000003140004
  96. this.scanItAllData('M002')
  97. return false
  98. let _this = this
  99. uni.scanCode({
  100. success: function(res) {
  101. _this.scanItAllData(res.result)
  102. }
  103. })
  104. },
  105. scanItAllData(result) {
  106. scanLedger(result).then(res => {
  107. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  108. if (this.objData.equipmentList.length == 0) {
  109. this.objData.equipmentList = res
  110. this.$forceUpdate()
  111. } else {
  112. if (this.objData.equipmentList[0].instanceId != res[0].instanceId) {
  113. uni.showToast({
  114. title: '设备不匹配',
  115. icon: 'none'
  116. })
  117. } else {
  118. uni.showToast({
  119. title: '设备匹配成功',
  120. icon: 'none'
  121. })
  122. }
  123. }
  124. }
  125. if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 磨具
  126. if (this.objData.modelList.length == 0) {
  127. this.objData.modelList = res
  128. this.$forceUpdate()
  129. } else {
  130. if (this.objData.modelList[0].instanceId != res[0].instanceId) {
  131. uni.showToast({
  132. title: '模具不匹配',
  133. icon: 'none'
  134. })
  135. } else {
  136. uni.showToast({
  137. title: '设备匹配成功',
  138. icon: 'none'
  139. })
  140. }
  141. }
  142. } else if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  143. let isFals = this.objData.turnover.some(m => m.code == result)
  144. if (isFals) {
  145. uni.showToast({
  146. title: '周转车已存在',
  147. icon: 'none'
  148. })
  149. return false
  150. }
  151. this.objData.turnover.push(res[0])
  152. this.$forceUpdate()
  153. }
  154. })
  155. },
  156. handleDel(idx, type) {
  157. if (type == 'turnover') {
  158. this.objData.turnover.splice(idx, 1)
  159. this.$forceUpdate()
  160. }
  161. },
  162. handleScan(id, type) {
  163. let _this = this
  164. uni.scanCode({
  165. success: function(res) {
  166. _this.scanData(res.result, type, id)
  167. }
  168. })
  169. },
  170. scanData(result, type, id) {
  171. if (type == 'wordOrder') {
  172. getByCodeReport(result, this.taskId).then(res => {
  173. this.objData = res
  174. if (!this.objData.hasOwnProperty('turnover')) {
  175. this.objData['turnover'] = []
  176. }
  177. if (!this.objData.hasOwnProperty('aridRegionList')) {
  178. this.objData['aridRegionList'] = []
  179. }
  180. })
  181. } else if (type == 'turnover') {
  182. let isFals = this.objData.turnover.some(m => m.code == result)
  183. if (isFals) {
  184. uni.showToast({
  185. title: '周转车已存在',
  186. icon: 'none'
  187. })
  188. return false
  189. }
  190. getByCodeReport(result, this.taskId).then(res => {
  191. this.objData.turnover[id] = res
  192. })
  193. }
  194. },
  195. getList() {
  196. getByIdReport(this.id, this.taskId).then(res => {
  197. this.objData = res
  198. if (!this.objData.hasOwnProperty('turnover')) {
  199. this.objData['turnover'] = []
  200. }
  201. if (!this.objData.hasOwnProperty('aridRegionList')) {
  202. this.objData['aridRegionList'] = []
  203. }
  204. console.log(this.objData)
  205. })
  206. },
  207. scrolltolower() {},
  208. handAdd() {
  209. const storageKey = Date.now() + "";
  210. uni.setStorageSync(storageKey, this.objData || {});
  211. uni.navigateTo({
  212. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job`
  213. })
  214. },
  215. save() {
  216. }
  217. }
  218. }
  219. </script>
  220. <style lang="scss" scoped>
  221. .content-box {
  222. height: 100vh;
  223. overflow: hidden;
  224. display: flex;
  225. flex-direction: column;
  226. }
  227. .list_box {
  228. flex: 1;
  229. overflow: hidden;
  230. padding: 4rpx 0;
  231. .u-list {
  232. height: 100% !important;
  233. }
  234. .card_box {
  235. padding: 16rpx 24rpx;
  236. }
  237. }
  238. .bottom-wrapper {
  239. .btn_box {
  240. width: 750rpx;
  241. height: 88rpx;
  242. line-height: 88rpx;
  243. background: $theme-color;
  244. text-align: center;
  245. font-size: 36rpx;
  246. font-style: normal;
  247. font-weight: 400;
  248. color: #fff;
  249. }
  250. }
  251. .operate_box {
  252. padding: 10rpx 160rpx;
  253. /deep/ .u-button {
  254. width: 160rpx;
  255. }
  256. }
  257. </style>