| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- <style>
- .table-body {
- padding: 20px;
- background-color: #fff;
- }
- .input-item {
- display: inline-block;
- width: 250px;
- margin: 0 0 20px;
- }
- .input-item .el-input__inner {
- border-right: 0;
- }
- .input-item .el-input__inner:hover {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input__inner:focus {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input-group__append {
- background-color: #fff;
- border-left: 0;
- width: 10%;
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- margin: 0;
- }
- .table-body .el-button {
- padding: 0 !important;
- border: 0;
- margin: 0 5px;
- }
- .el-table th > .cell {
- color: #333;
- font-weight: bold;
- font-size: 14px;
- }
- .el-table__footer-wrapper, .el-table__header-wrapper {
- border-bottom: 1.4px solid #D6D6D6;
- }
- .el-button--primary2 {
- color: #FFF;
- background-color: #03C5FF;
- border-color: #03C5FF;
- }
- </style>
- <div id="app" v-cloak>
- <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <div>
- <span>系统通知</span>
- </div>
- </template>
- </div>
- <div class="table-body">
- <el-button class="el-button--primary2" style="padding: 9px 15px!important; float: right;" type="primary"
- @click="addgsForm()" size="small">新增
- </el-button>
- <div class="input-item" style="float: left;">
- <el-input @keyup.enter.native="search" size="small"
- placeholder="搜索系统通知"
- v-model="keyword"
- clearable
- @clear="search">
- <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
- </el-input>
- </div>
- <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
- <el-table-column prop="id" label="ID" min-width="80" align="center"></el-table-column>
- <el-table-column
- label="系统通知内容"
- min-width="150"
- align="center">
- <template slot-scope="scope">
- <com-ellipsis :line="2">{{scope.row.content}}</com-ellipsis>
- </template>
- </el-table-column>
- <el-table-column prop="scope" width="180" label="创建时间">
- <template slot-scope="scope">
- {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
- </template>
- </el-table-column>
- <el-table-column prop="scope" width="180" label="修改时间">
- <template slot-scope="scope">
- {{scope.row.updated_at|dateTimeFormat('Y-m-d H:i:s')}}
- </template>
- </el-table-column>
- <el-table-column
- label="操作"
- min-width="180"
- align="center">
- <template slot-scope="scope">
- <el-button circle size="mini" type="text" @click="getEdit(scope.row)">
- 编辑
- </el-button>
- <el-button circle size="mini" type="text" @click="delNotice(scope.row)">
- 删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <div style="text-align: right;margin: 20px 0;">
- <el-pagination v-if="pagination" :page-size="pagination.pageSize"
- style="display: inline-block;float: right;" background @current-change="pageChange"
- layout="prev, pager, next" :total="pagination.total_count">
- </el-pagination>
- </div>
- </div>
- <!--弹框添加分类开始-->
- <el-dialog :title="title" width="30%" :visible.sync="dialogAddgsVisible"
- :modal-append-to-body="false">
- <el-form :model="addForm" ref="addForm" :rules="addRule" >
- <el-form-item label="系统通知" prop="content">
- <el-input type="textarea" v-model="addForm.content" @input="sortChange" placeholder="请填写系统通知"></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogAddgsVisible = false">取 消</el-button>
- <el-button type="primary" :loading="btnLoading" @click="handle('edit','addForm')">确 定</el-button>
- </span>
- </el-dialog>
- <!--弹框添加分类结束-->
- </el-card>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- var validatePass = (rule, value, callback) => {
- var reg = /^[\u4e00-\u9fa5\w]+$/;
- if (reg.test(value)) {
- callback();
- }else{
- callback(new Error('规则名不能含有特殊字符'));
- }
- };
- return {
- list: [],
- id: null,
- sort: 0,
- keyword: '',
- listLoading: false,
- btnLoading: false,
- pagination:null,
- page: 1,
- pageCount: 0,
- //弹框配置
- addForm: {
- id:'',
- centent : '',
- },
- addRule: {
- content: [
- {required: true, message: '请填写系统通知', trigger: 'change'},
- {
- validator: (rule, value, callback) => {
- if(value.length>500){
- callback('最大长度在500个字内');
- }
- callback();
- }
- },
- ],
- },
- ptypeList: [
- {key: "0", value: "成功"},
- {key: "1", value: "失败"},
- ],
- title:'',
- dialogAddgsVisible: false,
- dataList: [],
- // 对话框显示与否
- dialogVisible: false,
- dataloading: false,
- addGroupVisible: false,
- };
- },
- methods: {
- sortChange(){
- this.$forceUpdate();
- },
- editSort(row) {
- this.id = row.id;
- this.sort = row.sort;
- },
- quit() {
- this.id = null;
- },
- search() {
- this.page = 1;
- this.getList();
- },
- pageChange(currentPage) {
- let self = this;
- self.page = currentPage; //console.log(currentPage,999999);
- self.getList();
- },
- getList() {
- let self = this;
- self.listLoading = true;
- request({
- params: {
- r: 'admin/setting/notice',
- page: self.page,
- keyword: this.keyword
- },
- method: 'get',
- }).then(e => {
- self.listLoading = false;
- self.list = e.data.data.list;
- this.pagination = e.data.data.pagination;
- this.pagination.pageSize = e.data.data.page_size;
- this.pagination.total_count = e.data.data.count;
- }).catch(e => {
- console.log(e);
- });
- },
- getEdit(data) {
- this.dialogAddgsVisible = true;
- this.title = "编辑系统通知";
- this.addForm.id = data.id;
- this.addForm.content = data.content;
- },
- handle(type,data = null){
- this.$refs[data].validate((valid) => {
- let self = this;
- if (valid) {
- if(this.addForm.id){
- this.send({content : self.addForm.content,id:this.addForm.id});
- }else{
- this.send({content : self.addForm.content});
- }
- } else {
- console.log('error submit!!');
- return false;
- }
- });
- },
- send(data){
- let self = this;
- self.btnLoading = true;
- request({
- params: {
- r: 'admin/setting/notice-edit',
- },
- method: 'post',
- data:data,
- }).then(e => {
- this.dialogAddgsVisible = false;
- this.btnLoading = false;
- if (e.data.code == 0) {
- self.$message.success(e.data.msg);
- self.getList();
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- delNotice(data){
- this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {
- let self = this;
- self.btnLoading = true;
- request({
- params: {
- r: 'admin/setting/notice-del',
- },
- method: 'post',
- data:{id: data.id,status:-1},
- }).then(e => {
- this.dialogAddgsVisible = false;
- this.btnLoading = false;
- if (e.data.code == 0) {
- self.$message.success(e.data.msg);
- self.getList();
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- })
- },
- /**
- *点击新增按钮,弹出新增模态框
- * @param
- */
- addgsForm() {
- this.dialogAddgsVisible = true;
- this.title = "添加系统通知";
- this.addForm.id = '';
- this.addForm.sort = 99;
- },
- /**
- *关闭或取消模态框,清空值
- * @param
- */
- closeDialogAddgsVisible() {
- this.$refs.addForm.resetFields();//element封装的方法,清空模态框的值
- this.title = "" //初始化title的值
- this.addForm = {//初始化addForm中的值
- name: "",
- }
- },
- },
- mounted: function () {
- this.getList();
- }
- });
- </script>
|