|
|
@ -260,7 +260,7 @@ |
|
|
</el-form> |
|
|
</el-form> |
|
|
<template #footer> |
|
|
<template #footer> |
|
|
<el-button @click="editVisible = false">取消</el-button> |
|
|
<el-button @click="editVisible = false">取消</el-button> |
|
|
<el-button type="primary" @click="submitEdit">保存</el-button> |
|
|
|
|
|
|
|
|
<el-button type="primary" :loading="editSubmitting" @click="submitEdit">保存</el-button> |
|
|
</template> |
|
|
</template> |
|
|
</el-dialog> |
|
|
</el-dialog> |
|
|
</div> |
|
|
</div> |
|
|
@ -277,28 +277,42 @@ const userStore = useUserStore(); |
|
|
|
|
|
|
|
|
// 列表和筛选 |
|
|
// 列表和筛选 |
|
|
const loading = ref(false); |
|
|
const loading = ref(false); |
|
|
|
|
|
let listRequestSeq = 0; |
|
|
const tableData = ref([]); |
|
|
const tableData = ref([]); |
|
|
const searchParams = ref({ workOrderCode: '', mfgMonth: '' }); |
|
|
const searchParams = ref({ workOrderCode: '', mfgMonth: '' }); |
|
|
const pageParams = ref({ index: 1, size: 20, total: 0 }); |
|
|
const pageParams = ref({ index: 1, size: 20, total: 0 }); |
|
|
|
|
|
|
|
|
const getList = async () => { |
|
|
const getList = async () => { |
|
|
|
|
|
const requestSeq = ++listRequestSeq; |
|
|
loading.value = true; |
|
|
loading.value = true; |
|
|
const { code, body } = await workhour.fillPageList({ |
|
|
|
|
|
index: pageParams.value.index, |
|
|
|
|
|
size: pageParams.value.size, |
|
|
|
|
|
workOrderCode: searchParams.value.workOrderCode, |
|
|
|
|
|
mfgMonth: searchParams.value.mfgMonth, |
|
|
|
|
|
}); |
|
|
|
|
|
loading.value = false; |
|
|
|
|
|
if (code === 0) { |
|
|
|
|
|
tableData.value = body.data || []; |
|
|
|
|
|
pageParams.value.total = body.total || 0; |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const { code, body, msg } = await workhour.fillPageList({ |
|
|
|
|
|
index: pageParams.value.index, |
|
|
|
|
|
size: pageParams.value.size, |
|
|
|
|
|
workOrderCode: searchParams.value.workOrderCode, |
|
|
|
|
|
mfgMonth: searchParams.value.mfgMonth, |
|
|
|
|
|
}); |
|
|
|
|
|
if (requestSeq !== listRequestSeq) return; |
|
|
|
|
|
if (code === 0) { |
|
|
|
|
|
tableData.value = body.data || []; |
|
|
|
|
|
pageParams.value.total = body.total || 0; |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage({ message: msg || '工时记录加载失败', type: 'error', customClass: 'elmessage-style' }); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
if (requestSeq === listRequestSeq) { |
|
|
|
|
|
ElMessage({ message: error?.message || '工时记录加载失败,请检查服务连接', type: 'error', customClass: 'elmessage-style' }); |
|
|
|
|
|
} |
|
|
|
|
|
} finally { |
|
|
|
|
|
if (requestSeq === listRequestSeq) loading.value = false; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// 工时填报 |
|
|
// 工时填报 |
|
|
const fillVisible = ref(false); |
|
|
const fillVisible = ref(false); |
|
|
const orderLoading = ref(false); |
|
|
const orderLoading = ref(false); |
|
|
|
|
|
let orderLookupRequestSeq = 0; |
|
|
|
|
|
let activeOrderLookupCode = ''; |
|
|
const submitting = ref(false); |
|
|
const submitting = ref(false); |
|
|
const productList = ref([]); |
|
|
const productList = ref([]); |
|
|
const productTableRef = ref(null); |
|
|
const productTableRef = ref(null); |
|
|
@ -306,6 +320,7 @@ const currentProduct = ref(null); |
|
|
const queriedWorkOrderCode = ref(''); |
|
|
const queriedWorkOrderCode = ref(''); |
|
|
const processList = ref([]); |
|
|
const processList = ref([]); |
|
|
const processDictionaryRows = ref([]); |
|
|
const processDictionaryRows = ref([]); |
|
|
|
|
|
let processListRequestSeq = 0; |
|
|
const groupList = ref([]); |
|
|
const groupList = ref([]); |
|
|
const categoryList = ref([]); |
|
|
const categoryList = ref([]); |
|
|
const abnormalGroupOptions = ref([]); |
|
|
const abnormalGroupOptions = ref([]); |
|
|
@ -351,6 +366,9 @@ const today = () => { |
|
|
const thisMonth = () => today().slice(0, 7); |
|
|
const thisMonth = () => today().slice(0, 7); |
|
|
|
|
|
|
|
|
const openFill = () => { |
|
|
const openFill = () => { |
|
|
|
|
|
orderLookupRequestSeq += 1; |
|
|
|
|
|
activeOrderLookupCode = ''; |
|
|
|
|
|
orderLoading.value = false; |
|
|
if (!categoryList.value.length && !abnormalGroupOptions.value.length) { |
|
|
if (!categoryList.value.length && !abnormalGroupOptions.value.length) { |
|
|
ElMessage({ message: '当前账号未分配工时填报权限', type: 'warning', customClass: 'elmessage-style' }); |
|
|
ElMessage({ message: '当前账号未分配工时填报权限', type: 'warning', customClass: 'elmessage-style' }); |
|
|
return; |
|
|
return; |
|
|
@ -387,11 +405,14 @@ const getOrderProducts = async () => { |
|
|
ElMessage({ message: '请输入工单号', type: 'warning', customClass: 'elmessage-style' }); |
|
|
ElMessage({ message: '请输入工单号', type: 'warning', customClass: 'elmessage-style' }); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
if (orderLoading.value || (queriedWorkOrderCode.value === workOrderCode && productList.value.length > 0)) return; |
|
|
|
|
|
|
|
|
if ((orderLoading.value && activeOrderLookupCode === workOrderCode) |
|
|
|
|
|
|| (queriedWorkOrderCode.value === workOrderCode && productList.value.length > 0)) return; |
|
|
|
|
|
const requestSeq = ++orderLookupRequestSeq; |
|
|
|
|
|
activeOrderLookupCode = workOrderCode; |
|
|
orderLoading.value = true; |
|
|
orderLoading.value = true; |
|
|
try { |
|
|
try { |
|
|
const { code, msg, body } = await workhour.orderProductList({ workOrderCode }); |
|
|
const { code, msg, body } = await workhour.orderProductList({ workOrderCode }); |
|
|
if (workOrderCode !== fillForm.value.workOrderCode.trim()) return; |
|
|
|
|
|
|
|
|
if (requestSeq !== orderLookupRequestSeq || workOrderCode !== fillForm.value.workOrderCode.trim()) return; |
|
|
if (code === 0) { |
|
|
if (code === 0) { |
|
|
queriedWorkOrderCode.value = workOrderCode; |
|
|
queriedWorkOrderCode.value = workOrderCode; |
|
|
productList.value = body || []; |
|
|
productList.value = body || []; |
|
|
@ -405,17 +426,19 @@ const getOrderProducts = async () => { |
|
|
if (productList.value.length === 0) { |
|
|
if (productList.value.length === 0) { |
|
|
ElMessage({ message: '该工单下没有可填报产品', type: 'warning', customClass: 'elmessage-style' }); |
|
|
ElMessage({ message: '该工单下没有可填报产品', type: 'warning', customClass: 'elmessage-style' }); |
|
|
} else if (productList.value.length === 1) { |
|
|
} else if (productList.value.length === 1) { |
|
|
|
|
|
const product = productList.value[0]; |
|
|
await nextTick(); |
|
|
await nextTick(); |
|
|
productTableRef.value?.setCurrentRow(productList.value[0]); |
|
|
|
|
|
if (currentProduct.value?.devCode !== productList.value[0].devCode) { |
|
|
|
|
|
await handleProductChange(productList.value[0]); |
|
|
|
|
|
|
|
|
if (requestSeq !== orderLookupRequestSeq || workOrderCode !== fillForm.value.workOrderCode.trim()) return; |
|
|
|
|
|
productTableRef.value?.setCurrentRow(product); |
|
|
|
|
|
if (currentProduct.value?.devCode !== product.devCode) { |
|
|
|
|
|
await handleProductChange(product); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
ElMessage({ message: msg, type: 'error', customClass: 'elmessage-style' }); |
|
|
ElMessage({ message: msg, type: 'error', customClass: 'elmessage-style' }); |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
if (workOrderCode === fillForm.value.workOrderCode.trim()) { |
|
|
|
|
|
|
|
|
if (requestSeq === orderLookupRequestSeq && workOrderCode === fillForm.value.workOrderCode.trim()) { |
|
|
ElMessage({ |
|
|
ElMessage({ |
|
|
message: error?.message || 'ERP 查询失败,请检查登录状态和服务连接', |
|
|
message: error?.message || 'ERP 查询失败,请检查登录状态和服务连接', |
|
|
type: 'error', |
|
|
type: 'error', |
|
|
@ -423,11 +446,17 @@ const getOrderProducts = async () => { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} finally { |
|
|
} finally { |
|
|
orderLoading.value = false; |
|
|
|
|
|
|
|
|
if (requestSeq === orderLookupRequestSeq) { |
|
|
|
|
|
activeOrderLookupCode = ''; |
|
|
|
|
|
orderLoading.value = false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const invalidateOrderLookup = () => { |
|
|
const invalidateOrderLookup = () => { |
|
|
|
|
|
orderLookupRequestSeq += 1; |
|
|
|
|
|
activeOrderLookupCode = ''; |
|
|
|
|
|
orderLoading.value = false; |
|
|
queriedWorkOrderCode.value = ''; |
|
|
queriedWorkOrderCode.value = ''; |
|
|
productList.value = []; |
|
|
productList.value = []; |
|
|
currentProduct.value = null; |
|
|
currentProduct.value = null; |
|
|
@ -436,6 +465,9 @@ const invalidateOrderLookup = () => { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const onWithoutWorkOrderChange = (checked) => { |
|
|
const onWithoutWorkOrderChange = (checked) => { |
|
|
|
|
|
orderLookupRequestSeq += 1; |
|
|
|
|
|
activeOrderLookupCode = ''; |
|
|
|
|
|
orderLoading.value = false; |
|
|
if (!checked) { |
|
|
if (!checked) { |
|
|
fillForm.value.productName = ''; |
|
|
fillForm.value.productName = ''; |
|
|
return; |
|
|
return; |
|
|
@ -463,6 +495,7 @@ const handleProductChange = async (row) => { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const getProcessList = async () => { |
|
|
const getProcessList = async () => { |
|
|
|
|
|
const requestSeq = ++processListRequestSeq; |
|
|
const abnormal = fillForm.value.dictType === '非正常工时'; |
|
|
const abnormal = fillForm.value.dictType === '非正常工时'; |
|
|
const directNormal = !abnormal && directNormalCategories.includes(fillForm.value.category); |
|
|
const directNormal = !abnormal && directNormalCategories.includes(fillForm.value.category); |
|
|
if (directNormal) { |
|
|
if (directNormal) { |
|
|
@ -483,12 +516,23 @@ const getProcessList = async () => { |
|
|
progress.value = { manuNum: 0, filledNum: 0, remainNum: 0, minutes: 0, warnings: [] }; |
|
|
progress.value = { manuNum: 0, filledNum: 0, remainNum: 0, minutes: 0, warnings: [] }; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
const { code, body } = await workhour.processList({ |
|
|
|
|
|
category: abnormal ? '全部组别' : fillForm.value.category, |
|
|
|
|
|
groupName: abnormal ? '全部组别' : undefined, |
|
|
|
|
|
dictType: fillForm.value.dictType, |
|
|
|
|
|
}); |
|
|
|
|
|
if (code === 0) { |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const { code, body, msg } = await workhour.processList({ |
|
|
|
|
|
category: abnormal ? '全部组别' : fillForm.value.category, |
|
|
|
|
|
groupName: abnormal ? '全部组别' : undefined, |
|
|
|
|
|
dictType: fillForm.value.dictType, |
|
|
|
|
|
}); |
|
|
|
|
|
if (requestSeq !== processListRequestSeq) return; |
|
|
|
|
|
if (code !== 0) { |
|
|
|
|
|
processDictionaryRows.value = []; |
|
|
|
|
|
groupList.value = []; |
|
|
|
|
|
processList.value = []; |
|
|
|
|
|
fillForm.value.groupName = ''; |
|
|
|
|
|
fillForm.value.processName = ''; |
|
|
|
|
|
progress.value = { manuNum: 0, filledNum: 0, remainNum: 0, minutes: 0, warnings: [] }; |
|
|
|
|
|
ElMessage({ message: msg || '工序加载失败', type: 'error', customClass: 'elmessage-style' }); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
processDictionaryRows.value = body || []; |
|
|
processDictionaryRows.value = body || []; |
|
|
if (abnormal) { |
|
|
if (abnormal) { |
|
|
groupList.value = abnormalGroupOptions.value.map((option) => option.groupName); |
|
|
groupList.value = abnormalGroupOptions.value.map((option) => option.groupName); |
|
|
@ -512,6 +556,15 @@ const getProcessList = async () => { |
|
|
fillForm.value.processName = ''; |
|
|
fillForm.value.processName = ''; |
|
|
} |
|
|
} |
|
|
refreshProgress(); |
|
|
refreshProgress(); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
if (requestSeq !== processListRequestSeq) return; |
|
|
|
|
|
processDictionaryRows.value = []; |
|
|
|
|
|
groupList.value = []; |
|
|
|
|
|
processList.value = []; |
|
|
|
|
|
fillForm.value.groupName = ''; |
|
|
|
|
|
fillForm.value.processName = ''; |
|
|
|
|
|
progress.value = { manuNum: 0, filledNum: 0, remainNum: 0, minutes: 0, warnings: [] }; |
|
|
|
|
|
ElMessage({ message: error?.message || '工序加载失败,请检查服务连接', type: 'error', customClass: 'elmessage-style' }); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
@ -558,24 +611,33 @@ const refreshProgress = async () => { |
|
|
progress.value = { manuNum: 0, filledNum: 0, remainNum: 0, minutes: 0, warnings: [] }; |
|
|
progress.value = { manuNum: 0, filledNum: 0, remainNum: 0, minutes: 0, warnings: [] }; |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
const { code, body } = await workhour.processProgress({ |
|
|
|
|
|
workOrderCode: fillForm.value.workOrderCode, |
|
|
|
|
|
devCode: fillForm.value.devCode, |
|
|
|
|
|
category: fillForm.value.category, |
|
|
|
|
|
groupName: fillForm.value.groupName, |
|
|
|
|
|
processName: fillForm.value.processName, |
|
|
|
|
|
qty: fillForm.value.qty, |
|
|
|
|
|
dictType: fillForm.value.dictType, |
|
|
|
|
|
}); |
|
|
|
|
|
if (requestSeq !== progressRequestSeq) return null; |
|
|
|
|
|
if (code === 0 && body) { |
|
|
|
|
|
progress.value = body; |
|
|
|
|
|
return body; |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const { code, body, msg } = await workhour.processProgress({ |
|
|
|
|
|
workOrderCode: fillForm.value.workOrderCode, |
|
|
|
|
|
devCode: fillForm.value.devCode, |
|
|
|
|
|
category: fillForm.value.category, |
|
|
|
|
|
groupName: fillForm.value.groupName, |
|
|
|
|
|
processName: fillForm.value.processName, |
|
|
|
|
|
qty: fillForm.value.qty, |
|
|
|
|
|
dictType: fillForm.value.dictType, |
|
|
|
|
|
}); |
|
|
|
|
|
if (requestSeq !== progressRequestSeq) return null; |
|
|
|
|
|
if (code === 0 && body) { |
|
|
|
|
|
progress.value = body; |
|
|
|
|
|
return body; |
|
|
|
|
|
} |
|
|
|
|
|
progress.value = { manuNum: 0, filledNum: 0, remainNum: 0, minutes: 0, warnings: [] }; |
|
|
|
|
|
if (code !== 0) ElMessage({ message: msg || '工时进度查询失败', type: 'error', customClass: 'elmessage-style' }); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
if (requestSeq !== progressRequestSeq) return null; |
|
|
|
|
|
progress.value = { manuNum: 0, filledNum: 0, remainNum: 0, minutes: 0, warnings: [] }; |
|
|
|
|
|
ElMessage({ message: error?.message || '工时进度查询失败,请检查服务连接', type: 'error', customClass: 'elmessage-style' }); |
|
|
} |
|
|
} |
|
|
return null; |
|
|
return null; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const submitFill = async () => { |
|
|
const submitFill = async () => { |
|
|
|
|
|
if (submitting.value) return; |
|
|
const directNormal = fillForm.value.dictType === '正常工时' |
|
|
const directNormal = fillForm.value.dictType === '正常工时' |
|
|
&& directNormalCategories.includes(fillForm.value.category); |
|
|
&& directNormalCategories.includes(fillForm.value.category); |
|
|
const noOrderAbnormal = fillForm.value.dictType === '非正常工时' && fillForm.value.withoutWorkOrder; |
|
|
const noOrderAbnormal = fillForm.value.dictType === '非正常工时' && fillForm.value.withoutWorkOrder; |
|
|
@ -619,20 +681,26 @@ const submitFill = async () => { |
|
|
normalizedFill.workOrderCode = ''; |
|
|
normalizedFill.workOrderCode = ''; |
|
|
normalizedFill.devCode = ''; |
|
|
normalizedFill.devCode = ''; |
|
|
} |
|
|
} |
|
|
const { code, msg, body } = await workhour.fillCreate(normalizedFill); |
|
|
|
|
|
submitting.value = false; |
|
|
|
|
|
if (code === 0) { |
|
|
|
|
|
if (body) progress.value = body; |
|
|
|
|
|
ElMessage({ message: '填报成功', type: 'success', customClass: 'elmessage-style' }); |
|
|
|
|
|
fillVisible.value = false; |
|
|
|
|
|
getList(); |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage({ message: msg, type: 'error', customClass: 'elmessage-style' }); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const { code, msg, body } = await workhour.fillCreate(normalizedFill); |
|
|
|
|
|
if (code === 0) { |
|
|
|
|
|
if (body) progress.value = body; |
|
|
|
|
|
ElMessage({ message: '填报成功', type: 'success', customClass: 'elmessage-style' }); |
|
|
|
|
|
fillVisible.value = false; |
|
|
|
|
|
getList(); |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage({ message: msg || '工时填报失败', type: 'error', customClass: 'elmessage-style' }); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
ElMessage({ message: error?.message || '工时填报失败,请检查服务连接', type: 'error', customClass: 'elmessage-style' }); |
|
|
|
|
|
} finally { |
|
|
|
|
|
submitting.value = false; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// 编辑工时记录 |
|
|
// 编辑工时记录 |
|
|
const editVisible = ref(false); |
|
|
const editVisible = ref(false); |
|
|
|
|
|
const editSubmitting = ref(false); |
|
|
const editForm = ref({ recordId: 0, dictType: '正常工时', workOrderCode: '', productName: '', qty: 0, minutes: 0, workDate: '', remark: '' }); |
|
|
const editForm = ref({ recordId: 0, dictType: '正常工时', workOrderCode: '', productName: '', qty: 0, minutes: 0, workDate: '', remark: '' }); |
|
|
|
|
|
|
|
|
const openEdit = (row) => { |
|
|
const openEdit = (row) => { |
|
|
@ -650,6 +718,7 @@ const openEdit = (row) => { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const submitEdit = async () => { |
|
|
const submitEdit = async () => { |
|
|
|
|
|
if (editSubmitting.value) return; |
|
|
if (editForm.value.qty <= 0 || editForm.value.minutes <= 0) { |
|
|
if (editForm.value.qty <= 0 || editForm.value.minutes <= 0) { |
|
|
ElMessage({ message: '填报数量和工时都必须大于0', type: 'warning', customClass: 'elmessage-style' }); |
|
|
ElMessage({ message: '填报数量和工时都必须大于0', type: 'warning', customClass: 'elmessage-style' }); |
|
|
return; |
|
|
return; |
|
|
@ -659,13 +728,20 @@ const submitEdit = async () => { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
const { recordId, productName, qty, minutes, workDate, remark } = editForm.value; |
|
|
const { recordId, productName, qty, minutes, workDate, remark } = editForm.value; |
|
|
const { code, msg } = await workhour.fillUpdate({ recordId, productName, qty, minutes, workDate, remark }); |
|
|
|
|
|
if (code === 0) { |
|
|
|
|
|
ElMessage({ message: '保存成功', type: 'success', customClass: 'elmessage-style' }); |
|
|
|
|
|
editVisible.value = false; |
|
|
|
|
|
getList(); |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage({ message: msg, type: 'error', customClass: 'elmessage-style' }); |
|
|
|
|
|
|
|
|
editSubmitting.value = true; |
|
|
|
|
|
try { |
|
|
|
|
|
const { code, msg } = await workhour.fillUpdate({ recordId, productName, qty, minutes, workDate, remark }); |
|
|
|
|
|
if (code === 0) { |
|
|
|
|
|
ElMessage({ message: '保存成功', type: 'success', customClass: 'elmessage-style' }); |
|
|
|
|
|
editVisible.value = false; |
|
|
|
|
|
getList(); |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage({ message: msg || '保存失败', type: 'error', customClass: 'elmessage-style' }); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
ElMessage({ message: error?.message || '保存失败,请检查服务连接', type: 'error', customClass: 'elmessage-style' }); |
|
|
|
|
|
} finally { |
|
|
|
|
|
editSubmitting.value = false; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|