|
@@ -41,6 +41,15 @@
|
|
|
@click="handleDelete"
|
|
|
>删除</el-button>
|
|
|
</el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="warning"
|
|
|
+ icon="el-icon-upload"
|
|
|
+ size="mini"
|
|
|
+ @click="handleUpload"
|
|
|
+ >导入</el-button>
|
|
|
+ </el-col>
|
|
|
+ <input ref="fileInput" type="file" @change="handleFileChange" accept=".xls,.xlsx" v-show="false"></input>
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
</el-row>
|
|
|
|
|
@@ -145,7 +154,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { listProject, getProject, delProject, addProject, updateProject } from "@/api/zcustom/project";
|
|
|
+import { listProject, getProject, delProject, addProject, updateProject, uploadExcel} from "@/api/zcustom/project";
|
|
|
import { getListTree, listPlatAppOrg } from '@/api/zcustom/platAppOrg'
|
|
|
|
|
|
export default {
|
|
@@ -386,6 +395,29 @@ export default {
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
}).catch(() => {});
|
|
|
},
|
|
|
+
|
|
|
+ /** 导入按钮操作 */
|
|
|
+ handleUpload() {
|
|
|
+ this.$refs.fileInput.click()
|
|
|
+ },
|
|
|
+
|
|
|
+ handleFileChange(event) {
|
|
|
+ const selectedFile = event.target.files[0];
|
|
|
+ const fileName = selectedFile.name.toLowerCase();
|
|
|
+ const allowedExtensions = /\.(xls|xlsx)$/i;
|
|
|
+ if (allowedExtensions.test(fileName)) {
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append('file', selectedFile);
|
|
|
+ uploadExcel(formData).then(res =>{
|
|
|
+ if (res.code === 200){
|
|
|
+ this.$modal.msgSuccess("导入成功");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.$modal.msgError("请选择正确的文件格式");
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
};
|
|
|
</script>
|