|
|
@@ -0,0 +1,358 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <!-- 搜索表单 -->
|
|
|
+ <el-form :inline="true" class="search-form" @keyup.enter="handleQuery">
|
|
|
+ <el-form-item label="小程序名称">
|
|
|
+ <el-input v-model="queryParams.name" placeholder="请输入小程序名称" clearable style="width: 200px" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="状态">
|
|
|
+ <el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 120px">
|
|
|
+ <el-option label="启用" value="1" />
|
|
|
+ <el-option label="禁用" value="0" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" :icon="Search" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button :icon="RefreshLeft" @click="resetQuery">重置</el-button>
|
|
|
+ <el-button type="success" :icon="Plus" @click="handleAdd">新增</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <!-- 表格 -->
|
|
|
+ <el-table v-loading="loading" :data="miniprogramList" style="width: 100%">
|
|
|
+ <el-table-column type="index" label="序号" width="80" />
|
|
|
+ <el-table-column prop="name" label="小程序名称" min-width="150" />
|
|
|
+ <el-table-column prop="logo" label="图标地址" width="100">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="url" label="链接" min-width="200" show-overflow-tooltip />
|
|
|
+ <el-table-column prop="status" label="状态" width="100">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-tag :type="scope.row.status == '1' ? 'success' : 'danger'">
|
|
|
+ {{ scope.row.status == '1' ? '启用' : '禁用' }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="desc" label="描述" min-width="150" show-overflow-tooltip />
|
|
|
+ <el-table-column label="操作" width="180" fixed="right">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button type="primary" size="small" :icon="Edit" @click="handleEdit(scope.row)">
|
|
|
+ 修改
|
|
|
+ </el-button>
|
|
|
+ <el-button type="danger" size="small" :icon="Delete" @click="handleDelete(scope.row.id)">
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <!-- 分页 -->
|
|
|
+ <el-pagination
|
|
|
+ v-model:current-page="queryParams.pageNum"
|
|
|
+ v-model:page-size="queryParams.pageSize"
|
|
|
+ :page-sizes="[10, 20, 30, 50]"
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ :total="total"
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 新增/修改对话框 -->
|
|
|
+ <el-dialog
|
|
|
+ v-model="dialogVisible"
|
|
|
+ :title="dialogTitle"
|
|
|
+ width="500px"
|
|
|
+ destroy-on-close
|
|
|
+ >
|
|
|
+ <el-form
|
|
|
+ ref="formRef"
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ label-width="100px"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-form-item label="小程序名称" prop="name">
|
|
|
+ <el-input v-model="form.name" placeholder="请输入小程序名称" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="图标地址" prop="logo">
|
|
|
+ <el-input v-model="form.logo" placeholder="请输入图标地址" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="链接" prop="url">
|
|
|
+ <el-input v-model="form.url" placeholder="请输入小程序链接" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="状态" prop="status">
|
|
|
+ <el-select v-model="form.status" placeholder="请选择状态">
|
|
|
+ <el-option label="启用" :value="1" />
|
|
|
+ <el-option label="禁用" :value="0" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="描述" prop="desc">
|
|
|
+ <el-input
|
|
|
+ v-model="form.desc"
|
|
|
+ type="textarea"
|
|
|
+ rows="3"
|
|
|
+ placeholder="请输入小程序描述"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="扩展1" prop="ext1">
|
|
|
+ <el-input v-model="form.ext1" placeholder="请输入扩展1" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="扩展2" prop="ext2">
|
|
|
+ <el-input v-model="form.ext2" placeholder="请输入扩展2" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button @click="dialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="handleSubmit">确定</el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { apisystemminiprogramlist, apisystemminiprogramadd, apisystemminiprogramupdate, apisystemminiprogramdel, apisystemminiprogramget } from '@/request/api';
|
|
|
+import { ElMessage, ElMessageBox } from 'element-plus';
|
|
|
+import { Plus, Search, RefreshLeft, Edit, Delete } from '@element-plus/icons-vue';
|
|
|
+import service from '@/request/index';
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'MiniprogramMan',
|
|
|
+ data() {
|
|
|
+ let Authorization = localStorage.getItem('access_token');
|
|
|
+ return {
|
|
|
+ Search,
|
|
|
+ RefreshLeft,
|
|
|
+ Plus,
|
|
|
+ Edit,
|
|
|
+ Delete,
|
|
|
+ loading: false,
|
|
|
+ miniprogramList: [],
|
|
|
+ total: 0,
|
|
|
+ dialogVisible: false,
|
|
|
+ dialogTitle: '',
|
|
|
+ form: {
|
|
|
+ id: '',
|
|
|
+ name: '',
|
|
|
+ logo: '',
|
|
|
+ url: '',
|
|
|
+ status: 1,
|
|
|
+ desc: '',
|
|
|
+ ext1: '',
|
|
|
+ ext2: ''
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ name: [{ required: true, message: '请输入小程序名称', trigger: 'blur' }],
|
|
|
+ url: [{ required: true, message: '请输入小程序链接', trigger: 'blur' }]
|
|
|
+ },
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ name: '',
|
|
|
+ status: ''
|
|
|
+ },
|
|
|
+ uploading: false,
|
|
|
+ fileList: [],
|
|
|
+ upUrl: window.baseUrl + '/api/resource/oss/upload',
|
|
|
+ headers: {
|
|
|
+ Authorization: 'Bearer' + ` ${Authorization}`,
|
|
|
+ clientid: 'e5cd7e4891bf95d1d19206ce24a7b32e'
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 获取列表
|
|
|
+ getList() {
|
|
|
+ this.loading = true;
|
|
|
+ apisystemminiprogramlist(this.queryParams)
|
|
|
+ .then(response => {
|
|
|
+ this.miniprogramList = response.rows;
|
|
|
+ this.total = response.total;
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('获取小程序列表失败:', error);
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 搜索
|
|
|
+ handleQuery() {
|
|
|
+ this.queryParams.pageNum = 1;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 重置搜索
|
|
|
+ resetQuery() {
|
|
|
+ this.queryParams = {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ name: '',
|
|
|
+ status: ''
|
|
|
+ };
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 分页大小变化
|
|
|
+ handleSizeChange(val) {
|
|
|
+ this.queryParams.pageSize = val;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 当前页变化
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ this.queryParams.pageNum = val;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 新增
|
|
|
+ handleAdd() {
|
|
|
+ this.dialogTitle = '新增小程序';
|
|
|
+ this.form = {
|
|
|
+ id: '',
|
|
|
+ name: '',
|
|
|
+ logo: '',
|
|
|
+ url: '',
|
|
|
+ status: 1,
|
|
|
+ desc: '',
|
|
|
+ ext1: '',
|
|
|
+ ext2: ''
|
|
|
+ };
|
|
|
+ this.fileList = [];
|
|
|
+ this.uploading = false;
|
|
|
+ this.dialogVisible = true;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 修改
|
|
|
+ handleEdit(row) {
|
|
|
+ this.dialogTitle = '修改小程序';
|
|
|
+ this.fileList = [];
|
|
|
+ this.uploading = false;
|
|
|
+ apisystemminiprogramget({ id: row.id })
|
|
|
+ .then(response => {
|
|
|
+ this.form = response.data;
|
|
|
+ this.dialogVisible = true;
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('获取小程序详情失败:', error);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 删除
|
|
|
+ handleDelete(id) {
|
|
|
+ ElMessageBox.confirm('确定要删除该小程序吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ apisystemminiprogramdel({ id })
|
|
|
+ .then(response => {
|
|
|
+ ElMessage.success('删除成功');
|
|
|
+ this.getList();
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('删除小程序失败:', error);
|
|
|
+ ElMessage.error('删除失败');
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
+
|
|
|
+ // 提交表单
|
|
|
+ handleSubmit() {
|
|
|
+ this.$refs.formRef.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.form.id) {
|
|
|
+ // 修改
|
|
|
+ apisystemminiprogramupdate(this.form)
|
|
|
+ .then(response => {
|
|
|
+ ElMessage.success('修改成功');
|
|
|
+ this.dialogVisible = false;
|
|
|
+ this.getList();
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('修改小程序失败:', error);
|
|
|
+ ElMessage.error('修改失败');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 新增
|
|
|
+ apisystemminiprogramadd(this.form)
|
|
|
+ .then(response => {
|
|
|
+ ElMessage.success('新增成功');
|
|
|
+ this.dialogVisible = false;
|
|
|
+ this.getList();
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('新增小程序失败:', error);
|
|
|
+ ElMessage.error('新增失败');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 上传图标变更
|
|
|
+ handleLogoUploadChange(file, fileList) {
|
|
|
+ this.uploading = true;
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append('file', file.raw);
|
|
|
+
|
|
|
+ service({
|
|
|
+ url: this.upUrl,
|
|
|
+ method: 'POST',
|
|
|
+ headers: {
|
|
|
+ ...this.headers,
|
|
|
+ 'Content-Type': 'multipart/form-data'
|
|
|
+ },
|
|
|
+ data: formData
|
|
|
+ }).then(response => {
|
|
|
+ this.uploading = false;
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.form.logo = response.data;
|
|
|
+ ElMessage.success('上传成功');
|
|
|
+ } else {
|
|
|
+ ElMessage.error('上传失败');
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.uploading = false;
|
|
|
+ console.error('上传失败:', error);
|
|
|
+ ElMessage.error('上传失败');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.search-form {
|
|
|
+ margin-bottom: 20px;
|
|
|
+ padding: 20px;
|
|
|
+ background: #f5f7fa;
|
|
|
+ border-radius: 4px;
|
|
|
+}
|
|
|
+
|
|
|
+.dialog-footer {
|
|
|
+ text-align: right;
|
|
|
+}
|
|
|
+
|
|
|
+.avatar {
|
|
|
+ border-radius: 6px;
|
|
|
+}
|
|
|
+
|
|
|
+.avatar-uploader-icon {
|
|
|
+ width: 100px;
|
|
|
+ height: 100px;
|
|
|
+ line-height: 100px;
|
|
|
+ border: 1px dashed #d9d9d9;
|
|
|
+ border-radius: 6px;
|
|
|
+ color: #999;
|
|
|
+ font-size: 28px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
+</style>
|