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

View File

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