You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

389 lines
9.9 KiB

3 years ago
<template>
<basic-container>
<!-- :table-loading="loading" :permission="permissionList" -->
<avue-crud
:option="option"
:data="data"
:page.sync="page"
:before-open="beforeOpen"
v-model="form"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template slot-scope="scope" slot="switch">
<el-switch
size="small"
v-model="scope.row.switch"
@change="handleswitch(scope)"
>
</el-switch>
</template>
<template slot-scope="scope" slot="menuBtn">
<el-dropdown-item>
<span class="el-icon-edit">文字按钮</span>
</el-dropdown-item>
<el-dropdown-item>
<span class="el-icon-edit">文字按钮</span>
</el-dropdown-item>
<el-dropdown-item>
<span class="el-icon-edit">文字按钮</span>
</el-dropdown-item>
</template>
</avue-crud>
</basic-container>
3 years ago
</template>
<script>
// import {getDetail, getList} from "@/api/core/customer/customerApi";
import { mapGetters } from "vuex";
export default {
data() {
return {
form: {},
query: {},
// loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
height: "auto", //高度自动
calcHeight: 30,
index: true, //表格序号
searchShow: true, //搜索是否展示
searchMenuSpan: 6, //搜索按钮的占位大小
searchType: "menu",
tip: true, //提示
border: true, //边框
headerAlign: "center", //表头居中
align: "center", //内容居中
addBtn: true, //添加按钮
editBtn: true, //编辑按钮
viewBtn: true, //查看按钮
delBtn: true, //删除按钮
searchBtn: true, //搜索按钮
saveBtn: true, //弹窗保存按钮
updateBtn: true, //更新按钮
cancelBtn: true, //弹窗取消按钮
dateBtn: false, //日期组件
printBtn: true, //打印按钮
excelBtn: true, //导出按钮
searchShowBtn: true, //搜索显隐
searchIcon: true, //搜索折叠
refreshBtn: true, //刷新按钮
filterBtn: false, //筛选按钮
showColumnBtn: false, //显隐字段按钮
dialogType: "dialog", //弹窗类型 dialog弹窗 drawer抽屉
dialogFullscreen: false, //弹窗是否全屏
dialogEscape: true, //弹窗esc关闭
dialogModal: true, //弹窗模态框
dialogClickModal: false, //弹窗点击模态框 是否关闭
dialogCloseBtn: true, //弹窗关闭按钮
menu: true, //操作栏是否显示
menuAlign: "center", //操作栏对齐方式
menuType: "menu", //按钮样式 icon 图标
column: [
{
label: "姓名", //表头
searchValue: "默认值", //搜索表单的默认值
searchPlaceholder: "搜索框辅助文字", //搜索框辅助文字
sortable: true, //排序
prop: "name", //列字段
type: "input",
size: "mini",
search: true,
span: 12,
formatter: (val, value, label) => {
if (value == "") {
return "-";
} else {
return `${value}`;
}
},
control: (val, form) => {
//通过control meetType(当前字段)控制别的字段是否要再弹窗中显示
if (val == "1" || val == "2") {
return {
auditingType: {
//这里就是其他的字段
display: false,
},
};
} else {
return {
takePart: {
//这里就是其他的字段
display: false,
},
};
}
},
},
{
label: "年龄",
prop: "age",
search: true,
span: 12,
},
{
label: "地区",
type: "select",
prop: "province",
multiple: true,
filterable: true,
props: {
label: "label",
value: "value",
},
dicData: [
{
label: "字典1",
value: 0,
},
{
label: "字典2",
value: 1,
},
],
search: true,
span: 12,
},
{
label: "照片",
prop: "photo",
alone: true,
type: "img",
search: true,
span: 12,
},
{
label: "switch",
prop: "switch",
type: "switch",
slot: true,
search: true,
span: 12,
},
{
label: "formslot",
prop: "age",
type: "input",
search: true,
formslot: true,
span: 12,
},
{
label: "年龄",
prop: "age",
type: "input",
search: true,
span: 12,
},
{
label: "年龄",
prop: "age",
type: "input",
search: true,
span: 12,
},
{
label: "年龄",
prop: "age",
type: "input",
search: true,
span: 12,
},
{
label: "年龄",
prop: "age",
type: "input",
search: true,
span: 12,
},
{
label: "年龄",
prop: "age",
type: "input",
search: true,
span: 12,
},
{
label: "年龄",
prop: "age",
type: "input",
search: true,
span: 12,
},
{
label: "年龄",
prop: "age",
type: "input",
search: true,
span: 12,
},
{
label: "年龄",
prop: "age",
type: "input",
search: true,
span: 12,
},
{
label: "年龄",
prop: "age",
type: "input",
search: true,
span: 12,
},
{
label: "年龄",
prop: "age",
type: "input",
search: true,
span: 12,
},
{
label: "年龄",
prop: "age",
type: "input",
search: true,
span: 12,
},
// {
// label: "时间",
// prop: "time",
// type: "timerange",
// search: true,
// span: 24,
// },
],
},
data: [],
};
},
computed: {
...mapGetters(["permission"]),
// permissionList() {
// return {
// viewBtn: this.vaildData(this.permission.sourceApi_view, false),
// editBtn: this.vaildData(this.permission.sourceApi_edit, false),
// delBtn: this.vaildData(this.permission.sourceApi_delete, false),
// };
// },
},
methods: {
handleswitch(e) {
console.log(e, 9999);
},
beforeOpen(done, type) {
if (["edit", "view"].includes(type)) {
console.log(done, type, 9988);
getDetail(this.form.id).then((res) => {
this.form = res.data.data;
});
}
done();
},
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!",
});
done();
},
(error) => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!",
});
done();
},
(error) => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!",
});
});
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
3 years ago
},
onLoad(page, params = {}) {
this.data = [
{
name: "喜羊羊",
age: 12,
},
{
name: "懒羊羊",
age: 16,
},
];
// this.loading = true;
// getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
// const data = res.data.data;
// this.page.total = data.total;
// this.data = data.records;
// this.loading = false;
// });
3 years ago
},
},
};
3 years ago
</script>
<style></style>