数据导出模板新增NameCN字段
continuous-integration/drone/push Build is passing Details

uat_us
DESKTOP-6C3NK6N\WXS 2024-08-06 17:04:48 +08:00
parent e98e826328
commit 0b49bd8dab
2 changed files with 282 additions and 191 deletions

View File

@ -3,7 +3,7 @@
ref="sysTemplateFrom"
v-loading="loading"
:model="form"
label-width="90px"
label-width="140px"
size="small"
:rules="rules"
class="upload-temporary-file"
@ -12,10 +12,13 @@
<el-form-item label="Code" prop="Code">
<el-input v-model="form.Code" />
</el-form-item>
<el-form-item label="业务场景: " prop="BusinessScenarioEnum">
<el-form-item
:label="$t('dictionary:attachment:export:form:business')"
prop="BusinessScenarioEnum"
>
<el-select
v-model="form.BusinessScenarioEnum"
style="width:100%;"
style="width: 100%"
size="small"
filterable
>
@ -27,7 +30,7 @@
/>
</el-select>
</el-form-item>
<el-form-item label="文件: ">
<el-form-item :label="$t('dictionary:attachment:export:form:file')">
<div class="upload-container">
<el-upload
class="upload-demo"
@ -43,84 +46,123 @@
:on-exceed="handleExceed"
:disabled="!form.FileTypeEnum || !form.BusinessScenarioEnum"
>
<el-button size="small" type="primary" :disabled="!form.FileTypeEnum || !form.BusinessScenarioEnum" :loading="btnLoading">Select</el-button>
<span
slot="tip"
style="margin-left:10px;"
class="el-upload__tip"
<el-button
size="small"
type="primary"
:disabled="!form.FileTypeEnum || !form.BusinessScenarioEnum"
:loading="btnLoading"
>Select</el-button
>
<span slot="tip" style="margin-left: 10px" class="el-upload__tip">
(must be in xlsx/xls/doc/docx format)
</span>
</el-upload>
</div>
</el-form-item>
<el-form-item label="文件名" prop="Name">
<el-form-item
:label="$t('dictionary:attachment:export:form:name')"
prop="Name"
>
<el-input v-model="form.Name" />
</el-form-item>
<el-form-item v-if="form.Id !== ''" label="是否废除: ">
<el-form-item
:label="$t('dictionary:attachment:export:form:nameCN')"
prop="NameCN"
>
<el-input v-model="form.NameCN" />
</el-form-item>
<el-form-item
v-if="form.Id !== ''"
:label="$t('dictionary:attachment:export:form:isDeleted')"
>
<el-radio-group v-model="form.IsDeleted">
<el-radio :label="true"></el-radio>
<el-radio :label="false"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="描述">
<el-form-item
:label="$t('dictionary:attachment:export:form:description')"
>
<el-input
v-model="form.Description"
type="textarea"
:autosize="{ minRows: 2, maxRows: 4}"
placeholder="请输入内容"
:autosize="{ minRows: 2, maxRows: 4 }"
placeholder=""
/>
</el-form-item>
</div>
<div class="base-dialog-footer" style="text-align:right;margin-top:10px;">
<el-form-item style="text-align:right;">
<el-button size="small" type="primary" :disabled="!form.FileTypeEnum || !form.BusinessScenarioEnum" :loading="saveBtnLoading" @click="handleSave">Save</el-button>
<div class="base-dialog-footer" style="text-align: right; margin-top: 10px">
<el-form-item style="text-align: right">
<el-button
size="small"
type="primary"
:disabled="!form.FileTypeEnum || !form.BusinessScenarioEnum"
:loading="saveBtnLoading"
@click="handleSave"
>{{ $t("common:button:save") }}</el-button
>
</el-form-item>
</div>
</el-form>
</template>
<script>
import { addOrUpdateCommonDocument, uploadCommonDoc, Upload } from '@/api/dictionary'
import { getBasicDataSelects } from '@/api/dictionary/dictionary'
import {
addOrUpdateCommonDocument,
uploadCommonDoc,
Upload,
} from "@/api/dictionary";
import { getBasicDataSelects } from "@/api/dictionary/dictionary";
export default {
name: 'TemplateForm',
name: "TemplateForm",
props: {
data: {
type: Object,
default() { return {} }
}
default() {
return {};
},
},
},
data() {
return {
form: {
Id: '',
Code: '',
Id: "",
Code: "",
FileTypeEnum: null,
BusinessScenarioEnum: null,
Name: '',
Path: '',
Description: '',
IsDeleted: false
Name: "",
NameCN: "",
Path: "",
Description: "",
IsDeleted: false,
},
rules: {
Code: [{ required: true, message: 'Please specify', trigger: ['blur'] }],
Name: [{ required: true, message: 'Please specify', trigger: ['blur'] }],
BusinessScenarioEnum: [{ required: true, message: 'Please select', trigger: ['blur'] }]
Code: [
{ required: true, message: "Please specify", trigger: ["blur"] },
],
Name: [
{ required: true, message: "Please specify", trigger: ["blur"] },
],
NameCN: [
{ required: true, message: "Please specify", trigger: ["blur"] },
],
BusinessScenarioEnum: [
{ required: true, message: "Please select", trigger: ["blur"] },
],
},
fileList: [],
btnLoading: false,
saveBtnLoading: false,
loading: false,
dictionaryList: {}
}
dictionaryList: {},
};
},
mounted() {
this.initForm()
this.initForm();
},
methods: {
async initForm() {
await this.getDicData()
await this.getDicData();
if (Object.keys(this.data).length > 0) {
if (this.data.Path) {
this.fileList = [
@ -128,97 +170,111 @@ export default {
name: this.data.Name,
path: this.data.Path,
url: this.data.Path,
type: this.data.Type
}
]
type: this.data.Type,
},
];
}
for (const k in this.form) {
if (this.data.hasOwnProperty(k)) {
this.form[k] = this.data[k]
this.form[k] = this.data[k];
}
}
}
},
//
getDicData() {
this.loading = true
getBasicDataSelects(['Common_File_ModuleType', 'Common_File_Type']).then(res => {
this.dictionaryList = { ...res.Result }
this.loading = false
}).catch(() => {
this.loading = false
})
this.loading = true;
getBasicDataSelects(["Common_File_ModuleType", "Common_File_Type"])
.then((res) => {
this.dictionaryList = { ...res.Result };
this.loading = false;
})
.catch(() => {
this.loading = false;
});
},
beforeUpload(file) {
//
if (this.checkFileSuffix(file.name)) {
this.fileList = []
return true
this.fileList = [];
return true;
} else {
this.$alert('必须是word/excel格式')
return false
// this.$alert("word/excel");
this.$alert(this.$t("dictionary:attachment:export:alert:formatFile"));
return false;
}
},
async handleUploadFile(param) {
this.loading = true
const formData = new FormData()
formData.append('file', param.file)
this.form.FileName = param.file.name
Upload(formData, 1).then(res => {
this.fileList.push({ name: param.file.name, path: res.Result.FilePath, fullPath: res.Result.FullFilePath, url: res.Result.FilePath })
this.form.Path = res.Result.FilePath
this.form.Name = param.file.name
this.loading = false
this.btnLoading = false
})
this.loading = true;
const formData = new FormData();
formData.append("file", param.file);
this.form.FileName = param.file.name;
Upload(formData, 1).then((res) => {
this.fileList.push({
name: param.file.name,
path: res.Result.FilePath,
fullPath: res.Result.FullFilePath,
url: res.Result.FilePath,
});
this.form.Path = res.Result.FilePath;
this.form.NameCN = param.file.name;
this.loading = false;
this.btnLoading = false;
});
},
handleSave() {
this.$refs.sysTemplateFrom.validate(valid => {
if (!valid) return
this.$refs.sysTemplateFrom.validate((valid) => {
if (!valid) return;
if (!this.form.Name) {
this.$alert('Please select file.')
return
this.$alert("Please select file.");
return;
}
this.saveBtnLoading = true
addOrUpdateCommonDocument(this.form).then(res => {
this.saveBtnLoading = false
this.$emit('closeDialog')
this.$emit('getList')
this.$message.success('Uploaded successfully')
}).catch(() => {
this.saveBtnLoading = false
})
})
this.saveBtnLoading = true;
addOrUpdateCommonDocument(this.form)
.then((res) => {
this.saveBtnLoading = false;
this.$emit("closeDialog");
this.$emit("getList");
this.$message.success(
this.$t("trials:uploadMonitor:table:uploadStatus")
);
})
.catch(() => {
this.saveBtnLoading = false;
});
});
},
handleRemoveFile() {
this.fileList = []
this.form.Path = ''
this.form.Name = ''
this.fileList = [];
this.form.Path = "";
this.form.NameCN = "";
this.form.Name = "";
},
handlePreview(file) {
if (file.fullPath) {
window.open(file.fullPath, '_blank')
window.open(file.fullPath, "_blank");
}
},
handleExceed(files, fileList) {
this.$message.warning(`Upload is currently limited to 1 file`)
this.$message.warning(`Upload is currently limited to 1 file`);
},
checkFileSuffix(fileName) {
var typeArr = ['xls', 'xlsx', 'doc', 'docx']
var extendName = fileName.substring(fileName.lastIndexOf('.') + 1).toLocaleLowerCase()
var typeArr = ["xls", "xlsx", "doc", "docx"];
var extendName = fileName
.substring(fileName.lastIndexOf(".") + 1)
.toLocaleLowerCase();
if (typeArr.indexOf(extendName) !== -1) {
return true
return true;
} else {
return false
return false;
}
}
}
}
},
},
};
</script>
<style lang="scss">
.upload-temporary-file{
.upload-temporary-file {
.upload-container .el-upload--text {
border: none;
width: 80px;
@ -231,8 +287,8 @@ export default {
color: #428bca;
font-size: 13px;
}
.account_item_clear{
.el-tag__close{
.account_item_clear {
.el-tag__close {
display: none !important;
}
}

View File

@ -2,10 +2,12 @@
<BaseContainer>
<template slot="search-container">
<el-form :inline="true" size="small">
<el-form-item label="业务场景">
<el-form-item
:label="$t('dictionary:attachment:export:search:business')"
>
<el-select
v-model="searchData.BusinessScenarioEnum"
style="width:150px;"
style="width: 150px"
>
<el-option
v-for="item of $d.Common_File_BusinessScenario"
@ -13,41 +15,42 @@
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="文件名称">
<el-input
v-model="searchData.Name"
style="width:130px;"
clearable
/>
<el-form-item
:label="$t('dictionary:attachment:export:search:fileName')"
>
<el-input v-model="searchData.Name" style="width: 130px" clearable />
</el-form-item>
<el-form-item>
<!-- 查询 -->
<el-button type="primary" icon="el-icon-search" @click="handleSearch">
{{ $t('common:button:search') }}
{{ $t("common:button:search") }}
</el-button>
<!-- 重置 -->
<el-button type="primary" icon="el-icon-refresh-left" @click="handleReset">
{{ $t('common:button:reset') }}
<el-button
type="primary"
icon="el-icon-refresh-left"
@click="handleReset"
>
{{ $t("common:button:reset") }}
</el-button>
</el-form-item>
<el-button
type="primary"
icon="el-icon-plus"
style="float: right"
size="small"
@click="handleAdd"
>
{{ $t("common:button:new") }}
</el-button>
</el-form>
<el-button
type="primary"
icon="el-icon-plus"
style="margin-left:auto;"
size="small"
@click="handleAdd"
>
{{ $t('common:button:new') }}
</el-button>
</template>
<template slot="main-container">
<el-table
v-adaptive="{bottomOffset:60}"
v-adaptive="{ bottomOffset: 60 }"
v-loading="loading"
:data="list"
stripe
@ -64,70 +67,81 @@
<el-table-column
prop="BusinessScenarioEnum"
label="业务场景"
:label="$t('dictionary:attachment:export:table:business')"
show-overflow-tooltip
sortable="custom"
>
<template slot-scope="scope">
{{ $fd('Common_File_BusinessScenario',scope.row.BusinessScenarioEnum) }}
{{
$fd(
"Common_File_BusinessScenario",
scope.row.BusinessScenarioEnum
)
}}
</template>
</el-table-column>
<el-table-column
prop="Name"
label="文件名称"
:label="$t('dictionary:attachment:export:table:name')"
show-overflow-tooltip
sortable="custom"
/>
<el-table-column
prop="NameCN"
:label="$t('dictionary:attachment:export:table:nameCN')"
show-overflow-tooltip
sortable="custom"
/>
<el-table-column
prop="Description"
label="描述"
:label="$t('dictionary:attachment:export:table:description')"
show-overflow-tooltip
/>
<el-table-column
prop="IsDeleted"
label="是否废除"
:label="$t('dictionary:attachment:export:table:isDeleted')"
show-overflow-tooltip
sortable="custom"
>
<template slot-scope="scope">
<el-tag v-if="scope.row.IsDeleted" type="danger">{{ $fd('YesOrNo', scope.row.IsDeleted) }}</el-tag>
<el-tag v-else type="primary">{{ $fd('YesOrNo', scope.row.IsDeleted) }}</el-tag>
<el-tag v-if="scope.row.IsDeleted" type="danger">{{
$fd("YesOrNo", scope.row.IsDeleted)
}}</el-tag>
<el-tag v-else type="primary">{{
$fd("YesOrNo", scope.row.IsDeleted)
}}</el-tag>
</template>
</el-table-column>
<el-table-column
prop="UpdateTime"
label="更新时间"
:label="$t('dictionary:attachment:export:table:updateTime')"
show-overflow-tooltip
sortable="custom"
/>
<el-table-column label="Action">
<el-table-column :label="$t('common:action:action')">
<template slot-scope="scope">
<el-button
type="text"
@click="handleDownload(scope.row)"
>
下载
<el-button type="text" @click="handleDownload(scope.row)">
{{ $t("common:button:download") }}
</el-button>
<el-button
type="text"
@click="handleEdit(scope.row)"
>
编辑
<el-button type="text" @click="handleEdit(scope.row)">
{{ $t("common:button:edit") }}
</el-button>
<el-button
type="text"
@click="handleDelete(scope.row)"
>
删除
<el-button type="text" @click="handleDelete(scope.row)">
{{ $t("common:button:delete") }}
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination class="page" :total="total" :page.sync="searchData.PageIndex" :limit.sync="searchData.PageSize" @pagination="getList" />
<pagination
class="page"
:total="total"
:page.sync="searchData.PageIndex"
:limit.sync="searchData.PageSize"
@pagination="getList"
/>
<!-- 新增/编辑 -->
<el-dialog
@ -138,28 +152,36 @@
width="600px"
custom-class="base-dialog-wrapper"
>
<TemplateForm :data="currentRow" @closeDialog="closeDialog" @getList="getList" />
<TemplateForm
:data="currentRow"
@closeDialog="closeDialog"
@getList="getList"
/>
</el-dialog>
</template>
</BaseContainer>
</template>
<script>
import { getCommonDocumentList, DownloadCommonDoc, deleteCommonDocument } from '@/api/dictionary'
import BaseContainer from '@/components/BaseContainer'
import Pagination from '@/components/Pagination'
import TemplateForm from './TemplateForm'
const FileTypeEnum = 2
import {
getCommonDocumentList,
DownloadCommonDoc,
deleteCommonDocument,
} from "@/api/dictionary";
import BaseContainer from "@/components/BaseContainer";
import Pagination from "@/components/Pagination";
import TemplateForm from "./TemplateForm";
const FileTypeEnum = 2;
const searchDataDefault = () => {
return {
FileTypeEnum: FileTypeEnum,
BusinessScenarioEnum: null,
Name: '',
Name: "",
PageIndex: 1,
PageSize: 20
}
}
PageSize: 20,
};
};
export default {
name: 'ExportTemplate',
name: "ExportTemplate",
components: { BaseContainer, Pagination, TemplateForm },
data() {
return {
@ -167,73 +189,86 @@ export default {
list: [],
total: 0,
currentRow: {},
editDialog: { title: '', visible: false },
loading: false
}
editDialog: { title: "", visible: false },
loading: false,
};
},
mounted() {
this.getList()
this.getList();
},
methods: {
handleDelete(row) {
this.$confirm('确定删除该模版?').then(() => {
this.$confirm(
this.$t("dictionary:attachment:export:confirm:delete")
).then(() => {
deleteCommonDocument(row.Id).then(() => {
this.$message.success('删除成功')
this.getList()
})
})
this.$message.success(this.$t("common:message:deletedSuccessfully"));
this.getList();
});
});
},
getList() {
this.loading = true
getCommonDocumentList(this.searchData).then(res => {
this.loading = false
this.list = res.Result.CurrentPageData
this.total = res.Result.TotalCount
}).catch(() => {
this.loading = false
})
this.loading = true;
getCommonDocumentList(this.searchData)
.then((res) => {
this.loading = false;
this.list = res.Result.CurrentPageData;
this.total = res.Result.TotalCount;
})
.catch(() => {
this.loading = false;
});
},
//
handleAdd() {
this.editDialog.title = 'Add'
this.currentRow = { FileTypeEnum: FileTypeEnum }
this.editDialog.visible = true
this.editDialog.title = "Add";
this.currentRow = { FileTypeEnum: FileTypeEnum };
this.editDialog.visible = true;
},
//
handleDownload(row) {
this.loading = true
DownloadCommonDoc(row.Code).then(data => {
this.loading = false
}).catch(() => { this.loading = false })
this.loading = true;
DownloadCommonDoc(row.Code)
.then((data) => {
this.loading = false;
})
.catch(() => {
this.loading = false;
});
},
//
handleEdit(row) {
this.editDialog.title = 'Edit'
this.currentRow = { ...row }
this.editDialog.visible = true
this.editDialog.title = "Edit";
this.currentRow = { ...row };
this.editDialog.visible = true;
},
handleSearch() {
this.searchData.PageIndex = 1
this.getList()
this.searchData.PageIndex = 1;
this.getList();
},
handleReset() {
this.searchData = searchDataDefault()
this.getList()
this.searchData = searchDataDefault();
this.getList();
},
closeDialog() {
this.editDialog.visible = false
this.editDialog.visible = false;
},
//
handleSortChange(column) {
if (column.order === 'ascending') {
this.searchData.Asc = true
if (column.order === "ascending") {
this.searchData.Asc = true;
} else {
this.searchData.Asc = false
this.searchData.Asc = false;
}
this.searchData.SortField = column.prop
this.searchData.PageIndex = 1
this.getList()
}
}
}
this.searchData.SortField = column.prop;
this.searchData.PageIndex = 1;
this.getList();
},
},
};
</script>
<style lang="scss" scoped>
::v-deep .search{
display: block;
}
</style>