first commit
This commit is contained in:
20
src/views/config/institutionalCenter/i18n/en.ts
Normal file
20
src/views/config/institutionalCenter/i18n/en.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export default {
|
||||
institutionalCenter: {
|
||||
attachmentName: 'File name',
|
||||
inputPlaceholder: 'Enter file name',
|
||||
table: {
|
||||
attachmentName: 'File name',
|
||||
downloadNum: 'Download count',
|
||||
uploader: 'Uploader',
|
||||
uploadTime: 'Upload time',
|
||||
},
|
||||
add: {
|
||||
title: 'Add policy file',
|
||||
uploadFile: 'Upload file',
|
||||
hint: 'Only pdf files are allowed, max 5MB. Only one file per upload.',
|
||||
uploadRequired: 'Please upload a file',
|
||||
cancel: 'Cancel',
|
||||
confirm: 'Confirm'
|
||||
},
|
||||
},
|
||||
};
|
||||
20
src/views/config/institutionalCenter/i18n/zh-cn.ts
Normal file
20
src/views/config/institutionalCenter/i18n/zh-cn.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export default {
|
||||
institutionalCenter: {
|
||||
attachmentName: '文件名',
|
||||
inputPlaceholder: '请输入文件名',
|
||||
table: {
|
||||
attachmentName: '文件名',
|
||||
downloadNum: '下载次数',
|
||||
uploader: '上传人',
|
||||
uploadTime: '上传时间',
|
||||
},
|
||||
add: {
|
||||
title: '添加制度文件',
|
||||
uploadFile: '上传文件',
|
||||
hint: '只能上传 pdf 文件,且不超过 5MB。单次只能上传一个文件。',
|
||||
uploadRequired: '请上传文件',
|
||||
cancel: '取消',
|
||||
confirm: '确认'
|
||||
},
|
||||
},
|
||||
};
|
||||
176
src/views/config/institutionalCenter/index.vue
Normal file
176
src/views/config/institutionalCenter/index.vue
Normal file
@@ -0,0 +1,176 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<el-row class="ml10 mb8">
|
||||
<el-form :inline="true" :model="queryForm" @keyup.enter="getDataList" ref="queryRef">
|
||||
<el-form-item :label="$t('institutionalCenter.attachmentName')">
|
||||
<el-input v-model="queryForm.attachmentName" :placeholder="$t('institutionalCenter.inputPlaceholder')" style="max-width:240px" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" @click="getDataList">{{ $t('common.queryBtn') }}</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">{{ $t('common.resetBtn') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<div class="mb8" style="width:100%">
|
||||
<el-button v-if="!isReadonly" class="ml10" type="primary" icon="folder-add" @click="openAddDialog">{{ $t('common.addBtn') }}</el-button>
|
||||
<right-toolbar style="float: right; margin-right:20px" @queryTable="getDataList" />
|
||||
</div>
|
||||
</el-row>
|
||||
|
||||
<el-table :data="state.dataList" style="width:100%" v-loading="state.loading" border row-key="id">
|
||||
<el-table-column type="index" label="#" width="60" />
|
||||
<el-table-column prop="attachmentName" :label="$t('institutionalCenter.table.attachmentName')" />
|
||||
<el-table-column prop="downloadNum" :label="$t('institutionalCenter.table.downloadNum')" />
|
||||
<el-table-column prop="createBy" :label="$t('institutionalCenter.table.uploader')" />
|
||||
<el-table-column prop="createTime" :label="$t('institutionalCenter.table.uploadTime')" width="180" />
|
||||
<el-table-column :label="$t('common.action')" width="200">
|
||||
<template #default="{ row }">
|
||||
<el-button text size="small" type="primary" icon="download" @click="handleDownload(row)">{{ $t('common.download') }}</el-button>
|
||||
<el-button v-if="!isReadonly" text size="small" type="primary" icon="delete" @click="handleDelete(row.id)">{{ $t('common.delBtn') }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle" />
|
||||
|
||||
<!-- Add Dialog -->
|
||||
<el-dialog :title="$t('institutionalCenter.add.title')" v-model="addDialogVisible" width="540px">
|
||||
<div>
|
||||
<el-form ref="addFormRef" :model="addForm">
|
||||
<el-form-item>
|
||||
<UploadFile :fileSize="5" :fileType="['pdf']" :limit="1" @change="handleFileChange" />
|
||||
<!-- <div class="mt8 text-gray-500 text-sm">{{ $t('institutionalCenter.add.hint') }}</div> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="addDialogVisible = false">{{ $t('institutionalCenter.add.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="submitAdd" :loading="addLoading">{{ $t('institutionalCenter.add.confirm') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import UploadFile from '/@/components/Upload/index.vue';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { fetchCompanyPoliciesPage, addCompanyPolicy, downloadCompanyPolicyCount, deleteCompanyPolicies } from '/@/api/config/institutionalCenter';
|
||||
import type { CompanyPolicyItem } from '/@/api/config/institutionalCenter/types';
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute()
|
||||
const message = useMessage();
|
||||
|
||||
// query form
|
||||
const queryForm = reactive({ attachmentName: '' });
|
||||
|
||||
const state: BasicTableProps = reactive({
|
||||
queryForm,
|
||||
pageList: fetchCompanyPoliciesPage,
|
||||
});
|
||||
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, downBlobFile } = useTable(state);
|
||||
|
||||
// dialog / add
|
||||
const addDialogVisible = ref(false);
|
||||
const addFormRef = ref();
|
||||
const addLoading = ref(false);
|
||||
const addForm = reactive({ attachmentName: '', attachmentUrl: '' });
|
||||
|
||||
const openAddDialog = () => {
|
||||
addForm.attachmentName = '';
|
||||
addForm.attachmentUrl = '';
|
||||
addDialogVisible.value = true;
|
||||
};
|
||||
|
||||
const handleFileChange = (url: string, files: File[]) => {
|
||||
if (files && files.length) {
|
||||
addForm.attachmentName = files[0].name;
|
||||
addForm.attachmentUrl = url;
|
||||
} else {
|
||||
addForm.attachmentName = '';
|
||||
addForm.attachmentUrl = '';
|
||||
}
|
||||
}
|
||||
|
||||
const submitAdd = async () => {
|
||||
if (!addForm.attachmentUrl) {
|
||||
message.warning(t('institutionalCenter.add.uploadRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
addLoading.value = true;
|
||||
try {
|
||||
await addCompanyPolicy(addForm);
|
||||
message.success(t('common.addSuccess') || '添加成功');
|
||||
addDialogVisible.value = false;
|
||||
getDataList();
|
||||
} catch (err: any) {
|
||||
message.error(err?.msg || err?.message || t('common.operateFail') || '提交失败');
|
||||
} finally {
|
||||
addLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const extractFileName = (url: string) => {
|
||||
if (!url) return '';
|
||||
if (url.includes('fileName=')) return decodeURIComponent(url.split('fileName=')[1]);
|
||||
return url.split('/').pop() || url;
|
||||
};
|
||||
|
||||
const handleDelete = async (ids: string) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await deleteCompanyPolicies(ids);
|
||||
message.success(t('common.delSuccessText'));
|
||||
getDataList();
|
||||
} catch (err: any) {
|
||||
message.error(err?.msg || err?.message || t('common.operateFail'));
|
||||
}
|
||||
};
|
||||
|
||||
const handleDownload = async (row: CompanyPolicyItem) => {
|
||||
if (!row?.id || !row.attachmentUrl) return;
|
||||
try {
|
||||
await downloadCompanyPolicyCount(row.id);
|
||||
} catch (e) {
|
||||
// ignore counting errors
|
||||
}
|
||||
// 下载文件
|
||||
downBlobFile(row.attachmentUrl!, {}, row.attachmentName || extractFileName(row.attachmentUrl!));
|
||||
getDataList()
|
||||
};
|
||||
|
||||
const resetQuery = () => {
|
||||
queryForm.attachmentName = '';
|
||||
getDataList();
|
||||
};
|
||||
|
||||
const isReadonly = ref(false)
|
||||
onMounted(() => {
|
||||
isReadonly.value = route.query.from === 'workbench'
|
||||
})
|
||||
|
||||
// initial fetch
|
||||
getDataList();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.layout-container .layout-padding-view {
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
25
src/views/config/projectReviewPolicy/i18n/en.ts
Normal file
25
src/views/config/projectReviewPolicy/i18n/en.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export default {
|
||||
projectReviewPolicy: {
|
||||
title: 'Post-Investment Review Policy',
|
||||
index: '#',
|
||||
projectType: 'Project Type',
|
||||
finalReminderPeriod: 'Final Reminder Period',
|
||||
advanceReminder: 'Advance Reminder',
|
||||
action: 'Actions',
|
||||
addRow: 'Add Row',
|
||||
saveAll: 'Save All',
|
||||
selectProjectType: 'Please select project type',
|
||||
year: 'year(s)',
|
||||
day: 'day(s)',
|
||||
advance: 'Advance ',
|
||||
none: 'None',
|
||||
infrastructure: 'Infrastructure Project',
|
||||
industrial: 'Industrial Project',
|
||||
civilEngineering: 'Civil Engineering Project',
|
||||
other: 'Other Project',
|
||||
saveSuccess: 'Saved successfully',
|
||||
updateSuccess: 'Updated successfully',
|
||||
deleteSuccess: 'Deleted successfully',
|
||||
saveAllSuccess: 'All saved successfully'
|
||||
}
|
||||
};
|
||||
25
src/views/config/projectReviewPolicy/i18n/zh-cn.ts
Normal file
25
src/views/config/projectReviewPolicy/i18n/zh-cn.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export default {
|
||||
projectReviewPolicy: {
|
||||
title: '投后评价策略配置',
|
||||
index: '#',
|
||||
projectType: '项目类型',
|
||||
finalReminderPeriod: '最后提醒期限',
|
||||
advanceReminder: '提前提醒',
|
||||
action: '操作',
|
||||
addRow: '添加行',
|
||||
saveAll: '保存全部',
|
||||
selectProjectType: '请选择项目类型',
|
||||
year: '年',
|
||||
day: '天',
|
||||
advance: '提前',
|
||||
none: '无',
|
||||
infrastructure: '基础设施项目',
|
||||
industrial: '工业项目',
|
||||
civilEngineering: '民用建筑工程',
|
||||
other: '其他项目',
|
||||
saveSuccess: '保存成功',
|
||||
updateSuccess: '更新成功',
|
||||
deleteSuccess: '删除成功',
|
||||
saveAllSuccess: '全部保存成功'
|
||||
}
|
||||
};
|
||||
259
src/views/config/projectReviewPolicy/index.vue
Normal file
259
src/views/config/projectReviewPolicy/index.vue
Normal file
@@ -0,0 +1,259 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<el-card shadow="never" class="mb-4 overflow-auto">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<div class="flex items-center">
|
||||
<el-button type="primary" icon="plus" @click="handleAddRow">
|
||||
{{ $t('projectReviewPolicy.addRow') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table
|
||||
:data="state.dataList"
|
||||
style="width: 100%"
|
||||
v-loading="state.loading"
|
||||
border
|
||||
row-key="id"
|
||||
>
|
||||
<el-table-column type="index" :label="$t('projectReviewPolicy.index')" width="60" />
|
||||
|
||||
<el-table-column prop="projectType" :label="$t('projectReviewPolicy.projectType')">
|
||||
<template #default="{ row, $index }">
|
||||
<el-select
|
||||
v-model="row.projectType"
|
||||
:placeholder="$t('projectReviewPolicy.selectProjectType')"
|
||||
@change="handleFieldChange($index)"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in projectTypeOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :label="$t('projectReviewPolicy.finalReminderPeriod')">
|
||||
<template #default="{ row, $index }">
|
||||
<el-select
|
||||
v-model="row.finalReminderPeriod"
|
||||
@change="handleFieldChange($index)"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in finalReminderPeriodOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :label="$t('projectReviewPolicy.advanceReminder')">
|
||||
<template #default="{ row, $index }">
|
||||
<el-select
|
||||
v-model="row.advanceReminderPeriod"
|
||||
@change="handleFieldChange($index)"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in advanceReminderPeriodOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :label="$t('projectReviewPolicy.action')" width="120">
|
||||
<template #default="{ row, $index }">
|
||||
<el-button
|
||||
text
|
||||
size="small"
|
||||
type="danger"
|
||||
icon="delete"
|
||||
@click="handleDeleteRow($index, row)"
|
||||
>
|
||||
{{ $t('common.delBtn') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="mt-4 flex justify-end">
|
||||
<el-button type="primary" @click="handleSaveAll" :loading="saving">
|
||||
{{ $t('projectReviewPolicy.saveAll') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import {
|
||||
fetchProjectReviewPolicyPage,
|
||||
addProjectReviewPolicy,
|
||||
updateProjectReviewPolicy,
|
||||
deleteProjectReviewPolicy
|
||||
} from '/@/api/config/projectReviewPolicy';
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
const { t } = useI18n();
|
||||
const message = useMessage();
|
||||
|
||||
// 定义项目类型选项
|
||||
const projectTypeOptions = ref([
|
||||
{ value: '1', label: t('projectReviewPolicy.infrastructure') },
|
||||
{ value: '2', label: t('projectReviewPolicy.industrial') },
|
||||
{ value: '3', label: t('projectReviewPolicy.civilEngineering') },
|
||||
{ value: '4', label: t('projectReviewPolicy.other') }
|
||||
]);
|
||||
|
||||
// 最后提醒期限选项 (1-9年)
|
||||
const finalReminderPeriodOptions = ref([
|
||||
{ value: 1, label: '1' + t('projectReviewPolicy.year') },
|
||||
{ value: 2, label: '2' + t('projectReviewPolicy.year') },
|
||||
{ value: 3, label: '3' + t('projectReviewPolicy.year') },
|
||||
{ value: 4, label: '4' + t('projectReviewPolicy.year') },
|
||||
{ value: 5, label: '5' + t('projectReviewPolicy.year') },
|
||||
{ value: 6, label: '6' + t('projectReviewPolicy.year') },
|
||||
{ value: 7, label: '7' + t('projectReviewPolicy.year') },
|
||||
{ value: 8, label: '8' + t('projectReviewPolicy.year') },
|
||||
{ value: 9, label: '9' + t('projectReviewPolicy.year') }
|
||||
]);
|
||||
|
||||
// 提前提醒选项 (无、提前3、15、30、60、90天)
|
||||
const advanceReminderPeriodOptions = ref([
|
||||
{ value: 0, label: t('projectReviewPolicy.none') },
|
||||
{ value: 3, label: t('projectReviewPolicy.advance') + '3' + t('projectReviewPolicy.day') },
|
||||
{ value: 15, label: t('projectReviewPolicy.advance') + '15' + t('projectReviewPolicy.day') },
|
||||
{ value: 30, label: t('projectReviewPolicy.advance') + '30' + t('projectReviewPolicy.day') },
|
||||
{ value: 60, label: t('projectReviewPolicy.advance') + '60' + t('projectReviewPolicy.day') },
|
||||
{ value: 90, label: t('projectReviewPolicy.advance') + '90' + t('projectReviewPolicy.day') }
|
||||
]);
|
||||
|
||||
// 表格状态
|
||||
const state = reactive({
|
||||
dataList: [] as any[],
|
||||
loading: false,
|
||||
});
|
||||
|
||||
// 保存状态
|
||||
const saving = ref(false);
|
||||
|
||||
// 防抖保存函数
|
||||
const debouncedSave = debounce(async (row, type) => {
|
||||
try {
|
||||
if (type === 'add') {
|
||||
const res = await addProjectReviewPolicy(row);
|
||||
// 更新ID
|
||||
row.id = res.data?.id || row.id;
|
||||
message.success(t('projectReviewPolicy.saveSuccess'));
|
||||
} else if (type === 'update') {
|
||||
await updateProjectReviewPolicy(row);
|
||||
message.success(t('projectReviewPolicy.updateSuccess'));
|
||||
}
|
||||
} catch (err: any) {
|
||||
message.error(err?.msg || err?.message || t('common.operateFail'));
|
||||
}
|
||||
}, 800);
|
||||
|
||||
// 字段变更处理
|
||||
const handleFieldChange = (index: number) => {
|
||||
const row = state.dataList[index];
|
||||
if (!row) return;
|
||||
|
||||
// 如果是新行且没有ID,则添加
|
||||
if (!row.id || row.id === '') {
|
||||
debouncedSave(row, 'add');
|
||||
} else {
|
||||
// 否则更新现有行
|
||||
debouncedSave(row, 'update');
|
||||
}
|
||||
};
|
||||
|
||||
// 添加行
|
||||
const handleAddRow = () => {
|
||||
state.dataList.push({
|
||||
id: '',
|
||||
projectType: '',
|
||||
finalReminderPeriod: 1,
|
||||
finalReminderUnit: '年',
|
||||
advanceReminderPeriod: 30,
|
||||
advanceReminderUnit: '天',
|
||||
createTime: ''
|
||||
});
|
||||
};
|
||||
|
||||
// 删除行
|
||||
const handleDeleteRow = async (index: number, row: any) => {
|
||||
try {
|
||||
if (row.id) {
|
||||
// 如果有ID,从服务器删除
|
||||
await deleteProjectReviewPolicy(row.id);
|
||||
}
|
||||
|
||||
// 从前端列表中移除
|
||||
state.dataList.splice(index, 1);
|
||||
message.success(t('projectReviewPolicy.deleteSuccess'));
|
||||
} catch (err: any) {
|
||||
message.error(err?.msg || err?.message || t('common.operateFail'));
|
||||
}
|
||||
};
|
||||
|
||||
// 保存所有数据
|
||||
const handleSaveAll = async () => {
|
||||
saving.value = true;
|
||||
try {
|
||||
// 取消所有待处理的防抖调用
|
||||
debouncedSave.cancel();
|
||||
|
||||
// 处理所有未保存的数据
|
||||
const promises = state.dataList.map(item => {
|
||||
if (!item.id || item.id === '') {
|
||||
return addProjectReviewPolicy(item);
|
||||
} else {
|
||||
return updateProjectReviewPolicy(item);
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
message.success(t('projectReviewPolicy.saveAllSuccess'));
|
||||
await getDataList();
|
||||
} catch (err: any) {
|
||||
message.error(err?.msg || err?.message || t('common.operateFail'));
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 获取数据列表
|
||||
const getDataList = async () => {
|
||||
try {
|
||||
state.loading = true;
|
||||
const res = await fetchProjectReviewPolicyPage({ page: 1, size: 1000 });
|
||||
state.dataList = res.data?.records || [];
|
||||
} catch (err: any) {
|
||||
message.error(err?.msg || err?.message || t('common.operateFail'));
|
||||
} finally {
|
||||
state.loading = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化加载数据
|
||||
onMounted(() => {
|
||||
getDataList();
|
||||
});
|
||||
</script>
|
||||
16
src/views/config/templateManage/i18n/en.ts
Normal file
16
src/views/config/templateManage/i18n/en.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export default {
|
||||
templateManage: {
|
||||
templateName: 'Template Name',
|
||||
inputPlaceholder: 'Please enter template name',
|
||||
table: {
|
||||
templateName: 'Template Name',
|
||||
templateType: 'Template Type',
|
||||
createTime: 'Create Time',
|
||||
viewBtn: 'Preview',
|
||||
},
|
||||
templateTypeMap: {
|
||||
contract: 'Contract Template',
|
||||
document: 'Document Template',
|
||||
},
|
||||
},
|
||||
};
|
||||
16
src/views/config/templateManage/i18n/zh-cn.ts
Normal file
16
src/views/config/templateManage/i18n/zh-cn.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export default {
|
||||
templateManage: {
|
||||
templateName: '模板名称',
|
||||
inputPlaceholder: '请输入模板名称',
|
||||
table: {
|
||||
templateName: '模板名称',
|
||||
templateType: '模板类型',
|
||||
createTime: '创建时间',
|
||||
viewBtn: '预览',
|
||||
},
|
||||
templateTypeMap: {
|
||||
contract: '合同模板',
|
||||
document: '文档模板',
|
||||
},
|
||||
},
|
||||
};
|
||||
96
src/views/config/templateManage/index.vue
Normal file
96
src/views/config/templateManage/index.vue
Normal file
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<el-row class="ml10 mb8">
|
||||
<el-form :inline="true" :model="queryForm" @keyup.enter="getDataList" ref="queryRef">
|
||||
<el-form-item :label="$t('templateManage.templateName')">
|
||||
<el-input v-model="queryForm.templateName" :placeholder="$t('templateManage.inputPlaceholder')" style="max-width:240px" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" @click="getDataList">{{ $t('common.queryBtn') }}</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">{{ $t('common.resetBtn') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
|
||||
<el-table :data="state.dataList" style="width:100%" v-loading="state.loading" border row-key="id">
|
||||
<el-table-column type="index" label="#" width="60" />
|
||||
<el-table-column prop="templateName" :label="$t('templateManage.table.templateName')" />
|
||||
<el-table-column prop="templateType" :label="$t('templateManage.table.templateType')">
|
||||
<template #default="{ row }">
|
||||
{{ getTypeName(row.templateType) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" :label="$t('templateManage.table.createTime')" width="180" />
|
||||
<el-table-column :label="$t('common.action')" width="160">
|
||||
<template #default="{ row }">
|
||||
<el-button text size="small" type="primary" icon="view">{{ $t('templateManage.table.viewBtn') }}</el-button>
|
||||
<el-button text size="small" type="primary" icon="delete" @click="handleDelete(row.id)">{{ $t('common.delBtn') }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { fetchTemplatesPage, deleteTemplate } from '/@/api/config/templateManage';
|
||||
import { flowNameOptions } from '/@/hooks/enums';
|
||||
|
||||
const { t } = useI18n();
|
||||
const message = useMessage();
|
||||
|
||||
const getTypeName = (templateType: number) => {
|
||||
const option = flowNameOptions.find(item => item.value === templateType)
|
||||
if (option) {
|
||||
return t(`flowTypes.${option.label}`)
|
||||
}
|
||||
return templateType
|
||||
}
|
||||
|
||||
// query form
|
||||
const queryForm = reactive({ templateName: '' });
|
||||
|
||||
const state: BasicTableProps = reactive({
|
||||
queryForm,
|
||||
pageList: fetchTemplatesPage,
|
||||
});
|
||||
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle } = useTable(state);
|
||||
|
||||
const handleDelete = async (ids: string) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await deleteTemplate(ids);
|
||||
message.success(t('common.delSuccessText'));
|
||||
getDataList();
|
||||
} catch (err: any) {
|
||||
message.error(err?.msg || err?.message || t('common.operateFail'));
|
||||
}
|
||||
};
|
||||
|
||||
const resetQuery = () => {
|
||||
queryForm.templateName = '';
|
||||
getDataList();
|
||||
};
|
||||
|
||||
// initial fetch
|
||||
getDataList();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.layout-container .layout-padding-view {
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user