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.
house/fount/views/modules/yonghu/list.vue

583 lines
29 KiB

<template>
<div class="main-content">
<!-- 列表页 -->
<div v-if="showFlag">
<!-- -->
<el-form :inline="true" :model="searchForm" class="form-content">
<!-- 搜索框所在行 -->
<el-row :gutter="20" class="slt" :style="{justifyContent:contents.searchBoxPosition=='1'?'flex-start':contents.searchBoxPosition=='2'?'center':'flex-end'}">
<!-- 用户名输入框 -->
<el-form-item :label="contents.inputTitle == 1 ? '用户名' : ''">
<!-- 前置图标 -->
<el-input v-if="contents.inputIcon == 1 && contents.inputIconPosition == 1" prefix-icon="el-icon-search" v-model="searchForm.yonghuming" placeholder="用户名" clearable></el-input>
<!-- 后置图标 -->
<el-input v-if="contents.inputIcon == 1 && contents.inputIconPosition == 2" suffix-icon="el-icon-search" v-model="searchForm.yonghuming" placeholder="用户名" clearable></el-input>
<!-- 无图标 -->
<el-input v-if="contents.inputIcon == 0" v-model="searchForm.yonghuming" placeholder="用户名" clearable></el-input>
</el-form-item>
<!-- 搜索和按钮 -->
<el-form-item>
<!-- 搜索框前置图标 -->
<el-button v-if="contents.searchBtnIcon == 1 && contents.searchBtnIconPosition == 1" icon="el-icon-search" type="success" @click="search()">{{ contents.searchBtnFont == 1?'查询':'' }}</el-button>
<!-- 搜索框后置图标 -->
<el-button v-if="contents.searchBtnIcon == 1 && contents.searchBtnIconPosition == 2" type="success" @click="search()">{{ contents.searchBtnFont == 1?'查询':'' }}<i class="el-icon-search el-icon--right"/></el-button>
<!-- 无图标 -->
<el-button v-if="contents.searchBtnIcon == 0" type="success" @click="search()">{{ contents.searchBtnFont == 1?'查询':'' }}</el-button>
</el-form-item>
</el-row>
<!-- 操作按钮行 -->
<el-row class="ad" :style="{justifyContent:contents.btnAdAllBoxPosition=='1'?'flex-start':contents.btnAdAllBoxPosition=='2'?'center':'flex-end'}">
<el-form-item>
<!-- 新增按钮 -->
<el-button
v-if="isAuth('yonghu','新增') && contents.btnAdAllIcon == 1 && contents.btnAdAllIconPosition == 1"
type="success"
icon="el-icon-plus"
@click="addOrUpdateHandler()"
>{{ contents.btnAdAllFont == 1?'新增':'' }}</el-button>
<!-- 删除按钮 -->
<el-button
v-if="isAuth('yonghu','删除') && contents.btnAdAllIcon == 1 && contents.btnAdAllIconPosition == 1 && contents.tableSelection"
:disabled="dataListSelections.length <= 0"
type="danger"
icon="el-icon-delete"
@click="deleteHandler()"
>{{ contents.btnAdAllFont == 1?'删除':'' }}</el-button>
</el-form-item>
</el-row>
</el-form>
<!-- 表格区域 -->
<div class="table-content">
<el-table class="tables" :size="contents.tableSize" :show-header="contents.tableShowHeader"
:header-row-style="headerRowStyle" :header-cell-style="headerCellStyle"
:border="contents.tableBorder"
:fit="contents.tableFit"
:stripe="contents.tableStripe"
:row-style="rowStyle"
:cell-style="cellStyle"
:style="{width: '100%',fontSize:contents.tableContentFontSize,color:contents.tableContentFontColor}"
v-if="isAuth('yonghu','查看')"
:data="dataList"
v-loading="dataListLoading"
@selection-change="selectionChangeHandler">
<!-- 多选框 -->
<el-table-column v-if="contents.tableSelection"
type="selection"
header-align="center"
align="center"
width="50">
</el-table-column>
<!-- 索引列 -->
<el-table-column label="索引" v-if="contents.tableIndex" type="index" width="50" />
<!-- 用户名列 -->
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="yonghuming"
header-align="center"
label="用户名">
<template slot-scope="scope">
{{scope.row.yonghuming}}
</template>
</el-table-column>
<!-- 密码列 -->
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="mima"
header-align="center"
label="密码">
<template slot-scope="scope">
{{scope.row.mima}}
</template>
</el-table-column>
<!-- 姓名列 -->
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="xingming"
header-align="center"
label="姓名">
<template slot-scope="scope">
{{scope.row.xingming}}
</template>
</el-table-column>
<!-- 头像列 -->
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign" prop="touxiang"
header-align="center"
width="200"
label="头像">
<template slot-scope="scope">
<div v-if="scope.row.touxiang">
<img :src="scope.row.touxiang.split(',')[0]" width="100" height="100">
</div>
<div v-else>无图片</div>
</template>
</el-table-column>
<!-- 性别列 -->
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="xingbie"
header-align="center"
label="性别">
<template slot-scope="scope">
{{scope.row.xingbie}}
</template>
</el-table-column>
<!-- 职业列 -->
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="zhiye"
header-align="center"
label="职业">
<template slot-scope="scope">
{{scope.row.zhiye}}
</template>
</el-table-column>
<!-- 联系电话列 -->
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="lianxidianhua"
header-align="center"
label="联系电话">
<template slot-scope="scope">
{{scope.row.lianxidianhua}}
</template>
</el-table-column>
<!-- 身份证列 -->
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="shenfenzheng"
header-align="center"
label="身份证">
<template slot-scope="scope">
{{scope.row.shenfenzheng}}
</template>
</el-table-column>
<!-- 操作列 -->
<el-table-column width="300" :align="contents.tableAlign"
header-align="center"
label="操作">
<template slot-scope="scope">
<!-- 详情按钮 -->
<el-button v-if="isAuth('yonghu','查看') && contents.tableBtnIcon == 1 && contents.tableBtnIconPosition == 1" type="success" icon="el-icon-tickets" size="mini" @click="addOrUpdateHandler(scope.row.id,'info')">{{ contents.tableBtnFont == 1?'详情':'' }}</el-button>
<!-- 修改按钮 -->
<el-button v-if="isAuth('yonghu','修改') && contents.tableBtnIcon == 1 && contents.tableBtnIconPosition == 1" type="primary" icon="el-icon-edit" size="mini" @click="addOrUpdateHandler(scope.row.id)">{{ contents.tableBtnFont == 1?'修改':'' }}</el-button>
<!-- 删除按钮 -->
<el-button v-if="isAuth('yonghu','删除') && contents.tableBtnIcon == 1 && contents.tableBtnIconPosition == 1" type="danger" icon="el-icon-delete" size="mini" @click="deleteHandler(scope.row.id)">{{ contents.tableBtnFont == 1?'删除':'' }}</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<el-pagination
clsss="pages"
:layout="layouts"
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="Number(contents.pageEachNum)"
:total="totalPage"
:small="contents.pageStyle"
class="pagination-content"
:background="contents.pageBtnBG"
:style="{textAlign:contents.pagePosition==1?'left':contents.pagePosition==2?'center':'right'}"
></el-pagination>
</div>
</div>
<!-- 添加/修改页面 -->
<add-or-update v-if="addOrUpdateFlag" :parent="this" ref="addOrUpdate"></add-or-update>
</div>
</template>
<script>
import AddOrUpdate from "./add-or-update";
export default {
data() {
return {
// 搜索表单数据
searchForm: {
key: ""
},
// 用户列表数据
dataList: [],
// 当前页码
pageIndex: 1,
// 每页条数
pageSize: 10,
// 总页数
totalPage: 0,
// 数据加载状态
dataListLoading: false,
// 多选数据
dataListSelections: [],
// 是否显示列表
showFlag: true,
// 是否显示筛选
sfshVisiable: false,
// 筛选表单
shForm: {},
// 是否显示图表
chartVisiable: false,
// 是否显示添加/修改页面
addOrUpdateFlag: false,
// 内容样式配置
contents: {"searchBtnFontColor":"#333","pagePosition":"1","inputFontSize":"14px","inputBorderRadius":"22px","tableBtnDelFontColor":"#333","tableBtnIconPosition":"1","searchBtnHeight":"40px","inputIconColor":"rgba(66, 130, 129, 1)","searchBtnBorderRadius":"22px","tableStripe":false,"btnAdAllWarnFontColor":"#333","tableBtnDelBgColor":"rgba(244, 150, 150, 1)","searchBtnIcon":"1","tableSize":"medium","searchBtnBorderStyle":"solid","tableSelection":true,"searchBtnBorderWidth":"1px","tableContentFontSize":"14px","searchBtnBgColor":"rgba(153, 239, 237, 1)","inputTitleSize":"14px","btnAdAllBorderColor":"#DCDFE6","pageJumper":true,"btnAdAllIconPosition":"1","searchBoxPosition":"1","tableBtnDetailFontColor":"#333","tableBtnHeight":"40px","pagePager":true,"searchBtnBorderColor":"#DCDFE6","tableHeaderFontColor":"rgba(33, 34, 35, 1)","inputTitle":"1","tableBtnBorderRadius":"22px","btnAdAllFont":"1","btnAdAllDelFontColor":"rgba(21, 20, 20, 1)","tableBtnIcon":"1","btnAdAllHeight":"40px","btnAdAllWarnBgColor":"rgba(238, 236, 126, 1)","btnAdAllBorderWidth":"1px","tableStripeFontColor":"#606266","tableBtnBorderStyle":"solid","inputHeight":"40px","btnAdAllBorderRadius":"22px","btnAdAllDelBgColor":"rgba(234, 93, 93, 0.69)","pagePrevNext":true,"btnAdAllAddBgColor":"rgba(153, 239, 237, 1)","searchBtnFont":"1","tableIndex":true,"btnAdAllIcon":"1","tableSortable":true,"pageEachNum":10,"tableFit":true,"pageBtnBG":true,"searchBtnFontSize":"14px","tableBtnEditBgColor":"rgba(240, 242, 124, 1)","inputBorderWidth":"1px","inputFontPosition":"1","inputFontColor":"#333","tableHeaderBgColor":"rgba(152, 129, 129, 1)","inputTitleColor":"#333","btnAdAllBoxPosition":"1","tableBtnDetailBgColor":"rgba(171, 239, 239, 1)","inputIcon":"0","searchBtnIconPosition":"1","btnAdAllFontSize":"14px","inputBorderStyle":"solid","inputBgColor":"rgba(197, 174, 174, 0.32)","pageStyle":false,"pageTotal":true,"btnAdAllAddFontColor":"#333","tableBtnFont":"1","tableContentFontColor":"rgba(22, 22, 23, 1)","inputBorderColor":"rgba(152, 129, 129, 1)","tableShowHeader":true,"tableBtnFontSize":"14px","tableBtnBorderColor":"rgba(196, 210, 244, 1)","inputIconPosition":"1","tableBorder":true,"btnAdAllBorderStyle":"solid","tableBtnBorderWidth":"1px","tableStripeBgColor":"rgba(213, 197, 197, 1)","tableBtnEditFontColor":"#333","tableAlign":"center"},
// 分页布局
layouts: '',
};
},
created() {
// 初始化方法
this.init();
// 获取用户列表数据
this.getDataList();
// 样式修改方法
this.contentStyleChange()
},
mounted() {
// 页面加载完成后执行的方法
},
filters: {
// 移除HTML标签和undefined
htmlfilter: function (val) {
return val.replace(/<[^>]*>/g).replace(/undefined/g,'');
}
},
components: {
// 引入添加/修改组件
AddOrUpdate,
},
methods: {
// 样式修改主方法
contentStyleChange() {
this.contentSearchStyleChange()
this.contentBtnAdAllStyleChange()
this.contentSearchBtnStyleChange()
this.contentTableBtnStyleChange()
this.contentPageStyleChange()
},
// 搜索框样式修改
contentSearchStyleChange() {
this.$nextTick(()=>{ // DOM渲染完成后的回调
document.querySelectorAll('.form-content .slt .el-input__inner').forEach(el=>{
let textAlign = 'left'
if(this.contents.inputFontPosition == 2) textAlign = 'center' // 设置文本水平居中
if(this.contents.inputFontPosition == 3) textAlign = 'right' // 设置文本水平右对齐
el.style.textAlign = textAlign
el.style.height = this.contents.inputHeight // 设置输入框高度
el.style.lineHeight = this.contents.inputHeight // 设置输入框行高
el.style.color = this.contents.inputFontColor // 设置输入框字体颜色
el.style.fontSize = this.contents.inputFontSize // 设置输入框字体大小
el.style.borderWidth = this.contents.inputBorderWidth // 设置输入框边框宽度
el.style.borderStyle = this.contents.inputBorderStyle // 设置输入框边框样式
el.style.borderColor = this.contents.inputBorderColor // 设置输入框边框颜色
el.style.borderRadius = this.contents.inputBorderRadius // 设置输入框圆角
el.style.backgroundColor = this.contents.inputBgColor // 设置输入框背景颜色
})
if(this.contents.inputTitle) { // 如果显示输入框标题
document.querySelectorAll('.form-content .slt .el-form-item__label').forEach(el=>{
el.style.color = this.contents.inputTitleColor // 设置标题颜色
el.style.fontSize = this.contents.inputTitleSize // 设置标题字体大小
el.style.lineHeight = this.contents.inputHeight // 设置标题行高
})
}
setTimeout(()=>{ // 延迟设置图标样式
document.querySelectorAll('.form-content .slt .el-input__prefix').forEach(el=>{
el.style.color = this.contents.inputIconColor // 设置前置图标颜色
el.style.lineHeight = this.contents.inputHeight // 设置前置图标行高
})
document.querySelectorAll('.form-content .slt .el-input__suffix').forEach(el=>{
el.style.color = this.contents.inputIconColor // 设置后置图标颜色
el.style.lineHeight = this.contents.inputHeight // 设置后置图标行高
})
document.querySelectorAll('.form-content .slt .el-input__icon').forEach(el=>{
el.style.lineHeight = this.contents.inputHeight // 设置图标行高
})
},10)
})
},
// 搜索网页图标样式修改
contentSearchBtnStyleChange() {
this.$nextTick(()=>{ // DOM渲染完成后的回调
document.querySelectorAll('.form-content .slt .el-button--success').forEach(el=>{
el.style.height = this.contents.searchBtnHeight // 设置按钮高度
el.style.color = this.contents.searchBtnFontColor // 设置按钮文字颜色
el.style.fontSize = this.contents.searchBtnFontSize // 设置按钮文字大小
el.style.borderWidth = this.contents.searchBtnBorderWidth // 设置按钮边框宽度
el.style.borderStyle = this.contents.searchBtnBorderStyle // 设置按钮边框样式
el.style.borderColor = this.contents.searchBtnBorderColor // 设置按钮边框颜色
el.style.borderRadius = this.contents.searchBtnBorderRadius // 设置按钮圆角
el.style.backgroundColor = this.contents.searchBtnBgColor // 设置按钮背景颜色
})
})
},
// 添加、批量删除按钮样式修改
contentBtnAdAllStyleChange() {
this.$nextTick(()=>{ // DOM渲染完成后的回调
document.querySelectorAll('.form-content .ad .el-button--success').forEach(el=>{
el.style.height = this.contents.btnAdAllHeight // 设置按钮高度
el.style.color = this.contents.btnAdAllAddFontColor // 设置按钮文字颜色
el.style.fontSize = this.contents.btnAdAllFontSize // 设置按钮文字大小
el.style.borderWidth = this.contents.btnAdAllBorderWidth // 设置按钮边框宽度
el.style.borderStyle = this.contents.btnAdAllBorderStyle // 设置按钮边框样式
el.style.borderColor = this.contents.btnAdAllBorderColor // 设置按钮边框颜色
el.style.borderRadius = this.contents.btnAdAllBorderRadius // 设置按钮圆角
el.style.backgroundColor = this.contents.btnAdAllAddBgColor // 设置按钮背景颜色
})
document.querySelectorAll('.form-content .ad .el-button--danger').forEach(el=>{
el.style.height = this.contents.btnAdAllHeight // 设置按钮高度
el.style.color = this.contents.btnAdAllDelFontColor // 设置按钮文字颜色
el.style.fontSize = this.contents.btnAdAllFontSize // 设置按钮文字大小
el.style.borderWidth = this.contents.btnAdAllBorderWidth // 设置按钮边框宽度
el.style.borderStyle = this.contents.btnAdAllBorderStyle // 设置按钮边框样式
el.style.borderColor = this.contents.btnAdAllBorderColor // 设置按钮边框颜色
el.style.borderRadius = this.contents.btnAdAllBorderRadius // 设置按钮圆角
el.style.backgroundColor = this.contents.btnAdAllDelBgColor // 设置按钮背景颜色
})
document.querySelectorAll('.form-content .ad .el-button--warning').forEach(el=>{
el.style.height = this.contents.btnAdAllHeight // 设置按钮高度
el.style.color = this.contents.btnAdAllWarnFontColor // 设置按钮文字颜色
el.style.fontSize = this.contents.btnAdAllFontSize // 设置按钮文字大小
el.style.borderWidth = this.contents.btnAdAllBorderWidth // 设置按钮边框宽度
el.style.borderStyle = this.contents.btnAdAllBorderStyle // 设置按钮边框样式
el.style.borderColor = this.contents.btnAdAllBorderColor // 设置按钮边框颜色
el.style.borderRadius = this.contents.btnAdAllBorderRadius // 设置按钮圆角
el.style.backgroundColor = this.contents.btnAdAllWarnBgColor // 设置按钮背景颜色
})
})
},
// 表格样式修改
rowStyle({ row, rowIndex}) {
if (rowIndex % 2 == 1) { // 奇数行
if(this.contents.tableStripe) { // 如果开启了表格斑马纹
return {color:this.contents.tableStripeFontColor} // 设置奇数行文字颜色
}
} else {
return ''
}
},
cellStyle({ row, rowIndex}) {
if (rowIndex % 2 == 1) { // 奇数行
if(this.contents.tableStripe) { // 如果开启了表格斑马纹
return {backgroundColor:this.contents.tableStripeBgColor} // 设置奇数行背景颜色
}
} else {
return ''
}
},
headerRowStyle({ row, rowIndex}) {
return {color: this.contents.tableHeaderFontColor} // 设置表头文字颜色
},
headerCellStyle({ row, rowIndex}) {
return {backgroundColor: this.contents.tableHeaderBgColor} // 设置表头背景颜色
},
// 表格操作按钮样式修改
contentTableBtnStyleChange(){
// 此处暂时注释,可根据需要启用
// this.$nextTick(()=>{ // DOM渲染完成后的回调
// setTimeout(()=>{ // 延迟设置按钮样式
// document.querySelectorAll('.table-content .tables .el-table__body .el-button--success').forEach(el=>{
// el.style.height = this.contents.tableBtnHeight // 设置按钮高度
// el.style.color = this.contents.tableBtnDetailFontColor // 设置按钮文字颜色
// el.style.fontSize = this.contents.tableBtnFontSize // 设置按钮文字大小
// el.style.borderWidth = this.contents.tableBtnBorderWidth // 设置按钮边框宽度
// el.style.borderStyle = this.contents.tableBtnBorderStyle // 设置按钮边框样式
// el.style.borderColor = this.contents.tableBtnBorderColor // 设置按钮边框颜色
// el.style.borderRadius = this.contents.tableBtnBorderRadius // 设置按钮圆角
// el.style.backgroundColor = this.contents.tableBtnDetailBgColor // 设置按钮背景颜色
// })
// document.querySelectorAll('.table-content .tables .el-table__body .el-button--primary').forEach(el=>{
// el.style.height = this.contents.tableBtnHeight // 设置按钮高度
// el.style.color = this.contents.tableBtnEditFontColor // 设置按钮文字颜色
// el.style.fontSize = this.contents.tableBtnFontSize // 设置按钮文字大小
// el.style.borderWidth = this.contents.tableBtnBorderWidth // 设置按钮边框宽度
// el.style.borderStyle = this.contents.tableBtnBorderStyle // 设置按钮边框样式
// el.style.borderColor = this.contents.tableBtnBorderColor // 设置按钮边框颜色
// el.style.borderRadius = this.contents.tableBtnBorderRadius // 设置按钮圆角
// el.style.backgroundColor = this.contents.tableBtnEditBgColor // 设置按钮背景颜色
// })
// document.querySelectorAll('.table-content .tables .el-table__body .el-button--danger').forEach(el=>{
// el.style.height = this.contents.tableBtnHeight // 设置按钮高度
// el.style.color = this.contents.tableBtnDelFontColor // 设置按钮文字颜色
// el.style.fontSize = this.contents.tableBtnFontSize // 设置按钮文字大小
// el.style.borderWidth = this.contents.tableBtnBorderWidth // 设置按钮边框宽度
// el.style.borderStyle = this.contents.tableBtnBorderStyle // 设置按钮边框样式
// el.style.borderColor = this.contents.tableBtnBorderColor // 设置按钮边框颜色
// el.style.borderRadius = this.contents.tableBtnBorderRadius // 设置按钮圆角
// el.style.backgroundColor = this.contents.tableBtnDelBgColor // 设置按钮背景颜色
// })
// }, 50) // 延迟50毫秒
// })
},
// 分页样式修改
contentPageStyleChange(){
let arr = []
if(this.contents.pageTotal) arr.push('total') // 是否显示总条数
if(this.contents.pageSizes) arr.push('sizes') // 是否显示每页条数选择器
if(this.contents.pagePrevNext){ // 是否显示前后翻页按钮
arr.push('prev') // 添加上一页按钮
if(this.contents.pagePager) arr.push('pager') // 是否显示页码
arr.push('next') // 添加下一页按钮
}
if(this.contents.pageJumper) arr.push('jumper') // 是否显示跳转输入框
this.layouts = arr.join() // 拼接分页布局
this.contents.pageEachNum = 10 // 设置每页条数默认值
},
// 初始化方法
init () {
// 此处可添加初始化逻辑
},
// 搜索框点击事件
search() {
this.pageIndex = 1; // 重置到第一页
this.getDataList(); // 获取用户列表数据
},
// 获取用户列表数据
getDataList() {
this.dataListLoading = true; // 开启数据加载状态
let params = {
page: this.pageIndex, // 当前页码
limit: this.pageSize, // 每页条数
sort: 'id', // 排序字段
}
// 如果用户名搜索框有内容,添加搜索条件
if(this.searchForm.yonghuming!='' && this.searchForm.yonghuming!=undefined){
params['yonghuming'] = '%' + this.searchForm.yonghuming + '%'
}
this.$http({
url: "yonghu/page", // 请求地址
method: "get", // 请求方法
params: params // 请求参数
}).then(({ data }) => {
if (data && data.code === 0) { // 如果请求成功
this.dataList = data.data.list; // 设置用户列表数据
this.totalPage = data.data.total; // 设置总页数
} else { // 如果请求失败
this.dataList = []; // 清空用户列表
this.totalPage = 0; // 重置总页数
}
this.dataListLoading = false; // 关闭数据加载状态
});
},
// 每页条数变化事件
sizeChangeHandle(val) {
this.pageSize = val; // 设置新的每页条数
this.pageIndex = 1; // 重置到第一页
this.getDataList(); // 获取用户列表数据
},
// 当前页码变化事件
currentChangeHandle(val) {
this.pageIndex = val; // 设置新的当前页码
this.getDataList(); // 获取用户列表数据
},
// 多选变化事件
selectionChangeHandler(val) {
this.dataListSelections = val; // 设置多选数据
},
// 添加/修改用户
addOrUpdateHandler(id,type) {
this.showFlag = false; // 隐藏列表页面
this.addOrUpdateFlag = true; // 显示添加/修改页面
this.crossAddOrUpdateFlag = false; // 未使用
if(type!='info'){ // 如果不是详情模式
type = 'else'; // 设置为其他模式
}
this.$nextTick(() => { // DOM渲染完成后的回调
this.$refs.addOrUpdate.init(id,type); // 调用子组件的初始化方法
});
},
// 下载文件
download(file){
window.open(`${file}`) // 打开文件链接
},
// 删除用户
deleteHandler(id) {
var ids = id ? [Number(id)] : this.dataListSelections.map(item => { // 获取要删除的ID列表
return Number(item.id);
});
this.$confirm(`确定进行[${id ? "删除" : "批量删除"}]操作?`, "提示", { // 显示确认对话框
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$http({
url: "yonghu/delete", // 请求地址
method: "post", // 请求方法
data: ids // 请求数据
}).then(({ data }) => {
if (data && data.code === 0) { // 如果请求成功
this.$message({ // 显示成功消息
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => { // 消息关闭后重新获取数据
this.search();
}
});
} else { // 如果请求失败
this.$message.error(data.msg); // 显示错误消息
}
});
});
},
}
};
</script>
<style lang="scss" scoped>
/* 搜索栏样式 */
.slt {
margin: 0 !important; /* 重置外边距 */
display: flex; /* 使用弹性布局 */
}
/* 操作栏样式 */
.ad {
margin: 0 !important; /* 重置外边距 */
display: flex; /* 使用弹性布局 */
}
/* 分页组件样式 */
.pages {
& /deep/ el-pagination__sizes{ /* 深度选择器,用于覆盖子组件样式 */
& /deep/ el-input__inner { /* 深度选择器,用于覆盖输入框样式 */
height: 22px; /* 设置高度 */
line-height: 22px; /* 设置行高 */
}
}
}
/* 按钮样式重置 */
.el-button+.el-button {
margin:0; /* 重置按钮间距 */
}
/* 表格内按钮样式 */
.tables {
& /deep/ .el-button--success { /* 成功按钮样式 */
height: 40px; /* 设置高度 */
color: #333; /* 设置文字颜色 */
font-size: 14px; /* 设置文字大小 */
border-width: 1px; /* 设置边框宽度 */
border-style: solid; /* 设置边框样式 */
border-color: rgba(196, 210, 244, 1); /* 设置边框颜色 */
border-radius: 22px; /* 设置圆角 */
background-color: rgba(171, 239, 239, 1); /* 设置背景颜色 */
}
& /deep/ .el-button--primary { /* 主要按钮样式 */
height: 40px; /* 设置高度 */
color: #333; /* 设置文字颜色 */
font-size: 14px; /* 设置文字大小 */
border-width: 1px; /* 设置边框宽度 */
border-style: solid; /* 设置边框样式 */
border-color: rgba(196, 210, 244, 1); /* 设置边框颜色 */
border-radius: 22px; /* 设置圆角 */
background-color: rgba(240, 242, 124, 1); /* 设置背景颜色 */
}
& /deep/ .el-button--danger { /* 危险按钮样式 */
height: 40px; /* 设置高度 */
color: #333; /* 设置文字颜色 */
font-size: 14px; /* 设置文字大小 */
border-width: 1px; /* 设置边框宽度 */
border-style: solid; /* 设置边框样式 */
border-color: rgba(196, 210, 244, 1); /* 设置边框颜色 */
border-radius: 22px; /* 设置圆角 */
background-color: rgba(244, 150, 150, 1); /* 设置背景颜色 */
}
& /deep/ .el-button { /* 按钮间距 */
margin: 4px; /* 设置间距 */
}
}
</style>