<template>
  <div class="classHourReward page-body">
    <div class="page-search row items-center">
      <div class="col row wrap q-mr-lg q-col-gutter-md">
        <div class="col-3">
          <q-select @input="resetSearch" standout="bg-primary text-white" option-value="TId" option-label="TeacherName"
                    v-model="msg.TeacherId" :options="TeacherList" emit-value map-options label="带班老师" />
        </div>
        <div class="col-3">
          <q-select @input="resetSearch" standout="bg-primary text-white" option-value="Id" option-label="Name"
                    v-model="msg.State" :options="StateList" emit-value map-options label="状态" />
        </div>
        <div class="col-3">
          <div class="col-3 Sysuser_Date">
            <q-field filled>
             <template v-slot:control>
            <el-date-picker v-model="msg.Month" @change="resetSearch()"  type="month" style="border:none;">
              </el-date-picker>       
            </template>
            </q-field>
          </div>
        </div>
      </div>
    </div>
    <div class="page-content">
      <q-table :pagination="msg" :loading="loading" no-data-label="暂无相关数据" flat class="sticky-tow-column-table"
               separator="none" title="" :data="data" :columns="columns" row-key="name">
        <template v-slot:top="props">
          <div class="page-option" style="width:100%;">
            <q-btn color="accent" style="float:right;margin-right:0;" size="sm" class="q-mr-md" icon="add" label="新增课时奖励" @click="Isadd=true" ></q-btn>
          </div>
        </template>
        <template v-slot:body-cell-State="props">
          <q-td :props="props">
            <div class="state-item" v-if="props.row.State==1" style="background: rgba(255, 204, 0, 0.2);color: #EDBE00">{{props.row.StateName}}</div>
            <div class="state-item" v-if="props.row.State==2" style="background: rgba(2, 196, 153, 10.2);color: #02C499">{{props.row.StateName}}</div>
            <div class="state-item" v-if="props.row.State==3" style="background: rgba(247, 46, 82, 0.2);color: #F72E52">{{props.row.StateName}}</div>
            <div class="state-item" v-if="props.row.State==4" style="background: rgba(41, 97, 254, 0.2);color: #2961FE">{{props.row.StateName}}</div>
          </q-td>
        </template>
        <template v-slot:body-cell-TeacherList="props">
          <q-td :props="props">
            <span style="color: #3FC4FF;cursor: pointer">{{props.row.TeacherList[0].TeacherName}}等{{props.row.TeacherList.length}}位老师
              <q-popup-proxy>
                    <q-banner>
                      <div class="price-popup">
                        <div class="row " v-for="(x,index2) in props.row.TeacherList" :key="index2" style="width: 200px;justify-content: space-between">
                            <div class="row">
                              <span style="color:#2D2D2D;">{{x.TeacherName}}</span>
                            </div>
                            <span style="color: #2860FB">{{x.Money.toFixed(2)}}</span>
                        </div>
                      </div>
                    </q-banner>
              </q-popup-proxy>
            </span>
          </q-td>
        </template>
        <template v-slot:body-cell-FrIdList="props">
          <q-td :props="props">
            <div class="row wrap" style="width: 100%;">
              <div class="frIdlist row" v-for="(x,j) in props.row.FrIdList" :key="j">
                <span style="font-size: 14px;color: #111111">{{x}}</span>
              </div>
            </div>
          </q-td>
        </template>

        <template v-slot:body-cell-optioned="props">
          <q-td :props="props">
            <q-btn flat size="xs" icon="iconfont icon-xiangqing-"  style="font-weight:400;color: #3FC4FF" class="q-mr-xs"
                   label="明细" @click="EditConfig(props.row.Id)" />
            <q-btn-dropdown flat size="xs" color="dark" label="更多" style="margin-left:10px;">
              <q-list>
                <q-item clickable v-close-popup>
                  <q-item-section @click="gostudent(item)">
                    <q-item-label>确认</q-item-label>
                  </q-item-section>
                </q-item>
                <q-item clickable v-close-popup>
                  <q-item-section @click="transferOrder(item)">
                    <q-item-label>取消</q-item-label>
                  </q-item-section>
                </q-item>
                <q-item clickable v-close-popup>
                  <q-item-section @click="editOrderRemark(item,1)">
                    <q-item-label>制单</q-item-label>
                  </q-item-section>
                </q-item>

              </q-list>
            </q-btn-dropdown>
          </q-td>
        </template>
        <template v-slot:bottom>
          <q-pagination class="full-width justify-end" v-model="msg.pageIndex" color="primary" :max="pageCount"
                        :input="true" @input="changePage" />
        </template>
      </q-table>
    </div>
<q-dialog v-model="Isadd" maximized full-height seamless position="right" style="z-index: 1000">
  <q-card style="margin-top:61px;width:400px" class="no-border-radius classinfo_Dialog">
    <div class="drawerTop">
      <div style="display:flex;align-items:center;margin:20px 0 0 20px;">
        <span class="drawer_Span" style="color: #2D2D2D;font-weight: bold">新增课时奖励</span>
      </div>
    </div>
    <div style="padding:20px 15px;" class="col">
      <div class="price-popup">
        <div class="class-h-r-popup">
          <q-select class="col-12 q-pb-lg q-pr-lg" multiple clearable filled stack-label use-input use-chips
                    option-value="TId" option-label="TeacherName" v-model="tempManager" ref="ManagerId" :options="TeacherList"
                    label="所有老师" :dense="false" emit-value map-options @filter="filterFn">
            <template v-slot:no-option>
              <q-item>
                <q-item-section class="text-grey">
                  未找到相关数据
                </q-item-section>
              </q-item>
            </template>
          </q-select>
          <div class="col-12">
            <div class="col-12 Sysuser_Date">
              <q-field filled>
                <template v-slot:control>
              <el-date-picker v-model="msg.Month" @change="resetSearch()"  type="month" style="border:none;" class='class-h-r-date' ></el-date-picker>       
              </template>
              </q-field>
            </div>
          </div>
        </div>
      </div>
      <div style="margin:30px 10px 0 0;">
        <q-btn class="q-mr-md" label="取消" @click="Isadd=false" />
        <q-btn color="accent" class="q-mr-md" label="保存" @click="saveOrderInfo()" />
      </div>
    </div>
  </q-card>
  <div class="dialog-out-close" @click="Isadd=false"
       style="height:40px !important;border-top-left-radius: 4px !important;border-bottom-left-radius: 4px !important;">
    <q-icon name="iconfont icon-jujue1" size="26px" />
  </div>
</q-dialog>
  </div>
</template>

<script>
  import {
    getTeachingBonusPageList,
    getBonusStateEnumList,//教师奖励状态 枚举
  } from '../../api/course/class'
  import {
    getTeacherDropDownList,
  } from '../../api/school/index';
    export default {
        name: "classHourReward",
      data(){
          return{
            loading:false,
            data:[],
            pageCount:0,
            Isadd:false,
            msg:{
              pageIndex:1,
              pageSize:10,
              Month:'',
              TeacherId:0,
              State:0,
            },
            //公告column
            columns: [{
              name: 'State',
              label: '状态',
              align: 'left'
            },
              {
                name: 'Month',
                field: 'Month',
                label: '月份',
                align: 'left',
              },
              {
                name: 'TeacherList',
                label: '关联老师',
                align: 'left'
              },
              {
                name: 'Money',
                label: '发放总金额',
                field: 'Money',
                align: 'left'
              },
              {
                name: 'UpdateTime',
                label: '生成时间',
                field:'UpdateTime',
                align: 'left'
              },
              {
                name: 'FrIdList',
                label: '财务单据',
                align: 'left'
              },
              {
                name: 'UpdateByName',
                label: '操作人',
                align: 'left',
                field: 'UpdateByName'
              }, {
                name: 'optioned',
                label: '操作',
                field: 'DeptId'
              }],
            TeacherList: [], //关联教师下拉数据
            AllTeacherList:[],//保存值
            StateList: [], //状态下拉
            tempManager:[],
          }
      },
      created() {
        this.getList();
        this.GetTeacherList()
        this.GetBonusStateList()
      },
      methods:{
        resetSearch() {
          this.msg.pageIndex = 1;
          this.getList()
        },
        //翻页
        changePage(val) {
          this.msg.pageIndex = val;
          this.getList()
        },
        getList(){

            this.loading = true;
            getTeachingBonusPageList(this.msg).then(res => {
              this.loading = false
              this.data = res.Data.PageData
              this.pageCount = res.Data.PageCount;


            }).catch(() => {
              this.loading = false
            })
        },
        //获取教师下拉
        GetTeacherList() {
          getTeacherDropDownList({}).then(res => {
            if (res.Code == 1) {
              this.TeacherList = res.Data;
              this.TeacherList.unshift({
                TId: 0,
                TeacherName: "不限"
              })
              this.AllTeacherList = this.TeacherList
            }
          })
        },
        GetBonusStateList(){
          getBonusStateEnumList({}).then(res => {
            if (res.Code == 1) {
              this.StateList = res.Data;
              this.StateList.unshift({
                Id: 0,
                Name: "不限"
              })
            }
          })
        },
        //筛选员工
        filterFn(val, update) {
          update(() => {
            if (val === '') {
              this.TeacherList = JSON.parse(JSON.stringify(this.AllTeacherList))
            } else {
              const needle = val.toLowerCase()
              this.TeacherList = this.AllTeacherList.filter(v => v.TeacherName.toLowerCase().indexOf(needle) > -1)
            }
          })
        },
      }
    }
</script>

<style scoped>
  .classHourReward .el-range-editor .el-range-input {
    background: none;
  }
  .classHourReward .el-range-editor.el-input__inner {
    background-color: transparent;
  }
  .classHourReward .state-item{
    padding: 3px 0px;border-radius: 3px;width: 70px;
    text-align: center;
  }
  .classHourReward .frIdlist{
    padding: 3px 10px;
    border-radius: 3px;
    background: #EEEEEF;
    align-items: center;
    justify-content: center;
    margin-right: 5px;
    margin-bottom: 5px;
    cursor: pointer;
  }
  .class-h-r-popup{
    width: 340px;
  }
  .class-h-r-popup .q-pr-lg{
    padding-right: 0;
  }
   .fullscreen{
    z-index: 1000;
  }


</style>
