index.vue 7.4 KB

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