index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  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' @weightEmit='weightEmit'></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>