form.vue 28 KB

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