| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <style>
- .el-table th>.cell {
- color: #333;
- font-weight: bold;
- font-size: 14px;
- }
- .table1 .el-table__footer-wrapper,
- .table1 .el-table__header-wrapper {
- border-bottom: 1.4px solid #D6D6D6;
- }
- </style>
- <div id="app">
- <div class="table-body" style="min-width: 1000px;">
- <div slot="header" class="clearfix" style="height: 20px;">
- <span>定金预售分类</span>
- <div style="float: right; margin: -5px 0">
- <el-button type="primary" size="small" @click="handleEdit(0)">新增</el-button>
- </div>
- </div>
- <div slot="header" class="clearfix" style="margin-top: 20px;">
- </div>
- <template>
- <el-table :data="list" stripe style="width: 100%" v-loading="listLoading" class="table1">
- <el-table-column prop="id" label="编号" width="150" align="center"></el-table-column>
- <el-table-column prop="name" label="名称" align="center"></el-table-column>
- <el-table-column prop="status" label="状态" width="150" >
- <template slot-scope="scope">
- <el-tag v-if="scope.row.status == 0" size="small" type="danger" @click="updateStatus(scope.row.id,1)">禁用</el-tag>
- <el-tag v-if="scope.row.status == 1" size="small" type="success" @click="updateStatus(scope.row.id,0)">启用</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="添加时间" width="300" align="center">
- <template slot-scope="scope">
- <span> {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="300" align="center">
- <template slot-scope="scope">
- <el-button @click="handleEdit(scope.row.id)" type="text" size="small">编辑</el-button>
- <el-button @click="updateStatus(scope.row.id,-1)" type="text" size="small">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div flex="main:right cross:center" style="margin-top: 20px;">
- <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
- style="display: inline-block;float: right;" background @current-change="pageChange"
- layout="prev, pager, next" :total="pagination.totalCount">
- </el-pagination>
- </div>
- </template>
- </div>
- <el-dialog :title="form.id==0 ? '新增' : '修改'" :visible.sync="dialogFormVisible" @close="handleClose()">
- <el-form :model="form" :rules="rules" ref="form" >
- <el-form-item label="名称" :label-width="formLabelWidth" prop="name">
- <el-input v-model="form.name" autocomplete="off"></el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogFormVisible = false">取 消</el-button>
- <el-button type="primary" @click="postEdit('form')">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- listLoading: false,
- dialogFormVisible: false,
- form: {
- id: 0,
- name: '',
- },
- formLabelWidth: '120px',
- rules: {
- name: [{
- required: true,
- message: '请输入名称',
- trigger: 'blur'
- },
- ],
- },
- list: [],
- pagination: {
- total: 0
- },
- LoadDataType: -1, //默认显示全部数据
- search: {
- page: 1,
- },
- }
- },
- methods: {
- pageChange(page) {
- this.search.page = page;
- this.loadData();
- },
- loadData() {
- this.listLoading = true;
- let params = {
- r: 'deposit-presale/default/cate-index'
- };
- // params = Object.assign(params, this.search);
- request({
- params: params,
- method: 'get',
- }).then(e => {
- let res = e.data;
- this.listLoading = false;
- if (res.code === 0) {
- this.list = res.data.list;
- this.pagination = res.data.pagination;
- } else {
- this.$message.error(res.msg);
- }
- }).catch(e => {});
- },
- handleEdit(id) {
- this.dialogFormVisible = true;
- if(id!=0){
- this.$request({
- params: {
- r:'deposit-presale/default/cate-edit',
- id:id,
- },
- }).then(e => {
- if (e.data.code == 0) {
- this.form.id = e.data.data.id;
- this.form.name = e.data.data.name;
- }
- }).catch(e => {
- });
- }
- },
- postEdit(formName){
- this.$refs[formName].validate((valid) => {
- if(valid){
- this.$request({
- method:"post",
- params: {
- r:'deposit-presale/default/cate-edit',
- },
- data:this.form
- }).then(e => {
- if(e.data.code==0){
- this.dialogFormVisible = false;
- this.$message({
- message: e.data.msg,
- type: 'success'
- });
- this.loadData();
- }else{
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- });
- }
- });
- },
- updateStatus(id,status){
- this.$request({
- method:"post",
- params: {
- r:'deposit-presale/default/cate-edit',
- },
- data:{
- id:id,
- status:status
- }
- }).then(e => {
- if(e.data.code==0){
- this.$message({
- message: e.data.msg,
- type: 'success'
- });
- this.loadData();
- }else{
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- });
- },
- handleClose(){
- this.form = {
- id: 0,
- name: '',
- };
- }
- },
- mounted() {
- this.LoadDataType = -1;
- this.loadData();
- }
- })
- </script>
|