forked from php-danfu.shenzhenbenwo.com

lefengyang
2025-09-10 3c9dcaf742cfa3e3c2b0843c8752cf7713aaf1fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<template>
  <div>
{%CONTENT_SEARCH_VUE%}
    <el-card shadow="never" dis-hover class="ivu-mt {%CLASS_NAME%}">
      <el-row type="flex">
        <el-col v-bind="grid">
          <el-button v-auth="['{%AUTH%}-add']" type="primary" icon="md-add" @click="add">添加{%MENUS%}</el-button>
        </el-col>
      </el-row>
      <el-table
          :data="dataList"
          ref="table"
          class="mt25"
          :loading="loading"
          highlight-current-row
      >
{%CONTENT_TABLE_VUE%}
        <el-table-column label="操作">
            <template slot-scope="scope">
              <a @click="show(scope.row)">详情</a>
              <el-divider direction="vertical" />
              <a @click="edit(scope.row.id)">修改</a>
              <el-divider direction="vertical" />
              <a @click="del(scope.row, '删除{%MENUS%}', scope.$index)">删除</a>
            </template>
        </el-table-column>
      </el-table>
      <div class="acea-row row-right page">
        <pagination :total="total"  @pagination="pageChange"  :limit.sync="from.limit" :page.sync="from.page" />
      </div>
    </el-card>
 
    <el-dialog title="查看详情" :visible.sync="dialogTableVisible" v-if='dialogTableVisible'>
        <el-descriptions title="{%MODEL_NAME%}">
{%CONTENT_DESCRIPTIONS_VUE%}
        </el-descriptions>
    </el-dialog>
 
  </div>
</template>
 
<script>
import { mapState } from 'vuex';
import { {%NAME_CAMEL%}SaveApi, {%NAME_CAMEL%}StatusApi, {%NAME_CAMEL%}DeleteApi, {%NAME_CAMEL%}UpdateApi, get{%NAME_STUDLY%}CreateApi, get{%NAME_STUDLY%}EditApi, get{%NAME_STUDLY%}ListApi, get{%NAME_STUDLY%}ReadApi} from '{%PATH_API_JS%}';
export default {
  name: '{%COMPONENT_NAME%}',
  data() {
    return {
      grid: {
        xl: 7,
        lg: 7,
        md: 12,
        sm: 24,
        xs: 24,
      },
      loading: false,
      from: {{%FROM_DATA_CONTENT_VUE%}
        page: 1,
        limit: 15,
      },
      dataList: [],
      total: 0,
      dialogTableVisible: false,
      info: {},
    };
  },
  computed: {
    ...mapState('media', ['isMobile']),
    labelWidth() {
      return this.isMobile ? undefined : '75px';
    },
    labelPosition() {
      return this.isMobile ? 'top' : 'left';
    },
  },
  created() {
    this.getList();
  },
  methods: {
    show(row) {
        get{%NAME_STUDLY%}ReadApi(row.id).then(res => {
           this.dialogTableVisible = true;
           this.info = res.data;
        }).catch(res => {
          this.$Message.error(res.msg);
        })
    },
    //修改状态
    updateStatus(row, field) {
        {%NAME_CAMEL%}StatusApi(row.id, {field: field, value: row[field]})
        .then(async (res) => {
          this.$message.success(res.msg);
        })
        .catch((res) => {
          this.$message.error(res.msg);
        });
    },
    // 添加
    add() {
      this.$modalForm(get{%NAME_STUDLY%}CreateApi()).then(() => this.getList());
    },
    // 表格搜索
    searchs() {
      this.from.page = 1;
      this.getList();
    },
    //列表
    getList() {
      this.loading = true;
      get{%NAME_STUDLY%}ListApi(this.from)
          .then(async (res) => {
            let data = res.data;
            this.dataList = data.list;
            this.total = data.count;
            this.loading = false;
          })
          .catch((res) => {
            this.loading = false;
            this.$Message.error(res.msg);
          });
    },
    //分页
    pageChange(index) {
      this.from.page = index;
      this.getList();
    },
    // 修改
    edit(id) {
      this.$modalForm(get{%NAME_STUDLY%}EditApi(id)).then(() => this.getList());
    },
    // 删除
    del(row, tit, num) {
      let delfromData = {
        title: tit,
        num: num,
        url: `{%ROUTE%}/${row.id}`,
        method: 'DELETE',
        ids: '',
      };
      this.$modalSure(delfromData)
          .then((res) => {
            this.$Message.success(res.msg);
            this.getList();
          })
          .catch((res) => {
            this.$Message.error(res.msg);
          });
    },
  },
};
</script>
 
<style scoped lang="stylus"></style>