form.vue 34 KB

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