<template>
<el-container>
	<el-header>
		<div class="left-panel">
			<el-select v-model="search.type" placeholder="请选择" style="width: 180px; margin-right: 10px;" clearable>
				<el-option :label="item.label" :value="item.value" v-for="(item, index) in typeList"></el-option>
			</el-select>
			<el-input v-model="search.store_title" placeholder="请输入店铺名称" style="width: 180px; margin-right: 10px;" clearable />
			<el-input v-model="search.username" placeholder="请输入用户名" style="width: 180px; margin-right: 10px;" clearable />
			<el-button-group style="margin-left: 10px;">
				<el-button type="primary" icon="el-icon-search" @click="upsearch">搜索</el-button>
			</el-button-group>
		</div>
		<div class="right-panel">
			<el-button-group>
				<el-button type="danger" icon="el-icon-plus" @click="add">添加</el-button>
			</el-button-group>
		</div>
	</el-header>
	<el-main class="nopadding">
		<scTable tableName="member" ref="table" :apiObj="list.apiObj" :column="list.column" row-key="id" :params="search" @selection-change="selectionChange" border stripe size="small">
			<el-table-column type="selection" width="50"></el-table-column>
			<template #member="scope">
				<span>{{ scope.row.member?.nickname }}</span>
			</template>
			<template #mobile="scope">
				{{ scope.row.member?.mobile }}
			</template>
		</scTable>
	</el-main>
</el-container>
<save v-if="dialog.save" ref="saveBox" @success="upsearch" @closed="dialog.save=false" />
</template>

<script>
import save from './save.vue'

export default{
	name: 'memberScore',
	components:{
		save
	},
	data(){
		return {
			dialog: {search: false, import: false, save: false},

			list: {
				apiObj: this.$API.member.score.list,
				column: [
					{prop: 'id', label: 'ID', width: 80},
					{prop: 'member', label: '用户'},
					{prop: 'mobile', label: '手机号码', width: 120},
					{prop: 'amount', label: '额度', width: 120},
					{prop: 'af_amount', label: '余额', width: 120},
					{prop: 'remark', label: '备注', width: 120},
					{prop: 'created_at', label: '添加时间', width: 140},
					{prop: 'updated_at', label: '更新时间', width: 140},
				],
			},
			selection: [],
			typeList: [{label: '分享', value: 'share'}, {label: '排队', value: 'queue'},{label: '合伙人', value: 'partner'},{label: '货款', value: 'sale'}],
			search: {is_admin: 1},
		}
	},
	methods: {
		upsearch(){
			this.$refs.table.reload(this.search);
		},
		moreUpsearch(search){
			this.search = search;
			this.upsearch();
		},
		moreSearch(){
			this.dialog.search = true
			this.$nextTick(() => {
				this.$refs.searchBox.open().setData(this.search)
			})
		},
		//表格选择后回调事件
		selectionChange(selection){
			this.selection = selection;
		},
		add(){
			this.dialog.save = true
			this.$nextTick(() => {
				this.$refs.saveBox.open().setData({})
			})
		}
	}
}
</script>
