form.vue 28 KB

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