clay : 退回做了一半 #31

Merged
clay merged 2 commits from master into pro 2023-03-01 07:57:07 +00:00
6 changed files with 567 additions and 0 deletions
Showing only changes of commit 49c295a5bc - Show all commits

View File

@ -0,0 +1,70 @@
import request from '@/api/request.js'
// 查询万能查询列表
export function listQuery(query) {
return request({
url: '/custom-query/uni/query',
method: 'get',
params: query
})
}
// 查询万能查询详细
export function getQuery(id) {
return request({
url: '/custom-query/uni/query/' + id,
method: 'get'
})
}
// 新增万能查询
export function addQuery(data) {
return request({
url: '/custom-query/uni/query',
method: 'post',
data: data
})
}
// 修改万能查询
export function updateQuery(data) {
return request({
url: '/custom-query/uni/query',
method: 'put',
data: data
})
}
// 删除万能查询
export function delQuery(id) {
return request({
url: '/custom-query/uni/query/' + id,
method: 'delete'
})
}
// 导出万能查询
export function exportQuery(query) {
return request({
url: '/custom-query/uni/query/export',
method: 'get',
params: query
})
}
// 获取条件
export function getQueryInfo(id) {
return request({
url: '/query/'+id,
method: 'get',
})
}
// 修改条件
export function editQueryInfo(data) {
return request({
url: '/query',
method: 'put',
data: data
})
}

View File

@ -0,0 +1,94 @@
<template>
<div :class="{'hidden':hidden}" class="pagination-container">
<el-pagination
:background="background"
:current-page.sync="currentPage"
:page-size.sync="pageSize"
:layout="layout"
:page-sizes="pageSizes"
:total="total"
v-bind="$attrs"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</template>
<script>
export default {
name: 'Pagination',
props: {
total: {
required: true,
type: Number
},
page: {
type: Number,
default: 1
},
limit: {
type: Number,
default: 20
},
pageSizes: {
type: Array,
default() {
return [10, 20, 30, 50]
}
},
layout: {
type: String,
default: 'total, sizes, prev, pager, next, jumper'
},
background: {
type: Boolean,
default: true
},
autoScroll: {
type: Boolean,
default: true
},
hidden: {
type: Boolean,
default: false
}
},
computed: {
currentPage: {
get() {
return this.page
},
set(val) {
this.$emit('update:page', val)
}
},
pageSize: {
get() {
return this.limit
},
set(val) {
this.$emit('update:limit', val)
}
}
},
methods: {
handleSizeChange(val) {
this.$emit('pagination', { page: this.currentPage, limit: val })
},
handleCurrentChange(val) {
this.$emit('pagination', { page: val, limit: this.pageSize })
}
}
}
</script>
<style scoped>
.pagination-container {
background: #fff;
padding: 32px 16px;
}
.pagination-container.hidden {
display: none;
}
</style>

View File

@ -0,0 +1,38 @@
<!-- @author Shiyn/ huangmx 20200807优化-->
<template>
<div class="top-right-btn">
<el-row>
<el-tooltip class="item" effect="dark" :content="showSearch ? '隐藏搜索' : '显示搜索'" placement="top">
<el-button size="mini" circle icon="el-icon-search" @click="toggleSearch()" />
</el-tooltip>
<el-tooltip class="item" effect="dark" content="刷新" placement="top">
<el-button size="mini" circle icon="el-icon-refresh" @click="refresh()" />
</el-tooltip>
</el-row>
</div>
</template>
<script>
export default {
name: "RightToolbar",
data() {
return {};
},
props: {
showSearch: {
type: Boolean,
default: true,
},
},
methods: {
//
toggleSearch() {
this.$emit("update:showSearch", !this.showSearch);
},
//
refresh() {
this.$emit("queryTable");
},
},
};
</script>

View File

@ -48,6 +48,13 @@ Vue.prototype.$deepCopy = function (obj) {
return JSON.parse(JSON.stringify(obj))
}
import Pagination from "@/components/Pagination";
//自定义表格工具扩展
import RightToolbar from "@/components/RightToolbar"
// 全局组件挂载
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)
new Vue({
router,

View File

@ -33,6 +33,12 @@ const router = new Router({
component: () => import("@/views/admin/FormsPanel.vue"),
meta: {title: '表单列表', viewport: viewport}
},
{
path: "/query",
name: "query",
component: () => import("@/views/query/index.vue"),
meta: {title: '自定义查询', viewport: viewport}
},
{
path: "/admin/design",
name: "design",

View File

@ -0,0 +1,352 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="名称" prop="uqName">
<el-input
v-model="queryParams.uqName"
placeholder="请输入名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="描述" prop="uqDescribe">
<el-input
v-model="queryParams.uqDescribe"
placeholder="请输入描述"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="daterangeCreateTime"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</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-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="queryList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column type="index" width="50"></el-table-column>
<el-table-column label="名称" align="center" prop="uqName"/>
<el-table-column label="描述" align="center" prop="uqDescribe"/>
<el-table-column label="创建时间" align="center" prop="createTime">
<template slot-scope="scope">
<span>{{ scope.row.createTime }}</span>
</template>
</el-table-column>
<el-table-column label="更新时间" align="center" prop="updateTime">
<template slot-scope="scope">
<span>{{ scope.row.updateTime }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<span v-if="scope.row.isRelease===2">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
type="text"
size="small"
icon="el-icon-edit-outline"
@click="handleEditTable(scope.row)"
>设计</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</span>
<span v-if="scope.row.isRelease===1">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handRelease(scope.row.id)"
>撤销</el-button>
</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改万能查询对话框 -->
<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="uqName">
<el-input v-model="form.uqName" placeholder="请输入名称"/>
</el-form-item>
<el-form-item label="描述" prop="uqDescribe">
<el-input v-model="form.uqDescribe" placeholder="请输入描述"/>
</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>
</template>
<script>
import {listQuery, getQuery, delQuery, addQuery, updateQuery, exportQuery, Release} from "@/api/query";
import {Message} from "element-ui";
export default {
name: "Query",
components: {},
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
queryList: [],
//
title: "",
//
open: false,
//
daterangeCreateTime: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
uqName: null,
uqDescribe: null,
type: 1
},
//
form: {},
//
rules: {
uqName: [
{required: true, message: "名称不能为空}", trigger: "blur"},
],
uqDescribe: [
{required: true, message: "描述不能为空}", trigger: "blur"},
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询万能查询列表 */
getList() {
this.loading = true;
listQuery(this.queryParams).then(response => {
let data = response.data
this.queryList = data.rows;
this.total = data.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
uqName: null,
uqDescribe: null,
};
// this.$refs['form'].resetFields()
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
handleEditTable(row) {
this.$router.push("/query/edit/" + row.id);
},
/** 发布与撤销 */
handRelease(id) {
let that = this
this.$confirm('是否确认撤销该查询?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
let data = {
id: id,
isRelease: 2
}
Release(data).then(res => {
Message({
message: res.msg,
type: 'success'
})
that.getList()
})
})
},
/** 重置按钮操作 */
resetQuery() {
this.daterangeCreateTime = [];
this.$refs.queryForm.resetFields()
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加自定义查询";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getQuery(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改自定义查询";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.form.type = 1
if (valid) {
if (this.form.id != null) {
updateQuery(this.form).then(response => {
Message({
message: "修改成功",
type: 'success'
})
this.open = false;
this.getList();
});
} else {
addQuery(this.form).then(response => {
Message({
message: "新增成功",
type: 'success'
})
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除自定义查询编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
return delQuery(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
})
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有自定义查询数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
return exportQuery(queryParams);
}).then(response => {
this.download(response.msg);
})
}
}
};
</script>