index.vue 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. <template>
  2. <!-- 报工页面 -->
  3. <view class="content-box">
  4. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" background-color="#F7F9FA"
  5. color="#000" @clickLeft="back" right-icon="scan" @clickRight="HandlScanCode">
  6. </uni-nav-bar>
  7. <view class="list_box">
  8. <u-list @scrolltolower="scrolltolower">
  9. <view class="card_box">
  10. <!-- 工单信息 objData 报告信息-->
  11. <workOrderBom :item='objData' v-if='objData' pType='job' :taskType="taskType"
  12. @handleScan='handleScan'>
  13. </workOrderBom>
  14. <paramBom v-if='paramDetailList.length != 0' :list='paramDetailList'></paramBom>
  15. <!-- 设备信息 -->
  16. <deviceBom v-if='objData.equipmentList.length != 0' :list='objData.equipmentList' :ishuoWei="false"
  17. :wordItem='objData' :isDetails='true'>
  18. </deviceBom>
  19. <modelBom v-if='objData.modelList.length != 0' :list='objData.modelList' pattern='job'
  20. ref='modelRef'>
  21. </modelBom>
  22. <!-- 1报工信息 -->
  23. <view v-if="clientEnvironmentId == 3 || objData.singleReport !== 1">
  24. <jobBom v-if='isLoad' :item='objData' ref='jobReftg' :notFormed='objData.notFormedList'
  25. @penalize='penalize' @modeNum='modeNum'></jobBom>
  26. </view>
  27. <!-- 单独报工报工信息 -->
  28. <!-- single -->
  29. <singleJobBom v-else :item='objData' ref='jobRef' :notFormed='objData.notFormedList'
  30. @penalize='penalize' @modeNum='modeNum'></singleJobBom>
  31. <palletBom v-if="objData.palletList.length != 0" :palletList='objData.palletList'></palletBom>
  32. <revolvingDiskBom v-if="isLoad && objData.revolvingDiskList.length > 0" pattern='job'
  33. :revolvingDiskList="objData.revolvingDiskList"></revolvingDiskBom>
  34. <!-- <oneJobBom
  35. v-if='objData.instanceList && objData.instanceList.length != 0 && taskType != 4 && taskType != 6'
  36. :item='objData' :list='objData.instanceList'>
  37. </oneJobBom> -->
  38. <!-- -->
  39. <!-- 报工信息 列表 -->
  40. <view v-if="clientEnvironmentId == 3 || this.objData.singleReport !== 1">
  41. <semiProductJobBom
  42. v-if='objData.semiProductList && objData.semiProductList.length != 0 && taskType != 4 && taskType != 6 && objData.singleReport == 1'
  43. :item='objData' :list='objData.semiProductList' :equipmentList="objData.equipmentList" @weightEmit='weightEmit'>
  44. </semiProductJobBom>
  45. </view>
  46. <semiProductJobBomPL
  47. v-if='objData.semiProductList && objData.semiProductList.length != 0 && taskType != 4 && taskType != 6 && objData.singleReport == 0'
  48. :item='objData' :list='objData.semiProductList' :equipmentList="objData.equipmentList">
  49. </semiProductJobBomPL>
  50. <oneJobQualityBom
  51. v-if='objData.semiProductList && objData.semiProductList.length != 0 && taskType == 6 && clientEnvironmentId == 3 && objData.singleReport == 1'
  52. :item='objData' :list='objData.semiProductList'></oneJobQualityBom>
  53. <oneJobQualityBomPL
  54. v-if='objData.semiProductList && objData.semiProductList.length != 0 && taskType == 6 && clientEnvironmentId == 3 && objData.singleReport == 0'
  55. :item='objData' :list='objData.semiProductList'></oneJobQualityBomPL>
  56. <!-- 副产品 -->
  57. <byProductBom v-if='objData.productRecycleList.length != 0' :list='objData.productRecycleList'
  58. @penalize='penalize'>
  59. </byProductBom>
  60. <!-- 周转车 -->
  61. <turnoverBom v-if='objData.turnover.length != 0' :list='objData.turnover' :itemValue='objData'
  62. :wordItem='objData' pattern='job' @handleScan='handleScan' @formedNumFn='formedNumFn'>
  63. </turnoverBom>
  64. <!-- // 区域扫码 -->
  65. <aridRegion v-if='objData.aridRegionList.length != 0' :list='objData.aridRegionList'
  66. :remainingTime='remainingTime' @handleScan='handleScan' :isType='true'></aridRegion>
  67. <!-- //包装扫码 -->
  68. <view v-if="clientEnvironmentId != 2 && objData.singleReport !== 1">
  69. <packingBom :taskId='taskId' :workOrderId='id' :objData='objData' ref="packRef"
  70. v-if='taskType == 4 && clientEnvironmentId != 3 && objData' :categoryId="categoryId">
  71. </packingBom>
  72. </view>
  73. <!-- 碳谷 包装扫码 -->
  74. <packingTgBom
  75. v-if='objData.pickOutInList && objData.pickOutInList.length != 0 && taskType == 4 && clientEnvironmentId == 3'
  76. :list='objData.pickOutInList' :objData="objData" :item='objData'></packingTgBom>
  77. <view class="operate_box rx-sc">
  78. <u-button size="small" class="u-reset-button" type="success" @click="handAdd">手动添加</u-button>
  79. </view>
  80. <view style="height: 100rpx;"></view>
  81. </view>
  82. </u-list>
  83. </view>
  84. <view :class="[operateBtn ? 'flex_btn' : 'flex_btn2']">
  85. <image v-if="operateBtn" class="jiantou" src="../../../../static/rightJt.png" @click="operateBtn = false">
  86. </image>
  87. <view class="close_box" @click="operateBtn = true">
  88. <image v-if="!operateBtn" class="close" src="../../../../static/close.png"></image>
  89. </view>
  90. <view v-if="!operateBtn" @click="removeCacheFn()">清空缓存</view>
  91. <view v-if="!operateBtn" @click="switchOrder = true">切换工单</view>
  92. </view>
  93. <view class="bottom-wrapper">
  94. <view class="btn_box" @click="save(1)">缓存</view>
  95. <view class="btn_box" @click="save(2)">一键报工</view>
  96. </view>
  97. <SearchPopup mode="bottom" v-if='searchShow'>
  98. <template v-slot:list>
  99. <view class="search_list">
  100. <u-form labelPosition="left" :model="formData" labelWidth="180" labelAlign="left" class="baseForm">
  101. <u-form-item label="仓库:" class="required-form" borderBottom prop="warehouseId">
  102. <zxz-uni-data-select :localdata="warehouseList" v-model="formData.warehouseId"
  103. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  104. </u-form-item>
  105. </u-form>
  106. </view>
  107. </template>
  108. <template v-slot:operate>
  109. <view class="operate_box rx-bc">
  110. <u-button size="small" class="u-reset-button" @click="searchCancel">
  111. 取消
  112. </u-button>
  113. <u-button type="success" size="small" class="u-reset-button" @click="popupOk">
  114. 确定
  115. </u-button>
  116. </view>
  117. </template>
  118. </SearchPopup>
  119. <SearchPopup mode="center" v-if='switchOrder'>
  120. <template v-slot:list>
  121. <view class="search_list2">
  122. <u-form labelPosition="left" :model="formData" labelWidth="180" labelAlign="left" class="baseForm">
  123. <u-form-item label="工单:" class="required-form" borderBottom prop="warehouseId">
  124. <zxz-uni-data-select :localdata="warehouseList" v-model="formData.warehouseId"
  125. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  126. </u-form-item>
  127. </u-form>
  128. </view>
  129. </template>
  130. <template v-slot:operate>
  131. <view class="operate_box rx-bc">
  132. <u-button size="small" class="u-reset-button" @click="switchOrder = false">
  133. 取消
  134. </u-button>
  135. <u-button type="success" size="small" class="u-reset-button">
  136. 确定
  137. </u-button>
  138. </view>
  139. </template>
  140. </SearchPopup>
  141. </view>
  142. </template>
  143. <script>
  144. import {
  145. getByIdReport,
  146. outSourceGetByIdReport,
  147. getByCodeReport,
  148. jobSave
  149. } from '@/api/pda/jobBooking.js'
  150. import {
  151. scanLedger,
  152. getWarehouseList,
  153. saveCache,
  154. getCache,
  155. removeCache
  156. } from '@/api/pda/workOrder.js'
  157. import workOrderBom from '../../feeding/components/workOrderBom.vue'
  158. import deviceBom from '../../feeding/components/deviceBom.vue'
  159. import modelBom from '../../feeding/components/modelBom.vue'
  160. import jobBom from '../components/jobBom.vue'
  161. import singleJobBom from '../components/singleJobBom.vue'
  162. import palletBom from '../components/palletBom.vue'
  163. import oneJobBom from '../components/oneJobBom.vue'
  164. import semiProductJobBom from '../components/semiProductJobBom.vue'
  165. import semiProductJobBomPL from '../components/semiProductJobBomPL.vue'
  166. import byProductBom from '../components/byProductBom'
  167. import turnoverBom from '../components/turnoverBom.vue'
  168. import aridRegion from '../../feeding/components/aridRegion.vue'
  169. import paramBom from '../../feeding/components/paramBom.vue'
  170. import packingBom from '../components/packingBom.vue'
  171. import packingTgBom from '../components/packingTgBom'
  172. import revolvingDiskBom from '../../feeding/components/revolvingDiskBom.vue'
  173. import SearchPopup from '../../components/searchPopup.vue'
  174. import oneJobQualityBom from '../components/oneJobQualityBom.vue'
  175. import oneJobQualityBomPL from '../components/oneJobQualityBomPL.vue'
  176. export default {
  177. components: {
  178. workOrderBom,
  179. deviceBom,
  180. modelBom,
  181. jobBom,
  182. singleJobBom,
  183. palletBom,
  184. oneJobBom,
  185. semiProductJobBom,
  186. semiProductJobBomPL,
  187. byProductBom,
  188. turnoverBom,
  189. aridRegion,
  190. paramBom,
  191. packingBom,
  192. packingTgBom,
  193. revolvingDiskBom,
  194. SearchPopup,
  195. oneJobQualityBom,
  196. oneJobQualityBomPL
  197. },
  198. data() {
  199. return {
  200. title: '',
  201. taskType: 1,
  202. isLoad: true,
  203. categoryId: '',
  204. objData: {
  205. formedNumLast: 0,
  206. product: [],
  207. equipmentList: [],
  208. modelList: [],
  209. turnover: [],
  210. productRecycleList: [],
  211. aridRegionList: [],
  212. palletList: [],
  213. workReportInfo: {
  214. },
  215. notFormedList: [], // 报工-不合格
  216. },
  217. searchShow: false,
  218. switchOrder: false,
  219. warehouseList: [],
  220. formData: {
  221. warehouseId: ''
  222. },
  223. penalizeIndex: null,
  224. paramDetailList: [],
  225. remainingTime: 0,
  226. id: null,
  227. taskId: null,
  228. clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo")
  229. .clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  230. operateBtn: true,
  231. isOutsource: 0,
  232. }
  233. },
  234. onLoad(options) {
  235. this.info = options.info;
  236. this.title = options.taskName ? options.taskName + '-报工' : '报工'
  237. this.taskType = options.taskType
  238. this.id = options.id
  239. this.taskId = options.taskId
  240. this.isOutsource = options.isOutsource
  241. this.categoryId = options.categoryId
  242. this.singleReport = options.singleReport // 单个报工 1是单 2多
  243. this.getList()
  244. },
  245. onShow() {
  246. uni.$off("setSelectList");
  247. uni.$on("setSelectList", (selectList, id) => {
  248. let turnover = []
  249. let equipmentList = [] // 生产设备
  250. let isEquipment = this.objData.equipmentList.length > 0 ? true : false // 判断是否有设置
  251. selectList.forEach(f => {
  252. if (f.rootCategoryLevelId == 4) { // 生产设备
  253. if (isEquipment) {
  254. equipmentList = this.objData.equipmentList
  255. } else {
  256. equipmentList = equipmentList.concat(f)
  257. }
  258. }
  259. if (f.rootCategoryLevelId == 7) { // 周转车
  260. turnover = turnover.concat(f)
  261. }
  262. })
  263. this.$set(this.objData, 'equipmentList', equipmentList)
  264. this.$set(this.objData, 'turnover', turnover)
  265. this.$forceUpdate()
  266. });
  267. },
  268. methods: {
  269. weightEmit(formedWeight,notFormedWeight){
  270. this.$refs.jobReftg.fWeightInput(formedWeight,notFormedWeight)
  271. this.$nextTick(() => {
  272. this.$set(this.objData.workReportInfo,'formedWeight',formedWeight)
  273. this.$set(this.objData.workReportInfo,'notFormedWeight',notFormedWeight)
  274. })
  275. this.$forceUpdate()
  276. },
  277. // 相机扫码
  278. HandlScanCode() {
  279. uni.scanCode({
  280. success: (res) => {
  281. this.scanItAllData(res.result)
  282. }
  283. })
  284. },
  285. scanItAllData(result) {
  286. scanLedger(result).then(res => {
  287. if (res[0].rootCategoryLevelId == 4) { // 设备
  288. let isFals = this.objData.equipmentList.some(m => m.code == result)
  289. if (isFals) {
  290. uni.showToast({
  291. title: '设备已存在',
  292. icon: 'none'
  293. })
  294. return false
  295. }
  296. this.objData.equipmentList.push(res[0])
  297. this.$forceUpdate()
  298. }
  299. if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 磨具
  300. if (this.objData.modelList.length == 0) {
  301. this.objData.modelList = res
  302. this.$forceUpdate()
  303. } else {
  304. if (this.objData.modelList[0].instanceId != res[0].instanceId) {
  305. uni.showToast({
  306. title: '模具不匹配',
  307. icon: 'none'
  308. })
  309. } else {
  310. uni.showToast({
  311. title: '设备匹配成功',
  312. icon: 'none'
  313. })
  314. }
  315. }
  316. } else if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  317. let isFals = this.objData.turnover.some(m => m.code == result)
  318. if (isFals) {
  319. uni.showToast({
  320. title: '周转车已存在',
  321. icon: 'none'
  322. })
  323. return false
  324. }
  325. this.objData.turnover.push(res[0])
  326. this.$forceUpdate()
  327. }
  328. })
  329. },
  330. handleScan(id, type) {
  331. uni.scanCode({
  332. success: (res) => {
  333. this.scanData(res.result, type, id)
  334. }
  335. })
  336. },
  337. scanData(result, type, id) {
  338. if (type == 'wordOrder') {
  339. getByCodeReport(result, this.taskId).then(res => {
  340. this.objData = res
  341. if (!this.objData.hasOwnProperty('turnover')) {
  342. this.objData['turnover'] = []
  343. }
  344. if (!this.objData.hasOwnProperty('aridRegionList')) {
  345. this.objData['aridRegionList'] = []
  346. }
  347. })
  348. } else if (type == 'turnover') {
  349. let isFals = this.objData.turnover.some(m => m.code == result)
  350. if (isFals) {
  351. uni.showToast({
  352. title: '周转车已存在',
  353. icon: 'none'
  354. })
  355. return false
  356. }
  357. getByCodeReport(result, this.taskId).then(res => {
  358. this.objData.turnover[id] = res
  359. })
  360. }
  361. },
  362. formedNumFn(num) {
  363. console.log(999, num)
  364. this.$refs.jobRef.setFormedNum(num)
  365. },
  366. getList() {
  367. this.isLoad = false
  368. let URL = this.isOutsource == 0 ? getByIdReport : outSourceGetByIdReport
  369. console.log(URL, 'URLURLURL');
  370. URL(this.id, this.taskId).then(res => {
  371. // currentTaskDiagram 有是否可以报工
  372. this.objData = res;
  373. console.log(22, res)
  374. if (!this.objData.hasOwnProperty('turnover')) {
  375. this.objData['turnover'] = []
  376. }
  377. if (!this.objData.hasOwnProperty('aridRegionList')) {
  378. this.objData['aridRegionList'] = []
  379. }
  380. if (!this.objData.hasOwnProperty('instanceList')) {
  381. this.objData['instanceList'] = []
  382. }
  383. if (!this.objData.hasOwnProperty('palletList')) {
  384. this.objData['palletList'] = []
  385. }
  386. if (!this.objData.hasOwnProperty('revolvingDiskList')) {
  387. this.objData['revolvingDiskList'] = []
  388. }
  389. // this.taskType = res.currentTaskDiagram.type
  390. if (this.objData.palletList.length > 0) {
  391. this.objData.palletList = this.objData.palletList.map(m => {
  392. return {
  393. hideKc: true, // 不显示库存
  394. quantity: m.feedQuantity,
  395. ...m
  396. }
  397. })
  398. } else {
  399. // this.objData.palletList = [{
  400. // categoryLevelId: '',
  401. // categoryLevelName: '',
  402. // categoryId: '',
  403. // rootCategoryLevelId: '',
  404. // code: '',
  405. // name: '',
  406. // specification: '',
  407. // brandNum: '',
  408. // modelType: '',
  409. // quantity: '',
  410. // unit: '',
  411. // }]
  412. }
  413. if ((this.taskType == 6 || this.isOutsource == 1) && this.clientEnvironmentId == 3) {
  414. this.objData.semiProductList = this.objData.pickOutInList
  415. }
  416. if (this.clientEnvironmentId == 3 && this.objData.singleReport == 0 && this.taskType != 6) {
  417. this.objData.semiProductList.map(a => {
  418. a.extInfo.batchReportInfo = [{
  419. allFeedQuantity: '',
  420. allReportWeight: '',
  421. taskId: '',
  422. taskName: ''
  423. }]
  424. a.extInfo.notBatchReportInfo = [{
  425. allFeedQuantity: '',
  426. allReportWeight: '',
  427. notType: '',
  428. taskId: '',
  429. taskName: '',
  430. notReason: ''
  431. }]
  432. return {
  433. a
  434. }
  435. })
  436. this.objData.semiProductList = this.objData.semiProductList
  437. }
  438. this.objData.workReportInfo = {
  439. formingNum: null,
  440. formingWeight: null,
  441. formedNum: null,
  442. formedWeight: null,
  443. taskId: this.taskId,
  444. executorTime: ''
  445. }
  446. this.objData.notFormedList = [{
  447. notFormedNum: null,
  448. notFormedWeight: null,
  449. weightUnit: res.weightUnit,
  450. unit: res.unit,
  451. warehouseId: null, // 处置 仓库id
  452. }]
  453. if (this.objData.semiProductList.length > 0) { // 预制体报工
  454. this.objData.workReportInfo.formedNum = this.objData.semiProductList.length
  455. }
  456. this.objData.workReportInfo.formingNum = res.formingNum
  457. this.objData.workReportInfo.formingWeight = res.formingWeight
  458. this.objData.workReportInfo.unit = res.unit
  459. this.objData.workReportInfo.weightUnit = res.weightUnit
  460. this.objData.workReportInfo.workOrderId = res.workOrderId
  461. this.paramDetailList = []
  462. this.paramDetailList = res.paramDetailList.map(m => {
  463. if (m.extInfo.textType == 5) {
  464. this.remainingTime = m.extInfo.remainingTime
  465. }
  466. return {
  467. ...m.extInfo
  468. }
  469. })
  470. }).finally(() => {
  471. this.isLoad = true
  472. if (this.taskType == 1) {
  473. this.getCacheFn()
  474. }
  475. })
  476. },
  477. scrolltolower() { },
  478. handAdd() {
  479. const storageKey = Date.now() + "";
  480. uni.setStorageSync(storageKey, this.objData || {});
  481. uni.navigateTo({
  482. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job&taskId=${this.taskId}`
  483. })
  484. },
  485. penalize(index) {
  486. if (index || index == 0) {
  487. console.log(index, '----');
  488. this.penalizeIndex = index
  489. this.formData.warehouseId = this.objData.productRecycleList[this.penalizeIndex].warehouseId || ''
  490. } else {
  491. this.penalizeIndex = null
  492. this.formData.warehouseId = this.objData.notFormedList[0].warehouseId || ''
  493. console.log(this.formData.warehouseId, '+++++');
  494. }
  495. this.$forceUpdate()
  496. if (this.warehouseList.length == 0) {
  497. getWarehouseList().then(res => {
  498. this.warehouseList = res
  499. this.searchShow = true
  500. })
  501. } else {
  502. this.searchShow = true
  503. }
  504. },
  505. inputChange(e) {
  506. console.log(e)
  507. },
  508. searchCancel() {
  509. this.searchShow = false
  510. },
  511. popupOk() {
  512. if (this.penalizeIndex == null) {
  513. this.$set(this.objData.notFormedList[0], 'warehouseId', this.formData.warehouseId || null)
  514. } else {
  515. this.objData.productRecycleList[this.penalizeIndex].warehouseId = this.formData.warehouseId
  516. }
  517. this.$forceUpdate()
  518. this.searchShow = false
  519. },
  520. modeNum(num) {
  521. console.log(num, '------------', this.objData.modelList.length);
  522. if (this.objData.modelList.length == 0) {
  523. return false
  524. }
  525. console.log(num);
  526. this.$refs.modelRef.setNum(num)
  527. },
  528. async save(type) {
  529. console.log(type, 'type');
  530. // 验证判断条件
  531. this.$isJobExls(1, this.objData);
  532. if (!(this.clientEnvironmentId == 3 || this.objData.singleReport !== 1)) {
  533. if (this.objData.semiProductList.length) {
  534. let arr = this.objData.semiProductList.filter(v => v.selected == true);
  535. this.objData.semiProductList = arr;
  536. if (!arr.length) {
  537. return uni.showToast({
  538. title: '请选择报工数量',
  539. icon: 'none'
  540. })
  541. }
  542. // else{
  543. // let engraveList = arr.filter(v=> v.extInfo.engrave ==null);
  544. // if(engraveList.length){
  545. // return uni.showToast({
  546. // title: '请输入刻码',
  547. // icon: 'none'
  548. // })
  549. // }
  550. // }
  551. }
  552. }
  553. uni.showLoading({
  554. title: '加载中'
  555. });
  556. if (!this.objData.workReportInfo['formedNum'] && this.objData.workReportInfo['formedNum'] != 0) {
  557. uni.showToast({
  558. title: '请输入合格品数量',
  559. icon: 'none'
  560. })
  561. return false
  562. }
  563. // 预制体
  564. if (this.clientEnvironmentId == 3 || this.objData.singleReport !== 1) {
  565. if (this.objData.semiProductList.length > 0 && this.taskType != 4 && this.objData.singleReport == 1 &&
  566. type == 2) {
  567. let bol
  568. let _i
  569. bol = this.objData.semiProductList.every((e, i) => {
  570. _i = i + 1
  571. if (this.taskType == 6) {
  572. return e.extInfo.hasOwnProperty('taskId') && e.extInfo.taskId
  573. } else {
  574. // if (e.extInfo.isQualified == 1 || e.extInfo.notType == 5) {
  575. // return e.extInfo.hasOwnProperty('taskId') && e.extInfo.taskId && e.extInfo
  576. // .reportWeight
  577. // } else {
  578. // return e.extInfo.hasOwnProperty('notType') && e.extInfo.notType
  579. // }
  580. return e.extInfo.hasOwnProperty('taskId') && e.extInfo.taskId && e.extInfo
  581. .reportWeight
  582. }
  583. })
  584. if (!bol) {
  585. uni.showToast({
  586. title: `请完善第${_i}处置方式`,
  587. icon: 'none'
  588. })
  589. return false
  590. }
  591. }
  592. }
  593. if (this.objData.productRecycleList.length > 0 && this.clientEnvironmentId != 2) {
  594. const isRecycle = await this.checkRecycle()
  595. if (!isRecycle) {
  596. return false
  597. }
  598. }
  599. if (this.taskType == 4 && this.clientEnvironmentId != 3 && this.clientEnvironmentId != 2 &&this.objData.singleReport !== 1) {
  600. const isPack = await this.checkPack()
  601. if (!isPack) {
  602. return false
  603. }
  604. }
  605. //
  606. // console.log(this.objData.currentTaskDiagram.isFirstTask,'22222');
  607. if (this.objData.currentTaskDiagram.isFirstTask == 0) { // isFirstTask 1是 判断是否首工序
  608. const isFirstTask = await this.checkFirstTask()
  609. if (!isFirstTask) {
  610. return false
  611. }
  612. }
  613. if (this.taskType == 1) {
  614. const isCache = await this.checkCache(type)
  615. if (!isCache) {
  616. return false
  617. }
  618. }
  619. if (this.clientEnvironmentId == 3 && type == 2 && this.taskType == 6 && this.objData.singleReport ==
  620. 0) {
  621. this.objData.semiProductList = []
  622. }
  623. if (this.clientEnvironmentId == 3 && this.taskType == 1) {
  624. if (this.objData && this.objData.executorTime && this.objData.executorTime != undefined) {
  625. // 正则表达式1:匹配 yyyy-MM-dd 格式
  626. const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
  627. if (dateRegex.test(this.objData.executorTime.trimRight())) {
  628. this.objData.workReportInfo['executorTime'] = this.objData.executorTime + ' 00:00:00'
  629. } else {
  630. this.objData.workReportInfo['executorTime'] = this.objData.executorTime
  631. }
  632. } else {
  633. uni.showToast({
  634. title: `请先选择实际报工时间`,
  635. icon: 'none'
  636. })
  637. return false
  638. }
  639. }
  640. if(this.objData.semiProductList.length>0){
  641. this.objData.semiProductList.map((ditem)=>{
  642. if(ditem.extInfo.batchReportInfo){
  643. ditem.extInfo.batchReportInfo.map((baItem)=>{
  644. let idvalue=baItem.deviceId?baItem.deviceId.split('/'):''
  645. baItem.deviceId=idvalue?idvalue[0]:''
  646. })
  647. }
  648. if(ditem.extInfo.notBatchReportInfo){
  649. ditem.extInfo.notBatchReportInfo.map((noItem)=>{
  650. let idvalue=noItem.deviceId?noItem.deviceId.split('/'):''
  651. noItem.deviceId=idvalue?idvalue[0]:''
  652. })
  653. }
  654. })
  655. }
  656. jobSave(this.objData).then(res => {
  657. uni.hideLoading();
  658. if (this.taskType == 4) {
  659. uni.showModal({
  660. title: '提示',
  661. content: '打包完成是否去入库!',
  662. confirmText: '确认', //这块是确定按钮的文字
  663. success: rr => {
  664. if (rr.confirm) {
  665. uni.redirectTo({
  666. url: `/pages/pda/warehousing/index?workOrderId=${this.id}&taskId=-1&workReportId=${res}&delta=-2`
  667. })
  668. } else {
  669. uni.navigateBack()
  670. }
  671. }
  672. })
  673. } else {
  674. uni.navigateBack()
  675. }
  676. }).finally(() => {
  677. setTimeout(function () {
  678. uni.hideLoading();
  679. }, 3000);
  680. })
  681. },
  682. checkRecycle() {
  683. uni.hideLoading();
  684. return new Promise((resolve) => {
  685. uni.showModal({
  686. title: '提示',
  687. content: '是否跳过副产品回收处置!',
  688. confirmText: '确认', //这块是确定按钮的文字
  689. success: function (res) {
  690. if (res.confirm) {
  691. resolve(true)
  692. } else {
  693. resolve(false)
  694. }
  695. }
  696. })
  697. })
  698. },
  699. checkPack() {
  700. uni.hideLoading();
  701. return new Promise((resolve) => {
  702. let packInfo = this.$refs.packRef.getData()
  703. this.objData.packInfo = packInfo
  704. this.objData.taskType = this.taskType
  705. if (packInfo.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(this
  706. .objData
  707. .notFormedList[0].notFormedNum)) {
  708. uni.hideLoading();
  709. uni.showModal({
  710. title: '提示',
  711. content: '合格品数量加不合格品数量不等于包装总数!',
  712. confirmText: '确认', //这块是确定按钮的文字
  713. success: function (res) {
  714. if (res.confirm) {
  715. resolve(true)
  716. } else {
  717. resolve(false)
  718. }
  719. }
  720. })
  721. } else {
  722. resolve(true)
  723. }
  724. })
  725. },
  726. checkFirstTask() {
  727. uni.hideLoading();
  728. return new Promise((resolve) => {
  729. if (this.objData.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(
  730. this.objData.notFormedList[0].notFormedNum)) {
  731. uni.showModal({
  732. title: '提示',
  733. content: '合格品数量加不合格品数量不等于上道工序数量!',
  734. confirmText: '确认', //这块是确定按钮的文字
  735. success: function (res) {
  736. if (res.confirm) {
  737. resolve(true)
  738. } else {
  739. resolve(false)
  740. }
  741. }
  742. })
  743. } else {
  744. resolve(true)
  745. }
  746. })
  747. },
  748. checkCache(type) {
  749. uni.hideLoading();
  750. return new Promise((resolve) => {
  751. if (type == 1) {
  752. saveCache(this.objData).then(rr => {
  753. uni.showToast({
  754. title: `已经缓存`,
  755. icon: 'none'
  756. })
  757. })
  758. resolve(false)
  759. } else if (type == 2) {
  760. resolve(true)
  761. }
  762. })
  763. },
  764. removeCacheFn() {
  765. uni.showModal({
  766. title: '缓存',
  767. content: '是否清空缓存!',
  768. confirmText: '确认', //这块是确定按钮的文字
  769. success: rr => {
  770. if (rr.confirm) {
  771. let parma = {
  772. workOrderIds: [this.id],
  773. taskId: this.taskId,
  774. type: 1
  775. }
  776. removeCache(parma).then(res => {
  777. this.getList()
  778. })
  779. }
  780. }
  781. })
  782. },
  783. getCacheFn() {
  784. let parma = {
  785. workOrderId: this.id,
  786. taskId: this.taskId,
  787. type: 1
  788. }
  789. getCache(parma).then(res => {
  790. if (!res || res.length < 0 || Object.getOwnPropertyNames(res).length === 0) {
  791. return false;
  792. }
  793. this.objData['product'] = res.extInfo.product
  794. this.objData['workReportInfo'] = res.extInfo.workReportInfo
  795. this.objData['notFormedList'] = res.extInfo.notFormedList
  796. this.objData['turnover'] = res.extInfo.turnover
  797. this.objData['productRecycleList'] = res.extInfo.productRecycleList
  798. this.objData['semiProductList'] = res.extInfo.semiProductList
  799. this.objData['modelList'] = res.extInfo.modelList
  800. })
  801. },
  802. },
  803. beforeDestroy() {
  804. uni.hideLoading();
  805. },
  806. }
  807. </script>
  808. <style lang="scss" scoped>
  809. .content-box {
  810. height: 100vh;
  811. overflow: hidden;
  812. display: flex;
  813. flex-direction: column;
  814. }
  815. .list_box {
  816. flex: 1;
  817. overflow: hidden;
  818. padding: 4rpx 0;
  819. .u-list {
  820. height: 100% !important;
  821. }
  822. .card_box {
  823. padding: 16rpx 20rpx;
  824. }
  825. }
  826. .bottom-wrapper {
  827. width: 100%;
  828. display: flex;
  829. align-items: center;
  830. justify-content: space-around;
  831. .btn_box {
  832. width: 50%;
  833. height: 88rpx;
  834. line-height: 88rpx;
  835. background: $theme-color;
  836. text-align: center;
  837. font-size: 36rpx;
  838. font-style: normal;
  839. font-weight: 400;
  840. color: #fff;
  841. &:first-child {
  842. border-right: 2rpx solid #fff;
  843. }
  844. }
  845. }
  846. .operate_box {
  847. padding: 10rpx 160rpx;
  848. /deep/ .u-button {
  849. width: 160rpx;
  850. }
  851. }
  852. .search_list {
  853. min-height: 500rpx;
  854. padding: 0 32rpx;
  855. }
  856. .search_list2 {
  857. min-height: 120rpx;
  858. padding: 0 32rpx;
  859. }
  860. .flex_btn {
  861. position: fixed;
  862. right: 0;
  863. bottom: 160rpx;
  864. width: 40rpx;
  865. height: 50rpx;
  866. line-height: 66rpx;
  867. border-radius: 22rpx 0 0 22rpx;
  868. background: $theme-color;
  869. text-align: center;
  870. font-size: 22rpx;
  871. font-style: normal;
  872. font-weight: 400;
  873. color: #fff;
  874. opacity: 0.6;
  875. .jiantou {
  876. width: 30rpx;
  877. height: 30rpx;
  878. }
  879. }
  880. .flex_btn2 {
  881. position: fixed;
  882. right: 0;
  883. bottom: 160rpx;
  884. width: 126rpx;
  885. min-height: 140rpx;
  886. line-height: 62rpx;
  887. border-radius: 22rpx 0 0 22rpx;
  888. background: $theme-color;
  889. text-align: center;
  890. font-size: 22rpx;
  891. font-style: normal;
  892. font-weight: 400;
  893. color: #fff;
  894. opacity: 0.7;
  895. .close_box {
  896. height: 50rpx;
  897. line-height: 50rpx;
  898. width: 126rpx;
  899. text-align: left;
  900. .close {
  901. width: 40rpx;
  902. height: 40rpx;
  903. padding: 6rpx 10rpx;
  904. }
  905. }
  906. }
  907. </style>