From d529e4e9f3b00ce5ff0d9d65670e37e422ec660c Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期一, 22 十二月 2025 20:19:56 +0800
Subject: [PATCH] 修改了代码
---
src/views/archivePlaceName/index.vue | 93 ++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 89 insertions(+), 4 deletions(-)
diff --git a/src/views/archivePlaceName/index.vue b/src/views/archivePlaceName/index.vue
index a10a45d..b32f348 100644
--- a/src/views/archivePlaceName/index.vue
+++ b/src/views/archivePlaceName/index.vue
@@ -9,6 +9,14 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
+ <el-form-item label="瀵瑰簲鐨勫尯鍚嶇О" prop="name">
+ <el-input
+ v-model="queryParams.name"
+ placeholder="璇疯緭鍏ュ搴旂殑鍖哄悕绉�"
+ clearable
+ @keyup.enter.native="handleQuery"
+ />
+ </el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
@@ -58,6 +66,35 @@
v-hasPermi="['system:name:export']"
>瀵煎嚭</el-button>
</el-col>
+
+ <el-col :span="1.5">
+ <el-button
+ type="primary"
+ plain
+ icon="el-icon-download"
+ size="mini"
+ @click="handleExportTemplate"
+ v-hasPermi="['system:name:export']"
+ >瀵煎叆妯℃澘涓嬭浇</el-button>
+ </el-col>
+
+ <el-col :span="1.5">
+
+ <el-upload
+ action=""
+
+ class="upload-demo"
+ :show-file-list="false"
+ :http-request="handleImport"
+ accept=".xlsx,.xls"
+
+ >
+ <el-button size="mini" type="primary"
+ plain
+ icon="el-icon-top">瀵煎叆</el-button>
+
+ </el-upload>
+ </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@@ -97,10 +134,10 @@
<!-- 娣诲姞鎴栦慨鏀广�愯濉啓鍔熻兘鍚嶇О銆戝璇濇 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
- <el-form-item label="瀵瑰簲鐨勫尯鍙�" prop="nnumber">
+ <el-form-item label="瀵瑰簲鐨勫尯鍙�" prop="nnumber" required>
<el-input v-model="form.nnumber" placeholder="璇疯緭鍏ュ搴旂殑鍖哄彿" />
</el-form-item>
- <el-form-item label="瀵瑰簲鐨勫尯鍚嶇О" prop="name">
+ <el-form-item label="瀵瑰簲鐨勫尯鍚嶇О" prop="name" required>
<el-input v-model="form.name" placeholder="璇疯緭鍏ュ唴瀹�" />
</el-form-item>
</el-form>
@@ -113,7 +150,7 @@
</template>
<script>
-import { listPlaceName, getName, delName, addName, updateName } from "@/api/system/placeName"
+import { listPlaceName, enload,getName, delName, addName, updateName } from "@/api/system/placeName"
export default {
name: "Name",
@@ -148,6 +185,12 @@
form: {},
// 琛ㄥ崟鏍¢獙
rules: {
+ nnumber: [
+ { required: true, message: '璇疯緭鍏ュ搴旂殑鍖哄彿', trigger: 'blur' }
+ ],
+ name: [
+ { required: true, message: '璇疯緭鍏ュ搴旂殑鍖哄悕绉�', trigger: 'blur' }
+ ]
}
}
},
@@ -245,8 +288,50 @@
this.download('/system/placeName/export', {
...this.queryParams
- }, `name_${new Date().getTime()}.xlsx`)
+ }, `name_${new Date().getTime()}.xls`)
+ },
+ /** 瀵煎叆妯℃澘涓嬭浇鎿嶄綔*/
+ handleExportTemplate()
+ {
+
+ this.download('/system/placeName/model', {
+
+ }, `placeName_${new Date().getTime()}.xls`)
+ },
+ /** 瀵煎叆鎿嶄綔*/
+ async handleImport({file}){
+ // 妫�鏌ユ枃浠剁被鍨嬫槸鍚︿负xlsx
+ // if (!params.file.name.endsWith('.xlsx')) {
+ // this.$message.error('璇蜂笂浼�.xlsx鏍煎紡鐨勬枃浠�');
+ // return;
+ // }
+ const formData = new FormData();
+ formData.append('file', file);
+ console.log(file)
+
+ // 鏄剧ず鍔犺浇涓姸鎬�
+ const loading = this.$loading({
+ lock: true,
+ text: '涓婁紶涓�...',
+ spinner: 'el-icon-loading',
+ background: 'rgba(0, 0, 0, 0.7)'
+ });
+
+ enload(formData, {
+ headers: {
+ 'Content-Type': 'multipart/form-data'
}
+ }).then(response => {
+ loading.close();
+ this.$message.success('瀵煎叆鎴愬姛');
+ this.getList();
+ }).catch(error => {
+ loading.close();
+ this.$message.error('瀵煎叆澶辫触: ' + (error.message || '鏈煡閿欒'));
+ });
+
+ }
+
}
}
</script>
--
Gitblit v1.9.1