|
|
@@ -30,11 +30,23 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<el-row >
|
|
|
-
|
|
|
- <el-button type="primary">上传</el-button>
|
|
|
-
|
|
|
- <el-button type="primary">一键导出签证</el-button>
|
|
|
-
|
|
|
+ <div>
|
|
|
+ <el-upload
|
|
|
+ class="upload-inline"
|
|
|
+ action="#"
|
|
|
+ :multiple="false"
|
|
|
+ :show-file-list="false"
|
|
|
+ :before-upload="beforeWordUpload"
|
|
|
+ :on-change="handleWordFileChange"
|
|
|
+ :auto-upload="false"
|
|
|
+ accept=".doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document">
|
|
|
+ <el-button type="primary" :loading="isUploading">
|
|
|
+ <span v-if="!isUploading">上传</span>
|
|
|
+ <span v-else>上传中...</span>
|
|
|
+ </el-button>
|
|
|
+ </el-upload>
|
|
|
+ <el-button @click="VisaFileDownload" type="primary">一键导出签证</el-button>
|
|
|
+ </div>
|
|
|
<!-- <el-button type="primary">一键导省外办</el-button>
|
|
|
<el-button type="primary">一键导市外办</el-button>
|
|
|
<el-button type="primary">签证事项表</el-button>
|
|
|
@@ -115,6 +127,9 @@ export default {
|
|
|
multipleTable: [],
|
|
|
token: '',
|
|
|
fileList: [],
|
|
|
+
|
|
|
+ uploadFile: null, // 当前选中的Word文件
|
|
|
+ isUploading: false, // 上传状态
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -165,6 +180,24 @@ export default {
|
|
|
that.getCrm()
|
|
|
})
|
|
|
},
|
|
|
+ //导出签证
|
|
|
+ VisaFileDownload() {
|
|
|
+ var url = "api/Groups/VisaFileDownload?groupId="+this.gnamevalue+"&fileTypeId="+this.groupvalues
|
|
|
+ var that = this
|
|
|
+ this.$axios({
|
|
|
+ method: 'get',
|
|
|
+ url: url,
|
|
|
+ headers: {
|
|
|
+ Authorization: 'Bearer ' + this.token
|
|
|
+ },
|
|
|
+ }).then(function (res) {
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ window.open(res.data.data);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
getCrm() {
|
|
|
this.tableData = [];
|
|
|
var url = "api/Groups/GetCrmByGroupId"
|
|
|
@@ -244,6 +277,137 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ handleWordFileChange(file, fileList) {
|
|
|
+ console.log('文件已选择:', file);
|
|
|
+ this.uploadFile = file.raw;
|
|
|
+
|
|
|
+ // 选择文件后立即自动上传
|
|
|
+ if (file.status === 'ready') {
|
|
|
+ this.uploadWordFile();
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 🆕 上传前的验证
|
|
|
+ beforeWordUpload(file) {
|
|
|
+ // 验证文件类型
|
|
|
+ const isWord = file.type === 'application/msword' ||
|
|
|
+ file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
|
|
+ file.name.endsWith('.doc') ||
|
|
|
+ file.name.endsWith('.docx');
|
|
|
+
|
|
|
+ if (!isWord) {
|
|
|
+ this.$message.error('只能上传Word文件(.doc/.docx)!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 验证文件大小(限制为10MB)
|
|
|
+ const isLt10M = file.size / 1024 / 1024 < 10;
|
|
|
+ if (!isLt10M) {
|
|
|
+ this.$message.error('文件大小不能超过10MB!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 🆕 执行上传到指定接口
|
|
|
+ async uploadWordFile() {
|
|
|
+ if (!this.uploadFile) {
|
|
|
+ this.$message.warning('请选择Word文件');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 验证文件类型
|
|
|
+ if (!this.beforeWordUpload(this.uploadFile)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.isUploading = true;
|
|
|
+
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append('visaFile', this.uploadFile);
|
|
|
+ var url = "api/Groups/VisaFileUploadAndUpdate"
|
|
|
+ var that = this
|
|
|
+ this.$axios({
|
|
|
+ method: 'post',
|
|
|
+ url: url,
|
|
|
+ headers: {
|
|
|
+ Authorization: 'Bearer ' + this.token
|
|
|
+ },
|
|
|
+ data: formData,
|
|
|
+
|
|
|
+ }).then(function (res) {
|
|
|
+ if (res.data.code==200) {
|
|
|
+ that.isUploading = false;
|
|
|
+ that.uploadFile = null;
|
|
|
+ }else{
|
|
|
+ that.isUploading = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // try {
|
|
|
+ // // 创建FormData对象
|
|
|
+ // // formData.append('groupId', this.gnamevalue);
|
|
|
+ // // formData.append('portType', '1');
|
|
|
+
|
|
|
+ // // 添加签证国别(如果已选择)
|
|
|
+ // // if (this.groupvalues) {
|
|
|
+ // // formData.append('visaNationality', this.groupvalues);
|
|
|
+ // // }
|
|
|
+
|
|
|
+ // const url = 'api/Groups/VisaFileUploadAndUpdate';
|
|
|
+ // const response = await this.$axios({
|
|
|
+ // method: 'post',
|
|
|
+ // url: url,
|
|
|
+ // headers: {
|
|
|
+ // 'Authorization': 'Bearer ' + this.token,
|
|
|
+ // 'Content-Type': 'multipart/form-data'
|
|
|
+ // },
|
|
|
+ // data: formData
|
|
|
+ // });
|
|
|
+
|
|
|
+ // console.log('上传接口响应:', response);
|
|
|
+
|
|
|
+ // if (response.data.code === 200) {
|
|
|
+ // this.$message.success(response.data.message || '文件上传成功!');
|
|
|
+
|
|
|
+ // // 上传成功后刷新表格数据
|
|
|
+ // this.getCrm();
|
|
|
+
|
|
|
+ // // 清空上传的文件
|
|
|
+ // this.uploadFile = null;
|
|
|
+
|
|
|
+ // // 如果接口返回了更新后的数据,可以在这里处理
|
|
|
+ // if (response.data.data) {
|
|
|
+ // // 根据实际接口返回的数据结构进行处理
|
|
|
+ // console.log('接口返回数据:', response.data.data);
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // this.$message.error(response.data.message || '上传失败,请重试!');
|
|
|
+ // }
|
|
|
+ // } catch (error) {
|
|
|
+ // console.error('上传过程中出错:', error);
|
|
|
+
|
|
|
+ // let errorMessage = '上传失败,请重试!';
|
|
|
+ // if (error.response) {
|
|
|
+ // // 服务器返回了错误状态码
|
|
|
+ // errorMessage = error.response.data.message || `服务器错误: ${error.response.status}`;
|
|
|
+ // } else if (error.request) {
|
|
|
+ // // 请求发出但没有收到响应
|
|
|
+ // errorMessage = '网络错误,请检查网络连接';
|
|
|
+ // }
|
|
|
+
|
|
|
+ // this.$message.error(errorMessage);
|
|
|
+ // } finally {
|
|
|
+ // this.isUploading = false;
|
|
|
+ // }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 🆕 如果需要,可以添加一个手动触发上传的方法
|
|
|
+ triggerUpload() {
|
|
|
+ // 这个方法可以通过编程方式触发文件选择
|
|
|
+ // 如果需要的话,可以添加相关逻辑
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
mounted() {
|
|
|
this.token = JSON.parse(localStorage.getItem('userinif')).token;
|
|
|
@@ -349,4 +513,19 @@ export default {
|
|
|
justify-content: space-between;
|
|
|
align-items: center;
|
|
|
}
|
|
|
+
|
|
|
+/* 🆕 添加上传按钮的内联样式 */
|
|
|
+.upload-inline {
|
|
|
+ display: inline-block;
|
|
|
+}
|
|
|
+
|
|
|
+/* 保持原有样式不变 */
|
|
|
+.visa-box {
|
|
|
+ background-color: #fff;
|
|
|
+ padding: 10px;
|
|
|
+ box-shadow: 0 0 5px #0005;
|
|
|
+ border-radius: 10px;
|
|
|
+ min-height: 780px;
|
|
|
+}
|
|
|
+
|
|
|
</style>
|