2023-12-14 10:15:23 +08:00
|
|
|
|
<template>
|
2023-12-24 16:07:13 +08:00
|
|
|
|
<div style="width: 1300px">
|
2023-12-14 10:15:23 +08:00
|
|
|
|
<div class="body-div">
|
2023-12-24 16:07:13 +08:00
|
|
|
|
<el-form
|
2025-01-19 03:31:48 +08:00
|
|
|
|
label-width="120px"
|
|
|
|
|
|
:model="editForm"
|
|
|
|
|
|
label-position="left"
|
|
|
|
|
|
:rules="rules"
|
|
|
|
|
|
ref="ruleFormRef"
|
2023-12-24 16:07:13 +08:00
|
|
|
|
>
|
2023-12-14 10:15:23 +08:00
|
|
|
|
<el-form-item label="类型:">
|
|
|
|
|
|
<el-radio-group v-model="radio">
|
2024-01-04 21:04:44 +08:00
|
|
|
|
<el-radio-button label="discuss" :disabled="artType !== 'discuss'"
|
2025-01-19 03:31:48 +08:00
|
|
|
|
>主题
|
2025-04-12 23:18:06 +08:00
|
|
|
|
</el-radio-button>
|
2024-01-04 21:04:44 +08:00
|
|
|
|
<el-radio-button label="article" :disabled="artType !== 'article'"
|
2025-01-19 03:31:48 +08:00
|
|
|
|
>文章
|
|
|
|
|
|
</el-radio-button
|
2024-01-04 21:04:44 +08:00
|
|
|
|
>
|
|
|
|
|
|
<el-radio-button label="plate" :disabled="artType !== 'plate'"
|
2025-01-19 03:31:48 +08:00
|
|
|
|
>板块
|
|
|
|
|
|
</el-radio-button
|
2024-01-04 21:04:44 +08:00
|
|
|
|
>
|
|
|
|
|
|
<el-radio-button label="orther" :disabled="artType !== 'orther'"
|
2025-01-19 03:31:48 +08:00
|
|
|
|
>其他
|
|
|
|
|
|
</el-radio-button
|
2024-01-04 21:04:44 +08:00
|
|
|
|
>
|
2023-12-14 10:15:23 +08:00
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
</el-form-item>
|
2025-04-12 23:18:06 +08:00
|
|
|
|
|
|
|
|
|
|
<el-form-item label="主题类型:" v-if="radio == 'discuss'">
|
|
|
|
|
|
<el-radio-group v-model="editForm.discussType">
|
|
|
|
|
|
<el-radio-button label="Article">基础</el-radio-button>
|
|
|
|
|
|
<el-radio-button label="Reward">有偿悬赏</el-radio-button>
|
|
|
|
|
|
<el-radio-button label="Test" :disabled="true">问答</el-radio-button>
|
|
|
|
|
|
<el-radio-button label="Test" :disabled="true">投票</el-radio-button>
|
2023-12-14 10:15:23 +08:00
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
</el-form-item>
|
2025-04-12 23:18:06 +08:00
|
|
|
|
<el-form-item label="悬赏金额:" v-if="editForm.discussType == 'Reward'">
|
|
|
|
|
|
<div class="reward-div">
|
|
|
|
|
|
<p style="color: red">通过”悬赏主题“发布问题,双方达成一致并解决问题后,建议有偿提供RMB给解决人员</p>
|
|
|
|
|
|
<p style="color: red">社区只提供解决问题平台,不参与任何交易,请自行联系</p>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<span>最少RMB:</span>
|
|
|
|
|
|
<el-input-number style="margin-right: 40px;" v-model="editForm.rewardData.minValue" :min="10">
|
|
|
|
|
|
</el-input-number>
|
|
|
|
|
|
|
|
|
|
|
|
<span>最多RMB:</span>
|
|
|
|
|
|
<el-input-number v-model="editForm.rewardData.maxValue" :min="10">
|
|
|
|
|
|
</el-input-number>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="联系方式:" v-if="editForm.discussType == 'Reward'">
|
|
|
|
|
|
<el-input v-model="editForm.rewardData.contact" placeholder="输入你的联系方式(例如微信号/QQ号)" />
|
2023-12-14 10:15:23 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
2025-04-12 23:18:06 +08:00
|
|
|
|
<el-form-item label="权限:" v-if="radio == 'discuss'">
|
|
|
|
|
|
<el-radio-group v-model="perRadio">
|
|
|
|
|
|
<el-radio-button label="Public">公开</el-radio-button>
|
|
|
|
|
|
<el-radio-button label="Role">所选角色可见</el-radio-button>
|
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
label="可见角色:"
|
|
|
|
|
|
v-if="radio == 'discuss' && perRadio == 'Role'"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input-tag
|
|
|
|
|
|
v-model="editForm.permissionRoleCodes"
|
|
|
|
|
|
placeholder="请输入角色code"
|
|
|
|
|
|
aria-label="按下回车,可选择多个"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="radio == 'article'"
|
|
|
|
|
|
label="子文章名称:"
|
|
|
|
|
|
prop="name"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input placeholder="请输入" v-model="editForm.name"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item v-else label="标题:" prop="title">
|
|
|
|
|
|
<el-input placeholder="请输入" v-model="editForm.title"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="描述:" prop="introduction">
|
|
|
|
|
|
<el-input placeholder="请输入" v-model="editForm.introduction"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="内容:" prop="content">
|
|
|
|
|
|
<MavonEdit
|
|
|
|
|
|
height="30rem"
|
|
|
|
|
|
v-model="editForm.content"
|
|
|
|
|
|
:codeStyle="codeStyle"
|
2024-01-04 20:40:57 +08:00
|
|
|
|
/>
|
2025-04-12 23:18:06 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="首页:" v-if="radio == 'discuss'">
|
|
|
|
|
|
|
|
|
|
|
|
<el-image
|
|
|
|
|
|
v-if="dialogImageUrl"
|
|
|
|
|
|
:src="getUrl"
|
|
|
|
|
|
style="width: 178px; height: 178px"
|
|
|
|
|
|
class="avatar"
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 主题首页选择 -->
|
|
|
|
|
|
<el-upload
|
|
|
|
|
|
class="avatar-uploader"
|
|
|
|
|
|
:action="fileUploadUrl"
|
|
|
|
|
|
:show-file-list="false"
|
|
|
|
|
|
:on-success="onSuccess"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-icon class="avatar-uploader-icon">
|
|
|
|
|
|
<Plus/>
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
</el-upload>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="分类标签:" prop="discussLable" v-if="radio == 'discuss'">
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
value-key="id"
|
|
|
|
|
|
v-model="selectLabelList"
|
|
|
|
|
|
multiple
|
|
|
|
|
|
filterable
|
|
|
|
|
|
remote
|
|
|
|
|
|
reserve-keyword
|
|
|
|
|
|
placeholder="请选择合适的文章标签"
|
|
|
|
|
|
:remote-method="remoteMethod"
|
|
|
|
|
|
:loading="labelLoading"
|
|
|
|
|
|
style="width: 435px"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in labelListData"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:label="item.name"
|
|
|
|
|
|
:value="item"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
@click="submit(ruleFormRef)"
|
|
|
|
|
|
class="submit-btn"
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
>提交
|
|
|
|
|
|
</el-button
|
|
|
|
|
|
>
|
|
|
|
|
|
</el-form-item
|
|
|
|
|
|
>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
<div class="import-content" v-show="radio == 'article'">
|
|
|
|
|
|
<div class="text">上传类型:</div>
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
v-model="currentType"
|
|
|
|
|
|
placeholder="请选择"
|
|
|
|
|
|
style="width: 120px"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in typeOptions"
|
|
|
|
|
|
:key="item.value"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
:icon="Download"
|
|
|
|
|
|
:loading="importLoading"
|
|
|
|
|
|
@click="handleImport"
|
|
|
|
|
|
class="import-btn"
|
|
|
|
|
|
>导入文章
|
|
|
|
|
|
</el-button
|
|
|
|
|
|
>
|
2023-12-14 10:15:23 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-04-12 23:18:06 +08:00
|
|
|
|
<!-- 文件弹框 -->
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<input
|
|
|
|
|
|
v-show="false"
|
|
|
|
|
|
ref="fileRef"
|
|
|
|
|
|
type="file"
|
|
|
|
|
|
multiple
|
|
|
|
|
|
@change="getFile"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2023-12-14 10:15:23 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import MavonEdit from "@/components/MavonEdit.vue";
|
2024-09-30 00:40:47 +08:00
|
|
|
|
import {ref, reactive, onMounted, computed} from "vue";
|
2025-01-19 03:31:48 +08:00
|
|
|
|
import {useRoute, useRouter} from "vue-router";
|
|
|
|
|
|
import {Plus, Download} from "@element-plus/icons-vue";
|
2023-12-14 10:15:23 +08:00
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
add as discussAdd,
|
|
|
|
|
|
update as discussUpdate,
|
|
|
|
|
|
get as discussGet,
|
|
|
|
|
|
} from "@/apis/discussApi.js";
|
|
|
|
|
|
|
2025-01-19 03:31:48 +08:00
|
|
|
|
import {
|
|
|
|
|
|
getAllList as getLableAllList
|
|
|
|
|
|
} from "@/apis/discussLableApi"
|
|
|
|
|
|
|
2023-12-14 10:15:23 +08:00
|
|
|
|
import {
|
|
|
|
|
|
add as articleAdd,
|
|
|
|
|
|
update as articleUpdate,
|
|
|
|
|
|
get as articleGet,
|
2024-01-03 23:32:32 +08:00
|
|
|
|
importArticle,
|
2023-12-14 10:15:23 +08:00
|
|
|
|
} from "@/apis/articleApi.js";
|
|
|
|
|
|
|
|
|
|
|
|
//数据定义
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
|
const router = useRouter();
|
2023-12-24 16:07:13 +08:00
|
|
|
|
const perRadio = ref("Public");
|
2023-12-14 10:15:23 +08:00
|
|
|
|
const radio = ref(route.query.artType);
|
|
|
|
|
|
const codeStyle = "atom-one-dark";
|
|
|
|
|
|
|
2024-01-04 21:04:44 +08:00
|
|
|
|
// 用于禁用判断
|
|
|
|
|
|
const artType = ref(route.query.artType);
|
2023-12-14 10:15:23 +08:00
|
|
|
|
//封面完整显示的url
|
2023-12-24 16:07:13 +08:00
|
|
|
|
const fileUploadUrl = `${import.meta.env.VITE_APP_BASEAPI}/file`;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
//封面的url
|
2023-12-24 16:07:13 +08:00
|
|
|
|
const dialogImageUrl = ref("");
|
2023-12-14 10:15:23 +08:00
|
|
|
|
|
2025-01-19 03:31:48 +08:00
|
|
|
|
//远程文章标签
|
|
|
|
|
|
const labelListData = ref([]);
|
|
|
|
|
|
const labelLoading = ref(false);
|
|
|
|
|
|
const selectLabelList = ref([]);
|
|
|
|
|
|
//远程下拉框查询文章标签
|
|
|
|
|
|
const remoteMethod = async (query) => {
|
|
|
|
|
|
labelLoading.value = true
|
2025-04-12 23:18:06 +08:00
|
|
|
|
const {data} = await getLableAllList({name: query});
|
2025-01-19 03:31:48 +08:00
|
|
|
|
labelLoading.value = false
|
2025-01-19 15:17:48 +08:00
|
|
|
|
labelListData.value = data.items;
|
2025-01-19 03:31:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-14 10:15:23 +08:00
|
|
|
|
//文件上传成功后
|
2023-12-24 16:07:13 +08:00
|
|
|
|
const onSuccess = (response) => {
|
2024-09-30 00:40:47 +08:00
|
|
|
|
dialogImageUrl.value = response[0].id;
|
2023-12-24 16:07:13 +08:00
|
|
|
|
};
|
2024-09-30 00:40:47 +08:00
|
|
|
|
|
2023-12-14 10:15:23 +08:00
|
|
|
|
//封面url
|
2025-01-19 03:31:48 +08:00
|
|
|
|
const getUrl = computed(() => {
|
2024-09-30 00:40:47 +08:00
|
|
|
|
return `${import.meta.env.VITE_APP_BASEAPI}/file/${dialogImageUrl.value}`;
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2023-12-14 10:15:23 +08:00
|
|
|
|
|
|
|
|
|
|
//整个页面上的表单
|
|
|
|
|
|
const editForm = reactive({
|
2025-04-12 23:18:06 +08:00
|
|
|
|
|
|
|
|
|
|
discussType: "Article",
|
2023-12-14 10:15:23 +08:00
|
|
|
|
title: "",
|
|
|
|
|
|
introduction: "",
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
name: "",
|
2025-01-19 18:40:42 +08:00
|
|
|
|
permissionRoleCodes: [],
|
2025-04-12 23:18:06 +08:00
|
|
|
|
discussLableIds: [],
|
|
|
|
|
|
rewardData: {
|
|
|
|
|
|
minValue: 10,
|
|
|
|
|
|
maxValue: 200,
|
|
|
|
|
|
contact:""
|
|
|
|
|
|
}
|
2023-12-14 10:15:23 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//组装主题内容: 需要更新主题信息
|
2023-12-24 16:07:13 +08:00
|
|
|
|
const discuss = {};
|
2023-12-14 10:15:23 +08:00
|
|
|
|
|
|
|
|
|
|
//组装文章内容:需要添加的文章信息
|
2023-12-24 16:07:13 +08:00
|
|
|
|
const article = {};
|
2023-12-14 10:15:23 +08:00
|
|
|
|
|
|
|
|
|
|
//定义效验规则
|
|
|
|
|
|
const ruleFormRef = ref(null);
|
|
|
|
|
|
const rules = reactive({
|
|
|
|
|
|
title: [
|
2025-01-19 03:31:48 +08:00
|
|
|
|
{required: true, message: "请输入标题", trigger: "blur"},
|
|
|
|
|
|
{min: 3, max: 40, message: "长度 3 到 20", trigger: "blur"},
|
2023-12-14 10:15:23 +08:00
|
|
|
|
],
|
2025-01-19 03:31:48 +08:00
|
|
|
|
name: [{required: true, message: "请输入子文章名称", trigger: "blur"}],
|
2023-12-14 10:15:23 +08:00
|
|
|
|
content: [
|
2025-01-19 03:31:48 +08:00
|
|
|
|
{required: true, message: "请输入内容", trigger: "blur"},
|
|
|
|
|
|
{min: 10, message: "长度 大于 10", trigger: "blur"},
|
2023-12-14 10:15:23 +08:00
|
|
|
|
],
|
|
|
|
|
|
});
|
|
|
|
|
|
//提交按钮,需要区分操作类型
|
|
|
|
|
|
const submit = async (formEl) => {
|
|
|
|
|
|
if (!formEl) return;
|
|
|
|
|
|
await formEl.validate(async (valid, fields) => {
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
//dicuss主题处理
|
2024-01-03 23:32:32 +08:00
|
|
|
|
if (radio.value == "discuss") {
|
2025-04-12 23:18:06 +08:00
|
|
|
|
discuss.discussType=editForm.discussType;
|
|
|
|
|
|
discuss.discussLableIds = selectLabelList.value.map((item) => item.id);
|
2023-12-14 10:15:23 +08:00
|
|
|
|
discuss.title = editForm.title;
|
|
|
|
|
|
discuss.introduction = editForm.introduction;
|
|
|
|
|
|
discuss.content = editForm.content;
|
2023-12-24 16:07:13 +08:00
|
|
|
|
discuss.plateId = discuss.plateId ?? route.query.plateId;
|
|
|
|
|
|
discuss.cover = dialogImageUrl.value;
|
|
|
|
|
|
discuss.permissionType = perRadio.value;
|
2025-01-19 18:40:42 +08:00
|
|
|
|
discuss.permissionRoleCodes = editForm.permissionRoleCodes;
|
2025-04-12 23:18:06 +08:00
|
|
|
|
//悬赏还需要新增参数
|
|
|
|
|
|
if (editForm.discussType == 'Reward')
|
|
|
|
|
|
{
|
|
|
|
|
|
discuss.rewardData= editForm.rewardData;
|
|
|
|
|
|
if (editForm.rewardData.contact=="")
|
|
|
|
|
|
{
|
|
|
|
|
|
ElMessage.error("悬赏的联系方式不能为空!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (editForm.rewardData.maxValue<editForm.rewardData.minValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
ElMessage.error("悬赏设置的最多金额不能小于最少金额");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//主题创建
|
2023-12-14 10:15:23 +08:00
|
|
|
|
if (route.query.operType == "create") {
|
|
|
|
|
|
const response = await discussAdd(discuss);
|
|
|
|
|
|
|
|
|
|
|
|
ElMessage({
|
|
|
|
|
|
message: `[${discuss.title}]主题创建成功!`,
|
2023-12-24 16:07:13 +08:00
|
|
|
|
type: "success",
|
|
|
|
|
|
});
|
2025-01-19 03:31:48 +08:00
|
|
|
|
var routerPer = {path: `/article/${response.data.id}`};
|
2023-12-14 10:15:23 +08:00
|
|
|
|
router.push(routerPer);
|
|
|
|
|
|
}
|
|
|
|
|
|
//主题更新
|
|
|
|
|
|
else if (route.query.operType == "update") {
|
2025-04-12 23:18:06 +08:00
|
|
|
|
discuss.discussLableIds = selectLabelList.value.map((item) => item.id);
|
2023-12-14 10:15:23 +08:00
|
|
|
|
await discussUpdate(route.query.discussId, discuss);
|
|
|
|
|
|
|
|
|
|
|
|
ElMessage({
|
|
|
|
|
|
message: `[${discuss.title}]主题更新成功!`,
|
2023-12-24 16:07:13 +08:00
|
|
|
|
type: "success",
|
|
|
|
|
|
});
|
2025-01-19 03:31:48 +08:00
|
|
|
|
var routerPer = {path: `/article/${route.query.discussId}`};
|
2023-12-14 10:15:23 +08:00
|
|
|
|
router.push(routerPer);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//artcle文章处理
|
2024-01-03 23:32:32 +08:00
|
|
|
|
else if (radio.value == "article") {
|
2023-12-14 10:15:23 +08:00
|
|
|
|
//组装文章内容:需要添加的文章信息
|
|
|
|
|
|
article.content = editForm.content;
|
|
|
|
|
|
article.name = editForm.name;
|
|
|
|
|
|
article.discussId = route.query.discussId;
|
2023-12-24 16:07:13 +08:00
|
|
|
|
article.parentId = route.query.parentArticleId;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
//文章创建
|
|
|
|
|
|
if (route.query.operType == "create") {
|
|
|
|
|
|
const response = await articleAdd(article);
|
|
|
|
|
|
ElMessage({
|
|
|
|
|
|
message: `[${article.name}]文章创建成功!`,
|
2023-12-24 16:07:13 +08:00
|
|
|
|
type: "success",
|
|
|
|
|
|
});
|
|
|
|
|
|
var routerPer = {
|
|
|
|
|
|
path: `/article/${route.query.discussId}/${response.data.id}`,
|
|
|
|
|
|
};
|
2023-12-14 10:15:23 +08:00
|
|
|
|
router.push(routerPer);
|
|
|
|
|
|
}
|
|
|
|
|
|
//文章更新
|
|
|
|
|
|
else if (route.query.operType == "update") {
|
|
|
|
|
|
await articleUpdate(route.query.articleId, article);
|
|
|
|
|
|
ElMessage({
|
|
|
|
|
|
message: `[${article.name}]文章更新成功!`,
|
2023-12-24 16:07:13 +08:00
|
|
|
|
type: "success",
|
|
|
|
|
|
});
|
|
|
|
|
|
var routerPer = {
|
|
|
|
|
|
path: `/article/${route.query.discussId}/${route.query.articleId}`,
|
|
|
|
|
|
};
|
2023-12-14 10:15:23 +08:00
|
|
|
|
router.push(routerPer);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
//如果是更新操作,需要先查询
|
|
|
|
|
|
if (route.query.operType == "update") {
|
|
|
|
|
|
//更新主题
|
2024-01-03 23:32:32 +08:00
|
|
|
|
if (radio.value == "discuss") {
|
2023-12-14 10:15:23 +08:00
|
|
|
|
await loadDiscuss();
|
|
|
|
|
|
|
|
|
|
|
|
//更新文章
|
2024-01-03 23:32:32 +08:00
|
|
|
|
} else if (radio.value == "article") {
|
2023-12-14 10:15:23 +08:00
|
|
|
|
await loadArticle();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
//加载主题
|
|
|
|
|
|
const loadDiscuss = async () => {
|
|
|
|
|
|
const response = await discussGet(route.query.discussId);
|
2023-12-24 16:07:13 +08:00
|
|
|
|
const res = response.data;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
editForm.content = res.content;
|
|
|
|
|
|
editForm.title = res.title;
|
|
|
|
|
|
editForm.introduction = res.introduction;
|
2025-04-12 23:18:06 +08:00
|
|
|
|
editForm.discussLableIds = res.discussLableIds;
|
2025-01-19 18:40:42 +08:00
|
|
|
|
editForm.permissionRoleCodes = res.permissionRoleCodes;
|
2025-04-12 23:18:06 +08:00
|
|
|
|
|
2025-01-19 15:17:48 +08:00
|
|
|
|
//编辑状态,已选择的就是全部
|
2025-04-12 23:18:06 +08:00
|
|
|
|
labelListData.value = res.lables;
|
|
|
|
|
|
selectLabelList.value = res.lables;
|
|
|
|
|
|
|
2023-12-14 10:15:23 +08:00
|
|
|
|
discuss.plateId = res.plateId;
|
2023-12-24 16:07:13 +08:00
|
|
|
|
dialogImageUrl.value = res.cover;
|
|
|
|
|
|
perRadio.value = res.permissionType;
|
2025-01-19 18:40:42 +08:00
|
|
|
|
|
2023-12-14 10:15:23 +08:00
|
|
|
|
};
|
|
|
|
|
|
//加载文章
|
|
|
|
|
|
const loadArticle = async () => {
|
|
|
|
|
|
const response = await articleGet(route.query.articleId);
|
2023-12-24 16:07:13 +08:00
|
|
|
|
const res = response.data;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
editForm.content = res.content;
|
|
|
|
|
|
editForm.name = res.name;
|
|
|
|
|
|
editForm.discussId = res.discussId;
|
|
|
|
|
|
};
|
2024-01-03 23:32:32 +08:00
|
|
|
|
|
|
|
|
|
|
// 导入
|
|
|
|
|
|
let importLoading = ref(false);
|
|
|
|
|
|
const fileRef = ref(null);
|
|
|
|
|
|
const handleImport = async () => {
|
|
|
|
|
|
fileRef.value.click();
|
|
|
|
|
|
};
|
2024-01-04 23:18:49 +08:00
|
|
|
|
const currentType = ref("Default");
|
2024-01-03 23:32:32 +08:00
|
|
|
|
const typeOptions = [
|
|
|
|
|
|
{
|
2024-01-04 23:18:49 +08:00
|
|
|
|
value: "Default",
|
2024-01-03 23:32:32 +08:00
|
|
|
|
label: "默认",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2024-01-05 00:04:34 +08:00
|
|
|
|
value: "VuePress",
|
|
|
|
|
|
label: "VuePress",
|
2024-01-03 23:32:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
const getFile = async (e) => {
|
|
|
|
|
|
importLoading.value = true;
|
|
|
|
|
|
try {
|
2024-01-04 20:40:57 +08:00
|
|
|
|
let formData = new FormData();
|
|
|
|
|
|
for (let i = 0; i < e.target.files.length; i++) {
|
|
|
|
|
|
formData.append("file", e.target.files[i]);
|
|
|
|
|
|
}
|
2024-01-03 23:32:32 +08:00
|
|
|
|
await importArticle(
|
2025-01-19 03:31:48 +08:00
|
|
|
|
{
|
|
|
|
|
|
discussId: route.query.discussId,
|
|
|
|
|
|
articleParentId: route.query.parentArticleId,
|
|
|
|
|
|
importType: currentType.value,
|
|
|
|
|
|
},
|
|
|
|
|
|
formData
|
2024-01-03 23:32:32 +08:00
|
|
|
|
);
|
|
|
|
|
|
ElMessage({
|
|
|
|
|
|
message: `导入成功!`,
|
|
|
|
|
|
type: "success",
|
|
|
|
|
|
});
|
|
|
|
|
|
importLoading.value = false;
|
2025-01-19 03:31:48 +08:00
|
|
|
|
const routerPer = {path: `/article/${route.query.discussId}`};
|
2024-01-04 19:41:55 +08:00
|
|
|
|
router.push(routerPer);
|
2024-01-03 23:32:32 +08:00
|
|
|
|
} catch (error) {
|
2024-01-04 20:47:08 +08:00
|
|
|
|
ElMessage.error(error.message);
|
2024-01-03 23:32:32 +08:00
|
|
|
|
importLoading.value = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2023-12-14 10:15:23 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.submit-btn {
|
|
|
|
|
|
width: 40%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-12 23:18:06 +08:00
|
|
|
|
.reward-div {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-14 10:15:23 +08:00
|
|
|
|
.body-div {
|
2024-01-03 23:32:32 +08:00
|
|
|
|
position: relative;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
min-height: 1000px;
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
margin: 1.5rem;
|
|
|
|
|
|
padding: 1.5rem;
|
2025-01-19 03:31:48 +08:00
|
|
|
|
|
2024-01-03 23:32:32 +08:00
|
|
|
|
.import-content {
|
2024-01-04 08:56:52 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2024-01-03 23:32:32 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 1.5rem;
|
|
|
|
|
|
right: 1.5rem;
|
2025-01-19 03:31:48 +08:00
|
|
|
|
|
2024-01-04 08:56:52 +08:00
|
|
|
|
.text {
|
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
}
|
2024-01-03 23:32:32 +08:00
|
|
|
|
}
|
2025-01-19 03:31:48 +08:00
|
|
|
|
|
2024-01-03 23:32:32 +08:00
|
|
|
|
.import-btn {
|
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
|
}
|
2023-12-14 10:15:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-24 16:07:13 +08:00
|
|
|
|
.avatar-uploader >>> .el-upload {
|
2023-12-14 10:15:23 +08:00
|
|
|
|
border: 1px dashed var(--el-border-color);
|
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
transition: var(--el-transition-duration-fast);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-24 16:07:13 +08:00
|
|
|
|
.avatar-uploader >>> .el-upload:hover {
|
2023-12-14 10:15:23 +08:00
|
|
|
|
border-color: var(--el-color-primary);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-icon.avatar-uploader-icon {
|
|
|
|
|
|
font-size: 28px;
|
|
|
|
|
|
color: #8c939d;
|
|
|
|
|
|
width: 178px;
|
|
|
|
|
|
height: 178px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
2025-01-19 03:31:48 +08:00
|
|
|
|
|
2023-12-24 16:07:13 +08:00
|
|
|
|
.el-upload {
|
2023-12-14 10:15:23 +08:00
|
|
|
|
}
|
2023-12-24 16:07:13 +08:00
|
|
|
|
</style>
|