form.vue 28 KB

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