1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279 |
- <template>
- <view class="page-container uni-column">
- <view class="lot-info uni-column">
- <view class="lot-code uni-row">
- <text>批次号</text>
- <text style="margin-left: 24rpx;">{{ dayworkItem.lotCode }}</text>
- </view>
- <view class="product-info">
- 产品描述: {{ dayworkItem.productDescription }}
- </view>
- <view class="product-info">
- 原材料厂家: {{ dayworkInfo.furnaceNoInfo.factory }}
- </view>
- <view class="product-info">
- 投产数量: {{ dayworkItem.prodNum }}
- </view>
- <view class="product-info">
- 设备: {{ dayworkItem.equipmentDetailCode }}
- </view>
- </view>
- <!-- 不合格信息 -->
- <view class="title unfit-title uni-row">
- <text>不合格信息</text>
- <view v-if="Number(dayworkItem.status) < 3" class="add-btn" @click="handleAddUnfit">添加</view>
- </view>
- <view class="unfit-container">
- <view class="unfit-item-container uni-column" v-for="(item, index) in unfitInfos" :key="index">
- <view class="title uni-row">
- <text>检查标准-{{ item.checkStandard }}</text>
- <uni-icons v-if="Number(dayworkItem.status) < 3" type="trash" size="24" color="#fc6565"
- @click="handleDelUnfit(index)" />
- </view>
- <!-- <view class="standard">检查标准:{{ item.checkStandard }}</view> -->
- <view class="result uni-row" style="display: flex;flex-direction: row;justify-content: space-between;">
- <!-- align-items: flex-start; -->
- <view class="label" style="padding-right: 16rpx;flex: 0 1 auto; min-width: 118rpx;">
- 检查结果</view>
- <input v-if="Number(dayworkItem.status) < 3" v-model="item.reason" placeholder="请输入检查结果" />
- <span v-else style="flex-grow: 1;">{{ item.reason }}</span>
- <view class="label"
- style="text-align: right; padding-right: 16rpx;flex: 0 1 auto; min-width: 68rpx;">数量</view>
- <input v-if="Number(dayworkItem.status) < 3" class="number" type="number" v-model="item.rejectNum"
- @blur="rejectNumberChange" />
- <span v-else>{{ item.rejectNum }}</span>
- </view>
- </view>
- </view>
- <!-- 咨询部分 -->
- <view class="title">咨询</view>
- <view class="consultation-container uni-column">
- <view class="consultation-item-container" v-for="(item, index) in consultations" :key="index">
- <view class="question uni-column">
- <view class="label uni-row">
- <text>问题描述</text>
- <text :style="{ color: showStatusColor(item.status) }">{{item.consultDepartment == 0?'技术':'品管'}}
- {{ selectText(item) }}</text>
- </view>
- <view class="content">{{ item.content }}</view>
- </view>
- <!-- <view v-if="item.answer !== ''" class="answer"
- style="margin-top: 24rpx; padding-top: 24rpx; border-top: 1px dotted #aaaaaa;">
- <view class="label">回复</view>
- <view class="content">{{ item.answer }}</view>
- </view> -->
- </view>
- </view>
- <!-- 零存库部分 -->
- <view class="title">零存库</view>
- <view class="consultation-container ">
- <view class="title unfit-title uni-row">
- <view class="title">零取</view>
- <view class="add-btn" v-if="Number(dayworkItem.status) < 3" style="background-color: #409eff;"
- @click="handleAddLot">添加</view>
- </view>
- <view>
- <zb-table v-if="Number(dayworkItem.status) < 3" :columns="column1" :stripe="true" :fit="true"
- @dele="dele" :data="retrievalInfo"></zb-table>
- <zb-table v-else :columns="column2" :stripe="true" :fit="true" @dele="dele"
- :data="retrievalInfo"></zb-table>
- <!-- <uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据" >
- <uni-tr >
- <uni-th style="font-size: 25rpx;" width="atuo" align="center">批次号</uni-th>
- <uni-th style="font-size: 25rpx;" width="120" align="center">数量</uni-th>
- <uni-th v-if="Number(dayworkItem.status) < 3" style="font-size: 25rpx;" width="80" align="center">操作</uni-th>
- </uni-tr>
- <uni-tr v-for="(item, index) in retrievalInfo" :key="index">
- <uni-th style="font-size: 24rpx;" width="auto" align="center">{{ item.lotCode }}</uni-th>
- <uni-th style="font-size: 25rpx;" width="120" align="center">
- {{ item.storageNum }}
- </uni-th>
- <uni-th v-if="Number(dayworkItem.status) < 3 && item.status == 0" align="center" width="80">
- <uni-icons type="closeempty" size="22" @click="handleDelete(item)"></uni-icons>
- </uni-th>
- </uni-tr>
- </uni-table> -->
- </view>
- <view v-if="saveFlag" class='middle'>
- <view class='segment'></view>
- <view class='segment'></view>
- </view>
- <view v-if="saveFlag" class="title unfit-title uni-row">
- <view class="title">零存</view>
- </view>
- <view v-if="saveFlag" class="save uni-row">
- <text class="label">存入数量</text>
- <input class="number" type="number"
- v-if="!(storageInfo.status == 1 || Number(dayworkItem.status) >= 3 || storageInfo.id)"
- placeholder="请输入" v-model="storageNum" />
- <span style="margin-left: 56rpx;flex: 1;" v-else>{{ storageNum }}</span>
- </view>
- <view v-if="saveFlag" class="save uni-row">
- <view class="label">选别类型</view>
- <view v-if="!(storageInfo.status == 1 || Number(dayworkItem.status) >= 3 || storageInfo.id)"
- style="width: 60%;align-items: center;">
- <uni-data-select v-model="type" :localdata="selectTypeList" :clear="false"
- style="outline: 2rpx solid #999999;border-radius: 10rpx;"></uni-data-select>
- </view>
- <span v-else style="margin-left: 56rpx;flex: 1;">{{ selectType(type) }}</span>
- </view>
- </view>
- <!-- 报工部分 -->
- <view class="daywork-container">
- <view class="result uni-row">
- <view class="label">合格量</view>
- <input v-if="Number(dayworkItem.status) < 3" type="number" placeholder="请输入合格量"
- v-model="dayworkItem.qualifiedNum" />
- <span v-else>{{ dayworkItem.qualifiedNum }}</span>
- <view class="label" style="text-align: right; padding-right: 24rpx">废品量</view>
- <input v-if="Number(dayworkItem.status) < 3" :disabled="true" type="number" placeholder="请输入废品量"
- v-model="dayworkItem.rejectNum" />
- <span v-else>{{ dayworkItem.rejectNum }}</span>
- </view>
- <view class="remark uni-row">
- <view class="label">备注</view>
- <textarea v-if="Number(dayworkItem.status) < 3" v-model="dayworkItem.remark" maxlength="999" />
- <span v-else>{{ dayworkItem.remark }}</span>
- </view>
- <view class="btns-container uni-row">
- <!-- 最后一步完成不能更换载具 -->
- <view v-if="dayworkItem.daywork != null && dayworkItem.daywork.status != 2" class="bottom-btn left-btn "
- @click="handleChangeCarrier">
- 更换载具</view>
- <view v-if="checkFinishable()&&Number(dayworkItem.status) < 3" class="finished-btn"
- @click.stop="handleFinishDaywork">结束报工</view>
- <view v-if="Number(dayworkItem.status) < 3" class="pause-btn" @click.stop="handleUpdateDaywork">暂停
- </view>
- <view v-if="Number(dayworkItem.status) < 3" class="question-btn uni-column"
- @click.stop="handleAddConsultation">
- <uni-icons type="headphones" size="24" />
- <text>咨询</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import {
- ref
- } from 'vue'
- import {
- onMounted,
- getCurrentInstance
- } from 'vue';
- import {
- getSortingDayworkItem,
- saveConsult,
- finish,
- update,
- selectInstructionList
- } from '@/api/business/sortDaywork.js'
- import {
- getTakeStockPeriod
- } from '@/api/business/taksStackLot.js'
- import {
- getDictInfoByType,
- getDictInfoByTypes
- } from '@/api/dict/dict.js'
- import {
- onLoad,
- onReady,
- onUnload,
- onShow
- } from '@dcloudio/uni-app'
- import {
- store
- } from '@/store/index.js'
- import {
- timestampToTime,
- toHHmmss
- } from '@/utils/common.js'
- const isEventTriggered = ref(false); // 创建一个标志位
- const unfitInfos = ref([])
- const consultations = ref([])
- const selectTypeList = ref([])
- const dayworkInfo = ref({})
- const retrievalInfo = ref([])
- // 创建一个引用来存储最后一次请求的时间戳
- const lastRequestTimestamp = ref(0);
- const dayworkItem = ref({})
- const saveFlag = ref(false)
- const storageNum = ref(null)
- const type = ref(null)
- const storageInfo = ref(null)
- const qualifiedNumUpRatio = ref(0)
- const qualifiedNumDownRatio = ref(0)
- const isFinish = ref(false)
- const column1 = [{
- name: 'lotCode',
- label: '批次号',
- align: 'center'
- },
- {
- name: 'storageNum',
- label: '数量',
- align: 'center'
- },
- {
- name: 'typeLabel',
- label: '选别类型',
- align: 'center'
- },
- {
- name: 'operation',
- type: 'operation',
- label: '操作',
- align: 'center',
- renders: [{
- name: '删除',
- type: 'warn',
- func: "dele",
- class: "buttonOp"
- }, ]
- },
- ]
- const column2 = [{
- name: 'lotCode',
- label: '批次号',
- align: 'center'
- },
- {
- name: 'storageNum',
- label: '数量',
- align: 'center'
- },
- {
- name: 'typeLabel',
- label: '选别类型',
- align: 'center'
- },
- ]
- /***************************** 页面生命周期函数 *****************************/
- onLoad(() => {})
- onShow(() => {
- uni.$off('addInfoEvent');
- uni.$off('addUnfitInfoEvent')
- })
- onMounted(() => {
- const instance = getCurrentInstance().proxy
- const eventChannel = instance.getOpenerEventChannel();
- eventChannel.on('acceptDataFromOpenerPage', function(data) {
- if (data && data.data) {
- dayworkInfo.value = data.data
- init({
- id: data.data.id
- })
- } else {
- let reqParam = {
- id: dayworkInfo.value.id
- }
- init(reqParam);
- }
- })
- })
- /***************************** 定义了一些方法 *****************************/
- const init = (data) => {
- let dics = ['sort_report_up_limit', 'sort_report_down_limit', 'select_type']
- //获取当前跟选报工合格数最大值
- getDictInfoByTypes(dics).then(res => {
- console.log(res.data);
- if (res.data) {
- // 遍历返回的 Map 对象
- Object.entries(res.data).forEach(([key, list]) => {
- if (list && list.length > 0) {
- // 根据 key 的名称,将 value 存储到对应的数组中
- list.forEach(item => {
- switch (key) {
- case 'sort_report_up_limit':
- qualifiedNumUpRatio.value = item.dictValue;
- break;
- case 'sort_report_down_limit':
- qualifiedNumDownRatio.value = item.dictValue;
- break;
- case 'select_type':
- selectTypeList.value.push({
- value: item.dictValue,
- text: item.dictLabel
- })
- break;
- }
- });
- }
- });
- console.log('sortReportUpLimitValues:', qualifiedNumUpRatio.value);
- console.log('sortReportDownLimitValues:', qualifiedNumDownRatio.value);
- console.log('selectTypeValues:', selectTypeList.value);
- }
- }).catch(err => {
- console.log(err);
- console.log('369 err');
- });
- console.log("dayworkInfo", dayworkInfo.value);
- // 获取当前报工信息
- getSortingDayworkItem(data).then(res => {
- console.log(res)
- if (res.code === 200) {
- dayworkItem.value = res.data
- //判断是否显示零存
- if (dayworkItem.value.processStepNumber == dayworkInfo.value.processSequence[dayworkInfo.value
- .processSequence.length - 1].processStepNumber) {
- saveFlag.value = true
- } else {
- saveFlag.value = false
- }
- console.log(dayworkItem.value)
- if (dayworkItem.value.status == 0 && dayworkItem.value.qualifiedNum === 0 && dayworkItem.value
- .rejectNum === 0) {
- dayworkItem.value.qualifiedNum = res.data.prodNum
- }
- if (res.data.retrievalInfo != null) {
- res.data.retrievalInfo = res.data.retrievalInfo.map(item => {
- const typeLabelItem = selectTypeList.value.find(v => v.value == item.type);
- return {
- ...item,
- typeLabel: typeLabelItem.text
- };
- })
- }
- retrievalInfo.value = res.data.retrievalInfo
- storageInfo.value = res.data.storageInfo
- console.log(Object.keys(storageInfo.value).length === 0)
- if (Object.keys(storageInfo.value).length !== 0) {
- storageNum.value = storageInfo.value.storageNum
- type.value = storageInfo.value.type
- }
- consultations.value = res.data.consults
- unfitInfos.value = res.data.rejectList
- } else {
- uni.showToast({
- icon: 'none',
- title: res.message
- })
- }
- })
- }
- const addInfo = (data) => {
- data.forEach(item => {
- console.log(retrievalInfo.value)
- retrievalInfo.value.push(item)
- })
- console.log(data)
- uni.$off('addInfoEvent');
- }
- //添加零取批次
- function handleAddLot() {
- console.log('調用 handleAddLot')
- uni.$on('addInfoEvent', (data) => {
- addInfo(data.data)
- })
- console.log(dayworkItem.value)
- const info = {
- deptId: dayworkItem.value.deptId,
- productId: dayworkItem.value.daywork.productId,
- drawingNumber: dayworkItem.value.drawingNumber,
- technologyVersion: dayworkItem.value.technologyVersion,
- retrievalLotId: dayworkItem.value.lotId,
- hasAddedList: retrievalInfo.value
- }
- // 将 info 对象转换为 JSON 字符串
- const serializedData = JSON.stringify(info);
- // 对 JSON 字符串进行 URL 编码
- const encodedData = encodeURIComponent(serializedData);
- // 构建 URL,确保使用正确编码的数据
- uni.navigateTo({
- url: `/pages/sorting/storageRetrieval?data=${encodedData}`
- });
- }
- const addUnfitInfo = (data) => {
- console.log(data)
- if (data && data.length > 0) {
- for (var i = 0; i < data.length; i++) {
- const info = {
- inspectionInstructionId: data[i].id,
- title: data[i].title,
- standard: data[i].standard,
- checkStandard: data[i].standard,
- type: data[i].type,
- reason: ''
- }
- unfitInfos.value.push(info)
- }
- }
- }
- function dele(ite, index) {
- if (ite.status == 1) {
- uni.showToast({
- icon: 'none',
- title: '已被领取,不能删除'
- })
- } else {
- retrievalInfo.value.splice(index, 1);
- }
- }
- const addConsultation = (data) => {
- const info = {
- dayworkItemId: dayworkItem.value.id,
- content: data.content,
- userId: store.userInfo.userId,
- nickName: store.userInfo.nickName,
- dayworkId: dayworkItem.value.dayworkId,
- productionPlandetailId: dayworkItem.value.productionPlandetailId,
- productionPlanDetailSubDetailId: dayworkItem.value.productionPlanDetailSubDetailId,
- lotId: dayworkItem.value.lotId,
- lotCode: dayworkItem.value.lotCode,
- productId: dayworkItem.value.productId,
- productDescription: dayworkItem.value.productDescription,
- technologicalProcessId: dayworkItem.value.technologicalProcessId,
- technologicalProcessDetailId: dayworkItem.value.technologicalProcessDetailId,
- processId: dayworkItem.value.processId,
- processAlias: dayworkItem.value.process.processAlias,
- // technicianId: dayworkItem.value.technicianId,
- technicianId: data.technicianId,
- departments: data.departments,
- pictures: data.pictures
- }
- saveConsult(info).then(res => {
- if (res.code === 200) {
- consultations.value = res.data
- console.log(consultations.value)
- } else {
- uni.showToast({
- icon: 'none',
- title: res.message
- })
- }
- })
- isEventTriggered.value = true; // 更新标志位状态
- consultations.value.push(info)
- }
- /***************************** 定义了一些事件 *****************************/
- // 添加不合格信息
- async function handleAddUnfit() {
- // 监听事件
- uni.$once('addUnfitInfoEvent', (data) => {
- addUnfitInfo(data)
- })
- const hasInstruction = await getHasInstruction();
- console.log(hasInstruction); // 这将打印 true 或 false
- if (!hasInstruction) {
- uni.navigateTo({
- url: "/pages/sorting/specialOptions",
- success: (res) => {
- // 通过eventChannel向被打开页面传送数据
- res.eventChannel.emit('acceptDataFromOpenerPage', {
- data: dayworkItem.value,
- query: {
- productId: dayworkItem.value.daywork.productId,
- processId: dayworkItem.value.process.id,
- // technologyVersion: dayworkItem.value.technologicalProcessDetail.technologyVersion
- technologyVersion: dayworkItem.value.technologyVersion
- },
- index: unfitInfos.value.length
- })
- }
- })
- } else {
- console.log(dayworkItem.value)
- uni.navigateTo({
- url: "/pages/sorting/options",
- success: (res) => {
- // 通过eventChannel向被打开页面传送数据
- res.eventChannel.emit('acceptDataFromOpenerPage', {
- data: dayworkItem.value,
- query: {
- productId: dayworkItem.value.daywork.productId,
- processCode: dayworkItem.value.process.processCode,
- // technologyVersion: dayworkItem.value.technologicalProcessDetail.technologyVersion
- technologyVersion: dayworkItem.value.technologyVersion
- },
- index: unfitInfos.value.length
- })
- }
- })
- }
- }
- async function getHasInstruction() {
- console.log(dayworkItem.value)
- const res = await selectInstructionList({
- technologicalProcessId: dayworkItem.value.technologicalProcessId,
- processCode: dayworkItem.value.process.processCode,
- lotId: dayworkItem.value.lotId
- })
- return res.data
- // .then(res=> {
- // console.log(res.data)
- // return res.data
- // })
- }
- // 删除不合格信息
- const handleDelUnfit = (index) => {
- let tempInfo = unfitInfos.value[index]
- console.log(tempInfo)
- uni.showModal({
- title: '提示',
- content: '确定删除该项?',
- success: function(res) {
- if (res.confirm) {
- dayworkItem.value.rejectNum = dayworkItem.value.rejectNum - tempInfo.rejectNum
- dayworkItem.value.qualifiedNum = parseInt(dayworkItem.value.qualifiedNum) + parseInt(
- tempInfo.rejectNum)
- unfitInfos.value.splice(index, 1)
- } else if (res.cancel) {
- return
- }
- }
- })
- }
- /* 更换载具*/
- function handleChangeCarrier(item) {
- // uni.$once('refreshQuickReport', () => {
- // init()
- // })
- store.dayworkInfo = null
- uni.navigateTo({
- url: "/pages/changeBox/index",
- success: function(res) {
- // 通过eventChannel向被打开页面传送数据
- res.eventChannel.emit('sortingFromOpenerPage', {
- data: dayworkItem.value
- })
- }
- })
- }
- // 添加咨询信息
- const handleAddConsultation = () => {
- isEventTriggered.value = false; // 更新标志位状态
- // 监听事件
- uni.$once('addConsulttationEvent', (data) => {
- if (!isEventTriggered.value) {
- // 如果事件尚未触发,则执行事件触发逻辑
- addConsultation(data)
- }
- })
- uni.navigateTo({
- url: "/pages/sorting/consultation",
- success: (res) => {
- // 通过eventChannel向被打开页面传送数据
- res.eventChannel.emit('acceptDataFromOpenerPage', {
- data: dayworkItem.value
- })
- }
- })
- }
- const checkFinishable = () => {
- if (consultations.value.findIndex(v => v.status === 0) >= 0) {
- return false
- } else {
- return true
- }
- }
- const showStatus = (status) => {
- // console.log(status)
- switch (status) {
- case 0:
- return '未确认'
- case 1:
- return '不合格'
- case 2:
- return '合格'
- default:
- return ''
- }
- }
- function selectText(item) {
- // for (var i = 0; i < consul.length; i++) {
- // if (item.status == consul[i].value) {
- // return consul[i].text
- // }
- // }
- if (item.consultResultId == 0) {
- return '待确认'
- } else {
- return item.result
- }
- }
- const showStatusColor = (status) => {
- // console.log(status)
- switch (status) {
- case 0:
- return '#fcab53'
- case 1:
- return '#fc044f'
- case 2:
- return '#1deb19'
- default:
- return ''
- }
- }
- const rejectNumberChange = () => {
- let sumReject = 0
- unfitInfos.value.forEach(v => {
- sumReject += v.rejectNum == null ? 0 : Number(v.rejectNum)
- })
- dayworkItem.value.rejectNum = sumReject
- dayworkItem.value.qualifiedNum = dayworkItem.value.prodNum - sumReject
- console.log(dayworkItem.value)
- }
- const promiseDownModal = () => new Promise((resolve) => {
- uni.showModal({
- title: '提示',
- content: `合格数过低,最低应为投产量的${qualifiedNumDownRatio.value}%, 是否确定保存`,
- showCancel: true,
- cancelText: '取消',
- confirmText: '确定',
- confirmColor: '#ff0000',
- cancelColor: '#55aa00',
- complete: (res) => { // 使用 complete 回调
- console.log("Modal complete callback triggered:", res);
- if (res.confirm) {
- resolve(true);
- } else {
- resolve(false);
- }
- }
- });
- });
- const promiseUpModal = () => new Promise((resolve) => {
- uni.showModal({
- title: '提示',
- content: `合格数过高,最高应为投产量的${qualifiedNumUpRatio.value}%, 是否确定保存`,
- showCancel: true,
- cancelText: '取消',
- confirmText: '确定',
- confirmColor: '#ff0000',
- cancelColor: '#55aa00',
- complete: (res) => { // 使用 complete 回调
- console.log("Modal complete callback triggered:", res);
- if (res.confirm) {
- resolve(true);
- } else {
- resolve(false);
- }
- }
- });
- });
- const validDownNum = async () => {
- // 只在结束报工的时候判断
- if (isFinish.value && dayworkItem.value.qualifiedNum < (dayworkItem.value.prodNum * (qualifiedNumDownRatio
- .value / 100))) {
- try {
- const promiseDown = await promiseDownModal(); // 等待用户确认或取消
- console.log(promiseDown);
- return promiseDown; // 返回用户的选择
- } catch (error) {
- console.log("用户取消操作", error);
- return false; // 用户取消,返回 false
- }
- } else {
- return true; // 合格数正常,直接返回 true
- }
- };
- const validUpNum = async () => {
- // 只在结束报工的时候判断
- if (isFinish.value && dayworkItem.value.qualifiedNum > (dayworkItem.value.prodNum * (qualifiedNumUpRatio
- .value / 100))) {
- try {
- const promiseUp = await promiseUpModal(); // 等待用户确认或取消
- console.log(promiseUp);
- return promiseUp; // 返回用户的选择
- } catch (error) {
- console.log("用户取消操作", error);
- return false; // 用户取消,返回 false
- }
- } else {
- return true; // 合格数正常,直接返回 true
- }
- };
- const validHandle = async () => {
- console.log(storageNum.value == "")
- if (storageNum.value != null && storageNum.value != "" && storageNum.value <= 0) {
- uni.showToast({
- icon: 'none',
- title: "存入数量应大于0",
- duration: 2000
- })
- return false;
- }
- if (storageNum.value != null && storageNum.value != "" && storageNum.value > 0 && storageNum.value > 0 &&
- type
- .value == null) {
- uni.showToast({
- icon: 'none',
- title: "选别类型不能为空",
- duration: 2000
- })
- return false;
- }
- for (let i = 0; i < unfitInfos.value.length; i++) {
- const e = unfitInfos.value[i]
- if (e.rejectNum == null || e.rejectNum == 0) {
- uni.showToast({
- icon: 'none',
- title: `第${i + 1}条不合格信息未输入不合格数量`
- })
- return false
- }
- }
- if (dayworkItem.value.qualifiedNum === null || dayworkItem.value.qualifiedNum === "") {
- uni.showToast({
- icon: 'none',
- title: "合格数不能为空",
- duration: 2000
- })
- return false;
- }
- if (isFinish.value && dayworkItem.value.qualifiedNum == 0) {
- uni.showToast({
- icon: 'none',
- title: "合格数不能为0",
- duration: 2000
- })
- return false;
- }
- if (dayworkItem.value.qualifiedNum < 0) {
- uni.showToast({
- icon: 'none',
- title: "合格数不能为负数,请检查不合格信息后提交",
- duration: 2000
- })
- return false;
- }
- if (isFinish.value && dayworkItem.value.qualifiedNum > (dayworkItem.value.prodNum * (qualifiedNumUpRatio
- .value / 100))) {
- // let flag = await validUpNum()
- // if (!flag) {
- // return false
- // }
- uni.showToast({
- icon: 'none',
- title: `合格数过高,最高应为投产量的${qualifiedNumUpRatio.value}%`,
- duration: 2000
- })
- return false;
- }
- if (isFinish.value && dayworkItem.value.qualifiedNum < (dayworkItem.value.prodNum * (qualifiedNumDownRatio
- .value / 100))) {
- console.log("666")
- let flag = await validDownNum()
- if (!flag) {
- return false
- }
- // uni.showToast({
- // icon: 'none',
- // title: `合格数过低,最低应为投产量的${qualifiedNumDownRatio.value}%`,
- // duration: 2000
- // })
- // return false;
- }
- return true
- // unfitInfos.value.forEach((e, i) => {
- // if (e.name)
- // })
- }
- async function handleCheckStock() {
- let currentProcessStepNumber = dayworkInfo.value.currentProcess.processStepNumber;
- let lastProcess = dayworkInfo.value.processSequence[dayworkInfo.value.processSequence.length - 1];
- // 判断当前工序是否是最后一道序
- if (currentProcessStepNumber === lastProcess.processStepNumber) {
- // 等待 getTakeStockPeriod() 的 Promise 完成
- const res = await getTakeStockPeriod({
- dayworkId: dayworkInfo.value.id
- });
- console.log(res.data.length);
- if (res.data.length > 0) {
- uni.showToast({
- icon: 'none',
- title: "此次盘点未结束,不能结束报工",
- duration: 2000
- });
- return false; // 如果盘点未结束,返回 false
- }
- }
- // 如果不是最后一道工序或盘点已结束,返回 true
- return true;
- }
- //状态文本
- function selectType(item) {
- for (var i = 0; i < selectTypeList.value.length; i++) {
- if (item == selectTypeList.value[i].value) {
- return selectTypeList.value[i].text
- }
- }
- }
- async function handleFinishDaywork() {
- isFinish.value = true
- // const downNum = await validDownNum()
- // console.log(downNum)
- // console.log(!validHandle(), !validUpNum(), !validDownNum())
- const res = await validHandle()
- if (!res) {
- return
- }
- console.log("999")
- //判断当前批次是否在盘点,如果盘点未结束,则不能结束报工
- let checkStockResult = await handleCheckStock();
- console.log(checkStockResult)
- if (!checkStockResult) {
- return;
- }
- //零存数据
- if (storageNum.value != null && storageNum.value != "") {
- if (Object.keys(storageInfo.value).length === 0) {
- storageInfo.value = {
- productionPlanDetailId: dayworkItem.value.productionPlanDetailId,
- productDescription: dayworkItem.value.productDescription,
- drawingNumber: dayworkItem.value.drawingNumber,
- lotId: dayworkItem.value.lotId,
- lotCode: dayworkItem.value.lotCode,
- deptId: dayworkItem.value.deptId,
- productId: dayworkItem.value.daywork.productId,
- technologyVersion: dayworkItem.value.technologyVersion,
- storageNum: storageNum.value,
- storagerId: store.userInfo.userId,
- type: type.value
- }
- } else {
- storageInfo.value.storageNum = storageNum.value
- storageInfo.value.type = type.value
- }
- } else {
- storageInfo.value = null
- }
- //零取数据
- if (retrievalInfo.value.length > 0) {
- retrievalInfo.value.forEach(item => {
- item.retrievalLotId = dayworkItem.value.lotId,
- item.retrievalLotCode = dayworkItem.value.lotCode,
- item.retrievalerId = store.userInfo.userId,
- item.retrievalTime = timestampToTime(new Date())
- })
- }
- const saveData = {
- rejectList: unfitInfos.value,
- consult: consultations.value,
- id: dayworkItem.value.id,
- prodNum: dayworkItem.value.prodNum,
- rejectNum: dayworkItem.value.rejectNum,
- qualifiedNum: dayworkItem.value.qualifiedNum,
- equipmentDetailId: dayworkItem.value.equipmentDetailId,
- equipmentDetailCode: dayworkItem.value.equipmentDetailCode,
- remark: dayworkItem.value.remark,
- storageInfo: storageInfo.value,
- retrievalInfo: retrievalInfo.value
- }
- const currentTime = Date.now();
- // 检查是否已经过去了 2 秒
- if (currentTime - lastRequestTimestamp.value < 2000) {
- // 如果在 2 秒 内已经点击,那么不执行
- uni.showToast({
- icon: 'none',
- title: `请勿重复点击`,
- duration: 2000
- })
- return;
- }
- lastRequestTimestamp.value = currentTime;
- console.log(saveData)
- // console.log(!validNum())
- finish(saveData).then(res => {
- if (res.code === 200) {
- uni.navigateBack()
- } else {
- uni.showToast({
- icon: 'none',
- title: res.message
- })
- }
- })
- }
- const handleUpdateDaywork = () => {
- isFinish.value = false
- if (!validHandle()) {
- return
- }
- //零存数据
- if (storageNum.value != null && storageNum.value != "") {
- if (Object.keys(storageInfo.value).length === 0) {
- storageInfo.value = {
- productionPlanDetailId: dayworkItem.value.productionPlanDetailId,
- productDescription: dayworkItem.value.productDescription,
- drawingNumber: dayworkItem.value.drawingNumber,
- lotId: dayworkItem.value.lotId,
- lotCode: dayworkItem.value.lotCode,
- deptId: dayworkItem.value.deptId,
- productId: dayworkItem.value.daywork.productId,
- technologyVersion: dayworkItem.value.technologyVersion,
- storageNum: storageNum.value,
- storagerId: store.userInfo.userId,
- type: type.value
- }
- } else {
- storageInfo.value.storageNum = storageNum.value
- storageInfo.value.type = type.value
- }
- } else {
- storageInfo.value = null
- }
- //零取数据
- if (retrievalInfo.value.length > 0) {
- retrievalInfo.value.forEach(item => {
- item.retrievalLotId = dayworkItem.value.lotId,
- item.retrievalLotCode = dayworkItem.value.lotCode,
- item.retrievalerId = store.userInfo.userId,
- item.retrievalTime = timestampToTime(new Date())
- })
- }
- const saveData = {
- rejectList: unfitInfos.value,
- consult: consultations.value,
- id: dayworkItem.value.id,
- prodNum: dayworkItem.value.prodNum,
- rejectNum: dayworkItem.value.rejectNum,
- qualifiedNum: dayworkItem.value.qualifiedNum,
- equipmentDetailId: dayworkItem.value.equipmentDetailId,
- equipmentDetailCode: dayworkItem.value.equipmentDetailCode,
- remark: dayworkItem.value.remark,
- storageInfo: storageInfo.value,
- retrievalInfo: retrievalInfo.value
- }
- console.log(saveData)
- update(saveData).then(res => {
- if (res.code === 200) {
- uni.$emit("formBack")
- uni.navigateBack()
- } else {
- uni.showToast({
- icon: 'none',
- title: res.message
- })
- }
- })
- }
- </script>
- <style lang="scss">
- .buttonOp {
- margin-top: 5px;
- }
- .page-container {
- // height: 100%;
- background-color: #ececec;
- font-size: 28rpx;
- overflow: auto;
- >.title {
- font-weight: 700;
- margin: 24rpx 16rpx;
- }
- }
- .add-btn {
- padding: 12rpx 32rpx;
- background-color: #a4adb3;
- color: #ffffff;
- border-radius: 12rpx;
- font-size: 24rpx;
- }
- .lot-info {
- margin: 32rpx 16rpx 0 16rpx;
- padding: 24rpx;
- background-color: #ffffff;
- border-radius: 8rpx;
- .lot-code {
- font-size: 32rpx;
- font-weight: 700;
- margin-bottom: 16rpx;
- }
- .product-info {
- font-size: 28rpx;
- color: #9f9f9f;
- }
- }
- .middle {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center
- }
- .segment {
- width: 80%;
- background-color: rgba(213, 213, 213, 1);
- border: 1rpx solid rgba(213, 213, 213, 1);
- margin: 16px 0;
- }
- .unfit-title {
- margin-bottom: 24rpx;
- justify-content: space-between;
- align-items: center;
- text {
- font-size: 28rpx;
- font-weight: 700;
- }
- .add-btn {
- padding: 12rpx 32rpx;
- background-color: #a4adb3;
- color: #ffffff;
- border-radius: 12rpx;
- font-size: 24rpx;
- }
- }
- .save {
- align-items: center;
- padding-bottom: 32rpx;
- justify-content: space-between;
- input {
- height: 56rpx;
- border: 1px solid #9f9f9f;
- font-size: 28rpx;
- &.number {
- width: 60%;
- text-align: center;
- }
- }
- }
- .unfit-container {
- padding: 24rpx;
- margin: 0 16rpx;
- background-color: #ffffff;
- border-radius: 12rpx;
- .unfit-item-container {
- position: relative;
- >* {
- margin-bottom: 24rpx;
- }
- .title {
- font-weight: 700;
- justify-content: space-between;
- align-items: center;
- image {
- width: 40rpx;
- height: 40rpx;
- }
- }
- .standard {}
- .result {
- align-items: center;
- border-bottom: 1px solid #9f9f9f;
- padding-bottom: 32rpx;
- .label {
- flex: 1;
- }
- input {
- width: 280rpx;
- height: 56rpx;
- border: 1px solid #9f9f9f;
- font-size: 28rpx;
- &.number {
- width: 104rpx;
- text-align: center;
- }
- }
- }
- }
- .unfit-item-container:last-child {
- .result {
- border-bottom: none;
- padding-bottom: 0;
- }
- }
- }
- .consultation-container {
- margin: 0 16rpx;
- padding: 24rpx;
- background-color: #ffffff;
- border-radius: 8rpx;
- .consultation-item-container {
- margin-bottom: 24rpx;
- border-bottom: 2px solid #888888;
- padding-bottom: 24rpx;
- }
- .consultation-item-container:last-child {
- margin-bottom: 0;
- border-bottom: 0;
- padding-bottom: 0;
- }
- .question,
- .answer {
- .label {
- justify-content: space-between;
- margin-bottom: 16rpx;
- font-weight: 700;
- }
- .content {
- line-height: 40rpx;
- }
- }
- .answer {
- margin-top: 24rpx;
- }
- }
- .daywork-container {
- margin-top: 24rpx;
- padding: 24rpx;
- background-color: #ffffff;
- border: 1px solid #bcbcbc;
- .result {
- align-items: center;
- .label {
- width: 112rpx;
- }
- input {
- flex: 1;
- height: 56rpx;
- border: 1px solid #9f9f9f;
- font-size: 28rpx;
- text-align: center;
- }
- }
- .remark {
- margin-top: 24rpx;
- .label {
- width: 112rpx;
- }
- textarea {
- flex: 1;
- border: 1px solid #9f9f9f;
- height: 168rpx;
- }
- }
- .btns-container {
- margin-top: 24rpx;
- .bottom-btn {
- display: flex;
- flex: 1;
- height: 80rpx;
- background-color: #5555ff;
- color: #ffffff;
- text-align: center;
- justify-content: center;
- align-items: center;
- border-radius: 8rpx;
- margin-right: 10rpx;
- &.left-btn {
- background-color: rgba(85, 85, 255, 1.0);
- }
- &.right-btn {
- margin-left: 24rpx;
- }
- }
- .finished-btn {
- display: flex;
- flex: 1;
- height: 80rpx;
- background-color: #fc6565;
- color: #ffffff;
- text-align: center;
- justify-content: center;
- align-items: center;
- border-radius: 8rpx;
- }
- .pause-btn {
- display: flex;
- flex: 1;
- height: 80rpx;
- background-color: #55d90d;
- color: #ffffff;
- text-align: center;
- justify-content: center;
- align-items: center;
- border-radius: 8rpx;
- margin-left: 12rpx;
- }
- .question-btn {
- width: 80rpx;
- align-items: flex-end;
- image {
- width: 48rpx;
- height: 48rpx;
- }
- text {
- font-size: 24rpx;
- }
- }
- }
- }
- .zb-table .item-tr {
- flex-direction: row;
- }
- </style>
|