feat:新增轮播图、发展历程模块
This commit is contained in:
parent
8b26cbd04c
commit
191432db37
@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<el-dialog v-model="dialogVisible" title="添加发展历程" width="900px" @closed="closeDialog" @open="openDialog">
|
||||
<el-form ref="formRef" :model="formData" :rules="rules">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label-width="labelWidth" label="年份" prop="development_history_year">
|
||||
<el-input v-model="formData.development_history_year" type="number" placeholder="请输入发展历程年份"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label-width="labelWidth" label="标题" prop="development_history_title">
|
||||
<el-input v-model="formData.development_history_title" placeholder="请输入发展历程标题" type="text"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label-width="labelWidth" label="内容" prop="development_history_content">
|
||||
<el-input v-model="formData.development_history_content" placeholder="请输入发展历程内容" type="textarea"
|
||||
:rows="20"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button type="primary" @click="handleAddClick(formRef)">添加</el-button>
|
||||
<el-button @click="handleResetClick(formRef)">重置</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref, watch } from "vue";
|
||||
import { addDevelopmentHistory } from "~/service/development_history";
|
||||
import { useLoginStore } from "~/store";
|
||||
|
||||
// --业务参数
|
||||
|
||||
|
||||
|
||||
// --业务方法
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// --基础参数
|
||||
const store = useLoginStore();
|
||||
const headers = {
|
||||
Accept: "application/json",
|
||||
...store.headers,
|
||||
};
|
||||
|
||||
const formRef = ref();
|
||||
const labelWidth = 90;
|
||||
const props = defineProps({
|
||||
modelValue: Boolean,
|
||||
done: Function,
|
||||
});
|
||||
const emits = defineEmits(["update:modelValue"]);
|
||||
const dialogVisible = ref(props.modelValue);
|
||||
const formData = reactive({});
|
||||
|
||||
const uoloadData = ref({
|
||||
dirName: "DevelopmentHistory"
|
||||
})
|
||||
|
||||
watch(props, (v) => {
|
||||
dialogVisible.value = v.modelValue;
|
||||
});
|
||||
|
||||
//验证规则
|
||||
const rules = reactive({
|
||||
development_history_year: [
|
||||
{
|
||||
required: true,
|
||||
validator: (rule, value, callback) => {
|
||||
if (!value) return callback(new Error("请输入发展历程年份"));
|
||||
if (isNaN(value)) return callback(new Error("年份必须为数字类型"));
|
||||
if (value % 1 != 0) return callback(new Error("年份必须为整数"));
|
||||
if (value <= 0) return callback(new Error("年份必须不能小于等于0"));
|
||||
return callback();
|
||||
},
|
||||
},
|
||||
],
|
||||
development_history_title: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入发展历程标题",
|
||||
},
|
||||
],
|
||||
development_history_content: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入发展历程内容",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
// --基础方法
|
||||
|
||||
// 打开弹窗时执行
|
||||
const openDialog = () => {
|
||||
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
handleResetClick(formRef.value);
|
||||
dialogVisible.value = false;
|
||||
emits("update:modelValue", false);
|
||||
props.done();
|
||||
};
|
||||
|
||||
const handleAddClick = async (formEl) => {
|
||||
console.log(formData);
|
||||
if (!formEl) return;
|
||||
formEl.validate(async (valid) => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { code } = await addDevelopmentHistory(formData);
|
||||
if (code == 0) {
|
||||
closeDialog();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleResetClick = async (formEl) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
@ -0,0 +1,133 @@
|
||||
<template>
|
||||
<el-dialog v-model="dialogVisible" title="编辑发展历程" width="900px" @closed="closeDialog" @open="openDialog">
|
||||
<el-form ref="formRef" :model="formData" :rules="rules">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label-width="labelWidth" label="年份" prop="development_history_year">
|
||||
<el-input v-model="formData.development_history_year" type="text" placeholder="请输入发展历程年份"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label-width="labelWidth" label="标题" prop="development_history_title">
|
||||
<el-input v-model="formData.development_history_title" placeholder="请输入发展历程标题" type="text"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label-width="labelWidth" label="内容" prop="development_history_content">
|
||||
<el-input v-model="formData.development_history_content" placeholder="请输入发展历程内容" type="textarea"
|
||||
:rows="20"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button type="primary" @click="handleEditClick(formRef)">编辑</el-button>
|
||||
<el-button @click="handleResetClick(formRef)">重置</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref, watch } from "vue";
|
||||
import { editDevelopmentHistory } from "~/service/development_history";
|
||||
import { isEmptyObject } from "~/utils/index";
|
||||
import { useLoginStore } from "~/store";
|
||||
|
||||
// --业务参数
|
||||
|
||||
|
||||
|
||||
// --业务方法
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// --基础参数
|
||||
const store = useLoginStore();
|
||||
const headers = {
|
||||
Accept: "application/json",
|
||||
...store.headers,
|
||||
};
|
||||
const formRef = ref();
|
||||
const labelWidth = 100;
|
||||
const props = defineProps({
|
||||
modelValue: Object,
|
||||
done: Function,
|
||||
});
|
||||
const emits = defineEmits(["update:modelValue"]);
|
||||
const formData = ref({
|
||||
...props.modelValue,
|
||||
});
|
||||
const uoloadData = ref({
|
||||
dirName: "DevelopmentHistory"
|
||||
})
|
||||
const dialogVisible = ref(!isEmptyObject(props.modelValue));
|
||||
|
||||
|
||||
// --基础方法
|
||||
watch(props, (v) => {
|
||||
formData.value = v.modelValue;
|
||||
dialogVisible.value = !isEmptyObject(v.modelValue);
|
||||
});
|
||||
|
||||
// 打开弹窗时执行
|
||||
const openDialog = () => {
|
||||
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
dialogVisible.value = false;
|
||||
props.done();
|
||||
emits("update:modelValue", {});
|
||||
};
|
||||
|
||||
const rules = reactive({
|
||||
development_history_year: [
|
||||
{
|
||||
required: true,
|
||||
message: '年份不能为空'
|
||||
}
|
||||
],
|
||||
development_history_title: [
|
||||
{
|
||||
required: true,
|
||||
message: '标题不能为空'
|
||||
}
|
||||
],
|
||||
development_history_content: [
|
||||
{
|
||||
required: true,
|
||||
message: '内容不能为空'
|
||||
}
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
const handleEditClick = async (formEl) => {
|
||||
console.log(formData.value);
|
||||
if (!formEl) return;
|
||||
formEl.validate(async (valid) => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { code } = await editDevelopmentHistory(formData.value);
|
||||
if (code == 0) {
|
||||
closeDialog();
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleResetClick = async (formEl) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
315
src/pages/index/about_us/development_history/index.vue
Normal file
315
src/pages/index/about_us/development_history/index.vue
Normal file
@ -0,0 +1,315 @@
|
||||
<template>
|
||||
<!-- 面包屑 -->
|
||||
<el-breadcrumb>
|
||||
<el-breadcrumb-item>关于我们</el-breadcrumb-item>
|
||||
<el-breadcrumb-item>发展历程</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
<!-- 悬浮按钮 -->
|
||||
<el-button type="primary" v-if="sortValue == 'desc'" class="desc_order_btn hover_button" @click="onSort('src')">
|
||||
降序
|
||||
</el-button>
|
||||
<el-button type="primary" v-if="sortValue == 'src'" class="asc_order_btn hover_button" @click="onSort('desc')">
|
||||
升序
|
||||
</el-button>
|
||||
<el-button type="primary" class="add_btn hover_button" @click="AddDevelopmentHistoryDialogVisible = true">
|
||||
添加
|
||||
</el-button>
|
||||
<el-button type="primary" class="export_btn hover_button" @click="exportExcel({ sort: sortValue })">
|
||||
导出
|
||||
</el-button>
|
||||
<el-button type="primary" class="import_template_btn hover_button" @click="downloadTemplate()">
|
||||
模板
|
||||
</el-button>
|
||||
<!-- <el-button type="primary" class="import_btn hover_button" @click="AddDevelopmentHistoryDialogVisible = true">
|
||||
导入
|
||||
</el-button> -->
|
||||
<el-upload :action="importExcel" :headers="headers" :on-success="handleExcelSuccess" :on-progress="uploadLoading"
|
||||
:on-error="closeUploadLoading" :show-file-list="false">
|
||||
<el-button class="hover_button import_btn" type="primary">导入</el-button>
|
||||
</el-upload>
|
||||
<div>
|
||||
<!-- 标题 -->
|
||||
<div class="title">发展历程</div>
|
||||
<!-- 时间线 -->
|
||||
<div class="history_box" v-for="( item, index ) in DevelopmentHistoryData.value ">
|
||||
<!-- 左 -->
|
||||
<div style="text-align: right;" class="history_info_placeholder">
|
||||
<h2 v-if="index % 2 == 0">{{ item.development_history_year }}</h2>
|
||||
<div class="history_info_box" v-if="index % 2 != 0">
|
||||
<div class="history_info_op_box">
|
||||
<el-button type="primary" class="m_btn" @click="EditDevelopmentHistoryDialogVisible = item
|
||||
">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="danger" class="m_btn" @click="handleDelete(item.development_history_guid)
|
||||
">
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="history_info_content_box" style="text-align: right;">
|
||||
<h4>{{ item.development_history_title }}</h4>
|
||||
<p>{{ item.development_history_content }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 左 -->
|
||||
|
||||
<!-- 线 -->
|
||||
<div class="history_link_box">
|
||||
<div class="history_node"></div>
|
||||
<div class="history_link"></div>
|
||||
</div>
|
||||
<!-- 线 -->
|
||||
|
||||
<!-- 右 -->
|
||||
<div class="history_info_placeholder">
|
||||
<h2 v-if="index % 2 != 0">{{ item.development_history_year }}</h2>
|
||||
<div class="history_info_box" v-if="index % 2 == 0">
|
||||
<div class=" history_info_content_box">
|
||||
<h4>{{ item.development_history_title }}</h4>
|
||||
<p>{{ item.development_history_content }}</p>
|
||||
</div>
|
||||
<div class="history_info_op_box">
|
||||
<el-button type="primary" class="m_btn" @click="EditDevelopmentHistoryDialogVisible = item
|
||||
">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="danger" class="m_btn" @click="handleDelete(item.development_history_guid)
|
||||
">
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 右 -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<AddDevelopmentHistoryDialog v-model="AddDevelopmentHistoryDialogVisible" :done="() => geData()">
|
||||
</AddDevelopmentHistoryDialog>
|
||||
|
||||
<EditDevelopmentHistoryDialog v-model="EditDevelopmentHistoryDialogVisible" :done="() => geData()">
|
||||
</EditDevelopmentHistoryDialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ArrowDown } from '@element-plus/icons-vue';
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { useLoginStore } from "~/store";
|
||||
import { getDevelopmentHistoryList, deleteDevelopmentHistory, exportExcel, downloadTemplate, importExcel } from '~/service/development_history';
|
||||
import AddDevelopmentHistoryDialog from './components/AddDevelopmentHistoryDialog.vue';
|
||||
import EditDevelopmentHistoryDialog from './components/EditDevelopmentHistoryDialog.vue';
|
||||
|
||||
//请求头
|
||||
const store = useLoginStore();
|
||||
const headers = {
|
||||
Accept: "application/json",
|
||||
...store.headers,
|
||||
};
|
||||
|
||||
const AddDevelopmentHistoryDialogVisible = ref(false);
|
||||
const EditDevelopmentHistoryDialogVisible = ref({});
|
||||
|
||||
//发展历程数据
|
||||
const DevelopmentHistoryData = reactive([]);
|
||||
|
||||
//排序
|
||||
const sortValue = ref('desc');
|
||||
const onSort = (value) => {
|
||||
sortValue.value = value;
|
||||
geData();
|
||||
};
|
||||
|
||||
// 导入方法
|
||||
let loadingImoprt = null;
|
||||
const uploadLoading = () => {
|
||||
loadingImoprt = ElLoading.service({
|
||||
lock: true,
|
||||
text: "正在导入中...",
|
||||
background: "rgba(255, 255, 255, 0.7)",
|
||||
});
|
||||
};
|
||||
const closeUploadLoading = () => loadingImoprt.close();
|
||||
const handleExcelSuccess = (value) => {
|
||||
if (value.code == 0) {
|
||||
ElMessageBox.alert(value.msg, "导入信息", {
|
||||
dangerouslyUseHTMLString: true,
|
||||
confirmButtonText: "确定",
|
||||
});
|
||||
} else {
|
||||
ElMessage.error(value.msg);
|
||||
}
|
||||
closeUploadLoading();
|
||||
geData();
|
||||
};
|
||||
|
||||
//获取发展历程数据
|
||||
const geData = async () => {
|
||||
const { code, data } = await getDevelopmentHistoryList({ sort: sortValue.value });
|
||||
if (code == 0) {
|
||||
DevelopmentHistoryData.value = data;
|
||||
}
|
||||
};
|
||||
geData();
|
||||
|
||||
// 删除数据
|
||||
const handleDelete = (development_history_guid) => {
|
||||
ElMessageBox.confirm(`您确定要删除该发展历程吗?`).then(async () => {
|
||||
const { code } = await deleteDevelopmentHistory({
|
||||
development_history_guid: development_history_guid,
|
||||
});
|
||||
if (code == 0) {
|
||||
geData();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.asc_order_btn {
|
||||
background-color: rgba(163, 0, 0, 0.9) !important;
|
||||
box-shadow: rgba(0, 0, 0, 0.3) -5px 10px 20px 1px !important;
|
||||
color: white !important;
|
||||
font-size: 15px;
|
||||
top: 12% !important;
|
||||
}
|
||||
|
||||
.desc_order_btn {
|
||||
font-size: 15px;
|
||||
// top: 12% !important;
|
||||
top: 110px !important;
|
||||
}
|
||||
|
||||
.add_btn {
|
||||
// top: 19% !important;
|
||||
top: 170px !important
|
||||
}
|
||||
|
||||
.export_btn {
|
||||
top: 230px !important;
|
||||
// top: 26% !important;
|
||||
}
|
||||
|
||||
.import_template_btn {
|
||||
top: 290px !important;
|
||||
// top: 33% !important;
|
||||
}
|
||||
|
||||
.import_btn {
|
||||
top: 350px !important;
|
||||
// top: 40% !important;
|
||||
left: 220px !important;
|
||||
}
|
||||
|
||||
|
||||
// 饿了么按钮
|
||||
.el-button {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
|
||||
// 标题
|
||||
.title {
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 4%;
|
||||
}
|
||||
|
||||
// 悬浮按钮
|
||||
.hover_button {
|
||||
width: 80px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
position: fixed;
|
||||
font-weight: bold;
|
||||
transition: 0.3s;
|
||||
font-size: 15px;
|
||||
z-index: 998;
|
||||
color: rgb(153, 149, 149);
|
||||
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
|
||||
border: none;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.hover_button:hover {
|
||||
background-color: rgba(163, 0, 0, 0.8);
|
||||
color: white;
|
||||
box-shadow: rgba(0, 0, 0, 0.3) -5px 10px 20px 1px;
|
||||
transition: 0.3s;
|
||||
border: none;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
// 时间线
|
||||
.history_box {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
//占位盒子
|
||||
.history_info_placeholder {
|
||||
width: 35%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
// 线盒子
|
||||
.history_link_box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 0 20px;
|
||||
|
||||
.history_node {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border: 2.5px rgba(163, 0, 0, 0.8) solid;
|
||||
border-radius: 100%;
|
||||
}
|
||||
|
||||
.history_link {
|
||||
width: 2px;
|
||||
height: 100%;
|
||||
background-color: rgba(1, 1, 1, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 信息盒子
|
||||
.history_info_box {
|
||||
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
|
||||
background-color: #ffffff;
|
||||
height: 100%;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
.history_info_content_box {
|
||||
padding: 15px 25px;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.history_info_op_box {
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
justify-content: space-around;
|
||||
|
||||
.m_btn {
|
||||
border-radius: 0;
|
||||
margin: 0;
|
||||
width: 50px;
|
||||
height: 100%;
|
||||
border-left: none;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
148
src/pages/index/banner/components/AddBannerDialog.vue
Normal file
148
src/pages/index/banner/components/AddBannerDialog.vue
Normal file
@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<el-dialog v-model="dialogVisible" title="添加轮播图" width="900px" @closed="closeDialog" @open="openDialog">
|
||||
<el-form ref="formRef" :model="formData" :rules="rules">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="轮播图位置" prop="banner_location">
|
||||
<el-select v-model="formData.banner_location" clearable placeholder="请选择">
|
||||
<el-option v-for="item in banner_location" :key="item.dictionary_guid" :label="item.dictionary_name"
|
||||
:value="item.dictionary_value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span='12'>
|
||||
<el-form-item :label-width='labelWidth' label='轮播图' prop='banner_img'>
|
||||
<UploadImage ref='uploadRef' v-model='formData.banner_img' :data=uoloadData :limit='1' :fileSize='5'
|
||||
:drag='true' :isShowTip='false' />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label-width="labelWidth" label="排序" prop="banner_order">
|
||||
<el-input-number v-model='formData.banner_order' controls-position='right'></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button type="primary" @click="handleAddClick(formRef)">添加</el-button>
|
||||
<el-button @click="handleResetClick(formRef)">重置</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref, watch } from "vue";
|
||||
import { addBanner, getDictionary } from "~/service/banner";
|
||||
import { useLoginStore } from "~/store";
|
||||
|
||||
// --业务参数
|
||||
|
||||
|
||||
|
||||
// --业务方法
|
||||
|
||||
// 字典获取
|
||||
const banner_location = ref([]);
|
||||
async function get_banner_location() {
|
||||
await getDictionary({ dictionary_value: 'banner_location' }).then((res) => {
|
||||
banner_location.value = res
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// --基础参数
|
||||
const store = useLoginStore();
|
||||
const headers = {
|
||||
Accept: "application/json",
|
||||
...store.headers,
|
||||
};
|
||||
|
||||
const formRef = ref();
|
||||
const labelWidth = 90;
|
||||
const props = defineProps({
|
||||
modelValue: Boolean,
|
||||
done: Function,
|
||||
});
|
||||
const emits = defineEmits(["update:modelValue"]);
|
||||
const dialogVisible = ref(props.modelValue);
|
||||
const formData = reactive({
|
||||
banner_order: 0
|
||||
});
|
||||
|
||||
const uoloadData = ref({
|
||||
dirName: "Banner"
|
||||
})
|
||||
|
||||
watch(props, (v) => {
|
||||
dialogVisible.value = v.modelValue;
|
||||
});
|
||||
|
||||
const rules = reactive({
|
||||
banner_img: [
|
||||
{
|
||||
required: true,
|
||||
message: '轮播图图片不能为空'
|
||||
}
|
||||
],
|
||||
banner_location: [
|
||||
{
|
||||
required: true,
|
||||
message: '轮播图片位置(字典)不能为空'
|
||||
}
|
||||
],
|
||||
banner_order: [
|
||||
{
|
||||
required: true,
|
||||
message: '排序不能为空'
|
||||
}
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
|
||||
// --基础方法
|
||||
|
||||
// 打开弹窗时执行
|
||||
const openDialog = () => {
|
||||
get_banner_location()
|
||||
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
handleResetClick(formRef.value);
|
||||
dialogVisible.value = false;
|
||||
emits("update:modelValue", false);
|
||||
};
|
||||
|
||||
const handleAddClick = async (formEl) => {
|
||||
console.log(formData);
|
||||
if (!formEl) return;
|
||||
formEl.validate(async (valid) => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { code } = await addBanner(formData);
|
||||
if (code == 0) {
|
||||
closeDialog();
|
||||
props.done();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleResetClick = async (formEl) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
88
src/pages/index/banner/components/DetailBannerDialog.vue
Normal file
88
src/pages/index/banner/components/DetailBannerDialog.vue
Normal file
@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<el-dialog v-model="props.modelValue" title="轮播图详情" width="900px" @closed="closeDialog" @open="openDialog">
|
||||
<el-form ref="formRef" :model="formData" :disabled="true">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="轮播图位置" prop="banner_location">
|
||||
<el-select v-model="formData.banner_location" clearable placeholder="请选择">
|
||||
<el-option v-for="item in banner_location" :key="item.dictionary_guid" :label="item.dictionary_name"
|
||||
:value="item.dictionary_value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span='12'>
|
||||
<el-form-item :label-width='labelWidth' label='轮播图' prop='banner_img'>
|
||||
<UploadImage ref='uploadRef' v-model='formData.banner_img' :data=uoloadData :limit='1' :fileSize='5'
|
||||
:drag='true' :isShowTip='false' />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label-width="labelWidth" label="排序" prop="banner_order">
|
||||
<el-input-number v-model='formData.banner_order' controls-position='right'></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref, watch } from "vue";
|
||||
import { isEmptyObject } from "~/utils/index";
|
||||
import { getDictionary } from '~/service/banner';
|
||||
|
||||
// --业务参数
|
||||
|
||||
|
||||
|
||||
// --业务方法
|
||||
|
||||
// 字典获取
|
||||
const banner_location = ref([]);
|
||||
async function get_banner_location() {
|
||||
await getDictionary({ dictionary_value: 'banner_location' }).then((res) => {
|
||||
banner_location.value = res
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --基础参数
|
||||
const formRef = ref();
|
||||
const labelWidth = 100;
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: Boolean,
|
||||
data: Object,
|
||||
done: Function,
|
||||
});
|
||||
const emits = defineEmits(["update:modelValue"]);
|
||||
const formData = ref({
|
||||
...props.data,
|
||||
});
|
||||
|
||||
|
||||
// --基础方法
|
||||
watch(props, (v) => {
|
||||
formData.value = v.data;
|
||||
|
||||
|
||||
});
|
||||
|
||||
// 打开弹窗时执行
|
||||
const openDialog = () => {
|
||||
|
||||
get_banner_location()
|
||||
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
emits("update:modelValue", false);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
144
src/pages/index/banner/components/EditBannerDialog.vue
Normal file
144
src/pages/index/banner/components/EditBannerDialog.vue
Normal file
@ -0,0 +1,144 @@
|
||||
<template>
|
||||
<el-dialog v-model="props.modelValue" title="编辑轮播图" width="900px" @closed="closeDialog" @open="openDialog">
|
||||
<el-form ref="formRef" :model="formData" :rules="rules">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="轮播图位置" prop="banner_location">
|
||||
<el-select v-model="formData.banner_location" clearable placeholder="请选择">
|
||||
<el-option v-for="item in banner_location" :key="item.dictionary_guid" :label="item.dictionary_name"
|
||||
:value="item.dictionary_value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span='12'>
|
||||
<el-form-item :label-width='labelWidth' label='轮播图' prop='banner_img'>
|
||||
<UploadImage ref='uploadRef' v-model='formData.banner_img' :data=uoloadData :limit='1' :fileSize='5'
|
||||
:drag='true' :isShowTip='false' />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label-width="labelWidth" label="排序" prop="banner_order">
|
||||
<el-input-number v-model='formData.banner_order' controls-position='right'></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button type="primary" @click="handleEditClick(formRef)">编辑</el-button>
|
||||
<el-button @click="handleResetClick(formRef)">重置</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref, watch } from "vue";
|
||||
import { editBanner, getDictionary } from "~/service/banner";
|
||||
import { useLoginStore } from "~/store";
|
||||
|
||||
// --业务参数
|
||||
|
||||
|
||||
|
||||
// --业务方法
|
||||
|
||||
// 字典获取
|
||||
const banner_location = ref([]);
|
||||
async function get_banner_location() {
|
||||
await getDictionary({ dictionary_value: 'banner_location' }).then((res) => {
|
||||
banner_location.value = res
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// --基础参数
|
||||
const store = useLoginStore();
|
||||
const headers = {
|
||||
Accept: "application/json",
|
||||
...store.headers,
|
||||
};
|
||||
const formRef = ref();
|
||||
const labelWidth = 100;
|
||||
const props = defineProps({
|
||||
modelValue: Boolean,
|
||||
data: Object,
|
||||
done: Function,
|
||||
});
|
||||
const emits = defineEmits(["update:modelValue"]);
|
||||
const formData = ref({
|
||||
...props.data,
|
||||
});
|
||||
const uoloadData = ref({
|
||||
dirName: "Banner"
|
||||
})
|
||||
|
||||
|
||||
// --基础方法
|
||||
watch(props, (v) => {
|
||||
formData.value = v.data;
|
||||
|
||||
|
||||
});
|
||||
|
||||
// 打开弹窗时执行
|
||||
const openDialog = () => {
|
||||
get_banner_location()
|
||||
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
props.done();
|
||||
emits("update:modelValue", false);
|
||||
};
|
||||
|
||||
const rules = reactive({
|
||||
banner_img: [
|
||||
{
|
||||
required: true,
|
||||
message: '轮播图图片不能为空'
|
||||
}
|
||||
],
|
||||
banner_location: [
|
||||
{
|
||||
required: true,
|
||||
message: '轮播图片位置(字典)不能为空'
|
||||
}
|
||||
],
|
||||
banner_order: [
|
||||
{
|
||||
required: true,
|
||||
message: '排序不能为空'
|
||||
}
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
const handleEditClick = async (formEl) => {
|
||||
console.log(formData.value);
|
||||
if (!formEl) return;
|
||||
formEl.validate(async (valid) => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { code } = await editBanner(formData.value);
|
||||
if (code == 0) {
|
||||
closeDialog();
|
||||
props.done();
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleResetClick = async (formEl) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
208
src/pages/index/banner/index.vue
Normal file
208
src/pages/index/banner/index.vue
Normal file
@ -0,0 +1,208 @@
|
||||
<template>
|
||||
<!-- 面包屑 -->
|
||||
<el-breadcrumb>
|
||||
<el-breadcrumb-item>轮播图管理</el-breadcrumb-item>
|
||||
<el-breadcrumb-item to="/banner/list">轮播图列表</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
<!-- 搜索 -->
|
||||
<el-form inline :model="params">
|
||||
<el-form-item label="轮播图位置">
|
||||
<el-select v-model="params.banner_location" clearable placeholder="请选择">
|
||||
<el-option v-for="item in banner_location" :key="item.dictionary_guid" :label="item.dictionary_name"
|
||||
:value="item.dictionary_value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="tableRef.reload()" icon="ElIconSearch">
|
||||
搜索
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-space style="margin-bottom: 10px;">
|
||||
<!-- 添加轮播图 -->
|
||||
<el-col :span="1">
|
||||
<el-button type="primary" @click="addBannerDialogVisible = true"> 添加 </el-button>
|
||||
</el-col>
|
||||
<!-- 下拉操作 -->
|
||||
<el-dropdown v-if="selectionData.length">
|
||||
<el-button type="primary">
|
||||
批量操作<el-icon class="el-icon--right"><arrow-down /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item @click="handleDelete(selectionData)">
|
||||
批量删除
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-space>
|
||||
<!-- 数据表格 -->
|
||||
<DataTable v-loading="loading" ref="tableRef" style="width: 100%" :onSelectionChange="data => (selectionData = data)" :column="column"
|
||||
:params="params" :request="params => getBannerList(params)">
|
||||
<!-- 排序 -->
|
||||
<template #banner_order="scope">
|
||||
<el-input-number :disabled="loading" v-model='scope.row.banner_order' controls-position="right"
|
||||
@change="handleEditOrder(scope.row)"></el-input-number>
|
||||
</template>
|
||||
<!-- 图片 -->
|
||||
<template #banner_img="scope">
|
||||
<el-image v-if="scope.row.banner_img" :src="scope.row.banner_img.split(',')[0]" lazy
|
||||
:preview-src-list="scope.row.banner_img.split(',')" :preview-teleported="true" :hide-on-click-modal="true"
|
||||
fit="contain" class="el-avatar"></el-image>
|
||||
<template v-else>暂无图片</template>
|
||||
</template>
|
||||
|
||||
<template #banner_location='scope'>
|
||||
<dict-tag :options='banner_location' :value='scope.row.banner_location' />
|
||||
</template>
|
||||
|
||||
<template #chaoz="scope">
|
||||
<el-space>
|
||||
<el-button size="small" @click="handleUpdate(scope.row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-dropdown @command="handleCommand">
|
||||
<el-button type="primary" size="small">
|
||||
更多<el-icon class="el-icon--right"><arrow-down /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item :command="{ type: 'detail', row: scope.row }">
|
||||
详情
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :command="{ type: 'delete', row: scope.row }">
|
||||
删除
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-space>
|
||||
</template>
|
||||
</DataTable>
|
||||
|
||||
<!-- 添加轮播图 -->
|
||||
<AddBannerDialog v-model="addBannerDialogVisible" :done="() => tableRef.reload()"></AddBannerDialog>
|
||||
<!-- 编辑轮播图 -->
|
||||
<EditBannerDialog v-model="EditBannerDialogVisible" :data="EditBannerDialogRow" :done="() => tableRef.reload()">
|
||||
</EditBannerDialog>
|
||||
<!-- 轮播图详情 -->
|
||||
<DetailBannerDialog v-model="DetailBannerDialogVisible" :data="DetailBannerDialogRow"></DetailBannerDialog>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ArrowDown } from '@element-plus/icons-vue';
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { useLoginStore } from "~/store";
|
||||
import { getBannerList, editBanner, deleteBanner, getDictionary } from '~/service/banner';
|
||||
import AddBannerDialog from './components/AddBannerDialog.vue';
|
||||
import EditBannerDialog from './components/EditBannerDialog.vue';
|
||||
import DetailBannerDialog from './components/DetailBannerDialog.vue';
|
||||
|
||||
const tableRef = ref();
|
||||
const selectionData = ref([]);
|
||||
const store = useLoginStore();
|
||||
|
||||
const addBannerDialogVisible = ref(false);
|
||||
const EditBannerDialogVisible = ref(false);
|
||||
const EditBannerDialogRow = ref({});
|
||||
const DetailBannerDialogVisible = ref(false);
|
||||
const DetailBannerDialogRow = ref({});
|
||||
const loading = ref(false)
|
||||
|
||||
const headers = {
|
||||
Accept: "application/json",
|
||||
...store.headers,
|
||||
};
|
||||
|
||||
// 查询参数
|
||||
const params = reactive({
|
||||
banner_location: "",
|
||||
|
||||
});
|
||||
const column = [
|
||||
|
||||
{
|
||||
fixed: true,
|
||||
type: 'selection'
|
||||
},
|
||||
{
|
||||
prop: "banner_img",
|
||||
label: '轮播图图片',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
prop: "banner_location",
|
||||
label: '轮播图位置',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
prop: "banner_order",
|
||||
label: '排序',
|
||||
width: '200'
|
||||
},
|
||||
{
|
||||
label: '操作',
|
||||
prop: 'chaoz',
|
||||
width: '250',
|
||||
fixed: 'right'
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
const handleCommand = ({ type, row }) => {
|
||||
switch (type) {
|
||||
case "detail":
|
||||
handleDetail(row);
|
||||
break;
|
||||
case 'delete':
|
||||
handleDelete([row]);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// 删除数据
|
||||
const handleDelete = data => {
|
||||
ElMessageBox.confirm(`您确定要删除该轮播图吗?`).then(async () => {
|
||||
const res = await deleteBanner({
|
||||
banner_guid: data.map(v => v.banner_guid).join()
|
||||
});
|
||||
if (res) {
|
||||
tableRef.value.reload();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//排序
|
||||
async function handleEditOrder(data) {
|
||||
loading.value = true
|
||||
const { code, msg } = await editBanner(data);
|
||||
if (code == 0) {
|
||||
loading.value = false
|
||||
tableRef.value.reload()
|
||||
ElMessage.success(msg);
|
||||
} else {
|
||||
ElMessage.error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// 修改
|
||||
function handleUpdate(row) {
|
||||
EditBannerDialogVisible.value = true
|
||||
EditBannerDialogRow.value = row
|
||||
}
|
||||
|
||||
// 详情
|
||||
function handleDetail(row) {
|
||||
DetailBannerDialogVisible.value = true
|
||||
DetailBannerDialogRow.value = row
|
||||
}
|
||||
|
||||
// 字典获取
|
||||
const banner_location = ref([]);
|
||||
async function get_banner_location() {
|
||||
await getDictionary({ dictionary_value: 'banner_location' }).then((res) => {
|
||||
banner_location.value = res
|
||||
})
|
||||
}
|
||||
get_banner_location()
|
||||
</script>
|
@ -271,6 +271,7 @@ async function handleEditLikeCount(data) {
|
||||
if (code == 0) {
|
||||
loading.value = false
|
||||
tableRef.value.reload()
|
||||
ElMessage.success(msg);
|
||||
} else {
|
||||
ElMessage.error(msg);
|
||||
}
|
||||
|
@ -7,14 +7,18 @@ import {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
* 获取字典值
|
||||
* @param {Object} data
|
||||
* @return {Promise} api
|
||||
*/
|
||||
export const uploadBannerImg = createApiUrl('Banner.Banner/uploadBannerImg');
|
||||
|
||||
|
||||
|
||||
|
||||
export function getDictionary(data) {
|
||||
return api.post('Dictionary.Dictionary/getDictionary', data, {});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -58,8 +62,8 @@ export function addBanner(data) {
|
||||
*/
|
||||
export function editBanner(data) {
|
||||
return api.post('Banner.Banner/editBanner', data, {
|
||||
isTransformResponse: true,
|
||||
isShowSuccessMessage: true,
|
||||
// isTransformResponse: true,
|
||||
// isShowSuccessMessage: true,
|
||||
errorMessageText: '编辑失败'
|
||||
});
|
||||
}
|
79
src/service/development_history.js
Normal file
79
src/service/development_history.js
Normal file
@ -0,0 +1,79 @@
|
||||
import {
|
||||
api,
|
||||
downloadFile,
|
||||
createApiUrl
|
||||
} from '~/utils/axios';
|
||||
|
||||
|
||||
/**
|
||||
* 导出发展历程
|
||||
* @param {Object} data
|
||||
* @return {Promise} api
|
||||
*/
|
||||
export function exportExcel(data) {
|
||||
downloadFile(createApiUrl('AboutUs.DevelopmentHistory/exportExcel'), data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载发展历程模板
|
||||
* @param {Object} data
|
||||
* @return {Promise} api
|
||||
*/
|
||||
export function downloadTemplate(data) {
|
||||
downloadFile(createApiUrl('AboutUs.DevelopmentHistory/downloadTemplate'), data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入发展历程
|
||||
* @param {Object} data
|
||||
* @return {Promise} api
|
||||
*/
|
||||
export const importExcel = createApiUrl('AboutUs.DevelopmentHistory/importExcel');
|
||||
|
||||
/**
|
||||
* 获取发展历程列表
|
||||
* @param {Object} data
|
||||
* @return {Promise} api
|
||||
*/
|
||||
export function getDevelopmentHistoryList(data) {
|
||||
return api.post('AboutUs.DevelopmentHistory/getDevelopmentHistoryList', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除发展历程
|
||||
* @param {Object} data
|
||||
* @return {Promise} api
|
||||
*/
|
||||
export function deleteDevelopmentHistory(data) {
|
||||
return api.post('AboutUs.DevelopmentHistory/deleteDevelopmentHistory', data, {
|
||||
isTransformResponse: true,
|
||||
isShowSuccessMessage: true,
|
||||
errorMessageText: '删除失败'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加发展历程
|
||||
* @param {Object} data
|
||||
* @return {Promise} api
|
||||
*/
|
||||
export function addDevelopmentHistory(data) {
|
||||
return api.post('AboutUs.DevelopmentHistory/addDevelopmentHistory', data, {
|
||||
isTransformResponse: true,
|
||||
isShowSuccessMessage: true,
|
||||
errorMessageText: '添加失败'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑发展历程
|
||||
* @param {Object} data
|
||||
* @return {Promise} api
|
||||
*/
|
||||
export function editDevelopmentHistory(data) {
|
||||
return api.post('AboutUs.DevelopmentHistory/editDevelopmentHistory', data, {
|
||||
isTransformResponse: true,
|
||||
isShowSuccessMessage: true,
|
||||
errorMessageText: '编辑失败'
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user