|
@@ -178,7 +178,7 @@
|
|
|
getTakeStockPeriod
|
|
|
} from '@/api/business/taksStackLot.js'
|
|
|
import {
|
|
|
- getDictInfoByType
|
|
|
+ getDictInfoByTypes
|
|
|
} from '@/api/dict/dict.js'
|
|
|
import {
|
|
|
onLoad,
|
|
@@ -199,6 +199,7 @@
|
|
|
const consultations = ref([])
|
|
|
const dayworkInfo = ref({})
|
|
|
const retrievalInfo = ref([])
|
|
|
+ const qualifiedNumDownRatio = ref(0)
|
|
|
// 创建一个引用来存储最后一次请求的时间戳
|
|
|
const lastRequestTimestamp = ref(0);
|
|
|
const selectTypeList = ref([])
|
|
@@ -207,7 +208,7 @@
|
|
|
const saveFlag = ref(false)
|
|
|
const storageNum = ref('')
|
|
|
const storageInfo = ref(null)
|
|
|
- const qualifiedNumRatio = ref(0)
|
|
|
+ const qualifiedNumUpRatio = ref(0)
|
|
|
const isFinish = ref(false)
|
|
|
const column1 = [{
|
|
|
name: 'lotCode',
|
|
@@ -281,27 +282,44 @@
|
|
|
|
|
|
/***************************** 定义了一些方法 *****************************/
|
|
|
const init = (data) => {
|
|
|
+ let dics = ['sort_report_up_limit', 'sort_report_down_limit', 'select_type']
|
|
|
//获取当前跟选报工合格数最大值
|
|
|
- // getDictInfoByType("sort_report_limit").then(res => {
|
|
|
- // console.log(res.data && res.data.length >0)
|
|
|
- // if(res.data && res.data.length >0) {
|
|
|
- // qualifiedNumRatio.value =parseInt(res.data[0].dictValue)
|
|
|
- // }
|
|
|
- // }).catch(err => {
|
|
|
- // console.log(err)
|
|
|
- // console.log('369 err')
|
|
|
- // })
|
|
|
- //获取选别类型
|
|
|
- getDictInfoByType("select_type").then(res => {
|
|
|
- console.log(res.data && res.data.length > 0)
|
|
|
- selectTypeList.value = res.data.map(v => {
|
|
|
- return {
|
|
|
- value: v.dictValue,
|
|
|
- text: v.dictLabel
|
|
|
- };
|
|
|
- });
|
|
|
- })
|
|
|
- console.log("dayworkInfo", dayworkInfo.value);
|
|
|
+ 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');
|
|
|
+ });
|
|
|
// 获取当前报工信息
|
|
|
getSortingDayworkItem(data).then(res => {
|
|
|
console.log(res)
|
|
@@ -596,6 +614,77 @@
|
|
|
return item.result
|
|
|
}
|
|
|
}
|
|
|
+ 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 showStatusColor = (status) => {
|
|
|
// console.log(status)
|
|
@@ -620,7 +709,7 @@
|
|
|
console.log(dayworkItem.value)
|
|
|
}
|
|
|
|
|
|
- const validHandle = () => {
|
|
|
+ const validHandle = async () => {
|
|
|
console.log(storageNum.value == "")
|
|
|
if (storageNum.value != null && storageNum.value != "" && storageNum.value <= 0) {
|
|
|
uni.showToast({
|
|
@@ -630,7 +719,8 @@
|
|
|
})
|
|
|
return false;
|
|
|
}
|
|
|
- if (storageNum.value != null && storageNum.value != "" && storageNum.value > 0 && storageNum.value > 0 && type
|
|
|
+ if (storageNum.value != null && storageNum.value != "" && storageNum.value > 0 && storageNum.value > 0 &&
|
|
|
+ type
|
|
|
.value == null) {
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
@@ -674,15 +764,33 @@
|
|
|
})
|
|
|
return false;
|
|
|
}
|
|
|
- //只在结束报工的时候判断
|
|
|
- // if(isFinish.value &&dayworkItem.value.qualifiedNum > (dayworkItem.value.prodNum * (qualifiedNumRatio.value/100))){
|
|
|
- // uni.showToast({
|
|
|
- // icon: 'none',
|
|
|
- // title: "合格数不能超过投产量的"+qualifiedNumRatio.value+"%",
|
|
|
- // 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)
|
|
@@ -722,7 +830,8 @@
|
|
|
|
|
|
async function handleFinishDaywork() {
|
|
|
isFinish.value = true
|
|
|
- if (!validHandle()) {
|
|
|
+ const res = await validHandle()
|
|
|
+ if (!res) {
|
|
|
return
|
|
|
}
|
|
|
//判断当前批次是否在盘点,如果盘点未结束,则不能结束报工
|