<template>
|
<div class="app-container">
|
<el-form
|
:model="queryParams"
|
ref="queryForm"
|
size="small"
|
:inline="true"
|
v-show="showSearch"
|
label-width="68px"
|
>
|
<el-form-item label="名称" prop="name">
|
<el-input
|
v-model="queryParams.name"
|
placeholder="请输入名称"
|
clearable
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
<el-form-item label="启用状态" prop="isStart">
|
<el-input
|
v-model="queryParams.isStart"
|
placeholder="请输入启用状态"
|
clearable
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
<el-form-item>
|
<el-button
|
type="primary"
|
icon="el-icon-search"
|
size="mini"
|
@click="handleQuery"
|
>搜索</el-button
|
>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
|
>重置</el-button
|
>
|
</el-form-item>
|
</el-form>
|
<el-table
|
v-loading="loading"
|
:data="reportList"
|
@selection-change="handleSelectionChange"
|
border
|
>
|
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column
|
label="主键"
|
align="center"
|
prop="id"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="名称"
|
align="center"
|
prop="name"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="打印模板类型"
|
align="center"
|
prop="printType"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<dict-tag
|
:options="dict.type.online_report_type"
|
:value="scope.row.printType"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="启用状态"
|
align="center"
|
prop="isStart"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<el-switch
|
v-model="scope.row.isStart"
|
active-value="0"
|
inactive-value="1"
|
@change="changeSwitch(scope.row)"
|
></el-switch>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="说明"
|
align="center"
|
prop="note"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="类型"
|
align="center"
|
prop="type"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<span v-if="scope.row.type == 'printinfo'">打印设计</span>
|
<span v-if="scope.row.type == 'datainfo'">数据报表</span>
|
<span v-if="scope.row.type == 'chartinfo'">图形报表</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="创建人"
|
align="center"
|
prop="createBy"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="创建时间"
|
align="center"
|
prop="createTime"
|
width="180"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d}") }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="修改人"
|
align="center"
|
prop="updateBy"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="修改时间"
|
align="center"
|
prop="updateTime"
|
width="180"
|
>
|
<template slot-scope="scope">
|
<span>{{ parseTime(scope.row.updateTime, "{y}-{m}-{d}") }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="操作"
|
fixed="right"
|
align="center"
|
width="100px"
|
class-name="small-padding fixed-width"
|
>
|
<template slot-scope="scope" v-if="scope.row.userId !== 1">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-edit"
|
@click="handleUpdate(scope.row)"
|
title="修改"
|
></el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<!-- 修改报告模板对话框 -->
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form-item label="名称" prop="name">
|
<el-input v-model="form.name" placeholder="请输入名称" />
|
</el-form-item>
|
<el-form-item label="模板类型" prop="printType">
|
<el-select
|
v-model="form.printType"
|
placeholder="请选择模板类型"
|
clearable
|
>
|
<el-option
|
v-for="dict in dict.type.online_report_type"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<!-- <el-form-item label="启用状态" prop="isStart">
|
<el-switch
|
v-model="form.isStart"
|
active-value="0"
|
inactive-value="1"
|
@change="changeSwitch1"
|
></el-switch>
|
</el-form-item> -->
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
</div>
|
</el-dialog>
|
|
<div class="pag">
|
<div class="pag1">
|
<pagination
|
v-show="total > 0"
|
:total="total"
|
:page.sync="queryParams.pageNum"
|
:limit.sync="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
</div>
|
</div>
|
|
<!-- 添加或修改在线excel设计器对话框 -->
|
<!-- <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
</div>
|
</el-dialog> -->
|
</div>
|
</template>
|
|
<script>
|
import {
|
listReport,
|
getReport,
|
delReport,
|
addReport,
|
updateReport,
|
changeOpen
|
} from "@/api/system/onlinereport";
|
|
export default {
|
name: "Report",
|
dicts: ["online_report_type", "online_report_status", "online_report_type"],
|
data() {
|
return {
|
rows:{},
|
// 遮罩层
|
loading: true,
|
// 选中数组
|
ids: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 在线excel设计器表格数据
|
reportList: [],
|
// 弹出层标题
|
title: "",
|
// 是否显示弹出层
|
open: false,
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
name: null,
|
template: null,
|
printType: null,
|
isStart: null,
|
},
|
// 表单参数
|
form: {},
|
// 表单校验
|
rules: {},
|
};
|
},
|
created() {
|
this.getList();
|
},
|
methods: {
|
/** 查询在线excel设计器列表 */
|
getList() {
|
this.loading = true;
|
listReport(this.queryParams).then((response) => {
|
this.reportList = response.rows;
|
this.total = response.total;
|
this.loading = false;
|
});
|
},
|
// 取消按钮
|
cancel() {
|
this.open = false;
|
this.reset();
|
},
|
// 表单重置
|
reset() {
|
this.form = {
|
id: null,
|
code: null,
|
name: null,
|
note: null,
|
status: "0",
|
type: null,
|
jsonStr: null,
|
apiUrl: null,
|
thumb: null,
|
createBy: null,
|
createTime: null,
|
updateBy: null,
|
updateTime: null,
|
delFlag: null,
|
apiMethod: null,
|
apiCode: null,
|
template: null,
|
viewCount: null,
|
cssStr: null,
|
jsStr: null,
|
tenantId: null,
|
printType: null,
|
isStart: null,
|
};
|
this.resetForm("form");
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.queryParams.pageNum = 1;
|
this.getList();
|
},
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.resetForm("queryForm");
|
this.handleQuery();
|
},
|
// 多选框选中数据
|
handleSelectionChange(selection) {
|
this.ids = selection.map((item) => item.id);
|
this.single = selection.length !== 1;
|
this.multiple = !selection.length;
|
},
|
// 开关事件
|
changeSwitch(row) {
|
this.rows = row;
|
let text = row.isStart === "0" ? "启用" : "停用";
|
this.$modal
|
.confirm('确认要"' + text + '""' + row.name + '"模板吗?')
|
.then(function () {
|
return changeOpen(row.id, row.isStart, row.printType, row.type);
|
})
|
.then(() => {
|
this.$modal.msgSuccess(text + "成功");
|
this.getList();
|
})
|
.catch(function () {
|
row.isStart = row.isStart === "0" ? "1" : "0";
|
});
|
},
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset();
|
const id = row.id || this.ids;
|
getReport(id).then((response) => {
|
this.form = response.data;
|
this.open = true;
|
this.title = "报表模板维护";
|
});
|
},
|
/** 提交按钮 */
|
submitForm() {
|
this.$refs["form"].validate((valid) => {
|
if (valid) {
|
if (this.form.id != null) {
|
updateReport(this.form).then((response) => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.getList();
|
});
|
} else {
|
addReport(this.form).then((response) => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
this.getList();
|
});
|
}
|
}
|
});
|
},
|
},
|
};
|
</script>
|
<style scoped>
|
.pag {
|
width: 100%;
|
display: flex;
|
justify-content: center;
|
}
|
|
.pag1 {
|
width: 30%;
|
}
|
</style>
|