<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>
|