feat 添加表情包管理

This commit is contained in:
AERWEN\26795 2023-10-29 10:16:04 +08:00
parent f333c9e2be
commit c5a70b3a20
11 changed files with 819 additions and 4 deletions

2
.env
View File

@ -1,3 +1,3 @@
# 页面标题
VITE_APP_TITLE = '小程序模板'
VITE_APP_TITLE = '暴走阿B表情包'

View File

@ -0,0 +1,57 @@
import request from '@/utils/request'
/**
* @Descripttion: 表情包Api接口
* @version: (1.0)
* @Author: (lwh)
* @Date: (2023-10-28)
* @LastEditors: (lwh)
* @LastEditTime: (2023-10-28)
*/
// 表情包分页查询列表
export function emoticonDataList(query) {
return request({
url: '/business/EmoticonData/getEmoticonDataList',
method: 'get',
params: query
})
}
// 表情包新增或修改
export function addOrUpdateEmoticonData(data) {
return request({
url: '/business/EmoticonData/addOrUpdateEmoticonData',
method: 'post',
data: data,
})
}
// 批量添加添加表情包
export function batchAddEmoticonData(data) {
return request({
url: '/business/EmoticonData/batchAddEmoticonData',
method: 'post',
data: data,
})
}
// 表情包删除
export function delEmoticonData(ids) {
return request({
url: '/business/EmoticonData/'+ ids,
method: 'delete'
})
}
// 表情包导出
export function exportEmoticonData(query) {
return request({
url: 'business/EmoticonData/exportEmoticonData',
method: 'get',
params: query
})
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 128 KiB

View File

@ -50,7 +50,7 @@ const props = defineProps({
// , ['png', 'jpg', 'jpeg']
fileType: {
type: Array,
default: () => ['png', 'jpg', 'jpeg'],
default: () => ['png', 'jpg', 'jpeg','gif'],
},
//
isShowTip: {

View File

@ -55,7 +55,7 @@ export default {
/**
* 版权信息
*/
copyright: 'Copyright ©2023 <a target="_black" href="http://aerwen.net">阿尔文</a> All Rights Reserved.',
copyright: 'Copyright ©2023 <a target="_black" href="#">暴走阿B微信公众号</a> All Rights Reserved.',
/**
* 是否显示底部栏
*/

View File

@ -0,0 +1,138 @@
<!--
* @Descripttion: (表情包/tb_emoticon_data 添加弹窗)
* @version: (1.0)
* @Author: (lwh)
* @Date: (2023-10-28)
* @LastEditors: (lwh)
* @LastEditTime: (2023-10-28)
-->
<template>
<el-dialog v-model="props.modelValue" title="添加表情包信息" width="900px" @closed="closeDialog" @open="openDialog">
<el-form ref="formRef" :model="formData" :rules="rules">
<el-row :gutter="20">
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="表情包分类" prop="emotionCategoryGuid">
<el-cascader class="w100" :options="emoticonCategoryList"
:props="{ checkStrictly: true, value: 'emotionCategoryGuid', label: 'emotionCategoryName', emitPath: false }"
placeholder="请选择表情包分类" clearable v-model="formData.emoticonCategoryGuid">
<template #default="{ node, data }">
<span>{{ data.emotionCategoryName }}</span>
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
</template>
</el-cascader>
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="名称" prop="emoticonDataName">
<el-input v-model="formData.emoticonDataName" placeholder="请输入名称" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="图片" prop="emoticonDataImg">
<UploadImage ref="uploadRef" v-model="formData.emoticonDataImg" :data=imgData :limit="1" :fileSize="5"
:drag="true" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="排序" prop="emoticonDataSort">
<el-input-number v-model.number="formData.emoticonDataSort" controls-position="right" :min="0" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div key="dialog-footer">
<el-button type="primary" @click="handleAddClick(formRef)" :loading="loadingStatus">添加</el-button>
<el-button @click="handleResetClick(formRef)">重置</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import { reactive, ref, watch } from "vue";
import { ElMessage } from 'element-plus'
import modal from '@/plugins/modal.js'
import { addOrUpdateEmoticonData } from '@/api/business/EmotionManage/EmoticonDatas/emoticonData.js';
import { emotionCategoryTreeList } from '@/api/business/EmotionManage/EmotionCategorys/emotionCategory.js';
//
const openDialog = async () => {
getTreeList()
}
//
let emoticonCategoryList = ref([])
//
async function getTreeList() {
emotionCategoryTreeList().then((res) => {
if (res.code == 200) {
emoticonCategoryList.value = res.data
}
})
}
// -
const loadingStatus = ref(false)
const labelWidth = 100;
const formRef = ref();
const { proxy } = getCurrentInstance()
const emits = defineEmits(["update:modelValue"]);
const formData = reactive({
emoticonDataSort: 100
});
const props = defineProps({
modelValue: Boolean,
done: Function,
});
const imgData = ref({
fileDir: "EmoticonData"
})
//
const rules = reactive({
emoticonDataGuid: [{ required: true, message: "不能为空", trigger: "blur", type: "number" }],
emoticonCategoryGuid: [{ required: true, message: "分类guid不能为空", trigger: "blur", type: "number" }],
emoticonDataImg: [{ required: true, message: "图片不能为空", trigger: "blur" }],
emoticonDataSort: [{ required: true, message: "排序不能为空", trigger: "blur", type: "number" }],
});
// -
//
const handleAddClick = async (formEl) => {
if (!formEl) return;
formEl.validate(async (valid) => {
if (!valid) {
return;
}
loadingStatus.value = true
const { code } = await addOrUpdateEmoticonData(formData);
if (code == 200) {
modal.msgSuccess('添加成功')
closeDialog();
loadingStatus.value = false
}
});
};
const closeDialog = () => {
handleResetClick(formRef.value);
props.done();
emits("update:modelValue", false);
};
const handleResetClick = async (formEl) => {
if (!formEl) return;
formEl.resetFields();
};
</script>

View File

@ -0,0 +1,94 @@
<!--
* @Descripttion: (表情包/tb_emoticon_data 详情弹窗)
* @version: (1.0)
* @Author: (lwh)
* @Date: (2023-10-28)
* @LastEditors: (lwh)
* @LastEditTime: (2023-10-28)
-->
<template>
<el-dialog v-model="props.modelValue" title="表情包信息详情" width="900px" @closed="closeDialog" @open="openDialog">
<el-form ref="formRef" :model="formData" :disabled="true">
<el-row :gutter="20">
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="分类guid" >
<el-input v-model="formData.emoticonCategoryGuid" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="名称" >
<el-input v-model="formData.emoticonDataName" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="图片" >
<UploadImage ref="uploadRef" v-model="formData.emoticonDataImg" :limit="1" :fileSize="5"
:drag="true" :isShowTip="false" :isDisabled="true"/>
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="排序" >
<el-input-number v-model.number="formData.emoticonDataSort" controls-position="right" :precision="2" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-dialog>
</template>
<script setup>
import { ElMessage } from 'element-plus'
import { reactive, ref, watch } from "vue";
//
const openDialog = async () => {
}
const formData = ref({
...props.data,
});
watch(props, async (v) => {
formData.value = v.data;
});
// -
// -
//
const formRef = ref();
const labelWidth = 100;
const { proxy } = getCurrentInstance()
const props = defineProps({
modelValue: Boolean,
data: Object,
done: Function,
});
const emits = defineEmits(["update:modelValue"]);
// -
const closeDialog = () => {
emits("update:modelValue", false);
};
</script>

View File

@ -0,0 +1,139 @@
<!--
* @Descripttion: (表情包/tb_emoticon_data 编辑弹窗)
* @version: (1.0)
* @Author: (lwh)
* @Date: (2023-10-28)
* @LastEditors: (lwh)
* @LastEditTime: (2023-10-28)
-->
<template>
<el-dialog v-model="props.modelValue" title="修改表情包信息" width="900px" @closed="closeDialog" @open="openDialog">
<el-form ref="formRef" :model="formData" :rules="rules">
<el-row :gutter="20">
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="分类guid" prop="emoticonCategoryGuid">
<el-input v-model="formData.emoticonCategoryGuid" placeholder="请输入分类guid" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="名称" prop="emoticonDataName">
<el-input v-model="formData.emoticonDataName" placeholder="请输入名称" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="图片" prop="emoticonDataImg">
<UploadImage ref="uploadRef" v-model="formData.emoticonDataImg" :data=imgData :limit="1" :fileSize="5"
:drag="true" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="排序" prop="emoticonDataSort">
<el-input-number v-model.number="formData.emoticonDataSort" controls-position="right" :min="0" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="handleEditClick(formRef)" :loading="loadingStatus">编辑</el-button>
<el-button @click="handleResetClick(formRef)">重置</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import { ElMessage } from 'element-plus'
import modal from '@/plugins/modal.js'
import { reactive, ref, watch } from "vue";
import { addOrUpdateEmoticonData } from "@/api/business/EmotionManage/EmoticonDatas/emoticonData.js";
//
const openDialog = async () => {
}
const formData = ref({
...props.data,
});
watch(props, async (v) => {
formData.value = v.data;
});
//
// -
// -
const props = defineProps({
modelValue: Boolean,
data: Object,
done: Function,
});
const loadingStatus = ref(false)
const labelWidth = 100;
const formRef = ref();
const { proxy } = getCurrentInstance()
const emits = defineEmits(["update:modelValue"]);
const imgData = ref({
fileDir: "EmoticonData"
})
//
const rules = reactive({
emoticonDataGuid: [{ required: true, message: "不能为空", trigger: "blur", type: "number" }],
emoticonCategoryGuid: [{ required: true, message: "分类guid不能为空", trigger: "blur", type: "number" }],
emoticonDataImg: [{ required: true, message: "图片不能为空", trigger: "blur" }],
emoticonDataSort: [{ required: true, message: "排序不能为空", trigger: "blur", type: "number" }],
});
// -
//
const handleEditClick = async (formEl) => {
if (!formEl) return;
formEl.validate(async (valid) => {
if (!valid) {
return;
}
loadingStatus.value = true
const { code } = await addOrUpdateEmoticonData(formData.value);
if (code == 200) {
modal.msgSuccess('修改成功')
closeDialog();
loadingStatus.value = false
}
});
}
const handleResetClick = async (formEl) => {
if (!formEl) return;
formEl.resetFields();
}
const closeDialog = () => {
props.done();
emits("update:modelValue", false);
};
</script>

View File

@ -0,0 +1,128 @@
<!--
* @Descripttion: (表情包/tb_emoticon_data 添加弹窗)
* @version: (1.0)
* @Author: (lwh)
* @Date: (2023-10-28)
* @LastEditors: (lwh)
* @LastEditTime: (2023-10-28)
-->
<template>
<el-dialog v-model="props.modelValue" title="添加表情包信息" width="900px" @closed="closeDialog" @open="openDialog">
<el-form ref="formRef" :model="formData" :rules="rules">
<el-row :gutter="20">
<el-col :lg="12">
<el-form-item :label-width="labelWidth" label="表情包分类" prop="emotionCategoryGuid">
<el-cascader class="w100" :options="emoticonCategoryList"
:props="{ checkStrictly: true, value: 'emotionCategoryGuid', label: 'emotionCategoryName', emitPath: false }"
placeholder="请选择表情包分类" clearable v-model="formData.emoticonCategoryGuid">
<template #default="{ node, data }">
<span>{{ data.emotionCategoryName }}</span>
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
</template>
</el-cascader>
</el-form-item>
</el-col>
<el-col :lg="24">
<el-form-item :label-width="labelWidth" label="图片" prop="emoticonDataImg">
<UploadImage ref="uploadRef" v-model="formData.emoticonDataImg" :data=imgData :limit="100" :fileSize="15"
:drag="true" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div key="dialog-footer">
<el-button type="primary" @click="handleAddClick(formRef)" :loading="loadingStatus">添加</el-button>
<el-button @click="handleResetClick(formRef)">重置</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import { reactive, ref, watch } from "vue";
import { ElMessage } from 'element-plus'
import modal from '@/plugins/modal.js'
import { addOrUpdateEmoticonData,batchAddEmoticonData } from '@/api/business/EmotionManage/EmoticonDatas/emoticonData.js';
import { emotionCategoryTreeList } from '@/api/business/EmotionManage/EmotionCategorys/emotionCategory.js';
//
const openDialog = async () => {
getTreeList()
}
//
let emoticonCategoryList = ref([])
//
async function getTreeList() {
emotionCategoryTreeList().then((res) => {
if (res.code == 200) {
emoticonCategoryList.value = res.data
}
})
}
// -
const loadingStatus = ref(false)
const labelWidth = 100;
const formRef = ref();
const { proxy } = getCurrentInstance()
const emits = defineEmits(["update:modelValue"]);
const formData = reactive({
emoticonDataSort: 100
});
const props = defineProps({
modelValue: Boolean,
done: Function,
});
const imgData = ref({
fileDir: "EmoticonData"
})
//
const rules = reactive({
emoticonCategoryGuid: [{ required: true, message: "分类guid不能为空", trigger: "blur", type: "number" }],
emoticonDataImg: [{ required: true, message: "图片不能为空", trigger: "blur" }],
});
// -
//
const handleAddClick = async (formEl) => {
if (!formEl) return;
formEl.validate(async (valid) => {
if (!valid) {
return;
}
loadingStatus.value = true
const { code } = await batchAddEmoticonData(formData);
if (code == 200) {
modal.msgSuccess('批量添加成功')
closeDialog();
loadingStatus.value = false
}
});
};
const closeDialog = () => {
handleResetClick(formRef.value);
props.done();
emits("update:modelValue", false);
};
const handleResetClick = async (formEl) => {
if (!formEl) return;
formEl.resetFields();
};
</script>

View File

@ -0,0 +1,259 @@
<!--
* @Descripttion: (表情包/tb_emoticon_data)
* @version: (1.0)
* @Author: (lwh)
* @Date: (2023-10-28)
* @LastEditors: (lwh)
* @LastEditTime: (2023-10-28)
-->
<template>
<div class="app-container">
<el-row :gutter="24">
<!-- 搜索框 queryParams.需要搜索的字段 -->
<el-form :model="queryParams" label-position="left" style="margin:15px;" inline ref="queryForm" v-show="showSearch"
@submit.prevent>
<el-form-item :label-width="labelWidth" label="表情包分类" prop="emotionCategoryGuid">
<el-cascader class="w100" :options="emotionCategoryList"
:props="{ checkStrictly: true, value: 'emotionCategoryGuid', label: 'emotionCategoryName', emitPath: false }"
placeholder="请选择表情包分类" clearable v-model="queryParams.emoticonCategoryGuid" @change="handleQuery">
<template #default="{ node, data }">
<span>{{ data.emotionCategoryName }}</span>
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
</template>
</el-cascader>
</el-form-item>
<el-form-item label="名称" prop="emoticonDataName">
<el-input v-model="queryParams.emoticonDataName" placeholder="请输入名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button icon="search" type="primary" @click="handleQuery">{{ $t('btn.search') }}</el-button>
<el-button icon="refresh" @click="resetQuery">{{ $t('btn.reset') }}</el-button>
</el-form-item>
</el-form>
</el-row>
<!-- 工具按钮 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" v-hasPermi="['business:emoticondata:addOrUpdate']" plain icon="plus"
@click="AddDialogVisible = true">
{{ $t('btn.add') }}
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" :disabled="multiple" v-hasPermi="['business:emoticondata:delete']" plain icon="delete"
@click="handleDelete">
{{ $t('btn.delete') }}
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="primary" plain icon="Upload" @click="UploadDialogVisible = true"
v-hasPermi="['business:emoticondata:import']">导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="download" @click="handleExport"
v-hasPermi="['business:emoticondata:export']">
{{ $t('btn.export') }}
</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 表格渲染 prop="对应的字段"-->
<el-table v-loading="loading" :data="dataList" ref="tableRef" border highlight-current-row
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column prop="emoticonCategoryName" label="分类名称" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="emoticonDataName" label="名称" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="emoticonDataImg" label="图片" align="center">
<template #default="scope">
<el-image preview-teleported :hide-on-click-modal="true" lazy class="table-td-thumb" fit="contain"
:src="scope.row.emoticonDataImg?.split(',')[0]" :preview-src-list="scope.row.emoticonDataImg?.split(',')">
<div><el-icon :size="15">
<document />
</el-icon></div>
</el-image>
</template>
</el-table-column>
<el-table-column prop="emoticonDataSort" label="排序" align="center" sortable />
<el-table-column label="操作" width="350" fixed="right">
<template #default="scope">
<el-button type="primary" size="small" icon="edit" @click="handleUpdate(scope.row)"
v-hasPermi="['business:emoticondata:addOrUpdate']">编辑</el-button>
<el-button type="danger" size="small" icon="delete" @click="handleDelete(scope.row)"
v-hasPermi="['business:emoticondata:delete']">删除</el-button>
<el-button size="small" icon="view" @click="handleDetail(scope.row)">查看</el-button>
</template>
</el-table-column>
</el-table>
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
@pagination="getList" />
</div>
<!-- 添加 -->
<AddDialog v-model="AddDialogVisible" :done="() => resetQuery()"></AddDialog>
<!-- 编辑 -->
<EditDialog v-model="EditDialogVisible" :data="EditDialogRow" :done="() => resetQuery()"></EditDialog>
<!-- 详情 -->
<DetailDialog v-model="DetailDialogVisible" :data="DetailDialogRow" :done="() => resetQuery()"></DetailDialog>
<!-- 导入 -->
<UploadDialog v-model="UploadDialogVisible" :done="() => resetQuery()"></UploadDialog>
</template>
<script setup name="emoticondata">
import { ElMessageBox } from 'element-plus'
import modal from '@/plugins/modal.js'
import { exportEmoticonData, emoticonDataList, delEmoticonData } from '@/api/business/EmotionManage/EmoticonDatas/emoticonData.js'
import { emotionCategoryTreeList } from '@/api/business/EmotionManage/EmotionCategorys/emotionCategory.js';
import AddDialog from "./components/AddDialog.vue";
import EditDialog from "./components/EditDialog.vue";
import DetailDialog from "./components/DetailDialog.vue";
import UploadDialog from "./components/UploadDialog.vue";
const AddDialogVisible = ref(false);
const EditDialogVisible = ref(false);
const EditDialogRow = ref({});
const DetailDialogVisible = ref(false);
const DetailDialogRow = ref({});
const UploadDialogVisible = ref(false);
const { proxy } = getCurrentInstance()
// categoryId
const ids = ref([])
//
const single = ref(true)
//
const multiple = ref(true)
//
const showSearch = ref(true)
//
const dataList = ref([])
//
const total = ref(0)
//
const loading = ref(true)
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10
},
})
const { queryParams } = toRefs(data)
//
let emotionCategoryList = ref([])
//
async function getTreeList() {
emotionCategoryTreeList().then((res) => {
if (res.code == 200) {
emotionCategoryList.value = res.data
}
})
}
getTreeList()
//
//
function getList() {
loading.value = true
emoticonDataList(queryParams.value).then((res) => {
if (res.code == 200) {
loading.value = false;
dataList.value = res.data.result;
total.value = res.data.totalNum;
}
});
}
//
function handleSelectionChange(selection) {
ids.value = selection.map((item) => item.emoticonDataId)
single.value = selection.length != 1
multiple.value = !selection.length
}
/** 重置查询操作 */
function resetQuery() {
queryParams.emoticonCategoryGuid = 0
proxy.resetForm('queryForm')
handleQuery()
}
/** 搜索按钮操作 */
function handleQuery() {
getList()
}
/** 删除按钮操作 */
function handleDelete(row) {
const Ids = row.emoticonDataId || ids.value
ElMessageBox.confirm("是否确认删除?", "系统提示", {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: "warning",
})
.then(function () {
return delEmoticonData(Ids)
})
.then(() => {
handleQuery()
modal.msgSuccess("删除成功")
})
.catch(() => { })
}
/** 导出按钮操作 */
function handleExport(row) {
const Ids = row.emoticonDataId || ids.value
const name = ref("所有")
if (Ids.length != 0) {
let str = ''
for (const key in Ids) {
str += Ids[key] + ','
}
str = str.slice(0, str.length - 1)
queryParams.value.ids = str
name.value = "选中"
}
ElMessageBox.confirm('是否确认导出' + name.value + '数据?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(function () {
return exportEmoticonData(queryParams.value)
})
.then((response) => {
proxy.download(response.data.path)
})
}
//
function handleUpdate(row) {
EditDialogVisible.value = true
EditDialogRow.value = row
}
//
function handleDetail(row) {
DetailDialogVisible.value = true
DetailDialogRow.value = row
}
handleQuery()
</script>

View File

@ -2,7 +2,7 @@
<starBackground></starBackground>
<div class="login">
<div class="login-img-box">
<img src="@/assets/images/login_img.png" alt="">
<!-- <img src="@/assets/images/login_img.png" alt=""> -->
</div>
<el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">