﻿<template>
	<div class="NCC-common-layout">
		<div class="NCC-common-layout-center">
			<el-row class="NCC-common-search-box" :gutter="16">
				<el-form @submit.native.prevent>
					<el-col :span="6">
						<el-form-item label="主键">
							<el-input v-model="query.id" placeholder="主键" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="月份">
							<el-input v-model="query.yf" placeholder="月份" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="门店">
							<el-input v-model="query.md" placeholder="门店" clearable />	
						</el-form-item>
					</el-col>
					<template v-if="showAll">
					<el-col :span="6">
						<el-form-item label="金三角">
							<el-input v-model="query.jsj" placeholder="金三角" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="岗位">
							<el-input v-model="query.gw" placeholder="岗位" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="健康师">
							<el-input v-model="query.jks" placeholder="健康师" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="成交率">
							<el-input v-model="query.cjl" placeholder="成交率" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="成交业绩">
							<el-input v-model="query.cjyj" placeholder="成交业绩" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="成交提点">
							<el-input v-model="query.cjtd" placeholder="成交提点" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="剩余业绩">
							<el-input v-model="query.syyj" placeholder="剩余业绩" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="出勤天数">
							<el-input v-model="query.cqts" placeholder="出勤天数" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="系统业绩">
							<el-input v-model="query.xtyj" placeholder="系统业绩" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="总业绩">
							<el-input v-model="query.zyj" placeholder="总业绩" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="基础业绩">
							<el-input v-model="query.jcyj" placeholder="基础业绩" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="合作业绩">
							<el-input v-model="query.hzyj" placeholder="合作业绩" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="奖励业绩">
							<el-input v-model="query.jlyj" placeholder="奖励业绩" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="项目数">
							<el-input v-model="query.xms" placeholder="项目数" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="手工">
							<el-input v-model="query.sg" placeholder="手工" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="是否属于战队">
							<el-input v-model="query.sfsyzd" placeholder="是否属于战队" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="是否满足考勤">
							<el-input v-model="query.fsmzkq" placeholder="是否满足考勤" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="战队最终人数">
							<el-input v-model="query.zdzzrs" placeholder="战队最终人数" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="视为单人">
							<el-input v-model="query.kqhbsyzd" placeholder="视为单人" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="战队提成">
							<el-input v-model="query.zdtc" placeholder="战队提成" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="按1人提成">
							<el-input v-model="query.ayrtc" placeholder="按1人提成" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="最终提成点">
							<el-input v-model="query.zztcd" placeholder="最终提成点" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="基础业绩提成">
							<el-input v-model="query.jcyjtc" placeholder="基础业绩提成" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="合作业绩提成">
							<el-input v-model="query.hzyjtc" placeholder="合作业绩提成" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="提成合计">
							<el-input v-model="query.tchj" placeholder="提成合计" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="个人占比">
							<el-input v-model="query.grzb" placeholder="个人占比" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="组员合计">
							<el-input v-model="query.zyhj" placeholder="组员合计" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="顾问提成">
							<el-input v-model="query.gwtc" placeholder="顾问提成" clearable />	
						</el-form-item>
					</el-col>
					</template>
					<el-col :span="6">
						<el-form-item>
							<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
							<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
							<el-button type="text" icon="el-icon-arrow-down" @click="showAll=true" v-if="!showAll">展开</el-button>
							<el-button type="text" icon="el-icon-arrow-up" @click="showAll=false" v-else>收起</el-button>
						</el-form-item>
					</el-col>
				</el-form>
			</el-row>
			<div class="NCC-common-layout-main NCC-flex-main">
				<div class="NCC-common-head">
					<div>
						<el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">新增</el-button>
						<el-button type="text" icon="el-icon-download" @click="exportData()">导出</el-button>
						<el-button type="text" icon="el-icon-delete" @click="handleBatchRemoveDel()">批量删除</el-button>
					</div>
					<div class="NCC-common-head-right">
						<el-tooltip effect="dark" content="刷新" placement="top">
							<el-link icon="icon-ym icon-ym-Refresh NCC-common-head-icon" :underline="false" @click="reset()" />
						</el-tooltip>
						<screenfull isContainer />
					</div>
				</div>
                <NCC-table v-loading="listLoading" :data="list" has-c @selection-change="handleSelectionChange">
					<el-table-column prop="id" label="主键" align="left" />
					<el-table-column prop="yf" label="月份" align="left" />
					<el-table-column prop="md" label="门店" align="left" />
					<el-table-column prop="jsj" label="金三角" align="left" />
					<el-table-column prop="gw" label="岗位" align="left" />
					<el-table-column prop="jks" label="健康师" align="left" />
					<el-table-column prop="cjl" label="成交率" align="left" />
					<el-table-column prop="cjyj" label="成交业绩" align="left" />
					<el-table-column prop="cjtd" label="成交提点" align="left" />
					<el-table-column prop="syyj" label="剩余业绩" align="left" />
					<el-table-column prop="cqts" label="出勤天数" align="left" />
					<el-table-column prop="xtyj" label="系统业绩" align="left" />
					<el-table-column prop="zyj" label="总业绩" align="left" />
					<el-table-column prop="jcyj" label="基础业绩" align="left" />
					<el-table-column prop="hzyj" label="合作业绩" align="left" />
					<el-table-column prop="jlyj" label="奖励业绩" align="left" />
					<el-table-column prop="xms" label="项目数" align="left" />
					<el-table-column prop="sg" label="手工" align="left" />
					<el-table-column prop="sfsyzd" label="是否属于战队" align="left" />
					<el-table-column prop="fsmzkq" label="是否满足考勤" align="left" />
					<el-table-column prop="zdzzrs" label="战队最终人数" align="left" />
					<el-table-column prop="kqhbsyzd" label="视为单人" align="left" />
					<el-table-column prop="zdtc" label="战队提成" align="left" />
					<el-table-column prop="ayrtc" label="按1人提成" align="left" />
					<el-table-column prop="zztcd" label="最终提成点" align="left" />
					<el-table-column prop="jcyjtc" label="基础业绩提成" align="left" />
					<el-table-column prop="hzyjtc" label="合作业绩提成" align="left" />
					<el-table-column prop="tchj" label="提成合计" align="left" />
					<el-table-column prop="grzb" label="个人占比" align="left" />
					<el-table-column prop="zyhj" label="组员合计" align="left" />
					<el-table-column prop="gwtc" label="顾问提成" align="left" />
					<el-table-column label="操作" fixed="right" width="100">
							<template slot-scope="scope">
							<el-button type="text" @click="addOrUpdateHandle(scope.row.id)" >编辑</el-button>
							<el-button type="text" @click="handleDel(scope.row.id)" class="NCC-table-delBtn" >删除</el-button>
						</template>
					</el-table-column>
				</NCC-table>
                <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
            </div>
        </div>
		<NCC-Form v-if="formVisible" ref="NCCForm" @refresh="refresh" />
		<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" />
	</div>
</template>
<script>
    import request from '@/utils/request'
    import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
    import NCCForm from './Form'
    import ExportBox from './ExportBox'
    import { previewDataInterface } from '@/api/systemData/dataInterface'
	export default {
        components: { NCCForm, ExportBox },
        data() {
            return {
                showAll: false,
				query: {
                    id:undefined,
                    yf:undefined,
                    md:undefined,
                    jsj:undefined,
                    gw:undefined,
                    jks:undefined,
                    cjl:undefined,
                    cjyj:undefined,
                    cjtd:undefined,
                    syyj:undefined,
                    cqts:undefined,
                    xtyj:undefined,
                    zyj:undefined,
                    jcyj:undefined,
                    hzyj:undefined,
                    jlyj:undefined,
                    xms:undefined,
                    sg:undefined,
                    sfsyzd:undefined,
                    fsmzkq:undefined,
                    zdzzrs:undefined,
                    kqhbsyzd:undefined,
                    zdtc:undefined,
                    ayrtc:undefined,
                    zztcd:undefined,
                    jcyjtc:undefined,
                    hzyjtc:undefined,
                    tchj:undefined,
                    grzb:undefined,
                    zyhj:undefined,
                    gwtc:undefined,
				},
                list: [],
                listLoading: true,
                multipleSelection: [], total: 0,
                listQuery: {
                    currentPage: 1,
                    pageSize: 20,
					sort: "desc",
                    sidx: "",
                },
                formVisible: false,
                exportBoxVisible: false,
                columnList: [
                    { prop: 'id', label: '主键' },
                    { prop: 'yf', label: '月份' },
                    { prop: 'md', label: '门店' },
                    { prop: 'jsj', label: '金三角' },
                    { prop: 'gw', label: '岗位' },
                    { prop: 'jks', label: '健康师' },
                    { prop: 'cjl', label: '成交率' },
                    { prop: 'cjyj', label: '成交业绩' },
                    { prop: 'cjtd', label: '成交提点' },
                    { prop: 'syyj', label: '剩余业绩' },
                    { prop: 'cqts', label: '出勤天数' },
                    { prop: 'xtyj', label: '系统业绩' },
                    { prop: 'zyj', label: '总业绩' },
                    { prop: 'jcyj', label: '基础业绩' },
                    { prop: 'hzyj', label: '合作业绩' },
                    { prop: 'jlyj', label: '奖励业绩' },
                    { prop: 'xms', label: '项目数' },
                    { prop: 'sg', label: '手工' },
                    { prop: 'sfsyzd', label: '是否属于战队' },
                    { prop: 'fsmzkq', label: '是否满足考勤' },
                    { prop: 'zdzzrs', label: '战队最终人数' },
                    { prop: 'kqhbsyzd', label: '视为单人' },
                    { prop: 'zdtc', label: '战队提成' },
                    { prop: 'ayrtc', label: '按1人提成' },
                    { prop: 'zztcd', label: '最终提成点' },
                    { prop: 'jcyjtc', label: '基础业绩提成' },
                    { prop: 'hzyjtc', label: '合作业绩提成' },
                    { prop: 'tchj', label: '提成合计' },
                    { prop: 'grzb', label: '个人占比' },
                    { prop: 'zyhj', label: '组员合计' },
                    { prop: 'gwtc', label: '顾问提成' },
				],
			}
        },
		computed: {},
		created() {
			this.initData()
		},
		methods: {
			initData() {
                this.listLoading = true;
                let _query = {
                    ...this.listQuery,
                    ...this.query
                };
                let query = {}
                for (let key in _query) {
                    if (Array.isArray(_query[key])) {
                        query[key] = _query[key].join()
                    } else {
                        query[key] = _query[key]
                    }
                }
                request({
                    url: `/api/Extend/LqYcsdJsj`,
                    method: 'GET',
                    data: query
                }).then(res => {
                    this.list = res.data.list
                    this.total = res.data.pagination.total
                    this.listLoading = false
                })
            },
			handleDel(id) {
                this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
                    type: 'warning'
                }).then(() => {
                    request({
                        url: `/api/Extend/LqYcsdJsj/${id}`,
                        method: 'DELETE'
                    }).then(res => {
                        this.$message({
                            type: 'success',
                            message: res.msg,
                            onClose: () => {
                                this.initData()
                            }
                        });
                    })
                }).catch(() => {
                });
            },
			handleSelectionChange(val) {
                const res = val.map(item => item.id)
                this.multipleSelection = res
            },
            handleBatchRemoveDel() {
                if (!this.multipleSelection.length) {
                    this.$message({
                        type: 'error',
                        message: '请选择一条数据',
                        duration: 1500,
                    })
                    return
                }
                const ids = this.multipleSelection
                this.$confirm('您确定要删除这些数据吗, 是否继续？', '提示', {
                    type: 'warning'
                }).then(() => {
                    request({
                        url: `/api/Extend/LqYcsdJsj/batchRemove`,
                        method: 'POST',
                        data: ids ,
                    }).then(res => {
                        this.$message({
                            type: 'success',
                            message: res.msg,
                            onClose: () => {
                                this.initData()
                            }
                        });
                    })
                }).catch(() => { })
            },
			addOrUpdateHandle(id, isDetail) {
                this.formVisible = true
                this.$nextTick(() => {
                    this.$refs.NCCForm.init(id, isDetail)
                })
            },
			exportData() {
                this.exportBoxVisible = true
                this.$nextTick(() => {
                    this.$refs.ExportBox.init(this.columnList)
                })
            },
            download(data) {
                let query = { ...data, ...this.listQuery, ...this.query }
                request({
                    url: `/api/Extend/LqYcsdJsj/Actions/Export`,
                    method: 'GET',
                    data: query
                }).then(res => {
                    if (!res.data.url) return
                    window.location.href = this.define.comUrl + res.data.url
                    this.$refs.ExportBox.visible = false
                    this.exportBoxVisible = false
                })
            },
			search() {
                this.listQuery = {
                    currentPage: 1,
                    pageSize: 20,
                    sort: "desc",
                    sidx: "",
                }
                this.initData()
            },
            refresh(isrRefresh) {
                this.formVisible = false
                if (isrRefresh) this.reset()
            },
            reset() {
                for (let key in this.query) {
                    this.query[key] = undefined
                }
                this.listQuery = {
                    currentPage: 1,
                    pageSize: 20,
                    sort: "desc",
                    sidx: "",
                }
                this.initData()
            }
		}
    }
</script>