|
|
@@ -0,0 +1,384 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
+ <el-form-item label="模板名称" prop="templateName">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.templateName"
|
|
|
+ placeholder="请输入模板名称"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="Plus"
|
|
|
+ @click="handleAdd"
|
|
|
+ v-hasPermi="['biz:mapping:add']"
|
|
|
+ >新增</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="success"
|
|
|
+ plain
|
|
|
+ icon="Edit"
|
|
|
+ :disabled="single"
|
|
|
+ @click="handleUpdate"
|
|
|
+ v-hasPermi="['biz:mapping:edit']"
|
|
|
+ >修改</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ plain
|
|
|
+ icon="Delete"
|
|
|
+ :disabled="multiple"
|
|
|
+ @click="handleDelete"
|
|
|
+ v-hasPermi="['biz:mapping:remove']"
|
|
|
+ >删除</el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-table v-loading="loading" :data="mappingList" @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+ <el-table-column label="自增ID" align="center" prop="autoId" />
|
|
|
+ <el-table-column label="模板名称" align="center" prop="templateName" />
|
|
|
+ <el-table-column label="数据开始行" align="center" prop="startRow" />
|
|
|
+ <el-table-column label="映射明细" align="center" prop="mappingDetail" />
|
|
|
+ <el-table-column label="创建人" align="center" prop="createBy" />
|
|
|
+ <el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="更新人" align="center" prop="updateBy" />
|
|
|
+ <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="备注" align="center" prop="remark" />
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['biz:mapping:edit']">修改</el-button>
|
|
|
+ <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['biz:mapping:remove']">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination
|
|
|
+ v-show="total>0"
|
|
|
+ :total="total"
|
|
|
+ v-model:page="queryParams.pageNum"
|
|
|
+ v-model:limit="queryParams.pageSize"
|
|
|
+ @pagination="getList"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 添加或修改Excel字段映射对话框 -->
|
|
|
+ <el-dialog :title="title" v-model="open" width="800px" append-to-body>
|
|
|
+ <el-form ref="mappingRef" :model="form" :rules="rules" label-width="100px">
|
|
|
+ <el-form-item label="模板名称" prop="templateName">
|
|
|
+ <el-input v-model="form.templateName" placeholder="请输入模板名称" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="数据开始行" prop="startRow">
|
|
|
+ <el-input v-model="form.startRow" placeholder="请输入数据开始行" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="映射明细" prop="mappingDetail">
|
|
|
+ <el-button type="primary" @click="addMappingDetailItem" icon="Plus" style="margin-bottom: 10px">添加映射项</el-button>
|
|
|
+ <el-table :data="mappingDetailList" style="width: 100%">
|
|
|
+ <el-table-column prop="col" label="Excel列" width="180">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-input
|
|
|
+ v-model="row.col"
|
|
|
+ placeholder="输入Excel列如AA"
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="field" label="字段" width="250">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-select
|
|
|
+ v-model="row.field"
|
|
|
+ placeholder="选择字段"
|
|
|
+ filterable
|
|
|
+ allow-create
|
|
|
+ default-first-option
|
|
|
+ :reserve-keyword="false"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in personnelFlowFields"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="120">
|
|
|
+ <template #default="{ row, $index }">
|
|
|
+ <el-button link type="primary" @click="removeMappingDetailItem($index)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注" prop="remark">
|
|
|
+ <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup name="Mapping">
|
|
|
+import { listMapping, getMapping, delMapping, addMapping, updateMapping } from "@/api/biz/mapping";
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance();
|
|
|
+
|
|
|
+const mappingList = 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("");
|
|
|
+
|
|
|
+// 定义 PersonnelFlow 类的字段列表
|
|
|
+const personnelFlowFields = [
|
|
|
+ { label: "人员类别代码", value: "personnelCategoryCode" },
|
|
|
+ { label: "人员类别名称", value: "personnelCategoryName" },
|
|
|
+ { label: "姓名", value: "fullName" },
|
|
|
+ { label: "性别代码", value: "genderCode" },
|
|
|
+ { label: "性别中文", value: "genderCn" },
|
|
|
+ { label: "出生日期", value: "birthDate" },
|
|
|
+ { label: "国家地区代码", value: "countryCode" },
|
|
|
+ { label: "国家地区名称", value: "countryName" },
|
|
|
+ { label: "证件类别代码", value: "idTypeCode" },
|
|
|
+ { label: "证件类别名称", value: "idTypeName" },
|
|
|
+ { label: "证件号码", value: "idNumber" },
|
|
|
+ { label: "签证类型代码", value: "visaTypeCode" },
|
|
|
+ { label: "签证类型名称", value: "visaTypeName" },
|
|
|
+ { label: "签证号码", value: "visaNumber" },
|
|
|
+ { label: "停留期", value: "stayDuration" },
|
|
|
+ { label: "民族代码", value: "ethnicityCode" },
|
|
|
+ { label: "民族名称", value: "ethnicityName" },
|
|
|
+ { label: "出入标识", value: "inOutFlag" },
|
|
|
+ { label: "出入时间", value: "inOutTime" },
|
|
|
+ { label: "出入口岸代码", value: "portCode" },
|
|
|
+ { label: "出入口岸名称", value: "portName" },
|
|
|
+ { label: "交通方式", value: "transportMode" },
|
|
|
+ { label: "交通工具", value: "transportVehicle" },
|
|
|
+ { label: "前往地/出发地代码", value: "destinationCode" },
|
|
|
+ { label: "前往地/出发地名称", value: "destinationName" },
|
|
|
+ { label: "发证机关代码", value: "issuingAuthorityCode" },
|
|
|
+ { label: "发证机关名称", value: "issuingAuthorityName" },
|
|
|
+ { label: "出入境事由代码", value: "reasonCode" },
|
|
|
+ { label: "出入境事由名称", value: "reasonName" },
|
|
|
+ { label: "自定义代码", value: "customCode" },
|
|
|
+ { label: "自定义描述名称", value: "customDescription" },
|
|
|
+ { label: "自助通道标记", value: "selfServiceFlag" },
|
|
|
+ { label: "后台补录标记", value: "backfillFlag" },
|
|
|
+];
|
|
|
+
|
|
|
+// 映射明细相关变量
|
|
|
+const mappingDetailList = ref([]);
|
|
|
+
|
|
|
+// 导入图标
|
|
|
+import { Plus } from '@element-plus/icons-vue'
|
|
|
+const currentMappingIndex = ref(-1);
|
|
|
+
|
|
|
+// 添加映射明细项
|
|
|
+function addMappingDetailItem() {
|
|
|
+ mappingDetailList.value.push({
|
|
|
+ col: '',
|
|
|
+ field: ''
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 删除映射明细项
|
|
|
+function removeMappingDetailItem(index) {
|
|
|
+ mappingDetailList.value.splice(index, 1);
|
|
|
+}
|
|
|
+
|
|
|
+// 将映射明细列表转换为字符串格式
|
|
|
+function convertMappingDetailListToString() {
|
|
|
+ return JSON.stringify(mappingDetailList.value);
|
|
|
+}
|
|
|
+
|
|
|
+// 将字符串格式的映射明细转换为列表
|
|
|
+function convertStringToMappingDetailList(str) {
|
|
|
+ if (!str) return [];
|
|
|
+ try {
|
|
|
+ const parsed = JSON.parse(str);
|
|
|
+ return Array.isArray(parsed) ? parsed : [];
|
|
|
+ } catch (e) {
|
|
|
+ console.error('解析映射明细失败:', e);
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 准备表单数据,包括映射明细
|
|
|
+function prepareFormData() {
|
|
|
+ // 将映射明细列表转换为字符串并赋值给表单
|
|
|
+ form.value.mappingDetail = convertMappingDetailListToString();
|
|
|
+}
|
|
|
+
|
|
|
+// 初始化映射明细用于编辑
|
|
|
+function initMappingDetailForEdit(data) {
|
|
|
+ mappingDetailList.value = convertStringToMappingDetailList(data.mappingDetail);
|
|
|
+}
|
|
|
+
|
|
|
+const data = reactive({
|
|
|
+ form: {},
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ templateName: null,
|
|
|
+ startRow: null,
|
|
|
+ mappingDetail: null,
|
|
|
+ createBy: null,
|
|
|
+ createTime: null,
|
|
|
+ updateBy: null,
|
|
|
+ updateTime: null,
|
|
|
+ remark: null
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const { queryParams, form, rules } = toRefs(data);
|
|
|
+
|
|
|
+/** 查询Excel字段映射列表 */
|
|
|
+function getList() {
|
|
|
+ loading.value = true;
|
|
|
+ listMapping(queryParams.value).then(response => {
|
|
|
+ mappingList.value = response.rows;
|
|
|
+ total.value = response.total;
|
|
|
+ loading.value = false;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 取消按钮
|
|
|
+function cancel() {
|
|
|
+ open.value = false;
|
|
|
+ reset();
|
|
|
+}
|
|
|
+
|
|
|
+// 表单重置
|
|
|
+function reset() {
|
|
|
+ form.value = {
|
|
|
+ autoId: null,
|
|
|
+ templateName: null,
|
|
|
+ startRow: null,
|
|
|
+ mappingDetail: null,
|
|
|
+ createBy: null,
|
|
|
+ createTime: null,
|
|
|
+ updateBy: null,
|
|
|
+ updateTime: null,
|
|
|
+ remark: null
|
|
|
+ };
|
|
|
+ proxy.resetForm("mappingRef");
|
|
|
+}
|
|
|
+
|
|
|
+/** 搜索按钮操作 */
|
|
|
+function handleQuery() {
|
|
|
+ queryParams.value.pageNum = 1;
|
|
|
+ getList();
|
|
|
+}
|
|
|
+
|
|
|
+/** 重置按钮操作 */
|
|
|
+function resetQuery() {
|
|
|
+ proxy.resetForm("queryRef");
|
|
|
+ handleQuery();
|
|
|
+}
|
|
|
+
|
|
|
+// 多选框选中数据
|
|
|
+function handleSelectionChange(selection) {
|
|
|
+ ids.value = selection.map(item => item.autoId);
|
|
|
+ single.value = selection.length != 1;
|
|
|
+ multiple.value = !selection.length;
|
|
|
+}
|
|
|
+
|
|
|
+/** 新增按钮操作 */
|
|
|
+function handleAdd() {
|
|
|
+ reset();
|
|
|
+ open.value = true;
|
|
|
+ title.value = "添加Excel字段映射";
|
|
|
+ // 初始化时添加所有PersonnelFlow字段的映射项,这样新增时所有字段都显示在界面上
|
|
|
+ mappingDetailList.value = personnelFlowFields.map(field => ({
|
|
|
+ col: '', // Excel列初始为空,用户可以输入如AA、AB等
|
|
|
+ field: field.value // 字段使用PersonnelFlow中的字段
|
|
|
+ }));
|
|
|
+}
|
|
|
+
|
|
|
+/** 修改按钮操作 */
|
|
|
+function handleUpdate(row) {
|
|
|
+ reset();
|
|
|
+ const _autoId = row.autoId || ids.value
|
|
|
+ getMapping(_autoId).then(response => {
|
|
|
+ form.value = response.data;
|
|
|
+ initMappingDetailForEdit(response.data);
|
|
|
+ open.value = true;
|
|
|
+ title.value = "修改Excel字段映射";
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/** 提交按钮 */
|
|
|
+function submitForm() {
|
|
|
+ proxy.$refs["mappingRef"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ // 准备表单数据,包括映射明细
|
|
|
+ prepareFormData();
|
|
|
+ if (form.value.autoId != null) {
|
|
|
+ updateMapping(form.value).then(response => {
|
|
|
+ proxy.$modal.msgSuccess("修改成功");
|
|
|
+ open.value = false;
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addMapping(form.value).then(response => {
|
|
|
+ proxy.$modal.msgSuccess("新增成功");
|
|
|
+ open.value = false;
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/** 删除按钮操作 */
|
|
|
+function handleDelete(row) {
|
|
|
+ const _autoIds = row.autoId || ids.value;
|
|
|
+ proxy.$modal.confirm('是否确认删除Excel字段映射编号为"' + _autoIds + '"的数据项?').then(function() {
|
|
|
+ return delMapping(_autoIds);
|
|
|
+ }).then(() => {
|
|
|
+ getList();
|
|
|
+ proxy.$modal.msgSuccess("删除成功");
|
|
|
+ }).catch(() => {});
|
|
|
+}
|
|
|
+
|
|
|
+/** 导出按钮操作 */
|
|
|
+function handleExport() {
|
|
|
+ proxy.download('biz/mapping/export', {
|
|
|
+ ...queryParams.value
|
|
|
+ }, `mapping_${new Date().getTime()}.xlsx`)
|
|
|
+}
|
|
|
+
|
|
|
+getList();
|
|
|
+</script>
|