导出请求处理
This commit is contained in:
@@ -35,3 +35,11 @@ export function updateProduct(data: object) {
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
export function exportProduct(data: object) {
|
||||
return newService({
|
||||
url: '/customerService/product/export',
|
||||
method: 'get',
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ const service: AxiosInstance = axios.create({
|
||||
|
||||
// 配置新建第二个 axios 实例(新功能服务)
|
||||
const newService: AxiosInstance = axios.create({
|
||||
// baseURL: 'http://192.168.3.95:8000/', // 新后端地址
|
||||
baseURL: 'http://192.168.3.49:8000/', // 后端地址
|
||||
baseURL: 'http://192.168.3.95:8000/', // 新后端地址
|
||||
// baseURL: 'http://192.168.3.49:8000/', // 后端地址
|
||||
timeout: 50000, // 50秒超时
|
||||
headers: { 'Content-Type': 'application/json' }, // 默认JSON格式
|
||||
paramsSerializer: {
|
||||
@@ -50,7 +50,8 @@ const responseInterceptor = (response: any) => {
|
||||
// 对响应数据做点什么
|
||||
const res = response.data;
|
||||
const code = response.data.code;
|
||||
if (code === 401) {
|
||||
const message = response.data.message;
|
||||
if (code === 401 || message === 'token is invalid') {
|
||||
// 401未授权:token过期,跳转登录页
|
||||
ElMessageBox.alert('登录状态已过期,请重新登录', '提示', { confirmButtonText: '确定' })
|
||||
.then(() => {
|
||||
|
||||
@@ -142,7 +142,7 @@ const tableData = reactive<TableState>({
|
||||
});
|
||||
|
||||
// 模板引用
|
||||
const editRoleRef = ref<InstanceType<typeof EditRole>>();
|
||||
const editRoleRef = ref<InstanceType<typeof EditAccount>>();
|
||||
|
||||
/**
|
||||
* 获取客服账号列表
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<!-- 富文本编辑器 -->
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
||||
<el-form-item label="产品详情" prop="content">
|
||||
<el-form-item label="产品详情" prop="description" required>
|
||||
<Editor v-model="formData.description" height="400px" placeholder="请输入产品详细描述..." />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -81,11 +81,11 @@ const state = reactive<ComponentState>({
|
||||
|
||||
// 表单验证规则
|
||||
const rules: FormRules = {
|
||||
name: [
|
||||
{ required: true, message: '产品名称不能为空', trigger: 'blur' },
|
||||
{ min: 2, max: 50, message: '产品名称长度在 2 到 50 个字符', trigger: 'blur' },
|
||||
name: [{ required: true, message: '产品名称不能为空', trigger: 'blur' }, { max: 64, message: '产品名称长度最多 64 个字符', trigger: 'blur' }, 1],
|
||||
description: [
|
||||
{ required: true, message: '产品详情不能为空', trigger: 'blur' },
|
||||
{ max: 8126, message: '产品详情长度最多8126 个字符', trigger: 'blur' },
|
||||
],
|
||||
description: [{ required: true, message: '产品详情不能为空', trigger: 'blur' }],
|
||||
};
|
||||
|
||||
// 模板引用
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { exportProduct } from '/@/api/customerService/product';
|
||||
|
||||
const isShowDialog = ref(false);
|
||||
const tableData = ref([]);
|
||||
const exportname = ref();
|
||||
|
||||
const form = reactive({
|
||||
exportType: 'current',
|
||||
@@ -22,14 +24,23 @@ const form = reactive({
|
||||
});
|
||||
|
||||
// 打开对话框
|
||||
const openDialog = (data: any) => {
|
||||
tableData.value = data;
|
||||
const openDialog = (name: string) => {
|
||||
isShowDialog.value = true;
|
||||
exportname.value = name;
|
||||
};
|
||||
|
||||
// 处理导出
|
||||
const handleExport = () => {
|
||||
const handleExport = async () => {
|
||||
// 这里处理导出逻辑
|
||||
if (exportname.value) {
|
||||
await exportProduct({ name: exportname.value });
|
||||
} else {
|
||||
await exportProduct({});
|
||||
}
|
||||
|
||||
console.log(tableData.value, '111');
|
||||
console.log(exportname.value, '222');
|
||||
|
||||
ElMessage.success('导出成功');
|
||||
isShowDialog.value = false;
|
||||
};
|
||||
|
||||
@@ -264,7 +264,7 @@ const onOpenImport = () => {
|
||||
*/
|
||||
const onOpenExport = () => {
|
||||
if (exportDialogRef.value) {
|
||||
exportDialogRef.value.openDialog(tableData.data);
|
||||
exportDialogRef.value.openDialog(tableData.param.name);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -64,8 +64,14 @@ const state = reactive({
|
||||
|
||||
// 表单验证规则
|
||||
const rules: FormRules = {
|
||||
tag: [{ required: true, message: '标签名称不能为空', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '产品详情不能为空', trigger: 'blur' }],
|
||||
tag: [
|
||||
{ required: true, message: '标签名称不能为空', trigger: 'blur' },
|
||||
{ max: 64, message: '标签长度最多 64 个字符', trigger: 'blur' },
|
||||
],
|
||||
content: [
|
||||
{ required: true, message: '产品详情不能为空', trigger: 'blur' },
|
||||
{ max: 8126, message: '产品名称长度最多 8126 个字符', trigger: 'blur' },
|
||||
],
|
||||
};
|
||||
|
||||
// 模板引用
|
||||
|
||||
Reference in New Issue
Block a user