form.vue 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="lot-info uni-column">
  4. <view class="lot-code uni-row">
  5. <text>批次号</text>
  6. <text style="margin-left: 24rpx;">{{ dayworkItem.lotCode }}</text>
  7. </view>
  8. <view class="product-info">
  9. 产品描述: {{ dayworkItem.productDescription }}
  10. </view>
  11. <view class="product-info">
  12. 原材料厂家: {{ dayworkInfo.furnaceNoInfo.factory }}
  13. </view>
  14. <view class="product-info">
  15. 投产数量: {{ dayworkItem.prodNum }}
  16. </view>
  17. </view>
  18. <!-- 不合格信息 -->
  19. <view class="title unfit-title uni-row">
  20. <text>不合格信息</text>
  21. <view v-if="Number(dayworkItem.status) < 3" class="add-btn" @click="handleAddUnfit">添加</view>
  22. </view>
  23. <view class="unfit-container">
  24. <view class="unfit-item-container uni-column" v-for="(item, index) in unfitInfos" :key="index">
  25. <view class="title uni-row">
  26. <text>检查标准-{{ item.checkStandard }}</text>
  27. <uni-icons v-if="Number(dayworkItem.status) < 3" type="trash" size="24" color="#fc6565"
  28. @click="handleDelUnfit(index)" />
  29. </view>
  30. <!-- <view class="standard">检查标准:{{ item.checkStandard }}</view> -->
  31. <view class="result uni-row" style="display: flex;flex-direction: row;justify-content: space-between;">
  32. <!-- align-items: flex-start; -->
  33. <view class="label" style="padding-right: 16rpx;flex: 0 1 auto; min-width: 118rpx;">
  34. 检查结果</view>
  35. <input v-if="Number(dayworkItem.status) < 3" v-model="item.reason" placeholder="请输入检查结果" />
  36. <span v-else style="flex-grow: 1;">{{ item.reason }}</span>
  37. <view class="label"
  38. style="text-align: right; padding-right: 16rpx;flex: 0 1 auto; min-width: 68rpx;">数量</view>
  39. <input v-if="Number(dayworkItem.status) < 3" class="number" type="number" v-model="item.rejectNum"
  40. @blur="rejectNumberChange" />
  41. <span v-else>{{ item.rejectNum }}</span>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 咨询部分 -->
  46. <view class="title">咨询</view>
  47. <view class="consultation-container uni-column">
  48. <view class="consultation-item-container" v-for="(item, index) in consultations" :key="index">
  49. <view class="question uni-column">
  50. <view class="label uni-row">
  51. <text>问题描述</text>
  52. <text :style="{ color: showStatusColor(item.status) }">{{item.consultDepartment == 0?'技术':'品管'}} {{ showStatus(item.status) }}</text>
  53. </view>
  54. <view class="content">{{ item.content }}</view>
  55. </view>
  56. <!-- <view v-if="item.answer !== ''" class="answer"
  57. style="margin-top: 24rpx; padding-top: 24rpx; border-top: 1px dotted #aaaaaa;">
  58. <view class="label">回复</view>
  59. <view class="content">{{ item.answer }}</view>
  60. </view> -->
  61. </view>
  62. </view>
  63. <!-- 零存库部分 -->
  64. <view class="title">零存库</view>
  65. <view class="consultation-container ">
  66. <view class="title unfit-title uni-row">
  67. <view class="title">零取</view>
  68. <view class="add-btn" v-if="Number(dayworkItem.status) < 3" style="background-color: #409eff;" @click="handleAddLot">添加</view>
  69. </view>
  70. <view >
  71. <zb-table v-if="Number(dayworkItem.status) < 3"
  72. :columns="column1"
  73. :stripe="true"
  74. :fit="true"
  75. @dele="dele"
  76. :data="retrievalInfo"></zb-table>
  77. <zb-table v-else
  78. :columns="column2"
  79. :stripe="true"
  80. :fit="true"
  81. @dele="dele"
  82. :data="retrievalInfo"></zb-table>
  83. <!-- <uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据" >
  84. <uni-tr >
  85. <uni-th style="font-size: 25rpx;" width="atuo" align="center">批次号</uni-th>
  86. <uni-th style="font-size: 25rpx;" width="120" align="center">数量</uni-th>
  87. <uni-th v-if="Number(dayworkItem.status) < 3" style="font-size: 25rpx;" width="80" align="center">操作</uni-th>
  88. </uni-tr>
  89. <uni-tr v-for="(item, index) in retrievalInfo" :key="index">
  90. <uni-th style="font-size: 24rpx;" width="auto" align="center">{{ item.lotCode }}</uni-th>
  91. <uni-th style="font-size: 25rpx;" width="120" align="center">
  92. {{ item.storageNum }}
  93. </uni-th>
  94. <uni-th v-if="Number(dayworkItem.status) < 3 && item.status == 0" align="center" width="80">
  95. <uni-icons type="closeempty" size="22" @click="handleDelete(item)"></uni-icons>
  96. </uni-th>
  97. </uni-tr>
  98. </uni-table> -->
  99. </view>
  100. <view v-if="saveFlag" class='middle'>
  101. <view class='segment'></view>
  102. <view class='segment'></view>
  103. </view>
  104. <view v-if="saveFlag" class="title unfit-title uni-row">
  105. <view class="title">零存</view>
  106. </view>
  107. <view v-if="saveFlag" class="save uni-row">
  108. <text class="label">存入数量</text>
  109. <input class="number" type="number" v-if="!(storageInfo.status == 1 || Number(dayworkItem.status) >= 3 || storageInfo.id)" placeholder="请输入" v-model="storageNum" />
  110. <span style="margin-left: 56rpx;flex: 1;" v-else>{{ storageNum }}</span>
  111. </view>
  112. </view>
  113. <!-- 报工部分 -->
  114. <view class="daywork-container">
  115. <view class="result uni-row">
  116. <view class="label">合格量</view>
  117. <input v-if="Number(dayworkItem.status) < 3" type="number" placeholder="请输入合格量"
  118. v-model="dayworkItem.qualifiedNum" />
  119. <span v-else>{{ dayworkItem.qualifiedNum }}</span>
  120. <view class="label" style="text-align: right; padding-right: 24rpx">废品量</view>
  121. <input v-if="Number(dayworkItem.status) < 3" :disabled="true" type="number" placeholder="请输入废品量"
  122. v-model="dayworkItem.rejectNum" />
  123. <span v-else>{{ dayworkItem.rejectNum }}</span>
  124. </view>
  125. <view class="remark uni-row">
  126. <view class="label">备注</view>
  127. <textarea v-if="Number(dayworkItem.status) < 3" v-model="dayworkItem.remark" />
  128. <span v-else>{{ dayworkItem.remark }}</span>
  129. </view>
  130. <view class="btns-container uni-row">
  131. <!-- 最后一步完成不能更换载具 -->
  132. <view v-if="dayworkItem.daywork != null && dayworkItem.daywork.status != 2" class="bottom-btn left-btn "
  133. @click="handleChangeCarrier">
  134. 更换载具</view>
  135. <view v-if="checkFinishable()&&Number(dayworkItem.status) < 3" class="finished-btn"
  136. @click.stop="handleFinishDaywork">结束报工</view>
  137. <view v-if="!checkFinishable()&&Number(dayworkItem.status) < 3" class="pause-btn"
  138. @click.stop="handleUpdateDaywork">暂停</view>
  139. <view v-if="Number(dayworkItem.status) < 3" class="question-btn uni-column"
  140. @click.stop="handleAddConsultation">
  141. <uni-icons type="headphones" size="24" />
  142. <text>咨询</text>
  143. </view>
  144. </view>
  145. </view>
  146. </view>
  147. </template>
  148. <script setup>
  149. import {
  150. ref
  151. } from 'vue'
  152. import {
  153. onMounted,
  154. getCurrentInstance
  155. } from 'vue';
  156. import {
  157. getSortingDayworkItem,
  158. saveConsult,
  159. finish,
  160. update,
  161. selectInstructionList
  162. } from '@/api/business/sortDaywork.js'
  163. import {
  164. getTakeStockPeriod
  165. } from '@/api/business/taksStackLot.js'
  166. import {
  167. onLoad,
  168. onReady,
  169. onUnload,
  170. onShow
  171. } from '@dcloudio/uni-app'
  172. import {
  173. store
  174. } from '@/store/index.js'
  175. import {
  176. timestampToTime,
  177. toHHmmss
  178. } from '@/utils/common.js'
  179. const isEventTriggered = ref(false); // 创建一个标志位
  180. const unfitInfos = ref([])
  181. const consultations = ref([])
  182. const dayworkInfo = ref({})
  183. const retrievalInfo = ref([])
  184. // 创建一个引用来存储最后一次请求的时间戳
  185. const lastRequestTimestamp = ref(0);
  186. const dayworkItem = ref({})
  187. const saveFlag = ref(false)
  188. const storageNum = ref(null)
  189. const storageInfo = ref(null)
  190. const column1 = [
  191. { name: 'lotCode', label: '批次号',align:'center'},
  192. { name: 'storageNum', label: '数量',align:'center' },
  193. { name: 'operation', type:'operation',label: '操作',align:'center',renders:[
  194. {
  195. name:'删除',
  196. type:'warn',
  197. func:"dele",
  198. class:"buttonOp"
  199. },
  200. ]},
  201. ]
  202. const column2 = [
  203. { name: 'lotCode', label: '批次号',align:'center'},
  204. { name: 'storageNum', label: '数量',align:'center' },
  205. ]
  206. /***************************** 页面生命周期函数 *****************************/
  207. onLoad(()=>{
  208. })
  209. onShow(() => {
  210. uni.$off('addInfoEvent');
  211. uni.$off('addUnfitInfoEvent')
  212. })
  213. onMounted(() => {
  214. const instance = getCurrentInstance().proxy
  215. const eventChannel = instance.getOpenerEventChannel();
  216. eventChannel.on('acceptDataFromOpenerPage', function(data) {
  217. if (data && data.data) {
  218. dayworkInfo.value = data.data
  219. init({
  220. id: data.data.id
  221. })
  222. } else {
  223. let reqParam = {
  224. id: dayworkInfo.value.id
  225. }
  226. init(reqParam);
  227. }
  228. })
  229. })
  230. /***************************** 定义了一些方法 *****************************/
  231. const init = (data) => {
  232. console.log("dayworkInfo", dayworkInfo.value);
  233. // 获取当前报工信息
  234. getSortingDayworkItem(data).then(res => {
  235. console.log(res)
  236. if (res.code === 200) {
  237. dayworkItem.value = res.data
  238. //判断是否显示零存
  239. if(dayworkItem.value.processStepNumber == dayworkInfo.value.processSequence[dayworkInfo.value.processSequence.length - 1].processStepNumber) {
  240. saveFlag.value = true
  241. }else{
  242. saveFlag.value = false
  243. }
  244. console.log(dayworkItem.value)
  245. if (dayworkItem.value.qualifiedNum === 0 && dayworkItem.value.rejectNum === 0) {
  246. dayworkItem.value.qualifiedNum = res.data.prodNum
  247. }
  248. retrievalInfo.value = res.data.retrievalInfo
  249. storageInfo.value = res.data.storageInfo
  250. console.log(Object.keys(storageInfo.value).length === 0)
  251. if(Object.keys(storageInfo.value).length !== 0) {
  252. storageNum.value = storageInfo.value.storageNum
  253. }
  254. consultations.value = res.data.consults
  255. unfitInfos.value = res.data.rejectList
  256. } else {
  257. uni.showToast({
  258. icon: 'none',
  259. title: res.message
  260. })
  261. }
  262. })
  263. }
  264. const addInfo = (data) => {
  265. data.forEach(item=>{
  266. console.log(retrievalInfo.value)
  267. retrievalInfo.value.push(item)
  268. })
  269. console.log(data)
  270. uni.$off('addInfoEvent');
  271. }
  272. //添加零取批次
  273. function handleAddLot() {
  274. console.log('調用 handleAddLot')
  275. uni.$on('addInfoEvent', (data) => {
  276. addInfo(data.data)
  277. })
  278. console.log(dayworkItem.value)
  279. const info = {
  280. deptId:dayworkItem.value.deptId,
  281. productId:dayworkItem.value.daywork.productId,
  282. drawingNumber:dayworkItem.value.drawingNumber,
  283. technologyVersion:dayworkItem.value.technologyVersion,
  284. retrievalLotId:dayworkItem.value.lotId,
  285. hasAddedList : retrievalInfo.value
  286. }
  287. // 将 info 对象转换为 JSON 字符串
  288. const serializedData = JSON.stringify(info);
  289. // 对 JSON 字符串进行 URL 编码
  290. const encodedData = encodeURIComponent(serializedData);
  291. // 构建 URL,确保使用正确编码的数据
  292. uni.navigateTo({
  293. url: `/pages/sorting/storageRetrieval?data=${encodedData}`
  294. });
  295. }
  296. const addUnfitInfo = (data) => {
  297. console.log(data)
  298. if (data&& data.length >0) {
  299. for (var i = 0; i < data.length; i++) {
  300. const info = {
  301. inspectionInstructionId: data[i].id,
  302. title: data[i].title,
  303. standard: data[i].standard,
  304. checkStandard: data[i].standard,
  305. type: data[i].type,
  306. reason: ''
  307. }
  308. unfitInfos.value.push(info)
  309. }
  310. }
  311. }
  312. function dele(ite,index) {
  313. if(ite.status == 1){
  314. uni.showToast({
  315. icon: 'none',
  316. title: '已被领取,不能删除'
  317. })
  318. }else{
  319. retrievalInfo.value.splice(index, 1);
  320. }
  321. }
  322. const addConsultation = (data) => {
  323. const info = {
  324. dayworkItemId: dayworkItem.value.id,
  325. content: data.content,
  326. userId: store.userInfo.userId,
  327. nickName: store.userInfo.nickName,
  328. dayworkId: dayworkItem.value.dayworkId,
  329. productionPlandetailId: dayworkItem.value.productionPlandetailId,
  330. productionPlanDetailSubDetailId: dayworkItem.value.productionPlanDetailSubDetailId,
  331. lotId: dayworkItem.value.lotId,
  332. lotCode: dayworkItem.value.lotCode,
  333. productId: dayworkItem.value.productId,
  334. productDescription: dayworkItem.value.productDescription,
  335. technologicalProcessId: dayworkItem.value.technologicalProcessId,
  336. technologicalProcessDetailId: dayworkItem.value.technologicalProcessDetailId,
  337. processId: dayworkItem.value.processId,
  338. processAlias: dayworkItem.value.process.processAlias,
  339. technicianId: dayworkItem.value.technicianId,
  340. departments : data.departments,
  341. pictures : data.pictures
  342. }
  343. saveConsult(info).then(res => {
  344. if (res.code === 200) {
  345. consultations.value = res.data
  346. console.log(consultations.value)
  347. } else {
  348. uni.showToast({
  349. icon: 'none',
  350. title: res.message
  351. })
  352. }
  353. })
  354. isEventTriggered.value = true; // 更新标志位状态
  355. consultations.value.push(info)
  356. }
  357. /***************************** 定义了一些事件 *****************************/
  358. // 添加不合格信息
  359. const handleAddUnfit = () => {
  360. // 监听事件
  361. uni.$once('addUnfitInfoEvent', (data) => {
  362. addUnfitInfo(data)
  363. })
  364. console.log(getHasInstruction())
  365. if(!getHasInstruction()){
  366. uni.navigateTo({
  367. url: "/pages/sorting/specialOptions",
  368. success: (res) => {
  369. // 通过eventChannel向被打开页面传送数据
  370. res.eventChannel.emit('acceptDataFromOpenerPage', {
  371. data: dayworkItem.value,
  372. query: {
  373. productId: dayworkItem.value.daywork.productId,
  374. processId: dayworkItem.value.process.id,
  375. // technologyVersion: dayworkItem.value.technologicalProcessDetail.technologyVersion
  376. technologyVersion: dayworkItem.value.technologyVersion
  377. },
  378. index: unfitInfos.value.length
  379. })
  380. }
  381. })
  382. }else{
  383. console.log(dayworkItem.value)
  384. uni.navigateTo({
  385. url: "/pages/sorting/options",
  386. success: (res) => {
  387. // 通过eventChannel向被打开页面传送数据
  388. res.eventChannel.emit('acceptDataFromOpenerPage', {
  389. data: dayworkItem.value,
  390. query: {
  391. productId: dayworkItem.value.daywork.productId,
  392. processCode: dayworkItem.value.process.processCode,
  393. // technologyVersion: dayworkItem.value.technologicalProcessDetail.technologyVersion
  394. technologyVersion: dayworkItem.value.technologyVersion
  395. },
  396. index: unfitInfos.value.length
  397. })
  398. }
  399. })
  400. }
  401. }
  402. function getHasInstruction(){
  403. const res = selectInstructionList({
  404. technologicalProcessId: dayworkItem.value.technologicalProcessId,
  405. processCode: dayworkItem.value.processCode,
  406. lotId: dayworkItem.value.lotId
  407. }).then(res=> {
  408. return res.data
  409. })
  410. return res
  411. }
  412. // 删除不合格信息
  413. const handleDelUnfit = (index) => {
  414. let tempInfo = unfitInfos.value[index]
  415. console.log(tempInfo)
  416. uni.showModal({
  417. title: '提示',
  418. content: '确定删除该项?',
  419. success: function(res) {
  420. if (res.confirm) {
  421. dayworkItem.value.rejectNum = dayworkItem.value.rejectNum - tempInfo.rejectNum
  422. dayworkItem.value.qualifiedNum = parseInt(dayworkItem.value.qualifiedNum) + parseInt(
  423. tempInfo.rejectNum)
  424. unfitInfos.value.splice(index, 1)
  425. } else if (res.cancel) {
  426. return
  427. }
  428. }
  429. })
  430. }
  431. /* 更换载具*/
  432. function handleChangeCarrier(item) {
  433. // uni.$once('refreshQuickReport', () => {
  434. // init()
  435. // })
  436. store.dayworkInfo = null
  437. uni.navigateTo({
  438. url: "/pages/changeBox/index",
  439. success: function(res) {
  440. // 通过eventChannel向被打开页面传送数据
  441. res.eventChannel.emit('sortingFromOpenerPage', {
  442. data: dayworkItem.value
  443. })
  444. }
  445. })
  446. }
  447. // 添加不合格信息
  448. const handleAddConsultation = () => {
  449. isEventTriggered.value = false; // 更新标志位状态
  450. // 监听事件
  451. uni.$once('addConsulttationEvent', (data) => {
  452. if (!isEventTriggered.value) {
  453. // 如果事件尚未触发,则执行事件触发逻辑
  454. addConsultation(data)
  455. }
  456. })
  457. uni.navigateTo({
  458. url: "/pages/sorting/consultation",
  459. success: (res) => {
  460. // 通过eventChannel向被打开页面传送数据
  461. res.eventChannel.emit('acceptDataFromOpenerPage', {
  462. data: dayworkItem.value
  463. })
  464. }
  465. })
  466. }
  467. const checkFinishable = () => {
  468. if (consultations.value.findIndex(v => v.status === 0) >= 0) {
  469. return false
  470. } else {
  471. return true
  472. }
  473. }
  474. const showStatus = (status) => {
  475. // console.log(status)
  476. switch (status) {
  477. case 0:
  478. return '未确认'
  479. case 1:
  480. return '不合格'
  481. case 2:
  482. return '合格'
  483. default:
  484. return ''
  485. }
  486. }
  487. const showStatusColor = (status) => {
  488. // console.log(status)
  489. switch (status) {
  490. case 0:
  491. return '#fcab53'
  492. case 1:
  493. return '#fc044f'
  494. case 2:
  495. return '#1deb19'
  496. default:
  497. return ''
  498. }
  499. }
  500. const rejectNumberChange = () => {
  501. let sumReject = 0
  502. unfitInfos.value.forEach(v => {
  503. sumReject += v.rejectNum == null ? 0 : Number(v.rejectNum)
  504. })
  505. dayworkItem.value.rejectNum = sumReject
  506. dayworkItem.value.qualifiedNum = dayworkItem.value.prodNum - sumReject
  507. console.log(dayworkItem.value)
  508. }
  509. const validHandle = () => {
  510. console.log(storageNum.value == "")
  511. if(storageNum.value != null &&storageNum.value != "" && storageNum.value<=0) {
  512. uni.showToast({
  513. icon: 'none',
  514. title: "存入数量应大于0",
  515. duration: 2000
  516. })
  517. return false;
  518. }
  519. for (let i = 0; i < unfitInfos.value.length; i++) {
  520. const e = unfitInfos.value[i]
  521. if (e.rejectNum == null || e.rejectNum == 0) {
  522. uni.showToast({
  523. icon: 'none',
  524. title: `第${i + 1}条不合格信息未输入不合格数量`
  525. })
  526. return false
  527. }
  528. }
  529. if (!dayworkItem.value.qualifiedNum) {
  530. uni.showToast({
  531. icon: 'none',
  532. title: "合格数不能为空",
  533. duration: 2000
  534. })
  535. return false;
  536. }
  537. if (dayworkItem.value.qualifiedNum < 0) {
  538. uni.showToast({
  539. icon: 'none',
  540. title: "合格数不能为负数,请检查不合格信息后提交",
  541. duration: 2000
  542. })
  543. return false;
  544. }
  545. return true
  546. // unfitInfos.value.forEach((e, i) => {
  547. // if (e.name)
  548. // })
  549. }
  550. async function handleCheckStock() {
  551. let currentProcessStepNumber = dayworkInfo.value.currentProcess.processStepNumber;
  552. let lastProcess = dayworkInfo.value.processSequence[dayworkInfo.value.processSequence.length - 1];
  553. // 判断当前工序是否是最后一道序
  554. if (currentProcessStepNumber === lastProcess.processStepNumber) {
  555. // 等待 getTakeStockPeriod() 的 Promise 完成
  556. const res = await getTakeStockPeriod({dayworkId: dayworkInfo.value.id});
  557. console.log(res.data.length);
  558. if (res.data.length > 0) {
  559. uni.showToast({
  560. icon: 'none',
  561. title: "此次盘点未结束,不能结束报工",
  562. duration: 2000
  563. });
  564. return false; // 如果盘点未结束,返回 false
  565. }
  566. }
  567. // 如果不是最后一道工序或盘点已结束,返回 true
  568. return true;
  569. }
  570. async function handleFinishDaywork() {
  571. if (!validHandle()) {
  572. return
  573. }
  574. //判断当前批次是否在盘点,如果盘点未结束,则不能结束报工
  575. let checkStockResult = await handleCheckStock();
  576. console.log(checkStockResult)
  577. if(!checkStockResult ) {
  578. return;
  579. }
  580. //零存数据
  581. if(storageNum.value != null&& storageNum.value != "" ) {
  582. if(Object.keys(storageInfo.value).length === 0){
  583. storageInfo.value = {
  584. productionPlanDetailId:dayworkItem.value.productionPlanDetailId,
  585. productDescription:dayworkItem.value.productDescription,
  586. drawingNumber:dayworkItem.value.drawingNumber,
  587. lotId:dayworkItem.value.lotId,
  588. lotCode:dayworkItem.value.lotCode,
  589. deptId:dayworkItem.value.deptId,
  590. productId:dayworkItem.value.daywork.productId,
  591. technologyVersion:dayworkItem.value.technologyVersion,
  592. storageNum:storageNum.value,
  593. storagerId:store.userInfo.userId,
  594. }
  595. }
  596. else{
  597. storageInfo.value.storageNum = storageNum.value
  598. }
  599. }else{
  600. storageInfo.value = null
  601. }
  602. //零取数据
  603. if(retrievalInfo.value.length >0) {
  604. retrievalInfo.value.forEach(item =>{
  605. item.retrievalLotId = dayworkItem.value.lotId,
  606. item.retrievalLotCode = dayworkItem.value.lotCode,
  607. item.retrievalerId = store.userInfo.userId,
  608. item.retrievalTime = timestampToTime(new Date())
  609. })
  610. }
  611. const saveData = {
  612. rejectList: unfitInfos.value,
  613. consult: consultations.value,
  614. id: dayworkItem.value.id,
  615. prodNum: dayworkItem.value.prodNum,
  616. rejectNum: dayworkItem.value.rejectNum,
  617. qualifiedNum: dayworkItem.value.qualifiedNum,
  618. remark: dayworkItem.value.remark,
  619. storageInfo:storageInfo.value,
  620. retrievalInfo:retrievalInfo.value
  621. }
  622. const currentTime = Date.now();
  623. // 检查是否已经过去了 2 秒
  624. if (currentTime - lastRequestTimestamp.value < 2000) {
  625. // 如果在 2 秒 内已经点击,那么不执行
  626. uni.showToast({
  627. icon: 'none',
  628. title: `请勿重复点击`,
  629. duration: 2000
  630. })
  631. return;
  632. }
  633. console.log(saveData)
  634. finish(saveData).then(res => {
  635. if (res.code === 200) {
  636. uni.navigateBack()
  637. } else {
  638. uni.showToast({
  639. icon: 'none',
  640. title: res.message
  641. })
  642. }
  643. })
  644. }
  645. const handleUpdateDaywork = () => {
  646. if (!validHandle()) {
  647. return
  648. }
  649. //零存数据
  650. if(storageNum.value != null&& storageNum.value != "" ) {
  651. if(Object.keys(storageInfo.value).length === 0){
  652. storageInfo.value = {
  653. productionPlanDetailId:dayworkItem.value.productionPlanDetailId,
  654. productDescription:dayworkItem.value.productDescription,
  655. drawingNumber:dayworkItem.value.drawingNumber,
  656. lotId:dayworkItem.value.lotId,
  657. lotCode:dayworkItem.value.lotCode,
  658. deptId:dayworkItem.value.deptId,
  659. productId:dayworkItem.value.daywork.productId,
  660. technologyVersion:dayworkItem.value.technologyVersion,
  661. storageNum:storageNum.value,
  662. storagerId:store.userInfo.userId,
  663. }
  664. }
  665. else{
  666. storageInfo.value.storageNum = storageNum.value
  667. }
  668. }else{
  669. storageInfo.value = null
  670. }
  671. //零取数据
  672. if(retrievalInfo.value.length >0) {
  673. retrievalInfo.value.forEach(item =>{
  674. item.retrievalLotId = dayworkItem.value.lotId,
  675. item.retrievalLotCode = dayworkItem.value.lotCode,
  676. item.retrievalerId = store.userInfo.userId,
  677. item.retrievalTime = timestampToTime(new Date())
  678. })
  679. }
  680. const saveData = {
  681. rejectList: unfitInfos.value,
  682. consult: consultations.value,
  683. id: dayworkItem.value.id,
  684. prodNum: dayworkItem.value.prodNum,
  685. rejectNum: dayworkItem.value.rejectNum,
  686. qualifiedNum: dayworkItem.value.qualifiedNum,
  687. remark: dayworkItem.value.remark,
  688. storageInfo:storageInfo.value,
  689. retrievalInfo:retrievalInfo.value
  690. }
  691. console.log(saveData)
  692. update(saveData).then(res => {
  693. if (res.code === 200) {
  694. uni.$emit("formBack")
  695. uni.navigateBack()
  696. } else {
  697. uni.showToast({
  698. icon: 'none',
  699. title: res.message
  700. })
  701. }
  702. })
  703. }
  704. </script>
  705. <style lang="scss">
  706. .buttonOp {
  707. margin-top: 5px;
  708. }
  709. .page-container {
  710. height: 100%;
  711. background-color: #ececec;
  712. font-size: 28rpx;
  713. >.title {
  714. font-weight: 700;
  715. margin: 24rpx 16rpx;
  716. }
  717. }
  718. .add-btn {
  719. padding: 12rpx 32rpx;
  720. background-color: #a4adb3;
  721. color: #ffffff;
  722. border-radius: 12rpx;
  723. font-size: 24rpx;
  724. }
  725. .lot-info {
  726. margin: 32rpx 16rpx 0 16rpx;
  727. padding: 24rpx;
  728. background-color: #ffffff;
  729. border-radius: 8rpx;
  730. .lot-code {
  731. font-size: 32rpx;
  732. font-weight: 700;
  733. margin-bottom: 16rpx;
  734. }
  735. .product-info {
  736. font-size: 28rpx;
  737. color: #9f9f9f;
  738. }
  739. }
  740. .middle {
  741. display: flex;
  742. flex-direction: row;
  743. align-items: center;
  744. justify-content: center
  745. }
  746. .segment {
  747. width: 80%;
  748. background-color: rgba(213, 213, 213, 1);
  749. border: 1rpx solid rgba(213, 213, 213, 1);
  750. margin: 16px 0;
  751. }
  752. .unfit-title {
  753. margin-bottom: 24rpx;
  754. justify-content: space-between;
  755. align-items: center;
  756. text {
  757. font-size: 28rpx;
  758. font-weight: 700;
  759. }
  760. .add-btn {
  761. padding: 12rpx 32rpx;
  762. background-color: #a4adb3;
  763. color: #ffffff;
  764. border-radius: 12rpx;
  765. font-size: 24rpx;
  766. }
  767. }
  768. .save {
  769. align-items: center;
  770. padding-bottom: 32rpx;
  771. justify-content: space-between;
  772. input {
  773. height: 56rpx;
  774. border: 1px solid #9f9f9f;
  775. font-size: 28rpx;
  776. &.number {
  777. width: 60%;
  778. text-align: center;
  779. }
  780. }
  781. }
  782. .unfit-container {
  783. padding: 24rpx;
  784. margin: 0 16rpx;
  785. background-color: #ffffff;
  786. border-radius: 12rpx;
  787. .unfit-item-container {
  788. position: relative;
  789. >* {
  790. margin-bottom: 24rpx;
  791. }
  792. .title {
  793. font-weight: 700;
  794. justify-content: space-between;
  795. align-items: center;
  796. image {
  797. width: 40rpx;
  798. height: 40rpx;
  799. }
  800. }
  801. .standard {}
  802. .result {
  803. align-items: center;
  804. border-bottom: 1px solid #9f9f9f;
  805. padding-bottom: 32rpx;
  806. .label {
  807. flex: 1;
  808. }
  809. input {
  810. width: 280rpx;
  811. height: 56rpx;
  812. border: 1px solid #9f9f9f;
  813. font-size: 28rpx;
  814. &.number {
  815. width: 104rpx;
  816. text-align: center;
  817. }
  818. }
  819. }
  820. }
  821. .unfit-item-container:last-child {
  822. .result {
  823. border-bottom: none;
  824. padding-bottom: 0;
  825. }
  826. }
  827. }
  828. .consultation-container {
  829. margin: 0 16rpx;
  830. padding: 24rpx;
  831. background-color: #ffffff;
  832. border-radius: 8rpx;
  833. .consultation-item-container {
  834. margin-bottom: 24rpx;
  835. border-bottom: 2px solid #888888;
  836. padding-bottom: 24rpx;
  837. }
  838. .consultation-item-container:last-child {
  839. margin-bottom: 0;
  840. border-bottom: 0;
  841. padding-bottom: 0;
  842. }
  843. .question,
  844. .answer {
  845. .label {
  846. justify-content: space-between;
  847. margin-bottom: 16rpx;
  848. font-weight: 700;
  849. }
  850. .content {
  851. line-height: 40rpx;
  852. }
  853. }
  854. .answer {
  855. margin-top: 24rpx;
  856. }
  857. }
  858. .daywork-container {
  859. margin-top: 24rpx;
  860. padding: 24rpx;
  861. background-color: #ffffff;
  862. border: 1px solid #bcbcbc;
  863. .result {
  864. align-items: center;
  865. .label {
  866. width: 112rpx;
  867. }
  868. input {
  869. flex: 1;
  870. height: 56rpx;
  871. border: 1px solid #9f9f9f;
  872. font-size: 28rpx;
  873. text-align: center;
  874. }
  875. }
  876. .remark {
  877. margin-top: 24rpx;
  878. .label {
  879. width: 112rpx;
  880. }
  881. textarea {
  882. flex: 1;
  883. border: 1px solid #9f9f9f;
  884. height: 168rpx;
  885. }
  886. }
  887. .btns-container {
  888. margin-top: 24rpx;
  889. .bottom-btn {
  890. display: flex;
  891. flex: 1;
  892. height: 80rpx;
  893. background-color: #5555ff;
  894. color: #ffffff;
  895. text-align: center;
  896. justify-content: center;
  897. align-items: center;
  898. border-radius: 8rpx;
  899. margin-right: 10rpx;
  900. &.left-btn {
  901. background-color: rgba(85, 85, 255, 1.0);
  902. }
  903. &.right-btn {
  904. margin-left: 24rpx;
  905. }
  906. }
  907. .finished-btn {
  908. display: flex;
  909. flex: 1;
  910. height: 80rpx;
  911. background-color: #fc6565;
  912. color: #ffffff;
  913. text-align: center;
  914. justify-content: center;
  915. align-items: center;
  916. border-radius: 8rpx;
  917. }
  918. .pause-btn {
  919. display: flex;
  920. flex: 1;
  921. height: 80rpx;
  922. background-color: #55d90d;
  923. color: #ffffff;
  924. text-align: center;
  925. justify-content: center;
  926. align-items: center;
  927. border-radius: 8rpx;
  928. }
  929. .question-btn {
  930. width: 80rpx;
  931. align-items: flex-end;
  932. image {
  933. width: 48rpx;
  934. height: 48rpx;
  935. }
  936. text {
  937. font-size: 24rpx;
  938. }
  939. }
  940. }
  941. }
  942. .zb-table .item-tr {
  943. flex-direction: row;
  944. }
  945. </style>