|
@@ -18,6 +18,7 @@ import {
|
|
|
} from 'element-plus';
|
|
} from 'element-plus';
|
|
|
import { newsMap } from "./newsMap.js";
|
|
import { newsMap } from "./newsMap.js";
|
|
|
import MyEdit from "@/views/xyjsxx/zwxxfb/components/MyEdit.vue";
|
|
import MyEdit from "@/views/xyjsxx/zwxxfb/components/MyEdit.vue";
|
|
|
|
|
+import {Plus} from "@element-plus/icons-vue";
|
|
|
|
|
|
|
|
const tableData = ref([]);
|
|
const tableData = ref([]);
|
|
|
const currentPage = ref(1);
|
|
const currentPage = ref(1);
|
|
@@ -29,6 +30,9 @@ const multipleSelection = ref([]);
|
|
|
const specialColumns = ref([]);
|
|
const specialColumns = ref([]);
|
|
|
const dialogVisible = ref(false);
|
|
const dialogVisible = ref(false);
|
|
|
const myEdit = ref(null);
|
|
const myEdit = ref(null);
|
|
|
|
|
+const imageUrl = ref({id: '',imagesUrl:''});
|
|
|
|
|
+const baseUrl = import.meta.env.VITE_APP_BASE_API;
|
|
|
|
|
+const minioUrl = import.meta.env.VITE_MINIO_BASE_API;
|
|
|
const form = ref({
|
|
const form = ref({
|
|
|
title: '',
|
|
title: '',
|
|
|
specialColumn: '',
|
|
specialColumn: '',
|
|
@@ -41,7 +45,12 @@ const previewDialogVisible = ref(false);
|
|
|
const previewContent = ref('');
|
|
const previewContent = ref('');
|
|
|
|
|
|
|
|
const getList = async () => {
|
|
const getList = async () => {
|
|
|
- const conditionJson = [];
|
|
|
|
|
|
|
+ const conditionJson = [
|
|
|
|
|
+ {
|
|
|
|
|
+ column: 'create_time',
|
|
|
|
|
+ type: 'orderByDesc'
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
if (searchTitle.value) {
|
|
if (searchTitle.value) {
|
|
|
conditionJson.push({
|
|
conditionJson.push({
|
|
|
column: 'title',
|
|
column: 'title',
|
|
@@ -135,22 +144,44 @@ const handleSelectionChange = (val) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleAdd = () => {
|
|
const handleAdd = () => {
|
|
|
|
|
+ form.value = {
|
|
|
|
|
+ title: '',
|
|
|
|
|
+ specialColumn: '',
|
|
|
|
|
+ date: '',
|
|
|
|
|
+ content: '',
|
|
|
|
|
+ dataSource: '',
|
|
|
|
|
+ introduce: ''
|
|
|
|
|
+ };
|
|
|
|
|
+ imageUrl.value.imagesUrl = '';
|
|
|
|
|
+ imageUrl.value.id = '';
|
|
|
|
|
+ nextTick(()=>{
|
|
|
|
|
+ myEdit.value.setContent('');
|
|
|
|
|
+ })
|
|
|
dialogVisible.value = true;
|
|
dialogVisible.value = true;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleAddSubmit = async () => {
|
|
const handleAddSubmit = async () => {
|
|
|
try {
|
|
try {
|
|
|
form.value.content = myEdit.value.getContent();
|
|
form.value.content = myEdit.value.getContent();
|
|
|
- await request.post('/xcrNewsRelease/save', form.value);
|
|
|
|
|
- ElMessage.success('新增成功');
|
|
|
|
|
|
|
+ form.value.files = [{id:imageUrl.value.id}];
|
|
|
|
|
+ if (form.value.id) {
|
|
|
|
|
+ // 修改
|
|
|
|
|
+ await request.post('/xcrNewsRelease/updateById', form.value);
|
|
|
|
|
+ ElMessage.success('修改成功');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 新增
|
|
|
|
|
+ await request.post('/xcrNewsRelease/save', form.value);
|
|
|
|
|
+ ElMessage.success('新增成功');
|
|
|
|
|
+ }
|
|
|
dialogVisible.value = false;
|
|
dialogVisible.value = false;
|
|
|
getList();
|
|
getList();
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- ElMessage.error('新增失败');
|
|
|
|
|
|
|
+ ElMessage.error('操作失败');
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleAddCancel = () => {
|
|
const handleAddCancel = () => {
|
|
|
|
|
+ console.log(form.value);
|
|
|
ElMessageBox.confirm('确定退出编辑页面吗?')
|
|
ElMessageBox.confirm('确定退出编辑页面吗?')
|
|
|
.then(() => {
|
|
.then(() => {
|
|
|
dialogVisible.value = false;
|
|
dialogVisible.value = false;
|
|
@@ -162,6 +193,33 @@ const handlePreview = (content) => {
|
|
|
previewDialogVisible.value = true;
|
|
previewDialogVisible.value = true;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+const handleModify = async (id) => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await request.get(`/xcrNewsRelease/getById/${id}`);
|
|
|
|
|
+ form.value = res.data;
|
|
|
|
|
+ // console.log(res.data);
|
|
|
|
|
+ if(res.data.files.length>0){
|
|
|
|
|
+ imageUrl.value.imagesUrl = minioUrl+res.data.files[0].fileUrl;
|
|
|
|
|
+ imageUrl.value.id = res.data.files[0].id;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ imageUrl.value.imagesUrl = '';
|
|
|
|
|
+ imageUrl.value.id = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ nextTick(()=>{
|
|
|
|
|
+ myEdit.value.setContent(res.data.content);
|
|
|
|
|
+ })
|
|
|
|
|
+ dialogVisible.value = true;
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ ElMessage.error('获取数据失败');
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const handleSuccess = (res)=>{
|
|
|
|
|
+ imageUrl.value.imagesUrl = minioUrl+res.data.fileUrl;
|
|
|
|
|
+ imageUrl.value.id = res.data.id;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
newsMap.forEach((k, v) => {
|
|
newsMap.forEach((k, v) => {
|
|
|
specialColumns.value.push({ value: v, label: k });
|
|
specialColumns.value.push({ value: v, label: k });
|
|
@@ -213,20 +271,21 @@ onMounted(() => {
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column prop="date" label="发布时间" width="180" :show-overflow-tooltip="true"/>
|
|
<el-table-column prop="date" label="发布时间" width="180" :show-overflow-tooltip="true"/>
|
|
|
<el-table-column prop="content" label="内容" :show-overflow-tooltip="true"/>
|
|
<el-table-column prop="content" label="内容" :show-overflow-tooltip="true"/>
|
|
|
- <el-table-column prop="dataSource" label="数据来源" width="180" :show-overflow-tooltip="true"/>
|
|
|
|
|
|
|
+ <el-table-column prop="dataSource" label="数据来源" :show-overflow-tooltip="true"/>
|
|
|
<el-table-column prop="introduce" label="介绍" :show-overflow-tooltip="true"/>
|
|
<el-table-column prop="introduce" label="介绍" :show-overflow-tooltip="true"/>
|
|
|
<el-table-column prop="createBy" label="创建者" width="180" :show-overflow-tooltip="true"/>
|
|
<el-table-column prop="createBy" label="创建者" width="180" :show-overflow-tooltip="true"/>
|
|
|
<el-table-column prop="createTime" label="创建时间" width="180" :show-overflow-tooltip="true"/>
|
|
<el-table-column prop="createTime" label="创建时间" width="180" :show-overflow-tooltip="true"/>
|
|
|
<el-table-column prop="updateBy" label="更新者" width="180" :show-overflow-tooltip="true"/>
|
|
<el-table-column prop="updateBy" label="更新者" width="180" :show-overflow-tooltip="true"/>
|
|
|
<el-table-column prop="updateTime" label="更新时间" width="180" :show-overflow-tooltip="true"/>
|
|
<el-table-column prop="updateTime" label="更新时间" width="180" :show-overflow-tooltip="true"/>
|
|
|
- <el-table-column label="预览" width="180">
|
|
|
|
|
|
|
+ <el-table-column label="预览">
|
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
|
<el-button type="primary" size="small" @click="handlePreview(row.content)">预览</el-button>
|
|
<el-button type="primary" size="small" @click="handlePreview(row.content)">预览</el-button>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" width="120">
|
|
|
|
|
|
|
+ <el-table-column label="操作" width="180">
|
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
|
<el-button type="danger" size="small" @click="handleDelete(row.id)">删除</el-button>
|
|
<el-button type="danger" size="small" @click="handleDelete(row.id)">删除</el-button>
|
|
|
|
|
+ <el-button type="warning" size="small" @click="handleModify(row.id)">修改</el-button>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|
|
@@ -240,7 +299,7 @@ onMounted(() => {
|
|
|
:page-sizes="[10, 20, 30, 50]"
|
|
:page-sizes="[10, 20, 30, 50]"
|
|
|
/>
|
|
/>
|
|
|
<el-dialog
|
|
<el-dialog
|
|
|
- title="新增记录"
|
|
|
|
|
|
|
+ :title="form.value?.id ? '修改记录' : '新增记录'"
|
|
|
v-model="dialogVisible"
|
|
v-model="dialogVisible"
|
|
|
width="50%"
|
|
width="50%"
|
|
|
:before-close="handleAddCancel"
|
|
:before-close="handleAddCancel"
|
|
@@ -267,6 +326,19 @@ onMounted(() => {
|
|
|
<el-form-item label="介绍">
|
|
<el-form-item label="介绍">
|
|
|
<el-input v-model="form.introduce" type="textarea" placeholder="请输入介绍"/>
|
|
<el-input v-model="form.introduce" type="textarea" placeholder="请输入介绍"/>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
+ <el-form-item label="封面">
|
|
|
|
|
+ <el-upload
|
|
|
|
|
+ class="avatar-uploader"
|
|
|
|
|
+ :action="imageUrl.id?baseUrl+'/xcrFile/updateById':baseUrl+'/xcrFile/save'"
|
|
|
|
|
+ :on-success="handleSuccess"
|
|
|
|
|
+ :show-file-list="false"
|
|
|
|
|
+ :limit="100"
|
|
|
|
|
+ :data="{id:imageUrl.id,moduleName:'封面图'}"
|
|
|
|
|
+ >
|
|
|
|
|
+ <img alt="封面" v-if="imageUrl" :src="imageUrl.imagesUrl" class="w-100px h-a" />
|
|
|
|
|
+ <el-icon v-else class="w-100px h-a "><Plus /></el-icon>
|
|
|
|
|
+ </el-upload>
|
|
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="数据来源">
|
|
<el-form-item label="数据来源">
|
|
|
<el-input v-model="form.dataSource" placeholder="请输入数据来源"/>
|
|
<el-input v-model="form.dataSource" placeholder="请输入数据来源"/>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -292,7 +364,7 @@ onMounted(() => {
|
|
|
:before-close="() => previewDialogVisible = false"
|
|
:before-close="() => previewDialogVisible = false"
|
|
|
destroy-on-close
|
|
destroy-on-close
|
|
|
>
|
|
>
|
|
|
- <div v-html="previewContent"></div>
|
|
|
|
|
|
|
+ <pre v-html="previewContent"></pre>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|