<template>
|
<filter-dialog
|
ref="table"
|
:show.sync="showDialog"
|
:title="title"
|
:tableData="tableData"
|
:total="total"
|
:form="listQuery"
|
:formLabel="formLabel"
|
@page-info-change="handPageInfoChange"
|
@selected="handSelected"
|
@close="handleDialogClose"
|
:loading="loading"
|
:isSelectable="true"
|
:multipleSelected="multipleSelected"
|
:appendToBody="appendToBody"
|
:dataKey="'memberId'"
|
>
|
<template slot="condition">
|
<el-button type="primary" size="mini" @click="handleFilter"
|
>查询</el-button>
|
<el-button size="mini" @click="resetQuery">重置</el-button>
|
</template>
|
<template slot="columns">
|
<el-table-column label="会员账号" prop="memberName"></el-table-column>
|
<el-table-column label="会员昵称" prop="memberNickName">
|
<template slot-scope="scope">
|
{{scope.row.memberNickName ? scope.row.memberNickName : '-'}}
|
</template>
|
</el-table-column>
|
<el-table-column label="会员等级" prop="memberLevelName">
|
<template slot-scope="scope">
|
{{scope.row.memberLevelName ? scope.row.memberLevelName : '-'}}
|
</template>
|
</el-table-column>
|
<el-table-column label="手机号码" prop="memberPhone"></el-table-column>
|
<el-table-column label="会员来源" prop="state">
|
<template slot-scope="scope">
|
{{scope.row.memberSource?getArrayLable(memberSource,scope.row.memberSource):'APP'}}
|
</template>
|
</el-table-column>
|
<slot></slot>
|
</template>
|
</filter-dialog>
|
</template>
|
<script>
|
import filterDialog from '@/components/filterDialog/filterDialog.vue'
|
import memberInfoApi from '@/api/member/memberInfo'
|
import memberLevelApi from '@/api/member/memberLevel'
|
import { getArrayLable } from '@/utils/getArrayLable'
|
var memberSource = [
|
{
|
id: 'WLY',
|
name: 'APP'
|
},
|
{
|
id: 'YDJS',
|
name: '缘定晶生'
|
}
|
]
|
export default {
|
components: { filterDialog },
|
props: {
|
show: {
|
type: Boolean,
|
default: false
|
},
|
title: {
|
type: String,
|
default: null
|
},
|
multipleSelected: {
|
type: Boolean,
|
default: true
|
},
|
isSelectable: {
|
type: Boolean,
|
default: false
|
},
|
/**
|
* 是否嵌套弹出框
|
*/
|
appendToBody: {
|
type: Boolean,
|
default: false
|
}
|
},
|
data() {
|
return {
|
showDialog: false,
|
listQuery: {
|
memberName: null,
|
memberSource: null,
|
memberLevelName: null
|
},
|
tableData: [],
|
total: 0,
|
loading: false,
|
formLabel: [
|
{
|
model: 'memberName',
|
label: '会员账号',
|
type: 'input',
|
sm: 12
|
},
|
{
|
model: 'memberSource',
|
label: '会员来源',
|
type: 'select',
|
opts: memberSource,
|
sm: 12
|
},
|
{
|
model: 'memberLevelName',
|
label: '会员等级',
|
type: 'select',
|
opts: [],
|
sm: 12
|
}
|
],
|
selectedRows: null,
|
memberSource
|
}
|
},
|
watch: {
|
/**
|
* 监控外部显示变量变化
|
* 传递到dialog组件
|
*/
|
show: function(newShow, oldShow) {
|
this.showDialog = this.show
|
if (this.showDialog) {
|
this.queryLevelList() // 查询等级
|
}
|
},
|
/**
|
* 监控内部显示属性变化
|
* 传递到外部调用变量
|
*/
|
showDialog: function(newDialogShow, oldDialogShow) {
|
this.$emit('update:show', newDialogShow)
|
if (!newDialogShow) {
|
this.$nextTick(() => {
|
this.initForm() // 初始化表单
|
})
|
}
|
}
|
},
|
methods: {
|
/**
|
* 获取数组的label
|
*/
|
getArrayLable,
|
/**
|
* 查询等级
|
*/
|
queryLevelList() {
|
const query = {
|
pageNum: 1,
|
pageSize: 100
|
}
|
memberLevelApi.getList(query).then(res => {
|
if (res.data) {
|
this.formLabel[2].opts = res.data.list.map(item => {
|
return {
|
id: item.memberLevelName,
|
name: item.memberLevelName
|
}
|
})
|
}
|
})
|
},
|
/**
|
* '获取选中的数据
|
*/
|
handSelected(rows) {
|
this.selectedRows = rows
|
},
|
/**
|
* 弹出框关闭事件处理
|
*/
|
handleDialogClose() {
|
if (this.selectedRows) {
|
this.$emit('hand-selected-row-data', this.selectedRows)
|
}
|
},
|
/**
|
* 搜索条件变更处理
|
*/
|
handleFilter() {
|
this.$refs.table.changeCondition()
|
},
|
/**
|
* 重置
|
*/
|
resetQuery() {
|
this.$refs.table.reloadCurrent()
|
},
|
/**
|
* 初始化表单
|
*/
|
initForm() {
|
this.listQuery.memberName = null
|
this.listQuery.memberSource = null
|
this.listQuery.memberLevelName = null
|
},
|
/**
|
* 分页信息改变时,列表查询
|
*/
|
handPageInfoChange(pageInfo) {
|
this.queryList(pageInfo)
|
},
|
/**
|
* 查询列表
|
*/
|
queryList(pageInfo) {
|
this.loading = true
|
for (const key in this.listQuery) {
|
if (!this.listQuery[key]) {
|
this.listQuery[key] = null
|
}
|
}
|
this.listQuery.state = '1'
|
memberInfoApi
|
.getList({ ...this.listQuery, ...pageInfo }, false)
|
.then((res) => {
|
if (res.data) {
|
this.tableData = res.data.list
|
this.total = res.data.total
|
this.loading = false
|
} else {
|
this.loading = false
|
}
|
})
|
.catch(() => {
|
this.loading = false
|
})
|
}
|
}
|
}
|
</script>
|