From 585a468e1a128fb0906c22f0c8458fea9fa9e721 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期五, 22 十一月 2024 22:01:44 +0800 Subject: [PATCH] 项目库基本样式完善 --- src/views/projectEngineering/projectLibrary/index.vue | 256 ++++++++++++++------------- src/enums/fileType.js | 29 +++ src/components/VisibilityToolbar/index.vue | 2 src/views/projectEngineering/component/FileDialog.vue | 201 ++++++++++++++++++++++ 4 files changed, 363 insertions(+), 125 deletions(-) diff --git a/src/components/VisibilityToolbar/index.vue b/src/components/VisibilityToolbar/index.vue index 7b37a77..4f8ff18 100644 --- a/src/components/VisibilityToolbar/index.vue +++ b/src/components/VisibilityToolbar/index.vue @@ -12,7 +12,7 @@ </el-tooltip> </el-row> - <el-drawer v-model="table" title="淇℃伅鏄鹃殣绛涢��" size="30%" append-to-body> + <el-drawer :visible.sync="table" title="淇℃伅鏄鹃殣绛涢��" size="30%" append-to-body> <div slot="header"> <span>淇℃伅鏄鹃殣绛涢��</span> </div> diff --git a/src/enums/fileType.js b/src/enums/fileType.js new file mode 100644 index 0000000..d61a14a --- /dev/null +++ b/src/enums/fileType.js @@ -0,0 +1,29 @@ +// 鏂囦欢绫诲瀷鏋氫妇 +const FileTypeEnum = { + JPEG: 'image/jpeg', + JPG: 'image/jpg', + PNG: 'image/png', + GIF: 'image/gif', + SVG: 'image/svg+xml', + MP4: 'video/mp4', + AVI: 'video/x-msvideo', + MOV: 'video/quicktime', + MKV: 'video/x-matroska', + WMV: 'video/x-ms-wmv', + PDF: 'application/pdf', + DOC: 'application/msword', + DOCX: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + XLS: 'application/vnd.ms-excel', + XLSX: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + PPT: 'application/vnd.ms-powerpoint', + PPTX: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + TXT: 'text/plain', + CSV: 'text/csv', + JSON: 'application/json', + XML: 'application/xml', + ZIP: 'application/zip', + RAR: 'application/x-rar-compressed', + MP3: 'audio/mpeg', + WAV: 'audio/wav', + OGG: 'audio/ogg' +}; diff --git a/src/views/projectEngineering/component/FileDialog.vue b/src/views/projectEngineering/component/FileDialog.vue new file mode 100644 index 0000000..31395be --- /dev/null +++ b/src/views/projectEngineering/component/FileDialog.vue @@ -0,0 +1,201 @@ +<template> + <div> + <el-dialog + :visible.sync="fileDialogVisible" + ref="formDialogRef" + width="35%" + append-to-body + close-on-click-modal + @close="closeDialog" + > + <template slot="header"> + <span style="padding-bottom: 18px"> + {{ isImportOrExport ? '璇锋寜鐓ч渶姹傚鍑虹洰鏍囧唴瀹�' : '璇锋寜鐓фā鏉挎牱寮忎笂浼犻」鐩枃浠�' }} + </span> + </template> + <template slot="default"> + <div v-if="!isImportOrExport" class="dialog-content"> + <el-upload + ref="uploadRef" + class="upload-demo" + :action="upload.url" + :limit="1" + :accept="accept" + :headers="upload.headers" + :disabled="upload.isUploading" + :on-progress="handleFileUploadProgress" + :on-success="handleFileSuccess" + :auto-upload="false" + drag + > + <el-icon class="el-icon--upload"><upload-filled /></el-icon> + <div class="el-upload__text">璇蜂笂浼�<em>Zip</em>鏂囦欢锛屽ぇ灏忓湪<em>100M</em>浠ュ唴</div> + </el-upload> + <span>浠呭厑璁稿鍏ip鏍煎紡鏂囦欢銆�</span> + <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="handleDownloadFile">涓嬭浇妯℃澘</el-link> + </div> + <div v-else-if="isImportOrExport" class="dialog-content"> + <el-button class="export-button" @click="handleDownloadTargetList">瀵煎嚭鐩爣鍒楄〃鍐呭</el-button> + <el-button class="export-button">瀵煎嚭鎵�鏈夊垪琛ㄥ唴瀹�</el-button> + <el-button class="export-button">瀵煎嚭鐩爣椤圭洰璇︽儏</el-button> + <el-button class="export-button">瀵煎嚭鎵�鏈夐」鐩鎯�</el-button> + </div> + </template> + <template slot="footer"> + <div v-if="!isImportOrExport" class="dialog-footer"> + <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button> + <el-button @click="closeDialog">鍙� 娑�</el-button> + </div> + <div v-else-if="isImportOrExport"></div> + </template> + </el-dialog> + </div> +</template> + +<script> +// import UploadFilled from '@element/icons-vue/es/icons/UploadFilled.vue'; +import { globalHeaders } from '@/utils/request'; +import { FileTypeEnum } from '@/enums/fileType'; + +export default { + name: 'FileDialog', + // components: { + // UploadFilled + // }, + props: { + isImportOrExport: { + type: Boolean, + default: false + }, + fileDialogVisible: { + type: Boolean, + default: false + }, + currentColumns: { + type: Array, + default: function () { + return []; + } + } + }, + data() { + return { + uploadRef: null, + targetColumn: [], + accept: `${FileTypeEnum.ZIP}`, + upload: { + open: false, + title: '', + isUploading: false, + updateSupport: 0, + headers: globalHeaders(), + url: process.env.VITE_APP_BASE_API + '/project/import' + } + }; + }, + computed: { + // In Vue 2, computed properties don't use setters and getters as objects. + // Instead, you define them as functions for reading and use methods for writing. + // However, in this case, we can use a watcher to update the prop. + fileDialogVisible: { + get() { + return this.isFileDialogVisible; + }, + set(value) { + this.$emit('update:fileDialogVisible', value); + } + } + // Note: In Vue 2, you cannot directly define a computed property with a setter for a prop. + // Instead, you should use a watcher or a method to handle changes. + // Since `fileDialogVisible` is a prop, we'll use a watcher to sync it with the internal state. + // However, for simplicity, we'll rename `fileDialogVisible` to `isFileDialogVisible` in data and use a watcher. + }, + watch: { + fileDialogVisible(newVal) { + this.isFileDialogVisible = newVal; + }, + isFileDialogVisible(newVal) { + this.$emit('update:fileDialogVisible', newVal); + } + }, + methods: { + handleFileUploadProgress() { + this.upload.isUploading = true; + }, + handleFileSuccess(response, file) { + this.upload.open = false; + this.upload.isUploading = false; + if (this.uploadRef) { + this.uploadRef.handleRemove(file); + } + if (response.code === 200) { + this.$emit('fileDialogCancel'); + this.$message({ + message: response.msg, + type: 'success' + }); + } else { + this.$message.error(response.msg); + } + }, + handleDownloadFile() { + const self = this; + fetch(`${process.env.VITE_APP_BASE_API}/project/export/template`, { + method: 'GET', + headers: self.upload.headers + }) + .then(response => response.blob()) + .then(blob => { + const url = window.URL.createObjectURL(blob); + const a = document.createElement('a'); + a.style.display = 'none'; + a.href = url; + a.download = `椤圭洰鏂囦欢妯℃澘_${new Date().getTime()}.zip`; + document.body.appendChild(a); + a.click(); + window.URL.revokeObjectURL(url); + }) + .catch(error => { + console.error('鏂囦欢涓嬭浇澶辫触:', error); + }); + }, + submitFileForm() { + if (this.uploadRef) { + this.uploadRef.submit(); + } + }, + closeDialog() { + this.$emit('fileDialogCancel'); + }, + handleDownloadTargetList() { + console.log('瀵煎嚭鐩爣鍒楄〃鍐呭', this.currentColumns); + this.targetColumn = this.currentColumns.filter(item => item.visible); + } + }, + created() { + // Initialize the computed property as a data property in Vue 2 + this.isFileDialogVisible = this.fileDialogVisible; + } +}; +</script> + +<style scoped lang="scss"> +.dialog-content { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + height: 300px; + .export-button { + margin-left: 0; + margin-bottom: 10px; + } +} +.dialog-footer { + display: flex; + justify-content: center; +} +.upload-demo { + width: 100%; +} +</style> diff --git a/src/views/projectEngineering/projectLibrary/index.vue b/src/views/projectEngineering/projectLibrary/index.vue index 06d2b98..3d16906 100644 --- a/src/views/projectEngineering/projectLibrary/index.vue +++ b/src/views/projectEngineering/projectLibrary/index.vue @@ -1,6 +1,6 @@ <template> <div class="app-container"> - <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> + <el-form :model="queryParams" ref="queryParamsRef" size="small" :inline="true" v-show="showSearch" label-width="68px"> <div class="slot"> <div class="left-section"> <el-form-item label="椤圭洰鍚嶇О" prop="projectName"> @@ -40,7 +40,7 @@ </el-date-picker> </el-form-item> <el-form-item> - <el-button icon="el-icon-search" size="small" @click="handleQuery">鎼滅储</el-button> + <el-button icon="el-icon-search" size="small" @click="handleQuery">鏌ヨ</el-button> <el-button icon="el-icon-refresh" size="small" @click="resetQuery">閲嶇疆</el-button> </el-form-item> <el-popover :visible="popoverValue" :width="500" placement="bottom"> @@ -54,97 +54,96 @@ </el-button> </template> <span>绛涢�夋潯浠�</span> - <!-- 琛ㄥ崟鍐呭 --> -<!-- <el-form ref="queryFormRef" :inline="true" :model="queryForm" class="demo-form-inline">--> -<!-- <el-row>--> -<!-- <el-col :span="12">--> -<!-- <el-form-item label="椤圭洰绫诲瀷">--> -<!-- <el-select v-model="queryForm.projectType" clearable placeholder="璇烽�夋嫨" style="width: 140px">--> -<!-- <el-option v-for="items in sys_project_type" :key="items.value" :label="items.label" :value="items.value" />--> -<!-- </el-select>--> -<!-- </el-form-item>--> -<!-- </el-col>--> -<!-- <el-col :span="12">--> -<!-- <el-form-item label="閲嶇偣鍒嗙被">--> -<!-- <el-select v-model="queryForm.importanceType" clearable placeholder="璇烽�夋嫨" style="width: 140px">--> -<!-- <el-option v-for="items in sys_key_categories" :key="items.value" :label="items.label" :value="items.value" />--> -<!-- </el-select>--> -<!-- </el-form-item>--> -<!-- </el-col>--> -<!-- </el-row>--> -<!-- <el-row>--> -<!-- <el-col :span="12">--> -<!-- <el-form-item label="椤圭洰鏍囩">--> -<!-- <el-select v-model="queryForm.tag" clearable placeholder="璇烽�夋嫨" style="width: 140px">--> -<!-- <el-option v-for="items in sys_project_tags" :key="items.value" :label="items.label" :value="items.value" />--> -<!-- </el-select>--> -<!-- </el-form-item>--> -<!-- </el-col>--> -<!-- <el-col :span="12">--> -<!-- <el-form-item label="椤圭洰鐘舵��">--> -<!-- <el-select v-model="queryForm.projectStatus" :disabled="isProjectCategory" clearable placeholder="璇烽�夋嫨" style="width: 140px">--> -<!-- <el-option v-for="items in sys_project_status" :key="items.value" :label="items.label" :value="items.value" />--> -<!-- </el-select>--> -<!-- </el-form-item>--> -<!-- </el-col>--> -<!-- </el-row>--> -<!-- <el-row>--> -<!-- <el-col :span="12">--> -<!-- <el-form-item label="椤圭洰鐮�">--> -<!-- <el-select v-model="queryForm.projectColorCode" clearable placeholder="璇烽�夋嫨" style="width: 140px">--> -<!-- <el-option v-for="items in sys_project_code" :key="items.value" :label="items.label" :value="items.value" />--> -<!-- </el-select>--> -<!-- </el-form-item>--> -<!-- </el-col>--> -<!-- <el-col :span="12">--> -<!-- <el-form-item label="鍏宠仈鐘舵��">--> -<!-- <el-select v-model="queryForm.assignmentStatus" clearable placeholder="璇烽�夋嫨" style="width: 140px">--> -<!-- <el-option v-for="items in sys_association_status" :key="items.value" :label="items.label" :value="items.value" />--> -<!-- </el-select>--> -<!-- </el-form-item>--> -<!-- </el-col>--> -<!-- </el-row>--> -<!-- <el-row>--> -<!-- <el-col :span="12">--> -<!-- <el-form-item label="璧勯噾绫诲瀷">--> -<!-- <el-select v-model="queryForm.investmentType" clearable placeholder="璇烽�夋嫨" style="width: 140px">--> -<!-- <el-option v-for="items in sys_funding_type" :key="items.value" :label="items.label" :value="items.value" />--> -<!-- </el-select>--> -<!-- </el-form-item>--> -<!-- </el-col>--> -<!-- <el-col :span="12">--> -<!-- <el-form-item label="椤圭洰闃舵">--> -<!-- <el-select v-model="queryForm.projectPhase" clearable placeholder="璇烽�夋嫨" style="width: 140px">--> -<!-- <el-option v-for="items in sys_project_phases" :key="items.value" :label="items.label" :value="items.value" />--> -<!-- </el-select>--> -<!-- </el-form-item>--> -<!-- </el-col>--> -<!-- </el-row>--> -<!-- <el-row>--> -<!-- <el-col :span="12">--> -<!-- <el-form-item label="鎶曡祫绫诲埆">--> -<!-- <el-select v-model="queryForm.investType" clearable placeholder="璇烽�夋嫨" style="width: 140px">--> -<!-- <el-option v-for="items in sys_investment_type" :key="items.value" :label="items.label" :value="items.value" />--> -<!-- </el-select>--> -<!-- </el-form-item>--> -<!-- </el-col>--> -<!-- <el-col :span="12">--> -<!-- <el-form-item label="琛屾斂鍖哄垝">--> -<!-- <el-select v-model="queryForm.area" clearable placeholder="璇烽�夋嫨" style="width: 140px">--> -<!-- <el-option v-for="items in sys_administrative_divisions" :key="items.value" :label="items.label" :value="items.value" />--> -<!-- </el-select>--> -<!-- </el-form-item>--> -<!-- </el-col>--> -<!-- </el-row>--> -<!-- <el-row style="text-align: center">--> -<!-- <el-col :span="24">--> -<!-- <el-form-item>--> -<!--<!– <el-button type="primary" @click="handleQueryFrom">纭� 璁�</el-button>–>--> -<!--<!– <el-button @click="closePopover">鍙� 娑�</el-button>–>--> -<!-- </el-form-item>--> -<!-- </el-col>--> -<!-- </el-row>--> -<!-- </el-form>--> + <el-form ref="moreQueryParamsRef" label-width="68px" label-position="right" :model="moreQueryParams"> + <el-row> + <el-col :span="12"> + <el-form-item label="椤圭洰绫诲瀷"> + <el-select v-model="moreQueryParams.projectType" clearable placeholder="璇烽�夋嫨" class="select-option" size="small"> + <el-option v-for="items in sys_project_type" :key="items.value" :label="items.label" :value="items.value" /> + </el-select> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="閲嶇偣鍒嗙被"> + <el-select v-model="moreQueryParams.importanceType" clearable placeholder="璇烽�夋嫨" class="select-option"> + <el-option v-for="items in sys_key_categories" :key="items.value" :label="items.label" :value="items.value" /> + </el-select> + </el-form-item> + </el-col> + </el-row> + <el-row> + <el-col :span="12"> + <el-form-item label="椤圭洰鏍囩"> + <el-select v-model="moreQueryParams.tag" clearable placeholder="璇烽�夋嫨" class="select-option"> + <el-option v-for="items in sys_project_tags" :key="items.value" :label="items.label" :value="items.value" /> + </el-select> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="椤圭洰鐘舵��"> + <el-select v-model="moreQueryParams.projectStatus" :disabled="isProjectCategory" clearable placeholder="璇烽�夋嫨" class="select-option"> + <el-option v-for="items in sys_project_status" :key="items.value" :label="items.label" :value="items.value" /> + </el-select> + </el-form-item> + </el-col> + </el-row> + <el-row> + <el-col :span="12"> + <el-form-item label="椤圭洰鐮�"> + <el-select v-model="moreQueryParams.projectColorCode" clearable placeholder="璇烽�夋嫨" class="select-option"> + <el-option v-for="items in sys_project_code" :key="items.value" :label="items.label" :value="items.value" /> + </el-select> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="鍏宠仈鐘舵��"> + <el-select v-model="moreQueryParams.assignmentStatus" clearable placeholder="璇烽�夋嫨" class="select-option"> + <el-option v-for="items in sys_association_status" :key="items.value" :label="items.label" :value="items.value" /> + </el-select> + </el-form-item> + </el-col> + </el-row> + <el-row> + <el-col :span="12"> + <el-form-item label="璧勯噾绫诲瀷"> + <el-select v-model="moreQueryParams.investmentType" clearable placeholder="璇烽�夋嫨" class="select-option"> + <el-option v-for="items in sys_funding_type" :key="items.value" :label="items.label" :value="items.value" /> + </el-select> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="椤圭洰闃舵"> + <el-select v-model="moreQueryParams.projectPhase" clearable placeholder="璇烽�夋嫨" class="select-option"> + <el-option v-for="items in sys_project_phases" :key="items.value" :label="items.label" :value="items.value" /> + </el-select> + </el-form-item> + </el-col> + </el-row> + <el-row> + <el-col :span="12"> + <el-form-item label="鎶曡祫绫诲埆"> + <el-select v-model="moreQueryParams.investType" clearable placeholder="璇烽�夋嫨" class="select-option"> + <el-option v-for="items in sys_investment_type" :key="items.value" :label="items.label" :value="items.value" /> + </el-select> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="琛屾斂鍖哄垝"> + <el-select v-model="moreQueryParams.area" clearable placeholder="璇烽�夋嫨" class="select-option"> + <el-option v-for="items in sys_administrative_divisions" :key="items.value" :label="items.label" :value="items.value" /> + </el-select> + </el-form-item> + </el-col> + </el-row> + <el-row style="text-align: center"> + <el-col :span="24"> + <el-form-item label-width="0"> + <el-button type="primary" @click="handleQueryFrom">纭� 璁�</el-button> + <el-button @click="closePopover">鍙� 娑�</el-button> + </el-form-item> + </el-col> + </el-row> + </el-form> </el-popover> </div> <div class="right-section"> @@ -166,6 +165,7 @@ <VisibilityToolbar v-model:showSearch="showSearch" :columns="columnList" + @queryTable="handleQuery" ></VisibilityToolbar> <!-- @update:columns="handleUpdateColumns"--> <!-- @update:sort="handleUpdateSort"--> @@ -174,7 +174,13 @@ </div> </el-form> - <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange"> + <el-table + style="margin-top: 20px" + v-loading="loading" + :data="infoList" + @selection-change="handleSelectionChange" + height="60vh" + :show-overflow-tooltip = "true"> <el-table-column type="selection" width="55" align="center" /> <template v-for="item in columns"> <el-table-column @@ -233,6 +239,12 @@ @pagination="getList" /> +<!-- <FileDialog--> +<!-- v-model:fileDialogVisible="fileDialogVisible"--> +<!-- :isImportOrExport="isImportOrExport"--> +<!-- @fileDialogCancel="fileDialogCancel"--> +<!-- :currentColumns="currentColumns"--> +<!-- />--> </div> </template> @@ -244,6 +256,8 @@ name: "projectInfo", data() { return { + isImportOrExport: false, + fileDialogVisible: false, //鎺у埗鏄鹃殣鐨勮〃鍗� columnList: [], //鏄惁闇�瑕佹柊澧炴寜閽�(鍌ㄨ搫椤圭洰闇�瑕�) @@ -277,36 +291,18 @@ pageSize: 10, projectName: null, projectCode: null, - content: null, - projectType: null, - projectStatus: null, - fundType: null, - investType: null, - projectPhase: null, - tag: null, - competentDepartment: null, - areaCode: null, - managementCentralization: null, - projectApprovalType: null, - investmentCatalogue: null, - importanceType: null, - year: null, - yearInvestAmount: null, - createProjectTime: null, - planStartTime: null, - planCompleteTime: null, - winUnit: null, - winAmount: null, - winTime: null, - projectAddress: null, - longitude: null, - latitude: null, - projectOwnerUnit: null, - projectContactPerson: null, - contact: null, - gmtCreateTime: null, - gmtUpdateTime: null, - deleted: null + }, + moreQueryParams: { + projectType: '', // 椤圭洰绫诲瀷 + importanceType: '', // 閲嶇偣鍒嗙被 + projectStatus: '', // 椤圭洰鐘舵�� + projectColorCode: '', // 椤圭洰鐮� + investmentType: '', // 璧勯噾绫诲瀷 + projectPhase: '', // 椤圭洰闃舵 + investType: '', // 鎶曡祫绫诲埆 + area: '', // 琛屾斂鍖哄垝 + assignmentStatus: '', //鍏宠仈鐘舵�� + tag: '' //椤圭洰鏍囩 }, // 琛ㄥ崟鍙傛暟 form: {}, @@ -331,9 +327,13 @@ this.getList(); }, methods: { + handlePopover() { + this.popoverValue.value = !this.popoverValue.value; + }, /** 鏌ヨ椤圭洰绠$悊鍩虹淇℃伅鍒楄〃 */ getList() { this.loading = true; + console.log("鏌ヨ") // listInfo(this.queryParams).then(response => { // this.infoList = response.rows; // this.total = response.total; @@ -448,6 +448,11 @@ this.$modal.msgSuccess("鍒犻櫎鎴愬姛"); }).catch(() => {}); }, + /** 瀵煎叆鎸夐挳鎿嶄綔 */ + handleImport() { + this.isImportOrExport = false; + this.fileDialogVisible = true; + }, /** 瀵煎嚭鎸夐挳鎿嶄綔 */ handleExport() { this.download('code/info/export', { @@ -458,6 +463,9 @@ }; </script> <style lang="scss" scoped> + .select-option { + width: 140px; +} .slot { display: flex; } -- Gitblit v1.8.0