index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  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. <paramBom v-if='paramDetailList.length != 0' :list='paramDetailList'></paramBom>
  11. <deviceBom v-if='objData.equipmentList.length != 0' :list='objData.equipmentList'></deviceBom>
  12. <modelBom v-if='objData.modelList.length != 0' :list='objData.modelList' pattern='job'
  13. ref='modelRef'>
  14. </modelBom>
  15. <jobBom v-if='isLoad' :item='objData' :palletList='objData.palletList'
  16. :notFormed='objData.notFormedList' @penalize='penalize' @modeNum='modeNum'></jobBom>
  17. <oneJobBom v-if='objData.instanceList && objData.instanceList.length != 0' :item='objData'
  18. :list='objData.instanceList'>
  19. </oneJobBom>
  20. <byProductBom v-if='objData.productRecycleList.length != 0 ' :list='objData.productRecycleList'
  21. @penalize='penalize'>
  22. </byProductBom>
  23. <turnoverBom v-if='objData.turnover.length != 0' :list='objData.turnover' :wordItem='objData'
  24. pattern='job' @handleScan='handleScan'>
  25. </turnoverBom>
  26. <aridRegion v-if='objData.aridRegionList.length != 0' :list='objData.aridRegionList'
  27. :remainingTime='remainingTime' @handleScan='handleScan' :isType='true'></aridRegion>
  28. <packingBom :taskId='taskId' :workOrderId='id' :objData='objData' ref="packRef"
  29. v-if='taskType == 4 && objData'></packingBom>
  30. <view class="operate_box rx-sc">
  31. <u-button size="small" class="u-reset-button" type="success" @click="handAdd">手动添加</u-button>
  32. </view>
  33. </view>
  34. </u-list>
  35. </view>
  36. <view class="bottom-wrapper">
  37. <view class="btn_box" @click="save">一键报工</view>
  38. </view>
  39. <SearchPopup mode="bottom" v-if='searchShow'>
  40. <template v-slot:list>
  41. <view class="search_list">
  42. <u-form labelPosition="left" :model="formData" labelWidth="180" labelAlign="left" class="baseForm">
  43. <u-form-item label="仓库:" class="required-form" borderBottom prop="warehouseId">
  44. <zxz-uni-data-select :localdata="warehouseList" v-model="formData.warehouseId"
  45. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  46. </u-form-item>
  47. </u-form>
  48. </view>
  49. </template>
  50. <template v-slot:operate>
  51. <view class="operate_box rx-bc">
  52. <u-button size="small" class="u-reset-button" @click="searchCancel">
  53. 取消
  54. </u-button>
  55. <u-button type="success" size="small" class="u-reset-button" @click="popupOk">
  56. 确定
  57. </u-button>
  58. </view>
  59. </template>
  60. </SearchPopup>
  61. </view>
  62. </template>
  63. <script>
  64. import {
  65. getByIdReport,
  66. getByCodeReport,
  67. jobSave
  68. } from '@/api/pda/jobBooking.js'
  69. import {
  70. scanLedger,
  71. getWarehouseList,
  72. } from '@/api/pda/workOrder.js'
  73. import workOrderBom from '../../feeding/components/workOrderBom.vue'
  74. import deviceBom from '../../feeding/components/deviceBom.vue'
  75. import modelBom from '../../feeding/components/modelBom.vue'
  76. import jobBom from '../components/jobBom.vue'
  77. import oneJobBom from '../components/oneJobBom.vue'
  78. import byProductBom from '../components/byProductBom'
  79. import turnoverBom from '../components/turnoverBom.vue'
  80. import aridRegion from '../../feeding/components/aridRegion.vue'
  81. import paramBom from '../../feeding/components/paramBom.vue'
  82. import packingBom from '../components/packingBom.vue'
  83. import SearchPopup from '../../components/searchPopup.vue'
  84. export default {
  85. components: {
  86. workOrderBom,
  87. deviceBom,
  88. modelBom,
  89. jobBom,
  90. oneJobBom,
  91. byProductBom,
  92. turnoverBom,
  93. aridRegion,
  94. paramBom,
  95. packingBom,
  96. SearchPopup
  97. },
  98. data() {
  99. return {
  100. title: '',
  101. taskType: 1,
  102. isLoad: true,
  103. objData: {
  104. equipmentList: [],
  105. modelList: [],
  106. turnover: [],
  107. productRecycleList: [],
  108. aridRegionList: [],
  109. palletList: [],
  110. workReportInfo: {
  111. },
  112. notFormedList: [], // 报工-不合格
  113. },
  114. searchShow: false,
  115. warehouseList: [],
  116. formData: {
  117. warehouseId: ''
  118. },
  119. penalizeIndex: null,
  120. paramDetailList: [],
  121. remainingTime: 0,
  122. id: null,
  123. taskId: null,
  124. }
  125. },
  126. onLoad(options) {
  127. this.title = options.taskName ? options.taskName + '-报工' : '报工'
  128. this.taskType = options.taskType
  129. this.id = options.id
  130. this.taskId = options.taskId
  131. this.getList()
  132. },
  133. onShow() {
  134. uni.$off("setSelectList");
  135. uni.$on("setSelectList", (selectList, id) => {
  136. let turnover = []
  137. let equipmentList = [] // 生产设备
  138. let isEquipment = this.objData.equipmentList.length > 0 ? true : false // 判断是否有设置
  139. selectList.forEach(f => {
  140. if (f.rootCategoryLevelId == 4) { // 生产设备
  141. if (isEquipment) {
  142. equipmentList = this.objData.equipmentList
  143. } else {
  144. equipmentList = equipmentList.concat(f)
  145. }
  146. }
  147. if (f.rootCategoryLevelId == 7) { // 周转车
  148. turnover = turnover.concat(f)
  149. }
  150. })
  151. this.$set(this.objData, 'equipmentList', equipmentList)
  152. this.$set(this.objData, 'turnover', turnover)
  153. this.$forceUpdate()
  154. });
  155. },
  156. methods: {
  157. // 相机扫码
  158. HandlScanCode() {
  159. let _this = this
  160. uni.scanCode({
  161. success: function(res) {
  162. _this.scanItAllData(res.result)
  163. }
  164. })
  165. },
  166. scanItAllData(result) {
  167. scanLedger(result).then(res => {
  168. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  169. if (this.objData.equipmentList.length == 0) {
  170. this.objData.equipmentList = res
  171. this.$forceUpdate()
  172. } else {
  173. if (this.objData.equipmentList[0].instanceId != res[0].instanceId) {
  174. uni.showToast({
  175. title: '设备不匹配',
  176. icon: 'none'
  177. })
  178. } else {
  179. uni.showToast({
  180. title: '设备匹配成功',
  181. icon: 'none'
  182. })
  183. }
  184. }
  185. }
  186. if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 磨具
  187. if (this.objData.modelList.length == 0) {
  188. this.objData.modelList = res
  189. this.$forceUpdate()
  190. } else {
  191. if (this.objData.modelList[0].instanceId != res[0].instanceId) {
  192. uni.showToast({
  193. title: '模具不匹配',
  194. icon: 'none'
  195. })
  196. } else {
  197. uni.showToast({
  198. title: '设备匹配成功',
  199. icon: 'none'
  200. })
  201. }
  202. }
  203. } else if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  204. let isFals = this.objData.turnover.some(m => m.code == result)
  205. if (isFals) {
  206. uni.showToast({
  207. title: '周转车已存在',
  208. icon: 'none'
  209. })
  210. return false
  211. }
  212. this.objData.turnover.push(res[0])
  213. this.$forceUpdate()
  214. }
  215. })
  216. },
  217. handleScan(id, type) {
  218. let _this = this
  219. uni.scanCode({
  220. success: function(res) {
  221. _this.scanData(res.result, type, id)
  222. }
  223. })
  224. },
  225. scanData(result, type, id) {
  226. if (type == 'wordOrder') {
  227. getByCodeReport(result, this.taskId).then(res => {
  228. this.objData = res
  229. if (!this.objData.hasOwnProperty('turnover')) {
  230. this.objData['turnover'] = []
  231. }
  232. if (!this.objData.hasOwnProperty('aridRegionList')) {
  233. this.objData['aridRegionList'] = []
  234. }
  235. })
  236. } else if (type == 'turnover') {
  237. let isFals = this.objData.turnover.some(m => m.code == result)
  238. if (isFals) {
  239. uni.showToast({
  240. title: '周转车已存在',
  241. icon: 'none'
  242. })
  243. return false
  244. }
  245. getByCodeReport(result, this.taskId).then(res => {
  246. this.objData.turnover[id] = res
  247. })
  248. }
  249. },
  250. getList() {
  251. this.isLoad = false
  252. getByIdReport(this.id, this.taskId).then(res => {
  253. this.objData = res
  254. if (!this.objData.hasOwnProperty('turnover')) {
  255. this.objData['turnover'] = []
  256. }
  257. if (!this.objData.hasOwnProperty('aridRegionList')) {
  258. this.objData['aridRegionList'] = []
  259. }
  260. if (!this.objData.hasOwnProperty('instanceList')) {
  261. this.objData['instanceList'] = []
  262. }
  263. // this.taskType = res.currentTaskDiagram.type
  264. this.objData.palletList = [{
  265. categoryLevelId: '',
  266. categoryLevelName: '',
  267. categoryId: '',
  268. rootCategoryLevelId: '',
  269. code: '',
  270. name: '',
  271. specification: '',
  272. brandNum: '',
  273. modelType: '',
  274. quantity: '',
  275. unit: ''
  276. }]
  277. this.objData.workReportInfo = {
  278. formingNum: null,
  279. formingWeight: null,
  280. formedNum: null,
  281. formedWeight: null,
  282. taskId: this.taskId
  283. }
  284. this.objData.notFormedList = [{
  285. notFormedNum: null,
  286. notFormedWeight: null,
  287. weightUnit: res.weightUnit,
  288. unit: res.unit,
  289. warehouseId: null, // 处置 仓库id
  290. }]
  291. if (this.objData.instanceList.length > 0) { // 预制体报工
  292. this.objData.workReportInfo.formedNum = this.objData.instanceList.length
  293. }
  294. this.objData.workReportInfo.formingNum = res.formingNum
  295. this.objData.workReportInfo.formingWeight = res.formingWeight
  296. this.objData.workReportInfo.unit = res.unit
  297. this.objData.workReportInfo.weightUnit = res.weightUnit
  298. this.objData.workReportInfo.workOrderId = res.workOrderId
  299. this.paramDetailList = []
  300. this.paramDetailList = res.paramDetailList.map(m => {
  301. if (m.extInfo.textType == 5) {
  302. this.remainingTime = m.extInfo.remainingTime
  303. }
  304. return {
  305. ...m.extInfo
  306. }
  307. })
  308. }).finally(() => {
  309. this.isLoad = true
  310. })
  311. },
  312. scrolltolower() {},
  313. handAdd() {
  314. const storageKey = Date.now() + "";
  315. uni.setStorageSync(storageKey, this.objData || {});
  316. uni.navigateTo({
  317. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job&taskId=${this.taskId}`
  318. })
  319. },
  320. penalize(index) {
  321. if (index || index == 0) {
  322. this.penalizeIndex = index
  323. this.formData.warehouseId = this.objData.productRecycleList[this.penalizeIndex].warehouseId || ''
  324. } else {
  325. this.penalizeIndex = null
  326. this.formData.warehouseId = this.objData.notFormedList[0].warehouseId || ''
  327. }
  328. this.$forceUpdate()
  329. if (this.warehouseList.length == 0) {
  330. getWarehouseList().then(res => {
  331. this.warehouseList = res
  332. this.searchShow = true
  333. })
  334. } else {
  335. this.searchShow = true
  336. }
  337. },
  338. inputChange(e) {
  339. console.log(e)
  340. },
  341. searchCancel() {
  342. this.searchShow = false
  343. },
  344. popupOk() {
  345. if (this.penalizeIndex == null) {
  346. this.$set(this.objData.notFormedList[0], 'warehouseId', this.formData.warehouseId || null)
  347. } else {
  348. this.objData.productRecycleList[this.penalizeIndex].warehouseId = this.formData.warehouseId
  349. }
  350. this.$forceUpdate()
  351. this.searchShow = false
  352. },
  353. modeNum(num) {
  354. if (this.objData.modelList.length == 0) {
  355. return false
  356. }
  357. this.$refs.modelRef.setNum(num)
  358. },
  359. save() {
  360. uni.showLoading({
  361. title: '加载中'
  362. });
  363. if (!this.objData.workReportInfo['formedNum'] && this.objData.workReportInfo['formedNum'] != 0) {
  364. uni.showToast({
  365. title: '请输入合格品数量',
  366. icon: 'none'
  367. })
  368. return false
  369. }
  370. // if (!this.objData.workReportInfo['formedWeight'] && this.objData.workReportInfo['formedWeight'] != 0) {
  371. // uni.showToast({
  372. // title: '请输入合格品重量',
  373. // icon: 'none'
  374. // })
  375. // return false
  376. // }
  377. if (this.objData.notFormedList[0].notFormedNum > 0 && !this.objData.notFormedList[0].warehouseId) {
  378. uni.showToast({
  379. title: '请点击不合格品处置,选择仓库',
  380. icon: 'none'
  381. })
  382. return false
  383. }
  384. if (this.objData.productRecycleList.length > 0) {
  385. let bol
  386. bol = this.objData.productRecycleList.every(e => {
  387. return e.recycleQuantity >= 0 && e.warehouseId
  388. })
  389. if (!bol) {
  390. uni.showToast({
  391. title: '请选择副产品回收处置',
  392. icon: 'none'
  393. })
  394. return false
  395. }
  396. }
  397. // 预制体
  398. if (this.objData.instanceList.length > 0) {
  399. let bol
  400. let _i
  401. bol = this.objData.instanceList.every((e, i) => {
  402. _i = i + 1
  403. return e.extInfo.hasOwnProperty('taskId') && e.extInfo.taskId
  404. })
  405. if (!bol) {
  406. uni.showToast({
  407. title: `请完善第${_i}处置方式`,
  408. icon: 'none'
  409. })
  410. return false
  411. }
  412. }
  413. // 包装
  414. if (this.taskType == 4) {
  415. let packInfo = this.$refs.packRef.getData()
  416. this.objData.packInfo = packInfo
  417. this.objData.taskType = this.taskType
  418. if (packInfo.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(this.objData
  419. .notFormedList[0].notFormedNum)) {
  420. uni.hideLoading();
  421. uni.showModal({
  422. title: '提示',
  423. content: '合格品数量加不合格品数量不等于包装总数!',
  424. confirmText: '确认', //这块是确定按钮的文字
  425. success: function(res) {
  426. if (res.confirm) {
  427. // 执行确认后的操作
  428. } else {
  429. return false
  430. }
  431. }
  432. })
  433. }
  434. }
  435. if (this.objData.currentTaskDiagram.isFirstTask == 0) { // isFirstTask 判断是否首工序
  436. uni.hideLoading();
  437. if (this.objData.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(this
  438. .objData.notFormedList[0].notFormedNum)) {
  439. uni.showModal({
  440. title: '提示',
  441. content: '合格品数量加不合格品数量不等于上道工序数量!',
  442. confirmText: '确认', //这块是确定按钮的文字
  443. success: function(res) {
  444. if (res.confirm) {
  445. // 执行确认后的操作
  446. } else {
  447. return false
  448. }
  449. }
  450. })
  451. }
  452. }
  453. jobSave(this.objData).then(res => {
  454. uni.hideLoading();
  455. uni.navigateBack()
  456. }).finally(() => {
  457. setTimeout(function() {
  458. uni.hideLoading();
  459. }, 3000);
  460. })
  461. }
  462. }
  463. }
  464. </script>
  465. <style lang="scss" scoped>
  466. .content-box {
  467. height: 100vh;
  468. overflow: hidden;
  469. display: flex;
  470. flex-direction: column;
  471. }
  472. .list_box {
  473. flex: 1;
  474. overflow: hidden;
  475. padding: 4rpx 0;
  476. .u-list {
  477. height: 100% !important;
  478. }
  479. .card_box {
  480. padding: 16rpx 24rpx;
  481. }
  482. }
  483. .bottom-wrapper {
  484. .btn_box {
  485. width: 750rpx;
  486. height: 88rpx;
  487. line-height: 88rpx;
  488. background: $theme-color;
  489. text-align: center;
  490. font-size: 36rpx;
  491. font-style: normal;
  492. font-weight: 400;
  493. color: #fff;
  494. }
  495. }
  496. .operate_box {
  497. padding: 10rpx 160rpx;
  498. /deep/ .u-button {
  499. width: 160rpx;
  500. }
  501. }
  502. .search_list {
  503. min-height: 500rpx;
  504. padding: 0 32rpx;
  505. }
  506. </style>