<template>
    <div class="moreBrand">
        <div class="moreBrandBtn">
            <div class="collectSeach" :style="$utils.collectSeachSty()">
                <div class="exceed">
                    <span class="exceedSpan" style="width: 80px">业务属性：</span>
                    <el-select v-model="moduleStr" placeholder="请选择业务属性">
                        <el-option
                        v-for="item in moduleData"
                        :key="item.id"
                        :label="item.sectionName"
                        :value="item.id">
                        </el-option>
                    </el-select>
                </div>
                <div class="exceed">
                    <span class="exceedSpan" style="width: 80px">考评周期：</span>
                    <el-select v-model="checkCycleStr" placeholder="请选择考评周期">
                        <el-option
                        v-for="item in periodData"
                        :key="item.keyValue"
                        :label="item.keyName"
                        :value="item.keyValue">
                        </el-option>
                    </el-select>
                </div>
                <seachs @handleSeach="getSeachData" @handleRest="resetSeach"></seachs>
            </div>
            <div id="warnEch" :style="{'width': '100%','height': '35vh'}"></div>
            <div class="moreBrandTableData">
                <el-table :data="moreBrandData" style="width: 100%" :class="moreBrandTableSty()">
                    <el-table-column type="expand">
                    <template #default="props">
                        <div class="inTable">
                            <el-table :data="props.row.children" border>
                                <el-table-column label="单位名称" prop="organizationName" />
                                <el-table-column label="业务属性" prop="binSectionName" />
                                <el-table-column label="考评周期" prop="checkCycle">
                                    <template #default="scope">
                                        <span>{{scope.row.checkCycle === 'YDKP'?'月度考评':scope.row.checkCycle === 'JDKP'?'季度考评':'年度考评'}}</span>
                                    </template>
                                </el-table-column>
                                <el-table-column label="利润金额" prop="profit" />
                                <el-table-column label="分数" prop="score" />
                                <el-table-column label="年" prop="year" />
                                <el-table-column label="月" prop="month" />
                                <el-table-column label="备注" prop="remark" />
                            </el-table>
                        </div>
                    </template>
                    </el-table-column>
                    <el-table-column label="单位名称" prop="organizationName" />
                    <el-table-column label="业务属性" prop="binSectionName" />
                    <el-table-column label="考评周期" prop="checkCycle">
                        <template #default="scope">
                            <span>{{scope.row.checkCycle === 'YDKP'?'月度考评':scope.row.checkCycle === 'JDKP'?'季度考评':'年度考评'}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="利润金额" prop="profit" />
                    <el-table-column label="分数" prop="score" />
                    <el-table-column label="年" prop="year" />
                    <el-table-column label="月" prop="month" />
                    <el-table-column label="备注" prop="remark" />
                </el-table>
                <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="page.currentPage"
                    :page-size="page.pagesize"
                    layout="total, prev, pager, next, jumper"
                    :total="page.total">
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import seachs from '../seachGroup.vue'
import btns from '../elbuttonS.vue'
import {apiGetmultiplebrandtreeList, apiPostmultiplebrandSave, apiGetorganizationgetListTwo,
apiPostmultiplebrandRemove, apiGetbinsectionList, apiGetdatadictionaryList} from '../../api/api'
export default {
    components: { btns, seachs },
    data() {
        return {
            dialogVisible: false,
            title: '',
            isSave: false,
            moduleData: [],
            periodData: [],
            moduleStr: '',
            checkCycleStr: '',
            moreBrandData:[],
            companyDatas: [],
            addType: '',
            ruleForm: {
                organizationName: '',
                binSection: '',
                checkCycle: '',
                profit: 0,
                score: 0,
                year: '',
                month: 1,
                remark: ''
            },
            rules: {
                organizationName: [
                    { required: true, message: '请选择单位名称', trigger: 'change' }
                ],
                binSection: [
                    { required: true, message: '请选择业务属性', trigger: 'change' }
                ],
                checkCycle: [
                    { required: true, message: '请选择考评周期', trigger: 'change' }
                ],
                year: [
                    { required: true, message: '请选择年份', trigger: 'change' }
                ]
            },
            page:{
                pagesize: 12,
                currentPage: 1,
                total: 0
            },
            evalradio: {},
            winPix: window.devicePixelRatio,
            innerWidth: window.innerWidth
        }
    },
    created() {
        this.getMoreBrandData()
        this.getOrganizetionData()
        this.getDataDictionary()
    },
    mounted() {
        this.warnEcharts()
    },
    methods:{
        // 展示预警echarts
        warnEcharts() {
            this.echartsOption()
        },
        echartsOption() {
            let option = {
                xAxis: {
                    type: 'category',
                    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                    data: [150, 230, 224, 218, 135, 147, 260],
                    type: 'line'
                    }
                ]
            };
            let dom = document.getElementById('warnEch');
            // dom.removeAttribute("_echarts_instance_")
            let myChart = this.$echarts.init(dom);
            myChart.setOption(option);
            window.addEventListener("resize", function () {
                myChart.resize()
            })
        },
        // 查询指标数据
        getMoreBrandData() {
            let that = this
            let params = {
                pageNum: that.page.currentPage,
                pageSize: that.page.pagesize,
                binSection: that.moduleStr,
                checkCycle: that.checkCycleStr
            }
            apiGetmultiplebrandtreeList(params).then(datas =>{
                if (datas && datas.data) {
                    that.moreBrandData = datas.data.records
                    that.page.total = datas.data.total
                }
            })
        },
        //查询组织数据
        getOrganizetionData() {
            let that = this
            // let params = {
            //     id: id,
            //     num: num
            // }
            apiGetorganizationgetListTwo().then(datas => {
                if (datas && datas.data) {
                    that.companyDatas = datas.data
                }
            })
        },
        // 查询规则模块和阶段数据
        getDataDictionary() {
            let that = this
            apiGetbinsectionList().then(datas =>{
                if (datas && datas.data) {
                    that.moduleData = datas.data
                }
            })
            apiGetdatadictionaryList({superKey: 'KPZQ0001'}).then(datas => {
                if (datas && datas.data) {
                    that.periodData = datas.data
                }
            })
        },
        getSeachData() {
            this.page.currentPage = 1
            this.getMoreBrandData()
        },
        resetSeach() {
            this.page.currentPage = 1
            this.moduleStr = ''
            this.checkCycleStr = ''
            this.getMoreBrandData()
        },
        handleSizeChange(val){
            this.page.pagesize = val
            this.getMoreBrandData()
        },
        handleCurrentChange(val){
            this.page.currentPage =val
            this.getMoreBrandData()
        },
        moreBrandTableSty() {
            if (this.winPix === 1.25 || this.innerWidth < 1800) {
                return 'moreBrand125Table'
            } else {
                return 'moreBrand100Table'
            }
        }
    }
}
</script>

<style lang="less">
.moreBrand{
  .moreBrandBtn{
        .collectSeach{
            display: flex;
            padding: 24px 20px;
            border-bottom: 1px solid#D6DBEA;
                .exceed{
                    display: flex;
                    .exceedSpan{
                        width: 100px;
                        height: 12px;
                        font-size: 14px;
                        font-family: Microsoft YaHei;
                        font-weight: 400;
                        color: #8991B0;
                        line-height: 12px;
                        margin-top: 14px;
                    }
                    .el-select{
                        line-height: 40px !important;
                        .el-input__inner, .is-disabled{
                            height:40px !important;
                        }
                        .el-input__suffix{
                            .el-select__caret{
                                line-height:40px;
                            }
                        }
                    }
                }
                .el-select{
                    margin-right:10px;
                    .el-input__inner{
                        height:30px;
                    }
                    .el-input__suffix{
                        .el-select__caret{
                            line-height:30px;
                        }
                    }
                }
        }
        span{
            font-size:14px;
        }
        .el-button{
            height: 30px;
            // width:100px;
            padding: 0 30px ;
            // padding-top: 8px;
            span{
                margin:0;
            }
        }
    }
  .moreBrandTableData{
    .moreBrand125Table{
        .el-table__body-wrapper{
            height: 28vh !important;
        }
    }
    .moreBrand100Table{
        .el-table__body-wrapper{
            height: 30vh !important;
        }
    }
    .el-table{
        .el-input__inner{
            height: 30px !important;
        }
        .el-radio__label{
            display: none;
        }
        
        .inTable{
            padding: 20px;
            .el-table{
                .el-table__body-wrapper{
                    height: 30vh !important;
                }
            }
        }
        .indicitem{
            color: #409EFF;
            font-size: 12px;
            margin-right: 20px;
            cursor:pointer;
            &:hover{
                text-decoration: underline;
            }
        }
    }
    .el-pagination{
        margin-top: 20px;
        text-align: end;
        position: relative;
    }
    }
    
}
</style>