minor fix

master
huangjinysf 3 months ago
parent 7805a035c9
commit 9add61c9e9

@ -102,25 +102,15 @@
</template>
<script setup name="WmsImportResult">
import { ref, reactive, toRefs, getCurrentInstance, shallowRef } from 'vue'
import { listWmsImportResult, getWmsImportResult, delWmsImportResult, addWmsImportResult, updateWmsImportResult } from "@/api/warehouse/WmsImportResult"
import { ref, reactive, shallowRef } from 'vue'
import { API_CONFIG } from "@/config/api"
import ParetoAnalysis from './ParetoAnalysis.vue'
import EmptyContent from './EmptyContent.vue'
const { proxy } = getCurrentInstance()
const WmsImportResultList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")
const message = ref("")
const selectedTimeRange = ref("近1年")
const timeRangeOptions = ref([
{ value: "近1年", label: "近1年" },
{ value: "近2年", label: "近2年" },
@ -134,9 +124,6 @@ const dateRange = ref({
start_date: '',
end_date: ''
})
const aiDialogVisible = ref(false)
const aiAnalysisResult = ref("")
const aiAnalysisLoading = ref(false)
//
const currentComponent = shallowRef(EmptyContent)
@ -159,9 +146,6 @@ const data = reactive({
}
})
const { queryParams, form, rules } = toRefs(data)
function handlePareto() {
//
const endDate = new Date();
@ -186,7 +170,7 @@ function handlePareto() {
const startDateStr = formatDate(startDate);
const endDateStr = formatDate(endDate);
console.log(startDateStr, endDateStr);
// console.log(startDateStr, endDateStr);
// API
fetch(`${API_CONFIG.BASE_URL}${API_CONFIG.ENDPOINTS.PARETO_ANALYSIS}?start_date=${startDateStr}&end_date=${endDateStr}`)
.then(response => response.json())
@ -214,84 +198,6 @@ function handleAIAnalysisComplete(result) {
message.value = result;
}
// getList()
//
function getProgressColor(percentage) {
if (percentage >= 30) return '#f56c6c'; // -
if (percentage >= 15) return '#e6a23c'; // -
if (percentage >= 5) return '#409eff'; // -
return '#67c23a'; // 绿 -
}
// AI
async function handleAIAnalysis() {
if (paretoData.value.length === 0) {
message.value = '请先获取帕累托分析数据'
return
}
aiAnalysisLoading.value = true
aiDialogVisible.value = true
aiAnalysisResult.value = '正在分析中,请稍候...'
try {
//
const prompt = `请分析以下帕累托分析数据,提供专业的质量控制见解:
数据范围: ${dateRange.value.start_date} ${dateRange.value.end_date}
检测项目总数: ${paretoData.value.length}
详细数据:
${paretoData.value.map(item =>
`- ${item.item_name}: 缺陷数 ${item.defect_count}, 缺陷占比 ${item.defect_percentage}%, 累计占比 ${item.cumulative_percentage}%`
).join('\n')}
请从以下角度进行分析
1. 主要缺陷项及其影响程度
2. 帕累托原理(80/20法则)在此数据中的体现
3. 针对高缺陷率项的改进建议
4. 质量控制重点优化方向`
// DeepSeek API
const response = await fetch('https://api.deepseek.com/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer sk-4fa66e674e57479d961e4ad2036cbc52`
},
body: JSON.stringify({
model: 'deepseek-chat',
messages: [
{
role: 'system',
content: '你是一位专业的质量控制专家,擅长分析缺陷数据并提供专业的改进建议。'
},
{
role: 'user',
content: prompt
}
],
temperature: 0.7,
max_tokens: 1500
})
})
if (!response.ok) {
throw new Error(`API调用失败: ${response.status}`)
}
const data = await response.json()
const analysisResult = data.choices[0].message.content
aiAnalysisResult.value = analysisResult
//
message.value = analysisResult
} catch (error) {
console.error('AI分析失败:', error)
aiAnalysisResult.value = `AI分析失败: ${error.message}\n\n请检查网络连接或稍后再试。`
} finally {
aiAnalysisLoading.value = false
}
}
</script>

Loading…
Cancel
Save