<template>
|
<div>
|
<list-condition-template ref="table" :form="listQuery" :formLabel="formLabel"
|
:tableData="tableData" :total="total"
|
@page-info-change="handlePageInfoChange">
|
<template slot="otherElement">
|
<el-col :xs='6' :sm='6' :md='6' :lg='6' :xl='6' :offset="0">
|
<el-form-item>
|
<el-button size="mini" type="primary" @click="queryData">查询</el-button>
|
<el-button size="mini" @click="resetQuery">重置</el-button>
|
</el-form-item>
|
</el-col>
|
</template>
|
<template slot="operationSection">
|
<el-button size="mini" type="success" @click="addItem">新增</el-button>
|
</template>
|
<template slot="columns">
|
<el-table-column label="创建时间" prop="createTiem" width="180px"></el-table-column>
|
<el-table-column label="创建人" prop="creator" show-overflow-tooltip width="120px">
|
</el-table-column>
|
<el-table-column label="主题" prop="diyDes" show-overflow-tooltip></el-table-column>
|
<el-table-column label="修改人" prop="editor" show-overflow-tooltip width="120px">
|
</el-table-column>
|
<el-table-column label="修改时间" prop="updateTime" width="180px"></el-table-column>
|
<el-table-column label="状态" prop="status" width="100px">
|
<template slot-scope="scope">
|
<span class="statusTag"
|
:style="{ background: scope.row.status === '1' ? '#f5222d' :'#52c41a'}"></span>
|
<span>{{scope.row.status === '1' ? '停用' : '启用'}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" :width="`${3 * $store.getters.colSize + 20}px`">
|
<template slot-scope="scope">
|
<wly-btn type="danger" @click="editItem(scope.row,scope.$index)">修改</wly-btn>
|
<wly-btn type="warning" :disabled="scope.row.status === '2'"
|
@click="deleteItem(scope.row,scope.$index)">删除</wly-btn>
|
<wly-btn type="success" v-if="scope.row.status==='1'"
|
@click="updateStatus(scope.row,scope.$index)">启用</wly-btn>
|
<span style="margin-left:10px;" v-else>当前使用</span>
|
</template>
|
</el-table-column>
|
</template>
|
</list-condition-template>
|
</div>
|
</template>
|
<script>
|
import { getList, editDiy, stopDiyStatus, deleteDiy } from '@/api/diy'
|
export default {
|
components: {},
|
data() {
|
return {
|
tableData: [],
|
total: 0,
|
dialogVisible: false,
|
listQuery: {
|
creator: null,
|
diyDes: null,
|
status: null,
|
diyType: '1'
|
},
|
formLabel: [
|
{
|
model: 'creator',
|
label: '创建人',
|
type: 'input'
|
},
|
{
|
model: 'diyDes',
|
label: '主题',
|
type: 'input'
|
},
|
{
|
model: 'status',
|
label: '状态',
|
type: 'select',
|
opts: [
|
{
|
name: '启用',
|
id: '2'
|
},
|
{
|
name: '停用',
|
id: '1'
|
}
|
]
|
}
|
]
|
}
|
},
|
/*
|
* 数据变化后刷新列表
|
*/
|
mounted() {
|
this.queryList(this.$refs.table.getPageInfo())
|
},
|
methods: {
|
// 删除
|
deleteItem(row, index) {
|
this.$messageBox.confirm('确认删除数据吗?', '删除', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
deleteDiy(row.id).then(res => {
|
if (res.data) {
|
this.queryData()
|
this.$message({
|
message: '删除成功',
|
type: 'success'
|
})
|
}
|
})
|
}).catch(() => {
|
})
|
},
|
/**
|
* 修改状态
|
*/
|
updateStatus(row, index) {
|
this.$messageBox.confirm(`确定切换为(${row.diyDes})方案吗?`, '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
const status = row.status === '1' ? '2' : '1'
|
this.enableStatus(row, status)
|
})
|
},
|
// 启用状态
|
enableStatus(row, status) {
|
editDiy({ id: row.id, status, diyType: '1' }).then(res => {
|
if (res.data) {
|
row.status = status
|
this.$message({
|
message: '状态启用成功',
|
type: 'success'
|
})
|
this.$refs.table.reloadCurrent()
|
}
|
})
|
},
|
// 停用状态
|
stopStatus(row, status) {
|
stopDiyStatus(row.id).then(res => {
|
if (res.data) {
|
row.status = status
|
this.$message({
|
message: '状态修改成功',
|
type: 'success'
|
})
|
}
|
})
|
},
|
/**
|
* 编辑
|
*/
|
editItem(row, index) {
|
this.$router.push(`${this.$baseRouter}/diy/update?id=${row.id}`)
|
},
|
/**
|
* 新增
|
*/
|
addItem() {
|
this.$router.push(`${this.$baseRouter}/diy/add`)
|
},
|
/**
|
* '分页信息改变时查询列表
|
*/
|
handlePageInfoChange(pageInfo) {
|
this.queryList(pageInfo)
|
},
|
|
/**
|
* 重置
|
*/
|
resetQuery() {
|
this.$refs.table.reloadCurrent()
|
},
|
/**
|
* 点击查询按钮
|
*/
|
queryData() {
|
this.$refs.table.changeCondition()
|
},
|
/**
|
* 查询列表
|
*/
|
queryList(pageInfo = { pageNum: 1, pageSize: 10 }) {
|
getList({ param: this.listQuery, ...pageInfo }).then(res => {
|
if (res.data) {
|
this.tableData = res.data.list
|
this.total = res.data.total
|
}
|
})
|
}
|
}
|
}
|
</script>
|
<style lang="scss">
|
</style>
|