index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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></aridRegion>
  20. <view class="operate_box rx-sc">
  21. <u-button size="small" class="u-reset-button" type="success" @click="handAdd">手动添加</u-button>
  22. </view>
  23. </view>
  24. </u-list>
  25. </view>
  26. <view class="bottom-wrapper">
  27. <view class="btn_box" @click="save">一键报工</view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import {
  33. getByIdReport,
  34. getByCodeReport
  35. } from '@/api/pda/jobBooking.js'
  36. import {
  37. scanLedger
  38. } from '@/api/pda/workOrder.js'
  39. import workOrderBom from '../../feeding/components/workOrderBom.vue'
  40. import deviceBom from '../../feeding/components/deviceBom.vue'
  41. import modelBom from '../../feeding/components/modelBom.vue'
  42. import jobBom from '../components/jobBom.vue'
  43. import byProductBom from '../components/byProductBom'
  44. import turnoverBom from '../components/turnoverBom.vue'
  45. import aridRegion from '../components/aridRegion.vue'
  46. export default {
  47. components: {
  48. workOrderBom,
  49. deviceBom,
  50. modelBom,
  51. jobBom,
  52. byProductBom,
  53. turnoverBom,
  54. aridRegion
  55. },
  56. data() {
  57. return {
  58. title: '',
  59. objData: {
  60. equipmentList: [],
  61. modelList: [],
  62. turnover: [],
  63. productRecycleList: []
  64. },
  65. id: null,
  66. taskId: null,
  67. }
  68. },
  69. onLoad(options) {
  70. this.title = options.taskName ? options.taskName + '-报工' : '报工'
  71. this.id = options.id
  72. this.taskId = options.taskId
  73. this.getList()
  74. },
  75. onShow() {
  76. uni.$off("setSelectList");
  77. uni.$on("setSelectList", (selectList, id) => {
  78. let turnover = []
  79. selectList.forEach(f => {
  80. if (f.rootCategoryLevelId == 7) { // 周转车
  81. turnover = turnover.concat(f)
  82. }
  83. })
  84. this.$set(this.objData, 'turnover', turnover)
  85. console.log(this.objData)
  86. this.$forceUpdate()
  87. });
  88. },
  89. methods: {
  90. // 相机扫码
  91. HandlScanCode() {
  92. this.scanItAllData('w0300000003140004')
  93. return false
  94. let _this = this
  95. uni.scanCode({
  96. success: function(res) {
  97. _this.scanItAllData(res.result)
  98. }
  99. })
  100. },
  101. scanItAllData(result) {
  102. scanLedger(result).then(res => {
  103. if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  104. let isFals = this.objData.turnover.some(m => m.code == result)
  105. if (isFals) {
  106. uni.showToast({
  107. title: '周转车已存在',
  108. icon: 'none'
  109. })
  110. return false
  111. }
  112. this.objData.turnover.push(res[0])
  113. this.$forceUpdate()
  114. }
  115. })
  116. },
  117. handleDel(idx, type) {
  118. if (type == 'turnover') {
  119. this.objData.turnover.splice(idx, 1)
  120. this.$forceUpdate()
  121. }
  122. },
  123. handleScan(id, type) {
  124. let _this = this
  125. uni.scanCode({
  126. success: function(res) {
  127. _this.scanData(res.result, type, id)
  128. }
  129. })
  130. },
  131. scanData(result, type, id) {
  132. if (type == 'wordOrder') {
  133. getByCodeReport(result, this.taskId).then(res => {
  134. this.objData = res
  135. if (!this.objData.hasOwnProperty('turnover')) {
  136. this.objData['turnover'] = []
  137. }
  138. })
  139. } else if (type == 'turnover') {
  140. let isFals = this.objData.turnover.some(m => m.code == result)
  141. if (isFals) {
  142. uni.showToast({
  143. title: '周转车已存在',
  144. icon: 'none'
  145. })
  146. return false
  147. }
  148. getByCodeReport(result, this.taskId).then(res => {
  149. this.objData.turnover[id] = res
  150. })
  151. }
  152. },
  153. getList() {
  154. getByIdReport(this.id, this.taskId).then(res => {
  155. this.objData = res
  156. if (!this.objData.hasOwnProperty('turnover')) {
  157. this.objData['turnover'] = []
  158. }
  159. console.log(this.objData)
  160. })
  161. },
  162. scrolltolower() {},
  163. handAdd() {
  164. const storageKey = Date.now() + "";
  165. uni.setStorageSync(storageKey, this.objData || {});
  166. uni.navigateTo({
  167. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job`
  168. })
  169. },
  170. save() {
  171. console.log(this.objData)
  172. }
  173. }
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. .content-box {
  178. height: 100vh;
  179. overflow: hidden;
  180. display: flex;
  181. flex-direction: column;
  182. }
  183. .list_box {
  184. flex: 1;
  185. overflow: hidden;
  186. padding: 4rpx 0;
  187. .u-list {
  188. height: 100% !important;
  189. }
  190. .card_box {
  191. padding: 16rpx 24rpx;
  192. }
  193. }
  194. .bottom-wrapper {
  195. .btn_box {
  196. width: 750rpx;
  197. height: 88rpx;
  198. line-height: 88rpx;
  199. background: $theme-color;
  200. text-align: center;
  201. font-size: 36rpx;
  202. font-style: normal;
  203. font-weight: 400;
  204. color: #fff;
  205. }
  206. }
  207. .operate_box {
  208. padding: 10rpx 160rpx;
  209. /deep/ .u-button {
  210. width: 160rpx;
  211. }
  212. }
  213. </style>