index.vue 5.4 KB

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