index.vue 7.0 KB

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