<template>
  <div class="tktjClass">
    <div style="margin-bottom: 20px;">
      <span style="font-size: 22px;font-weight: bold;margin: 20px;">评课明细表</span>
      <span style="color: #9a9a9a;">（点击下方数据查看问卷内容）</span>
    </div>
    <!--查询区域-->
      <a-form @keyup.enter.native="searchQuery" :model="queryParam"  >
        <a-row :gutter="24">
          <a-col :span="3">
            <a-form-item label="">
              <JDictSelectTag placeholder="听课身份" v-model:value="queryParam.tksf" dictCode="kc_tksf"/>
            </a-form-item>
          </a-col>
          <a-col :span="4">
            <a-form-item label="">
              <JDictSelectTag placeholder="听课人所在单位" v-model:value="queryParam.szdw"  :dictCode="`tkrszdw_view,college,college`"/>
            </a-form-item>
          </a-col>
          <a-col :span="3">
            <a-form-item label="">
              <JDictSelectTag placeholder="开课单位" v-model:value="queryParam.kkdw" :dictCode="`kc_kkdw_view,kkdw,kkdw`"/>
            </a-form-item>
          </a-col>
          <a-col :span="3">
            <a-form-item label="">
              <JDictSelectTag placeholder="课程性质" v-model:value="queryParam.kcxz" dictCode="kcxz"/>
            </a-form-item>
          </a-col>
          <a-col :span="3">
            <a-form-item label="">
              <a-date-picker
                :showTime="false"
                valueFormat="YYYY-MM-DD"
                :placeholder="'请选择开始时间'"
                v-model:value="queryParam.startTime"
              ></a-date-picker>
            </a-form-item>
          </a-col>
          <a-col :span="3">
            <a-form-item label="">
              <a-date-picker
                :showTime="false"
                valueFormat="YYYY-MM-DD"
                :placeholder="'请选择结束时间'"
                v-model:value="queryParam.endTime"
              ></a-date-picker>
            </a-form-item>
          </a-col>
          <a-col :span="4">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                <a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
                <a-button  type="primary" preIcon="ant-design:export-outlined" style="margin-left: 10px;" @click="onExportXls"> 导出</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    <!--引用表格-->
    <BasicTable @register="registerTable">
      <template #openDcwj="{ text ,record}">
        <span @click="openDcwjxx(record)">{{text}}</span>
      </template>
    </BasicTable>
    <!-- 表单区域 -->

  <viewModalPage ref="viewModal"/>
  </div>
</template>

<script lang="ts" name="kcTingke-pkmxb" setup>
  import { ref, reactive, onMounted } from 'vue';
  import { BasicTable} from '/@/components/Table';
  import { useListPage } from '/@/hooks/system/useListPage';
  import { columns } from './pkmxb.data';
  import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './pkmxb.api';
  import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
  import { dateFormat } from '/@/utils/common/compUtils';
import viewModalPage from '/@/views/site/tingKeZuJi/components/viewModal.vue';

  const queryParam = ref<any>({});
  const toggleSearchStatus = ref<boolean>(false);
  const registerModal = ref();
const viewModal = ref();
  //注册table数据
  const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
    tableProps: {
      // title: '开课单位统计',
      api: list,
      columns,
      canResize:true,
      useSearchForm: false,
      showActionColumn: false,
      clickToRowSelect: true,
      pagination: {
        pageSize: 5
      },
      beforeFetch: (params) => {
        params.column = '',params.order = '';
        return Object.assign(params, queryParam.value);
      },
    },
    exportConfig: {
      name: "评课明细表",
      url: getExportUrl,
      params: queryParam.value,
    },
	  importConfig: {
	    url: getImportUrl,
	    success: handleSuccess
	  },
  });
  const [registerTable, { reload, }, { rowSelection, selectedRowKeys }] = tableContext;
  const labelCol = reactive({
    xs: { span: 24 },
    sm: { span: 7 },
  });
  const wrapperCol = reactive({
    xs: { span: 24 },
    sm: { span: 16 },
  });

  //进入就加载
  onMounted(() => {
    const format = 'yyyy-MM-dd';
    const startTime = new Date();
    startTime.setTime(startTime.getTime()-60000*60*24*7)
    queryParam.value.startTime =  dateFormat(startTime, format)
    queryParam.value.endTime =  dateFormat(new Date(), format)
  });

  /**
   * 成功回调
   */
  function handleSuccess() {
    (selectedRowKeys.value = []) && reload();
  }


  /**
   * 查询
   */
  function searchQuery() {
    reload();
  }

  /**
   * 重置
   */
  function searchReset() {
    queryParam.value = {};
    selectedRowKeys.value = [];
    //刷新数据
    reload();
  }

  function openDcwjxx(record){
    console.log(`🚀 ~ file: pkmxb.vue:150 ~ openDcwjxx ~ record:`, record)
    let { kcmc,skjs,zc:WEEK,jc:hh,userid,id:ketangbiaoid,evaluationver,} = record;
    //jc,zc,evaId
    //{{ form.kcmc }}-{{ form.skjs }}-星期{{ form.WEEK }}-{{ form.hh }}
    //userid: record.userid, minkcid: record.ketangbiaoid, evaluationver: record.evaluationver
    viewModal.value.view({kcmc,skjs,WEEK,hh,userid,ketangbiaoid,evaluationver})
  }



</script>

<style lang="less" scoped>
  .jeecg-basic-table-form-container {
    .table-page-search-submitButtons {
      display: block;
      margin-bottom: 24px;
      white-space: nowrap;
    }
    .query-group-cust{
      width: calc(50% - 15px);
      min-width: 100px !important;
    }
    .query-group-split-cust{
      width: 30px;
      display: inline-block;
      text-align: center
    }
  }
</style>
<style>

.jee-hidden{
    display: none;
  }
</style>