143 lines
3.0 KiB
Vue
143 lines
3.0 KiB
Vue
<template>
|
|
<div class="test-container">
|
|
<h2>项目审核人配置页面测试</h2>
|
|
|
|
<div class="test-section">
|
|
<h3>1. 数据初始化测试</h3>
|
|
<p>部门选项: {{ deptOptions.length }} 个</p>
|
|
<p>审核人列表: {{ auditorList.length }} 个</p>
|
|
<p>加载状态: {{ loading ? '加载中...' : '已完成' }}</p>
|
|
</div>
|
|
|
|
<div class="test-section">
|
|
<h3>2. API响应测试</h3>
|
|
<el-button @click="testAPI" type="primary">测试API调用</el-button>
|
|
<pre>{{ apiResult }}</pre>
|
|
</div>
|
|
|
|
<div class="test-section">
|
|
<h3>3. 部门选择测试</h3>
|
|
<el-tree-select v-model="selectedDept" :data="deptOptions" placeholder="选择部门" clearable style="width: 300px" />
|
|
<p>选中部门: {{ selectedDept }}</p>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts" name="ProjectAuditorTest">
|
|
import { ref, onMounted } from 'vue';
|
|
import { ElMessage } from 'element-plus';
|
|
|
|
// 测试数据
|
|
const deptOptions = ref<any[]>([]);
|
|
const auditorList = ref<any[]>([]);
|
|
const loading = ref(false);
|
|
const selectedDept = ref();
|
|
const apiResult = ref('');
|
|
|
|
// 模拟部门数据
|
|
const mockDeptOptions = [
|
|
{
|
|
value: '1',
|
|
label: '总公司',
|
|
children: [
|
|
{ value: '2', label: '财务部' },
|
|
{ value: '3', label: '人事部' }
|
|
]
|
|
},
|
|
{
|
|
value: '4',
|
|
label: '分公司',
|
|
children: [
|
|
{ value: '5', label: '技术部' },
|
|
{ value: '6', label: '市场部' }
|
|
]
|
|
}
|
|
];
|
|
|
|
// 模拟API响应数据
|
|
const mockApiResponse = {
|
|
code: 200,
|
|
msg: '操作成功',
|
|
data: {
|
|
rows: [
|
|
{
|
|
id: '1',
|
|
userId: '1001',
|
|
userName: '张三',
|
|
deptName: '财务部',
|
|
status: '1',
|
|
createTime: '2025-01-03 10:00:00'
|
|
},
|
|
{
|
|
id: '2',
|
|
userId: '1002',
|
|
userName: '李四',
|
|
deptName: '人事部',
|
|
status: '1',
|
|
createTime: '2025-01-03 11:00:00'
|
|
}
|
|
],
|
|
total: 2
|
|
}
|
|
};
|
|
|
|
// 测试API调用
|
|
const testAPI = () => {
|
|
loading.value = true;
|
|
|
|
// 模拟异步API调用
|
|
setTimeout(() => {
|
|
try {
|
|
const { data } = mockApiResponse;
|
|
auditorList.value = data?.rows || [];
|
|
apiResult.value = JSON.stringify(data, null, 2);
|
|
|
|
ElMessage.success('API调用成功');
|
|
} catch (error) {
|
|
console.error('API调用失败:', error);
|
|
ElMessage.error('API调用失败');
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}, 1000);
|
|
};
|
|
|
|
// 初始化数据
|
|
const initData = () => {
|
|
deptOptions.value = mockDeptOptions;
|
|
ElMessage.info('测试页面初始化完成');
|
|
};
|
|
|
|
onMounted(() => {
|
|
initData();
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.test-container {
|
|
padding: 20px;
|
|
max-width: 800px;
|
|
}
|
|
|
|
.test-section {
|
|
margin-bottom: 30px;
|
|
padding: 20px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 8px;
|
|
background-color: #f9f9f9;
|
|
}
|
|
|
|
.test-section h3 {
|
|
margin-top: 0;
|
|
color: #409eff;
|
|
}
|
|
|
|
pre {
|
|
background-color: #f4f4f4;
|
|
padding: 10px;
|
|
border-radius: 4px;
|
|
overflow-x: auto;
|
|
font-size: 12px;
|
|
}
|
|
</style>
|