|
@@ -0,0 +1,418 @@
|
|
|
+<template>
|
|
|
+ <div class="tenant">
|
|
|
+ <byTable
|
|
|
+ :source="sourceList.data"
|
|
|
+ :pagination="sourceList.pagination"
|
|
|
+ :config="config"
|
|
|
+ :loading="loading"
|
|
|
+ highlight-current-row
|
|
|
+ :selectConfig="selectConfig"
|
|
|
+ :table-events="{
|
|
|
+ select: select,
|
|
|
+ }"
|
|
|
+ :action-list="[
|
|
|
+ {
|
|
|
+ text: '添加荣誉',
|
|
|
+ action: () => openModal('add'),
|
|
|
+ },
|
|
|
+ ]"
|
|
|
+ @get-list="getList">
|
|
|
+ </byTable>
|
|
|
+ <el-dialog :title="modalType == 'add' ? '添加荣誉' : '编辑荣誉'" v-if="dialogVisible" v-model="dialogVisible" width="600" v-loading="loading">
|
|
|
+ <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
|
|
|
+ <template #honorCover>
|
|
|
+ <el-row style="width: 100%">
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item prop="honorCover">
|
|
|
+ <el-upload
|
|
|
+ class="avatar-uploader"
|
|
|
+ action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
|
|
|
+ :data="uploadDataOne"
|
|
|
+ :show-file-list="false"
|
|
|
+ accept=".gif, .jpeg, .jpg, .png"
|
|
|
+ :on-success="honorCoverListSuccess"
|
|
|
+ :before-upload="uploadFileOne">
|
|
|
+ <el-image
|
|
|
+ v-if="formData.data.honorCoverList && formData.data.honorCoverList.length > 0"
|
|
|
+ :src="formData.data.honorCoverList[0].fileUrl"
|
|
|
+ fit="scale-down"
|
|
|
+ class="avatar" />
|
|
|
+ <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
|
|
|
+ </el-upload>
|
|
|
+ <el-button
|
|
|
+ class="delete-btn"
|
|
|
+ type="danger"
|
|
|
+ v-if="formData.data.companyCoverList && formData.data.companyCoverList.length > 0"
|
|
|
+ @click="formData.data.companyCoverList = []">
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #detailsContent>
|
|
|
+ <div style="width: 100%" v-if="dialogVisible">
|
|
|
+ <TinymceEditor
|
|
|
+ :value="formData.data.detailsContent"
|
|
|
+ @updateValue="updateHandover"
|
|
|
+ ref="contentEditor"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </byForm>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="dialogVisible = false" size="large">取 消</el-button>
|
|
|
+ <el-button type="primary" v-no-double-click="submitForm" size="large" :loading="submitLoading">确 定</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
+import byTable from "@/components/byTable/index";
|
|
|
+import byForm from "@/components/byForm/index";
|
|
|
+import { computed, ref } from "vue";
|
|
|
+import {
|
|
|
+ addAboutUsHonor,
|
|
|
+ editAboutUsHonor,
|
|
|
+ findAboutUsHonorList,
|
|
|
+ getAboutUsHonor,
|
|
|
+ deleteAboutUsHonor
|
|
|
+} from "@/api/XMHJC/aboutUs";
|
|
|
+import TinymceEditor from "@/components/Editor/TinymceEditor.vue";
|
|
|
+import {getDictOneByXmhjc, getFileList,getFileStr} from "@/api/XMHJC/common";
|
|
|
+
|
|
|
+const loading = ref(false);
|
|
|
+const submitLoading = ref(false);
|
|
|
+const sourceList = ref({
|
|
|
+ data: [],
|
|
|
+ pagination: {
|
|
|
+ total: 0,
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ },
|
|
|
+});
|
|
|
+let dialogVisible = ref(false);
|
|
|
+let modalType = ref("add");
|
|
|
+
|
|
|
+let rules = ref({
|
|
|
+ honorName: [{ required: true, message: "请输入荣誉名称", trigger: "blur" }],
|
|
|
+ status: [{ required: true, message: "请选择启用状态", trigger: "change" }],
|
|
|
+ type: [{ required: true, message: "请输入跳转类型", trigger: "change" }],
|
|
|
+ toUrl: [{ required: true, message: "请输入第三方链接", trigger: "blur" }],
|
|
|
+ sort: [{ required: true, message: "请输入排序", trigger: "blur" }],
|
|
|
+});
|
|
|
+const { proxy } = getCurrentInstance();
|
|
|
+const toUrlType = ref([]);
|
|
|
+const enableStatus = ref([]);
|
|
|
+const selectConfig = [];
|
|
|
+const config = computed(() => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "荣誉名称",
|
|
|
+ prop: "honorName",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "跳转类型",
|
|
|
+ prop: "type",
|
|
|
+ },
|
|
|
+ render(type) {
|
|
|
+ return proxy.dictValueLabel(type, toUrlType.value);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "排序",
|
|
|
+ prop: "sort",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "状态",
|
|
|
+ prop: "status",
|
|
|
+ },
|
|
|
+ render(type) {
|
|
|
+ return proxy.dictValueLabel(type, enableStatus.value);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "操作",
|
|
|
+ width: "200",
|
|
|
+ align: "right",
|
|
|
+ },
|
|
|
+ renderHTML(row) {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "修改",
|
|
|
+ type: "primary",
|
|
|
+ text: true,
|
|
|
+ },
|
|
|
+ el: "button",
|
|
|
+ click() {
|
|
|
+ getDtl(row);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "删除",
|
|
|
+ type: "danger",
|
|
|
+ text: true,
|
|
|
+ },
|
|
|
+ el: "button",
|
|
|
+ click() {
|
|
|
+ ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ }).then(() => {
|
|
|
+ deleteAboutUsHonor({
|
|
|
+ id: row.id,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ ElMessage({
|
|
|
+ message: "删除成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+});
|
|
|
+let formData = reactive({
|
|
|
+ data: {
|
|
|
+ honorCoverList: [],
|
|
|
+ },
|
|
|
+});
|
|
|
+const formOption = reactive({
|
|
|
+ inline: true,
|
|
|
+ labelWidth: 100,
|
|
|
+ itemWidth: 100,
|
|
|
+ rules: [],
|
|
|
+});
|
|
|
+const byform = ref(null);
|
|
|
+const formConfig = computed(() => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ prop: "honorName",
|
|
|
+ label: "荣誉名称",
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "slot",
|
|
|
+ prop: "honorCover",
|
|
|
+ slotName: "honorCover",
|
|
|
+ label: "荣誉资质图片",
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ type: "number",
|
|
|
+ prop: "sort",
|
|
|
+ label: "排序",
|
|
|
+ precision: 0,
|
|
|
+ max: 999,
|
|
|
+ controls: false,
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "启用状态",
|
|
|
+ prop: "status",
|
|
|
+ type: "select",
|
|
|
+ data: enableStatus.value,
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "select",
|
|
|
+ prop: "type",
|
|
|
+ label: "跳转类型",
|
|
|
+ data: toUrlType.value,
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ prop: "toUrl",
|
|
|
+ label: "第三方链接",
|
|
|
+ required: true,
|
|
|
+ isShow: formData.data.type == "2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "slot",
|
|
|
+ slotName: "detailsContent",
|
|
|
+ prop: "detailsContent",
|
|
|
+ label: "详情内容",
|
|
|
+ isShow: formData.data.type == "3"
|
|
|
+ },
|
|
|
+ ];
|
|
|
+});
|
|
|
+
|
|
|
+const getDictlist = async () => {
|
|
|
+
|
|
|
+ const res = await getDictOneByXmhjc(["to_url_type","enable_status"]);
|
|
|
+ toUrlType.value = res["to_url_type"].map((x) => ({
|
|
|
+ label: x.dictValue,
|
|
|
+ value: x.dictKey,
|
|
|
+ }));
|
|
|
+ enableStatus.value = res["enable_status"].map((x) => ({
|
|
|
+ label: x.dictValue,
|
|
|
+ value: x.dictKey,
|
|
|
+ }));
|
|
|
+};
|
|
|
+
|
|
|
+const getList = async (req) => {
|
|
|
+ sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
|
|
|
+ loading.value = true;
|
|
|
+
|
|
|
+ const res = await findAboutUsHonorList(sourceList.value.pagination);
|
|
|
+ sourceList.value.data = res.data.rows;
|
|
|
+ sourceList.value.pagination.total = res.data.total;
|
|
|
+ setTimeout(() => {
|
|
|
+ loading.value = false;
|
|
|
+ }, 200);
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+const openModal = () => {
|
|
|
+ dialogVisible.value = true;
|
|
|
+ modalType.value = "add";
|
|
|
+
|
|
|
+ formData.data = {
|
|
|
+ honorCoverList: [],
|
|
|
+ detailsContent:''
|
|
|
+ };
|
|
|
+
|
|
|
+};
|
|
|
+const selection = ref({
|
|
|
+ data: [],
|
|
|
+});
|
|
|
+const select = (_selection, row) => {
|
|
|
+ selection.value.data = _selection;
|
|
|
+};
|
|
|
+const submitForm = () => {
|
|
|
+ byform.value.handleSubmit(() => {
|
|
|
+
|
|
|
+ if (!formData.data.honorCoverList) {
|
|
|
+ ElMessage({message: "请上传荣誉资质图片",type: "error",});
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (formData.data.type == '3' &&
|
|
|
+ !formData.data.detailsContent) {
|
|
|
+ ElMessage({message: "请填写详情内容",type: "error",});
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ submitLoading.value = true;
|
|
|
+ if (modalType.value === 'add'){
|
|
|
+ addAboutUsHonor(formData.data).then(response => {
|
|
|
+ ElMessage({
|
|
|
+ message: "添加成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ dialogVisible.value = false;
|
|
|
+ submitLoading.value = false;
|
|
|
+ getList();
|
|
|
+ }).catch(()=>{
|
|
|
+ submitLoading.value = false;
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ editAboutUsHonor(formData.data).then(response => {
|
|
|
+ ElMessage({
|
|
|
+ message: "编辑成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ dialogVisible.value = false;
|
|
|
+ submitLoading.value = false;
|
|
|
+ getList();
|
|
|
+ }).catch(()=>{
|
|
|
+ submitLoading.value = false;
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const getDtl = async (row) => {
|
|
|
+ modalType.value = "edit";
|
|
|
+ const response = await getAboutUsHonor({ id: row.id })
|
|
|
+ formData.data = response.data;
|
|
|
+ const resFile = await getFileList({businessIdList: [response.data.id], fileType: 1})
|
|
|
+ formData.data.honorCoverList = resFile.data[response.data.id];
|
|
|
+ dialogVisible.value = true;
|
|
|
+};
|
|
|
+
|
|
|
+const uploadDataOne = ref({});
|
|
|
+const uploadFileOne = async (file) => {
|
|
|
+ const res = await getFileStr({ fileName: file.name });
|
|
|
+ uploadDataOne.value = res.data.uploadBody;
|
|
|
+ file.id = res.data.id;
|
|
|
+ file.fileName = res.data.fileName;
|
|
|
+ file.fileUrl = res.data.fileUrl;
|
|
|
+ return true;
|
|
|
+};
|
|
|
+
|
|
|
+const honorCoverListSuccess = (response, uploadFile) => {
|
|
|
+ formData.data.honorCoverList = [
|
|
|
+ {
|
|
|
+ id: uploadFile.raw.id,
|
|
|
+ fileName: uploadFile.raw.fileName,
|
|
|
+ fileUrl: uploadFile.raw.fileUrl,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+};
|
|
|
+
|
|
|
+const updateHandover = (val) => {
|
|
|
+ formData.data.detailsContent = val;
|
|
|
+};
|
|
|
+
|
|
|
+getDictlist()
|
|
|
+getList()
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.tenant {
|
|
|
+ padding: 20px;
|
|
|
+ .delete-btn{
|
|
|
+ margin-top: 10px;
|
|
|
+ margin-left: 25px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.avatar-uploader .avatar {
|
|
|
+ width: 110px;
|
|
|
+ height: 110px;
|
|
|
+ display: block;
|
|
|
+ background-color: black;
|
|
|
+}
|
|
|
+.avatar-uploader .el-upload {
|
|
|
+ border: 1px dashed var(--el-border-color);
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+ transition: var(--el-transition-duration-fast);
|
|
|
+}
|
|
|
+.avatar-uploader .el-upload:hover {
|
|
|
+ border-color: var(--el-color-primary);
|
|
|
+}
|
|
|
+.el-icon.avatar-uploader-icon {
|
|
|
+ font-size: 28px;
|
|
|
+ color: #8c939d;
|
|
|
+ width: 110px;
|
|
|
+ height: 110px;
|
|
|
+ text-align: center;
|
|
|
+ border: 1px dashed var(--el-border-color);
|
|
|
+}
|
|
|
+</style>
|