数据上传模板添加字段文件名称(CN)

uat_us
DESKTOP-6C3NK6N\WXS 2024-09-09 15:47:53 +08:00
parent 15cad74264
commit 39c4a13f5e
2 changed files with 174 additions and 97 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"
@ -15,7 +15,7 @@
<el-form-item label="业务场景: " prop="BusinessScenarioEnum"> <el-form-item label="业务场景: " 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
> >
@ -44,12 +44,14 @@
: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>
@ -58,37 +60,61 @@
<el-form-item label="文件名" prop="Name"> <el-form-item label="文件名" prop="Name">
<el-input v-model="form.Name" /> <el-input v-model="form.Name" />
</el-form-item> </el-form-item>
<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="是否废除: "> <el-form-item v-if="form.Id !== ''" label="是否废除: ">
<el-radio-group v-model="form.IsDeleted"> <el-radio-group v-model="form.IsDeleted">
<el-radio v-for="item of $d.YesOrNo" :label="item.value">{{item.label}}</el-radio> <el-radio
v-for="item of $d.YesOrNo"
:label="item.value"
:key="item.id"
>{{ item.label }}</el-radio
>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="描述"> <el-form-item label="描述">
<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"
>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 {
addOrUpdateCommonDocument,
uploadCommonDoc,
Upload,
} from '@/api/dictionary'
import { getBasicDataSelects } from '@/api/dictionary/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() {
@ -99,20 +125,30 @@ export default {
FileTypeEnum: null, FileTypeEnum: null,
BusinessScenarioEnum: null, BusinessScenarioEnum: null,
Name: '', Name: '',
NameCN: '',
Path: '', Path: '',
Description: '', Description: '',
IsDeleted: false 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() {
@ -128,8 +164,8 @@ 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) {
@ -142,12 +178,14 @@ export default {
// //
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) {
// //
@ -165,35 +203,43 @@ export default {
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({
name: param.file.name,
path: res.Result.FilePath,
fullPath: res.Result.FullFilePath,
url: res.Result.FilePath,
})
this.form.Path = res.Result.FilePath this.form.Path = res.Result.FilePath
this.form.Name = param.file.name this.form.NameCN = param.file.name
this.loading = false this.loading = false
this.btnLoading = 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('Uploaded successfully')
this.saveBtnLoading = false })
}) .catch(() => {
this.saveBtnLoading = false
})
}) })
}, },
handleRemoveFile() { handleRemoveFile() {
this.fileList = [] this.fileList = []
this.form.Path = '' this.form.Path = ''
this.form.NameCN = ''
this.form.Name = '' this.form.Name = ''
}, },
handlePreview(file) { handlePreview(file) {
@ -206,19 +252,21 @@ export default {
}, },
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 +279,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

@ -5,7 +5,7 @@
<el-form-item label="业务场景"> <el-form-item label="业务场景">
<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,15 +13,10 @@
: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 label="文件名称">
<el-input <el-input v-model="searchData.Name" style="width: 130px" clearable />
v-model="searchData.Name"
style="width:130px;"
clearable
/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@ -30,24 +25,28 @@
{{ $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
type="primary"
icon="el-icon-refresh-left"
@click="handleReset"
>
{{ $t('common:button:reset') }} {{ $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
@ -69,9 +68,13 @@
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
@ -80,6 +83,12 @@
show-overflow-tooltip show-overflow-tooltip
sortable="custom" sortable="custom"
/> />
<el-table-column
prop="NameCN"
:label="$t('dictionary:attachment:upload:table:nameCN')"
show-overflow-tooltip
sortable="custom"
/>
<el-table-column <el-table-column
prop="Description" prop="Description"
label="描述" label="描述"
@ -92,8 +101,12 @@
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
@ -105,29 +118,26 @@
<el-table-column label="Action"> <el-table-column label="Action">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button type="text" @click="handleDownload(scope.row)">
type="text"
@click="handleDownload(scope.row)"
>
下载 下载
</el-button> </el-button>
<el-button <el-button type="text" @click="handleEdit(scope.row)">
type="text"
@click="handleEdit(scope.row)"
>
编辑 编辑
</el-button> </el-button>
<el-button <el-button type="text" @click="handleDelete(scope.row)">
type="text"
@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,13 +148,21 @@
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 {
getCommonDocumentList,
DownloadCommonDoc,
deleteCommonDocument,
} from '@/api/dictionary'
import BaseContainer from '@/components/BaseContainer' import BaseContainer from '@/components/BaseContainer'
import Pagination from '@/components/Pagination' import Pagination from '@/components/Pagination'
import TemplateForm from './TemplateForm' import TemplateForm from './TemplateForm'
@ -155,7 +173,7 @@ const searchDataDefault = () => {
BusinessScenarioEnum: null, BusinessScenarioEnum: null,
Name: '', Name: '',
PageIndex: 1, PageIndex: 1,
PageSize: 20 PageSize: 20,
} }
} }
export default { export default {
@ -168,7 +186,7 @@ export default {
total: 0, total: 0,
currentRow: {}, currentRow: {},
editDialog: { title: '', visible: false }, editDialog: { title: '', visible: false },
loading: false loading: false,
} }
}, },
mounted() { mounted() {
@ -185,13 +203,15 @@ export default {
}, },
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() {
@ -202,9 +222,13 @@ export default {
// //
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) {
@ -233,7 +257,12 @@ export default {
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>