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. <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. selectList.forEach(f => {
  76. if (f.rootCategoryLevelId == 7) { // 周转车
  77. this.objData.turnover.forEach(e => {
  78. if (e.code != f.code) {
  79. this.objData.turnover.push(f)
  80. this.$forceUpdate()
  81. }
  82. })
  83. console.log(this.objData.turnover)
  84. }
  85. })
  86. });
  87. },
  88. methods: {
  89. // 相机扫码
  90. HandlScanCode() {
  91. this.scanItAllData('w0300000003140004')
  92. return false
  93. let _this = this
  94. uni.scanCode({
  95. success: function(res) {
  96. _this.scanItAllData(res.result)
  97. }
  98. })
  99. },
  100. scanItAllData(result) {
  101. scanLedger(result).then(res => {
  102. console.log(this.objData.turnover)
  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. console.log(this.objData.turnover)
  115. }
  116. })
  117. },
  118. handleDel(idx, type) {
  119. if (type == 'turnover') {
  120. this.objData.turnover.splice(idx, 1)
  121. this.$forceUpdate()
  122. }
  123. },
  124. handleScan(id, type) {
  125. let _this = this
  126. uni.scanCode({
  127. success: function(res) {
  128. _this.scanData(res.result, type, id)
  129. }
  130. })
  131. },
  132. scanData(result, type, id) {
  133. if (type == 'wordOrder') {
  134. getByCodeReport(result, this.taskId).then(res => {
  135. this.objData = res
  136. if (!this.objData.hasOwnProperty('turnover')) {
  137. this.objData['turnover'] = []
  138. }
  139. })
  140. } else if (type == 'turnover') {
  141. let isFals = this.objData.turnover.some(m => m.code == result)
  142. if (isFals) {
  143. uni.showToast({
  144. title: '周转车已存在',
  145. icon: 'none'
  146. })
  147. return false
  148. }
  149. getByCodeReport(result, this.taskId).then(res => {
  150. this.objData.turnover[id] = res
  151. })
  152. }
  153. },
  154. getList() {
  155. getByIdReport(this.id, this.taskId).then(res => {
  156. this.objData = res
  157. if (!this.objData.hasOwnProperty('turnover')) {
  158. this.objData['turnover'] = []
  159. }
  160. console.log(this.objData)
  161. })
  162. },
  163. scrolltolower() {},
  164. handAdd() {
  165. const storageKey = Date.now() + "";
  166. uni.setStorageSync(storageKey, this.objData || {});
  167. uni.navigateTo({
  168. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job`
  169. })
  170. },
  171. save() {
  172. console.log(this.objData)
  173. }
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. .content-box {
  179. height: 100vh;
  180. overflow: hidden;
  181. display: flex;
  182. flex-direction: column;
  183. }
  184. .list_box {
  185. flex: 1;
  186. overflow: hidden;
  187. padding: 4rpx 0;
  188. .u-list {
  189. height: 100% !important;
  190. }
  191. .card_box {
  192. padding: 16rpx 24rpx;
  193. }
  194. }
  195. .bottom-wrapper {
  196. .btn_box {
  197. width: 750rpx;
  198. height: 88rpx;
  199. line-height: 88rpx;
  200. background: $theme-color;
  201. text-align: center;
  202. font-size: 36rpx;
  203. font-style: normal;
  204. font-weight: 400;
  205. color: #fff;
  206. }
  207. }
  208. .operate_box {
  209. padding: 10rpx 160rpx;
  210. /deep/ .u-button {
  211. width: 160rpx;
  212. }
  213. }
  214. </style>