|
|
@@ -0,0 +1,253 @@
|
|
|
+<template>
|
|
|
+ <div class="ele-body">
|
|
|
+ <el-card shadow="never">
|
|
|
+ <!-- 搜索表单 -->
|
|
|
+ <el-form :model="table.where" label-width="90px" class="ele-form-search"
|
|
|
+ @keyup.enter.native="$refs.table.reload()" @submit.native.prevent>
|
|
|
+ <el-row :gutter="15">
|
|
|
+ <el-col :md="8" :sm="12">
|
|
|
+ <el-form-item label="关键词:">
|
|
|
+ <el-input v-model="table.where.keyword" placeholder="请输入应用名称" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :md="6" :sm="12">
|
|
|
+ <el-form-item label="平台类型:">
|
|
|
+ <el-select v-model="table.where.link_type" placeholder="请选择" class="ele-fluid" clearable>
|
|
|
+ <el-option label="全部" :value="0" />
|
|
|
+ <el-option label="Web" :value="1" />
|
|
|
+ <el-option label="小程序" :value="2" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :md="6" :sm="12">
|
|
|
+ <el-form-item label="状态:">
|
|
|
+ <el-select v-model="table.where.status" placeholder="请选择" class="ele-fluid" clearable>
|
|
|
+ <el-option label="全部" :value="0" />
|
|
|
+ <el-option label="有效" :value="1" />
|
|
|
+ <el-option label="无效" :value="2" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :md="4" :sm="12">
|
|
|
+ <div class="ele-form-actions">
|
|
|
+ <el-button type="primary" @click="$refs.table.reload()" icon="el-icon-search"
|
|
|
+ class="ele-btn-icon">查询</el-button>
|
|
|
+ <el-button @click="handleReset()">重置</el-button>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <!-- 操作按钮 -->
|
|
|
+ <div class="ele-table-tool ele-table-tool-default">
|
|
|
+ <el-button @click="add()" type="primary" icon="el-icon-plus" class="ele-btn-icon" size="small"
|
|
|
+ v-if="permission.includes('sys:socialCircles:add')">添加应用</el-button>
|
|
|
+ </div>
|
|
|
+ <!-- 数据表格 -->
|
|
|
+ <ele-data-table ref="table" :config="table" :choose.sync="choose" height="calc(100vh - 315px)"
|
|
|
+ highlight-current-row>
|
|
|
+ <template>
|
|
|
+ <el-table-column type="selection" width="45" align="center" fixed="left" />
|
|
|
+ <el-table-column prop="id" label="ID" width="60" align="center" fixed="left" show-overflow-tooltip />
|
|
|
+ <el-table-column prop="logo" label="应用LOGO" width="100" align="center">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-image :src="row.logo" style="width: 50px; height: 50px;" fit="cover" v-if="row.logo" />
|
|
|
+ <span v-else>-</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="name" label="应用名称" show-overflow-tooltip min-width="150" />
|
|
|
+ <el-table-column prop="link_type" label="平台类型" width="100" align="center">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-tag :type="row.link_type == 1 ? 'primary' : 'success'" size="small">
|
|
|
+ {{ row.link_type == 1 ? 'Web' : '小程序' }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="link_url" label="链接地址" show-overflow-tooltip min-width="200" />
|
|
|
+ <el-table-column prop="app_id" label="AppID" show-overflow-tooltip min-width="150" />
|
|
|
+ <el-table-column prop="sort" label="排序" width="80" align="center" />
|
|
|
+ <el-table-column prop="status" label="状态" width="100" align="center">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-switch v-model="row.status" @change="editStatus(row)" :active-value="1" :inactive-value="2"
|
|
|
+ :disabled="!permission.includes('sys:socialCircles:status')" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="create_time" label="创建时间" show-overflow-tooltip min-width="160" align="center" />
|
|
|
+ <el-table-column label="操作" width="180px" align="center" :resizable="false" fixed="right">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-link @click="edit(row)" icon="el-icon-edit" type="primary" :underline="false"
|
|
|
+ v-if="permission.includes('sys:socialCircles:edit')">修改</el-link>
|
|
|
+ <el-popconfirm title="确定要删除此应用吗?" @confirm="remove(row)" class="ele-action">
|
|
|
+ <el-link slot="reference" icon="el-icon-delete" type="danger" :underline="false"
|
|
|
+ v-if="permission.includes('sys:socialCircles:delete')">删除</el-link>
|
|
|
+ </el-popconfirm>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </template>
|
|
|
+ </ele-data-table>
|
|
|
+ </el-card>
|
|
|
+ <!-- 编辑弹窗 -->
|
|
|
+ <el-dialog :title="editForm.id ? '修改应用' : '添加应用'" :visible.sync="showEdit" width="700px" @closed="resetEditForm()"
|
|
|
+ :destroy-on-close="true" custom-class="ele-dialog-form" :lock-scroll="false">
|
|
|
+ <el-form :model="editForm" ref="editForm" :rules="editRules" label-width="100px">
|
|
|
+ <el-form-item label="应用名称:" prop="name">
|
|
|
+ <el-input v-model="editForm.name" placeholder="请输入应用名称" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="应用LOGO:" prop="logo">
|
|
|
+ <upload-image v-model="editForm.logo" :limit="1" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="平台类型:" prop="link_type">
|
|
|
+ <el-radio-group v-model="editForm.link_type">
|
|
|
+ <el-radio :label="1">Web(需要域名授权)</el-radio>
|
|
|
+ <el-radio :label="2">小程序</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="链接地址:" prop="link_url" v-if="editForm.link_type == 1">
|
|
|
+ <el-input v-model="editForm.link_url" placeholder="请输入Web链接地址" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="页面地址:" prop="link_url" v-if="editForm.link_type == 2">
|
|
|
+ <el-input v-model="editForm.link_url" placeholder="请输入小程序页面地址" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="AppID:" prop="app_id" v-if="editForm.link_type == 2">
|
|
|
+ <el-input v-model="editForm.app_id" placeholder="请输入小程序AppID" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="排序:" prop="sort">
|
|
|
+ <el-input-number v-model="editForm.sort" :min="0" :max="9999" controls-position="right"
|
|
|
+ style="width: 100%;" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="状态:">
|
|
|
+ <el-radio-group v-model="editForm.status">
|
|
|
+ <el-radio :label="1">有效</el-radio>
|
|
|
+ <el-radio :label="2">无效</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button @click="showEdit = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="save">保存</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { mapGetters } from "vuex";
|
|
|
+import UploadImage from '@/components/uploadImage';
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "SocialCircles",
|
|
|
+ components: { UploadImage },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ table: { url: '/socialCircles/index', where: { status: 0 } },
|
|
|
+ choose: [],
|
|
|
+ showEdit: false,
|
|
|
+ editForm: { status: 1, link_type: 1, sort: 0 },
|
|
|
+ editRules: {
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入应用名称', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ link_type: [
|
|
|
+ { required: true, message: '请选择平台类型', trigger: 'change' }
|
|
|
+ ],
|
|
|
+ link_url: [
|
|
|
+ { required: true, message: '请输入链接地址', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ app_id: [
|
|
|
+ { required: true, message: '请输入AppID', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(["permission"]),
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ add() {
|
|
|
+ this.resetEditForm();
|
|
|
+ this.showEdit = true;
|
|
|
+ },
|
|
|
+ edit(row) {
|
|
|
+ const loading = this.$loading({ lock: true });
|
|
|
+ this.$http.get('/socialCircles/info', { params: { id: row.id } }).then(res => {
|
|
|
+ loading.close();
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ this.editForm = Object.assign({}, res.data.data);
|
|
|
+ this.showEdit = true;
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ loading.close();
|
|
|
+ this.$message.error(e.message);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ resetEditForm() {
|
|
|
+ this.editForm = { status: 1, link_type: 1, sort: 0, name: '', logo: '', link_url: '', app_id: '' };
|
|
|
+ if (this.$refs.editForm) {
|
|
|
+ this.$refs.editForm.clearValidate();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleReset() {
|
|
|
+ this.table.where = { status: 0 };
|
|
|
+ this.$refs.table.reload();
|
|
|
+ },
|
|
|
+ save() {
|
|
|
+ this.$refs['editForm'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ const loading = this.$loading({ lock: true });
|
|
|
+ this.$http.post('/socialCircles/edit', this.editForm).then(res => {
|
|
|
+ loading.close();
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ this.showEdit = false;
|
|
|
+ this.$message({ type: 'success', message: res.data.msg });
|
|
|
+ this.$refs.table.reload();
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ loading.close();
|
|
|
+ this.$message.error(e.message);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ remove(row) {
|
|
|
+ const loading = this.$loading({ lock: true });
|
|
|
+ this.$http.post('/socialCircles/delete', { id: row.id }).then(res => {
|
|
|
+ loading.close();
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ this.$message({ type: 'success', message: res.data.msg });
|
|
|
+ this.$refs.table.reload();
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ loading.close();
|
|
|
+ this.$message.error(e.message);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ editStatus(row) {
|
|
|
+ this.$message.closeAll()
|
|
|
+ const loading = this.$loading({ lock: true });
|
|
|
+ let params = { id: row.id, status: row.status };
|
|
|
+ this.$http.post('/socialCircles/status', params).then(res => {
|
|
|
+ loading.close();
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ this.$message({ type: 'success', message: res.data.msg });
|
|
|
+ } else {
|
|
|
+ row.status = row.status == 1 ? 2 : 1;
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ loading.close();
|
|
|
+ row.status = row.status == 1 ? 2 : 1;
|
|
|
+ this.$message.error(e.message);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped></style>
|