<template>
  <div style="background: #fafafa; height: calc(100vh - 225px); overflow-y: auto; margin: 10px 0; padding: 8px 0 0 0">
    <div v-if="showType == 0">
      <a-row>
        <a-col :span="24"><span class="title">课程作业次数设置</span><a-divider /></a-col>
        <div class="tishi">温馨提示：设置完成后，您也可以在课程教学过程中，随时根据实际情况进行调整。</div>
        <div class="work-img">
          <img class="work-img-img" src="../../../assets/images/homework.png" />
        </div>
        <a-col :span="24" style="text-align: center; color: #494b56">
          <div>老师您好，</div>
          <div>请根据课程教学大纲的要求，</div>
          <div>设置学生修完本课程需要完成的作业次数及每次作业在总成绩中所占的比例。</div>
          <div style="margin-top: 30px" class="ant-btn buttonClass"><a @click="handleSzzycs(1)">设置作业次数</a></div>
        </a-col>
      </a-row>
    </div>
    <div v-if="showType == 1">
      <a-row>
        <a-col :span="24"><span class="title">课程作业次数设置</span><a-divider /></a-col>
        <a-col :span="24" style="margin-top: 10px; height: 50px">
          <a-row style="text-align: center">
            <a-col :span="8"
              ><span>课程作业占比:</span><span>{{ kczyzb }}%;</span></a-col
            >
            <a-col :span="8"
              ><span>期末考试占比:</span><span>{{ qmkszb }}%;</span></a-col
            >
            <a-col :span="8"
              ><span>课堂测验占比:</span><span>{{ ktcyzb }}%;</span></a-col
            >
          </a-row>
        </a-col>
        <a-col :span="24" style="padding: 0 0 0 30px">
          <a-row>
            <a-col :span="18" style="margin-top: 5px">
              <span style="color: #777777">学生修完本课程需要完成的作业次数：</span>
              <a-input-number style="width: 30%" v-model:value="zycs" @change="handleZycs" :max="100" :disabled="zycsDisabled" /><span
                style="margin-left: 5px"
                >次</span
              >
            </a-col>
            <a-col :span="6" style="text-align: right; padding: 5px 0 0 0">
              <a-button type="primary" @click="handleAddZycs" class="mar-right20"><Icon icon="ant-design:file-add-outlined" />新增作业</a-button>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="24" style="margin-top: 10px">
          <a-table :columns="columns" :data-source="tableData" :pagination="false">
            <template #bodyCell="{ column, record }">
              <template v-if="column.key === 'score'">
                <span>
                  <a-input-number v-model:value="record.score" :min="0" :max="100"> <template #addonAfter> % </template></a-input-number>
                </span>
              </template>
              <template v-else-if="column.key === 'lstitle'">
                <span> 第{{ record.sort }}次作业 </span>
              </template>
              <template v-else-if="column.key === 'action'">
                <span>
                  <a @click="handleDelZycs(record.sort)">删除</a>
                </span>
              </template>
            </template>
          </a-table>
        </a-col>
        <a-col :span="24" style="margin-top: 30px; font-size: 18px">
          <div style="text-align: center">
            <a-button class="buttonClass" @click="handleBatchAdd"><Icon icon="ant-design:save-outlined" />保存</a-button>
            <a-divider type="vertical" />
            <a-button class="buttonClass" @click="reloadZy"><Icon icon="ant-design:export-outlined" />返回</a-button>
          </div>
        </a-col>
      </a-row>
    </div>
    <div v-if="showType == 2">
      <a-spin :spinning="confirmLoading">
        <a-row>
          <a-col :span="24">
            <div style="text-align: right">
              <a-button style="margin-right: 10px" type="primary" @click="handleYyzy" :disabled="editDisabled">引用作业</a-button>
            </div>
            <span class="title">编辑作业</span> - <span class="title2">布置作业：设置第{{ zyInfo.sort }}次作业内容及要求</span>
            <a-divider />
          </a-col>
          <a-col :span="24">
            <a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-row>
                <a-col :span="24">
                  <div class="region">
                    <div class="region-title"><span class="region-title-headline"></span><span>基本信息</span></div>
                    <a-col :span="24">
                      <a-form-item label="作业题目" v-bind="validateInfos.title">
                        <a-input v-model:value="zyInfo.title" placeholder="请输入作业题目" :disabled="editDisabled"></a-input>
                      </a-form-item>
                    </a-col>
                    <!-- <a-col :span="24">
                      <a-form-item label="考察内容" v-bind="validateInfos.kcnr">
                        <a-textarea v-model:value="zyInfo.kcnr" placeholder="请输入描述" hidden></a-textarea>
                        <a-button type="primary" @click="handleKcnr" :disabled="editDisabled">选择</a-button>
                      </a-form-item>
                    </a-col>
                    <a-col :span="24" style="padding: 0 20px" v-if="dataKhnr.length > 0">
                      <a-table :columns="columnsKhnr" rowKey="id" :data-source="dataKhnr" :pagination="false" />
                    </a-col> -->
                    <a-col :span="24">
                      <a-form-item label="作业截止时间" v-bind="validateInfos.endTime">
                        <a-date-picker
                          placeholder="请选择作业截止时间"
                          v-model:value="zyInfo.endTime"
                          :disabled-date="disabledDate"
                          :show-time="{ format: 'YYYY-MM-DD HH:mm' }"
                          valueFormat="YYYY-MM-DD HH:mm"
                          format="YYYY-MM-DD HH:mm"
                          style="width: 100%"
                          @change="handleEndTime"
                        />
                      </a-form-item>
                    </a-col>
                    <a-col :span="24">
                      <a-form-item label="作业发布时间" v-bind="validateInfos.startTime">
                        <a-date-picker
                          placeholder="请选择作业发布时间"
                          v-model:value="zyInfo.startTime"
                          :disabled-date="disabledDate"
                          :show-time="{ format: 'YYYY-MM-DD HH:mm' }"
                          valueFormat="YYYY-MM-DD HH:mm"
                          format="YYYY-MM-DD HH:mm"
                          style="width: 90%"
                          :disabled="editDisabled"
                        />
                        <span>
                          <a-popover title="温馨提示">
                            <template #content>
                              <p
                                >填写作业发布时间，则作业在指定时间进行发布；如未填写作业发布时间，则布置完成作业后，可手动点击“发布作业”进行作业发布。</p
                              >
                            </template>
                            <Icon
                              icon="ant-design:question-circle-outlined"
                              :size="20"
                              style="float: right; margin-top: 5px; color: #029c88; margin-right: 19px"
                            />
                          </a-popover>
                        </span>
                      </a-form-item>
                    </a-col>
                    <a-col :span="24">
                      <a-form-item label="作业要求" v-bind="validateInfos.content">
                        <j-editor v-model:value="zyInfo.content" v-if="zyyqShow" @blur="handleZyyqShow(0)" />
                        <div style="color: #777777" v-html="zyInfo.content" v-if="!zyyqShow"></div>
                        <div @click="handleZyyqShow(1)" class="tishi" v-if="!editDisabled">温馨提示：点击可编辑作业要求</div>
                        <!-- <div @click="handleZyyqShow(1)"><span style="cursor: pointer; color: #18a689">温馨提示：点击可编辑作业要求</span></div> -->
                      </a-form-item>
                    </a-col>
                    <a-col :span="24">
                      <a-form-item label="参考资料" v-bind="validateInfos.filePath">
                        <j-upload v-model:value="zyInfo.filePath" :disabled="editDisabled"></j-upload>
                      </a-form-item>
                    </a-col>
                    <a-col :span="24">
                      <a-form-item label="评分标准" layout="inline" v-bind="validateInfos.pfbz">
                        <a-form-item
                          label="是否允许学生查看"
                          :labelCol="labelCol2"
                          :wrapperCol="wrapperCol2"
                          style="margin-top: -1px; margin-left: -17px"
                        >
                          <j-dict-select-tag
                            type="radio"
                            v-model:value="zyInfo.sturead"
                            dictCode="yn"
                            placeholder="请选择评分标准是否允许学生查看"
                            :disabled="editDisabled"
                          />
                        </a-form-item>
                        <a-form-item label="">
                          <j-editor v-model:value="zyInfo.pfbz" v-if="pfbzShow" @blur="handlePfbzShow(0)" />
                          <div v-html="zyInfo.pfbz" v-if="!pfbzShow"></div>
                          <div class="tishi" @click="handlePfbzShow(1)" v-if="!editDisabled">温馨提示：点击可编辑评分标准</div>
                        </a-form-item>
                      </a-form-item>
                    </a-col>
                  </div>
                </a-col>
                <a-col :span="24">
                  <div class="region">
                    <div class="region-title"><span class="region-title-headline"></span><span>学生互评</span></div>
                    <a-form-item label="学生互评">
                      <div class="tishi" v-if="zyInfo.xshpkg == '1'"
                        >每份作业至少互评三次，每个学生互评五份作业。按时完成互评任务的学生，可额外获得最终分数的2%作为互评奖励；互评作业质量高的学生，可额外获得最终分数的5%作为互评奖励。</div
                      >
                      <j-dict-select-tag
                        type="radio"
                        v-model:value="zyInfo.xshpkg"
                        dictCode="yn"
                        placeholder="请选择是否允许学生查看"
                        style="margin-top: 15px"
                        :disabled="editDisabled"
                        @change="handleXshpkg"
                      />
                      <div v-if="zyInfo.xshpkg == '1'">
                        <!-- <a-form-item label="设置互评人数" :labelCol="labelCol3" :wrapperCol="wrapperCol3" style="margin-top: 20px">
                        <a-input-number v-model:value="zyInfo.xshprsq" placeholder="请设置互评人数" style="width: 60%" :max="100" :min="0">
                          <template #addonAfter>人</template>
                        </a-input-number>
                      </a-form-item> -->
                        <a-form-item
                          label="互评结果使用"
                          :labelCol="labelCol3"
                          :wrapperCol="wrapperCol3"
                          style="margin-top: 20px; margin-left: -30px"
                        >
                          <a-radio-group v-model:value="zyInfo.sfzzcj" style="width: 100%" size="default" :disabled="editDisabled">
                            <a-radio :value="'1'" style="width: 100%; margin-bottom: 5px">互评成绩为最终成绩</a-radio>
                            <a-radio :value="'0'" style="width: 100%; margin-bottom: 5px">互评成绩作为教师评分的参考成绩</a-radio>
                          </a-radio-group>
                        </a-form-item>
                        <a-form-item
                          label="是否允许学生看到互评成绩"
                          :labelCol="labelCol4"
                          :wrapperCol="wrapperCol4"
                          style="margin-top: 20px; margin-left: -10px"
                        >
                          <a-radio-group v-model:value="zyInfo.xssfck">
                            <a-radio :value="'1'" style="margin-top: 5px">是(匿名)</a-radio>
                            <a-radio :value="'0'" style="margin-top: 5px">否</a-radio>
                          </a-radio-group>
                          <!-- <j-dict-select-tag
                          type="radio"
                          v-model:value="zyInfo.xshpkg"
                          dictCode="yn"
                          placeholder="请选择是否允许学生查看"
                          style="margin-top: 15px"
                        /> -->
                        </a-form-item>
                        <a-form-item label="互评开始时间" :labelCol="labelCol2" :wrapperCol="wrapperCol2" hidden>
                          <a-date-picker
                            placeholder="请选择互评开始时间"
                            v-model:value="zyInfo.xshpkssj"
                            :disabled-date="disabledDate"
                            :show-time="{ format: 'YYYY-MM-DD HH:mm' }"
                            valueFormat="YYYY-MM-DD HH:mm"
                            format="YYYY-MM-DD HH:mm"
                            style="width: 100%"
                          />
                        </a-form-item>
                        <a-form-item label="互评结束时间" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
                          <a-date-picker
                            placeholder="请选择互评结束时间"
                            v-model:value="zyInfo.xshpjssj"
                            :disabled-date="disabledDate"
                            :show-time="{ format: 'YYYY-MM-DD HH:mm' }"
                            valueFormat="YYYY-MM-DD HH:mm"
                            format="YYYY-MM-DD HH:mm"
                            style="width: 100%"
                          />
                        </a-form-item>
                      </div>
                    </a-form-item>
                  </div>
                </a-col>
                <a-col :span="24">
                  <div class="region">
                    <div class="region-title"><span class="region-title-headline"></span><span>查重设置</span></div>
                    <a-form-item label="是否进行查重" :labelCol="labelCol3" :wrapperCol="wrapperCol3">
                      <j-dict-select-tag
                        type="radio"
                        v-model:value="zyInfo.sfcc"
                        dictCode="yn"
                        placeholder="请选择是否查重"
                        :disabled="editDisabled"
                      />
                    </a-form-item>

                    <a-form-item
                      label="检测通过率"
                      :labelCol="labelCol3"
                      :wrapperCol="wrapperCol3"
                      style="margin: -1px; margin-left: -10px"
                      v-if="zyInfo.sfcc == '1'"
                    >
                      <a-input-number
                        v-model:value="zyInfo.wwtgl"
                        placeholder="请输入检测通过率"
                        style="width: 50%"
                        :max="100"
                        :min="0"
                        :disabled="editDisabled"
                      >
                        <template #addonAfter> % </template>
                      </a-input-number>
                    </a-form-item>
                    <a-form-item
                      label="比对库设置"
                      :labelCol="labelCol3"
                      :wrapperCol="wrapperCol3"
                      style="margin-left: -10px"
                      v-if="zyInfo.sfcc == '1'"
                    >
                      <div style="padding: 5px 0">维普</div>
                      <div style="display: flex; flex-direction: column">
                        <a-checkbox v-model:checked="zyInfo.wwcc" :disabled="editDisabled" style="margin-left: 8px">
                          <span class="bled-countenance">维普资源库查重</span><br />
                          <span class="bled-countenance2">中文科技期刊数据库、硕博学位论文库、高校特色论文库、互联网数据资源/互联网文档资源</span>
                        </a-checkbox>
                        <a-checkbox v-model:checked="zyInfo.xncc" :disabled="editDisabled">
                          <span class="bled-countenance">学校作业库查重</span><br /><span class="bled-countenance2">历届学生提供的作业库内查重</span>
                        </a-checkbox>
                        <a-checkbox v-model:checked="zyInfo.nwcc" :disabled="editDisabled">
                          <span class="bled-countenance">本次作业查重</span><br /><span class="bled-countenance2">本次学生提交的作业间查重</span>
                        </a-checkbox>
                      </div>
                      <div style="padding: 5px 0">AIGC</div>
                      <div>
                        <a-checkbox v-model:checked="zyInfo.aigccc" style="margin-left: 8px" :disabled="editDisabled">
                          <span class="bled-countenance">AIGC查重</span><br /><span class="bled-countenance2"
                            >检测作业是否部分或全部由AI模型生成</span
                          >
                        </a-checkbox>
                      </div>
                    </a-form-item>
                  </div>
                </a-col>
                <a-col :span="24" style="text-align: center; margin-top: 10px; margin-bottom: 40px">
                  <a-button type="primary" @click="submitForm">保存</a-button>
                  <a-button type="primary" @click="reloadZy" style="margin-left: 15px">返回</a-button>
                </a-col>
              </a-row>
            </a-form>
          </a-col>
        </a-row>
      </a-spin>
    </div>
    <div v-show="showType == 3" style="overflow-y: auto">
      <a-row>
        <a-col :span="24"
          ><span class="title">批阅作业</span> - <span class="title2">作业详情页</span>
          <a-button type="primary" preIcon="ant-design:export-outlined" @click="reloadZy" style="float: right; margin-right: 8px"> 返回</a-button>
          <a-popover title="温馨提示">
            <template #content>
              <p>1、非高峰期预计30分钟内返回检测结果，高峰期预计时间会更长，请您耐心等待！</p>
              <p>2、点击互评分数，可查看同学间互评作业详情</p>
              <p>3、点击最高查重率，可分别查看学生“维普作业库查重”、“学校作业库查重”、“本次作业查重”、“AIGC查重”相似率</p>
              <p>4、学生上传的课程作业全部存档</p>
            </template>
            <Icon icon="ant-design:question-circle-outlined" :size="30" style="float: right; margin-right: 8px; color: #029c88" />
          </a-popover>
          <a-divider
        /></a-col>
        <a-col :span="24" style="overflow: hidden">
          <!--查询区域-->
          <div class="sear-distance">
            <a-form @keyup.enter.native="searchQueryZyxq" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
              <a-row :gutter="24">
                <a-col :lg="12">
                  <a-form-item label="学生姓名">
                    <j-input placeholder="请输入学生姓名" v-model:value="queryParam.studentName"></j-input>
                  </a-form-item>
                </a-col>
                <a-col :lg="12">
                  <a-form-item label="学生学号">
                    <j-input placeholder="请输入学生学号" v-model:value="queryParam.createBy"></j-input>
                  </a-form-item>
                </a-col>
                <a-col :lg="12">
                  <a-form-item label="作业状态">
                    <!-- <j-input placeholder="请输入学生学号" v-model:value="queryParam.createBy"></j-input> -->
                    <a-select v-model:value="queryType" style="width: 100%">
                      <a-select-option value="">全部</a-select-option>
                      <a-select-option value="1">待提交</a-select-option>
                      <a-select-option value="2">已提交</a-select-option>
                      <a-select-option value="5">待评阅</a-select-option>
                      <a-select-option value="4">已评阅</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQueryZyxq">查询</a-button>
                  <a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
                  <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls" style="margin-left: 8px"> 导出</a-button>
                  <a-button type="primary" preIcon="ant-design:export-outlined" @click="batchHandleFabu" style="margin-left: 8px">发布成绩</a-button>
                  <a-button type="primary" preIcon="ant-design:export-outlined" @click="batchHandleKhcl" style="margin-left: 8px">上传考核材料</a-button>
                  <span class="tishi" style="margin-left: 20px; padding: 10px">温馨提示：作业完成后，请及时发布评分</span>
                </a-col>
              </a-row>
            </a-form>
          </div>
          <!--引用表格-->
          <BasicTable @register="registerTable" :rowSelection="rowSelection">
            <template #action="{ record }">
              <TableAction :actions="getTableAction(record)" />
            </template>
            <template #zgcclaction="{ record }">
              <div v-if="record.alltgl">
                <span v-if="record.filePath">
                  <template v-if="record.zgccl && record.zgccl != '0'">
                    <span v-if="record.zgccl <= record.alltgl" title="通过" style="color: #36b395; cursor: pointer" @click="handleViewInfo(record)">
                      {{ record.zgccl }}
                    </span>
                    <span v-else title="未通过" style="color: red" @click="handleViewInfo(record)">{{ record.zgccl }}</span>
                  </template>
                  <template v-else>查重中</template>
                </span>
                <span v-else> </span>
              </div>
              <div v-else>
                <span></span>
              </div>
            </template>
            <template #scoreaction="{ record }">
              <span style="color: #36b395; cursor: pointer" v-if="record.scoreFabu == '1' || !record.filePath">
                {{ record.score }}
              </span>
              <span style="color: #36b395; cursor: pointer" v-if="record.scoreFabu != '1' && record.filePath">
                <a-input v-model:value="record.score" style="width: 90%" @blur="handleChangeScore(record)" />
              </span>
            </template>
            <template #xshpfsaction="{ record }">
              <span style="color: #36b395; cursor: pointer" @click="handleXshpfs(record)">
                {{ record.xshpfs }}
              </span>
            </template>

            <template #htmlSlot="{ text }">
              <div v-html="text"></div>
            </template>
          </BasicTable>
        </a-col>
      </a-row>
    </div>
    <div v-if="showType == 4">
      <a-row>
        <a-col :span="24"
          ><span class="title">批阅作业</span> - <span class="title2">作业详情页</span> - <span class="title2">查重相似度详情</span>
          <a-button type="primary" @click="handleShowType(3)" style="float: right; margin-right: 8px"
            ><Icon icon="ant-design:export-outlined" />返回</a-button
          >
          <a-divider
        /></a-col>
        <a-col :span="24">
          <a-table :columns="columnsCcjg" :data-source="tableCcjgData" :pagination="false">
            <template #bodyCell="{ column, record }">
              <template v-if="column.key === 'action'">
                <span>
                  <a @click="handleOpenLwxx(record)">查看</a>
                </span>
              </template>
            </template>
          </a-table>
        </a-col>
      </a-row>
    </div>
    <div v-if="showType == 5">
      <a-row>
        <a-col :span="24"
          ><span class="title">批阅作业</span> - <span class="title2">作业详情页</span> - <span class="title2">学生互评详情</span>
          <a-button type="primary" @click="handleShowType(3)" style="float: right; margin-right: 8px"
            ><Icon icon="ant-design:export-outlined" />返回</a-button
          >
          <a-divider
        /></a-col>
        <a-col :span="24">
          <a-table :columns="columnsXshp" :data-source="tableXshpData" :pagination="false"> </a-table>
        </a-col>
      </a-row>
    </div>

    <div v-if="showType == 999">
      <a-row>
        <a-col :span="24"><span class="title">布置作业</span><a-divider /></a-col>
        <a-col :span="24" style="text-align: right; margin-top: 5px">
          <a-button type="primary" @click="handleSzzycs(1)"><Icon icon="ant-design:edit-outlined" />修改课程作业次数</a-button>
          <a-divider type="vertical" />
          <a-button type="primary" @click="handleAddOne" class="mar-right20"><Icon icon="ant-design:file-add-outlined" />新增作业</a-button>
        </a-col>
        <a-col :span="24">
          <a-row style="padding: 10px">
            <a-col :lg="24" v-for="(item, index) in tableData" style="padding: 0 5px 12px 5px; border-radius: 5px" :key="index">
              <a-card :title="'第' + item.sort + '次作业(占比' + item.score + '%)'" v-if="!item.endTime" class="cardClass module-bg">
                <template #extra><span class="card-label3"> 待设置</span> </template>
                <p class="sznrClass">尚未布置作业题目及具体要求</p>
                <div style="text-align: right">
                  <a @click="handleEdit(item, false)" class="home-status"><Icon icon="ant-design:file-text-outlined" />设置作业内容及要求</a>
                  <a-divider type="vertical" />
                  <a @click="handleDelete(item)" class="home-status"><Icon icon="ant-design:delete-outlined" />删除</a>
                </div>
              </a-card>
              <a-card
                :title="'第' + item.sort + '次作业(占比' + item.score + '%)'"
                v-if="item.endTime && (item.zyStatus == '1' || item.zyStatus == '2')"
                class="cardClass module-bg"
              >
                <template #extra><span class="card-label">已发布</span> </template>
                <div class="ellip-title">
                  <span class="ellipsis elli-title" :title="item.title">{{ item.title }}</span>
                  <a class="button-zhta" @click="openXkrs(item)">{{ item.xkxs }}人选课</a>
                </div>

                <div style="width: 100%; display: flex">
                  <div class="data-suggest zuanqu" @click="handleZyxx(item, '1')"
                    ><span>{{ item.wtjnum }}人</span><span>待提交</span></div
                  >
                  <!-- <div class="data-suggest zuanqu" @click="handleZyxx(item, '2')"
                    ><span>{{ item.ytjnum }}人</span><span>已提交</span></div
                  > -->
                  <div class="data-suggest zuanqu" @click="handleZyxx(item, '5')"
                    ><span>{{ item.dpynum }}人</span><span>待评阅</span></div
                  >
                  <div class="data-suggest zuanqu" @click="handleZyxx(item, '4')"
                    ><span>{{ item.ypynum }}人</span><span>已评阅</span></div
                  >
                </div>
                <div class="flex">
                  <div style="width: 100%; display: flex; margin-top: 20px">
                    <div class="ellip-word"
                      ><span class="ellip-word2">作业发布时间：</span
                      >{{ item.startTime ? dayjs(item.startTime).format('YYYY.MM.DD HH:mm') : '未设置' }}</div
                    >
                    <div class="ellip-word"><span class="ellip-word2">作业截止时间：</span>{{ dayjs(item.endTime).format('YYYY.MM.DD HH:mm') }}</div>
                  </div>
                  <div style="text-align: right; margin-top: 20px; margin-bottom: -10px; width: 100%">
                    <!-- <a @click="handleWxtx(item)" class="home-status"><Icon icon="ant-design:wechat-outlined" />微信提醒</a>
                    <a-divider type="vertical" /> -->
                    <a @click="handleEdit(item, true)" v-if="item.ytjnum > 0" class="home-status"><Icon icon="ant-design:form-outlined" />编辑作业</a>
                    <a-divider type="vertical"  v-if="item.ytjnum > 0"/>
                    <a @click="handleFenxiang(item)" class="home-status"><Icon icon="ant-design:share-alt-outlined" />分享</a>
                    <a-divider type="vertical" />
                    <a @click="handleChehui(item)" v-if="item.dpynum == 0 && item.ypynum == 0" class="home-status"><Icon icon="ant-design:import-outlined" />撤回作业</a>
                    <a-divider type="vertical"  v-if="item.dpynum == 0 && item.ypynum == 0"/>
                    <a @click="handleZyxx(item, '')" class="home-status"><Icon icon="ant-design:file-done-outlined" />批阅作业</a>
                    <a-divider type="vertical"  v-if="item.dpynum == 0 && item.ypynum == 0"/>
                    <a @click="handleDelete(item)" v-if="item.dpynum == 0 && item.ypynum == 0" class="home-status"><Icon icon="ant-design:delete-outlined" />删除</a>
                  </div>
                </div>
              </a-card>
              <a-card
                :title="'第' + item.sort + '次作业(占比' + item.score + '%)'"
                v-if="item.endTime && item.zyStatus == '0'"
                class="cardClass"
                bodyStyle="background: #fff;"
              >
                <template #extra><span class="card-label2">待发布</span> </template>
                <div class="ellip-title">
                  <span class="ellipsis elli-title" :title="item.title">{{ item.title }}</span>
                  <a class="button-zhta" @click="openXkrs(item)">{{ item.xkxs }}人选课</a>
                </div>
                <div style="width: 100%">
                  <div class="ellip-word"
                    ><span class="ellip-word2">作业发布时间：</span
                    >{{ item.startTime ? dayjs(item.startTime).format('YYYY.MM.DD HH:mm') : '未设置' }}</div
                  >
                  <div class="ellip-word"><span class="ellip-word2">作业截止时间：</span>{{ dayjs(item.endTime).format('YYYY.MM.DD HH:mm') }}</div>
                </div>
                <div style="height: 45px">&nbsp;</div>
                <div style="text-align: right; margin-top: 30px">
                  <a @click="handleEdit(item, false)" class="home-status"><Icon icon="ant-design:form-outlined" />编辑作业</a>
                  <a-divider type="vertical" />
                  <a @click="handleFenxiang(item)" class="home-status"><Icon icon="ant-design:share-alt-outlined" />分享</a>
                  <a-divider type="vertical" />
                  <a @click="handleFabu(item)" class="home-status"><Icon icon="ant-design:upload-outlined" />发布作业</a>
                  <a-divider type="vertical" />
                  <a @click="handleDelete(item)" class="home-status"><Icon icon="ant-design:delete-outlined" />删除</a>
                </div>
              </a-card>
            </a-col>
          </a-row>
        </a-col>
      </a-row>
    </div>

    <SzybStudentModal ref="SzybStudentModalpage" @success="handleSuccess"></SzybStudentModal>
    <ZyInfoStudentScoreModal ref="registerScoreModal" @success="handleSuccess"></ZyInfoStudentScoreModal>
    <ZyInfoStudentPiyueModal ref="registerPiyueModal" @success="handleSuccess"></ZyInfoStudentPiyueModal>
    <KcTeachingUnitContentOneListModal ref="registerZcjcModal" @success="handleCheckZcjcSuccess"></KcTeachingUnitContentOneListModal>

    <ZyInfoDetailModal ref="registerDetialModal" @success="handleSuccess"></ZyInfoDetailModal>
    <ZyInfoModal ref="registerModal" @success="handleSuccess"></ZyInfoModal>
    <ZyInfoEditModal ref="registerEditModal" @success="handleSuccess"></ZyInfoEditModal>
    <ZyInfoStudentListModal ref="ZyInfoStudentListModalPage" @success="handleSuccess"></ZyInfoStudentListModal>
    <ZyInfoStudentModal ref="ZyInfoStudentModalPage"></ZyInfoStudentModal>
    <XxhbbksListModal ref="XxhbbksListModalPage"></XxhbbksListModal>
    <YyzyListModal ref="YyzyListModalPage" @success="handleCallYinyong"></YyzyListModal>
    <ZyCyFenxiangListModal ref="ZyCyFenxiangListModalpage"></ZyCyFenxiangListModal>

    <a-modal v-model:visible="imgvisible" title="图片预览" width="800px" :cancelText="`关闭`" :okButtonProps="{ class: { 'jee-hidden': true } }">
      <div style="padding: 10px 20px">
        <a-button type="primary" @click="rotateImage">顺时针旋转</a-button>
        <a-button type="primary" @click="rotateImage2" style="margin-left: 20px">逆时针旋转</a-button>
      </div>
      <div class="image-container">
        <img :src="ylimgurl" :style="{ transform: 'rotate(' + rotationAngle + 'deg)' }" class="rotated-image" />
      </div>
    </a-modal>
  </div>
</template>

<script lang="ts" name="zyInfo-zyInfo" setup>
import { ref, reactive, onMounted, unref } from 'vue';
import { list, deleteOne } from './ZyInfo.api';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import { Input, Popover, Pagination, Empty } from 'ant-design-vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { useRouter } from 'vue-router';
import { JInput } from '/@/components/Form';
import { Form } from 'ant-design-vue';
import { saveOrUpdate } from '/@/views/zy/zyInfo/ZyInfo.api';
import { getValueType } from '/@/utils';
import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
import JEditor from '/@/components/Form/src/jeecg/components/JEditor.vue';
import dayjs, { Dayjs } from 'dayjs';
import { useListPage } from '/@/hooks/system/useListPage';
import { newcolumns } from '/@/views/zy/zyInfoStudent/ZyInfoStudent.data';
import { getList2, getExportUrl, batchFabu,batchFabu2, batchKhcl } from '/@/views/zy/zyInfoStudent/ZyInfoStudent.api';
import { downloadFile } from '/@/utils/common/renderUtils';
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils';
import { useGlobSetting } from '/@/hooks/setting';
import { openByUrl } from '/@/utils/file/download';

import SzybStudentModal from '/@/views/zy/zyInfoStudent/components/SzybStudentModal.vue';
import ZyInfoStudentScoreModal from '/@/views/zy/zyInfoStudent/components/ZyInfoStudentScoreModal.vue';
import ZyInfoStudentPiyueModal from '/@/views/zy/zyInfoStudent/components/ZyInfoStudentPiyueModal.vue';
import KcTeachingUnitContentOneListModal from '/@/views/zy/zyInfo/zyCheckZcjc/KcTeachingUnitContentOneListModal.vue';

import ZyInfoDetailModal from './components/ZyInfoDetailModal.vue';
import ZyInfoModal from './components/ZyInfoModal.vue';
import ZyInfoStudentListModal from '/@/views/zy/zyInfoStudent/ZyInfoStudentListModal.vue';
import ZyInfoStudentModal from '/@/views/zy/zyInfoStudent/components/ZyInfoStudentModal.vue';
import XxhbbksListModal from '/@/views/kc/xxhbbks/XxhbbksListModal.vue';
import ZyInfoEditModal from './components/ZyInfoEditModal.vue';
import YyzyListModal from '/@/views/zy/zyInfo/YyzyListModal.vue';
import ZyCyFenxiangListModal from '/@/views/zy/zyCyFenxiang/ZyCyFenxiangListModal.vue';
import { encryptByBase64 } from '/@/utils/cipher';

const globSetting = useGlobSetting();
const baseApiUrl = globSetting.domainUrl;
//当前路由信息
const { currentRoute } = useRouter();
const { query } = unref(currentRoute);
const { rwbh, xqxn, type, teano } = query; //获取传递参数
const APagination = Pagination;
const { createConfirm, createMessage } = useMessage();
const queryParam = ref<any>({ rwbh });
const queryParamZy = ref<any>({});
const registerModal = ref();
const current = ref<number>(0);
const total = ref<number>(0);
const pageNo = ref<number>(0);
const pageSize = ref<number>(100);
const tableData = ref<any>([]);
const showType = ref<number>(0);
const zycs = ref<number>(0);
const otherKszb = ref<number>(0);
const kczyzb = ref<number>(0);
const qmkszb = ref<number>(0);
const ktcyzb = ref<number>(0);

const zycsDisabled = ref<boolean>(false);
const zyInfo = ref<any>({});
const formRef = ref();
const confirmLoading = ref<boolean>(false);
const zyyqShow = ref<boolean>(false);
const pfbzShow = ref<boolean>(false);
const sfccShow = ref<boolean>(false);
const editDisabled = ref<boolean>(false);
const imgvisible = ref<boolean>(false);
const queryType = ref<string>('');

const dataKhnr = ref<any>([]);
const tableCcjgData = ref<any>([]);
const tableXshpData = ref<any>([]);
const rowSelectionKhnr = ref<any>([]);
const ylimgurl = ref<any>('');
const rotationAngle = ref(0);

const SzybStudentModalpage = ref();
const registerScoreModal = ref();
const registerZcjcModal = ref();

const ZyInfoStudentListModalPage = ref();
const ZyInfoStudentModalPage = ref();
const XxhbbksListModalPage = ref();
const registerEditModal = ref();
const registerDetialModal = ref();
const registerPiyueModal = ref();
const YyzyListModalPage = ref();
const ZyCyFenxiangListModalpage = ref();
const pdfUrl = ref('/downPath/ylhpsf.pdf');
//注册table数据
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
  tableProps: {
    api: getList2,
    columns: newcolumns,
    canResize: false,
    useSearchForm: false,
    pagination: {
      current: 1,
      pageSize: 10,
    },
    actionColumn: {
      width: '200px',
      fixed: 'right',
    },
    showTableSetting: true,
    defSort: {
      field: 'name',
      order: 'ascend',
    },
    beforeFetch: (params) => {
      // params.column = 'publishTime',params.order = 'desc';//新生成的默认不带排序
      return Object.assign(params, queryParam.value);
    },
  },
  exportConfig: {
    name: '学生作业信息',
    url: getExportUrl,
    params: () => {
      return Object.assign({}, queryParam.value);
    },
  },
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] =
  tableContext;
//设置作业删除功能
const disabledDate = (current: Dayjs) => {
  return current && current < dayjs().subtract(1, 'days').endOf('day');
};
const useForm = Form.useForm;

//引用作业
function handleYyzy() {
  var params = { xqxn, rwbh };
  YyzyListModalPage.value.disableSubmit = true;
  YyzyListModalPage.value.init(params);
}
//引用作业回调
function handleCallYinyong(record) {
  console.log('👯‍♂️', record);
  var zysort = zyInfo.value.sort; //防止顺序错误
  var zyid = zyInfo.value.id; //替换原来的id，防止新增
  var createBy = zyInfo.value.createBy;//替换原来的id，防止新增
  var rwbh = zyInfo.value.rwbh;//替换原来的id，防止新增
  record.id = zyid;
  record.sort = zysort;
  record.zyLeixing = '0'; //作业类型，课程作业
  zyInfo.value = record;
  zyInfo.value.createBy = createBy
  zyInfo.value.rwbh = rwbh
  zyInfo.value.zyStatus = "0"
  console.log('😠', zyInfo);
}
//分享给他人
function handleFenxiang(record){
  // console.log(record);
  record.type="0";
  ZyCyFenxiangListModalpage.value.init(record)
  ZyCyFenxiangListModalpage.value.disableSubmit = true;
  // defHttp.get({url:'/zyInfoStudent/zyInfoStudent/cxccByZyId'}).then(res=>{
  //   console.log("🚀 ~ defHttp.get ~ res:", res)
    
  // })
}

//选择是否允许学生查看
function handleXshpkg(record) {
  console.log('👨‍👧‍👦', record);
}
//选择作业截止时间
function handleEndTime(record) {
  console.log('👽', record);
  zyInfo.value.xshpkssj = record;
}
//微信提醒
function handleWxtx(record) {
  defHttp.post({ url: '/zyInfo/zyInfo/sendWxtx', params: { id: record.id } }).then((res) => {
    console.log('👣', res);
  });
  createMessage.success('发送成功');
}
//图片旋转 顺时针旋转
function rotateImage() {
  rotationAngle.value += 90; // 每次点击旋转90度
}
//图片旋转 逆时针旋转
function rotateImage2() {
  rotationAngle.value -= 90; // 每次点击旋转90度
}
//成绩百分比
function handleJscjbfb() {
  var list = tableData.value;

  var cjbfb = qmkszb.value; //成绩百分比
  var cjbfb2 = kczyzb.value; //成绩百分比
  var zcj = 0;
  var score22 = 0;
  for (var i = 0; i < list.length; i++) {
    console.log('🥵', list);
    var score = list[i].score;
    if (score == null || score + '' == '') {
      createMessage.error('第' + (i + 1) + '次作业总成绩的百分比不能为空！');
      break;
    }
    score22 = parseInt(score22) + parseInt(score);
    if (score < 0 || score > 100) {
      createMessage.error('作业成绩百分比必须在0-100之间！');
      break;
    }
    if (score22 > 100) {
      createMessage.error('作业总的百分比（课程作业占比+期末考试占比+课堂测验占比）已经超过100%，请重新输入');
      break;
    }
  }
  zcj = parseInt(score22) + parseInt(cjbfb) + parseInt(cjbfb2);
  if (zcj > 100) {
    createMessage.error('作业总的百分比（课程作业占比+期末考试占比+课堂测验占比）已经超过100%，请重新输入');
  }
}

//获取查重结果
function handleViewInfo(record) {
  defHttp.get({ url: '/zyCcjg/zyCcjg/ccjglist', params: { zyStuId: record.id } }).then((res) => {
    console.log('🤦‍♀️', res);
    tableCcjgData.value = res;
  });
  handleShowType(4);
}
//教师修改作业分数
function handleChangeScore(record) {
  console.log('👯', record);
  var score = record.score;
  console.log('👝', score);
  console.log('👝', isNaN(score));
  if (isNaN(score)) {
    createMessage.error('请输入正确的评分1');
    return;
  } else if (parseInt(score) > 100 || parseInt(score) < 0) {
    createMessage.error('请输入正确的评分2');
    return;
  }

  defHttp.post({ url: '/zyInfoStudent/zyInfoStudent/editFabu', params: { id: record.id, score: record.score } }).then((res) => {
    console.log('😮', res);
    handleSuccess();
  });
}

//学生互评详细
function handleXshpfs(record) {
  defHttp.get({ url: '/zyInfoStudentHp/zyInfoStudentHp/list', params: { zyStuId: record.id, pageSize: -1 } }).then((res) => {
    console.log('🤦‍♀️', res);
    tableXshpData.value = res.records;
    console.log('😒', res.records);
    console.log('👨‍🦰', tableXshpData.value);
  });
  handleShowType(5);
}

//产看论文报告
function handleOpenLwxx(record) {
  window.open(record.paperviewurl, '_blank');
}

//选择章次节次后的回调
function handleCheckZcjcSuccess(record) {
  console.log('🙅‍♂️', record);
  console.log('🙅‍♂️', record[0]);
  var kcnr = '';
  kcnr = kcnr ? kcnr : '';
  for (var i = 0; i < record.length; i++) {
    kcnr = kcnr + record[i] + ',';
  }
  if (kcnr.indexOf(',') > -1) {
    kcnr = kcnr.substring(0, kcnr.length - 1);
  }
  zyInfo.value.kcnr = kcnr;

  console.log('💑', kcnr);
  if (kcnr) {
    defHttp.get({ url: '/teachingunitcontent/kcTeachingUnitContentOne/getAllList', params: { id: kcnr } }).then((res) => {
      console.log('🤦‍♀️', res);
      dataKhnr.value = res;
    });
  } else {
    dataKhnr.value = [];
  }
}

//选择考察内容
function handleKcnr() {
  registerZcjcModal.value.disableSubmit = false;
  registerZcjcModal.value.init({ rwbh, xnxq: xqxn, createBy: teano });
  // defHttp.get({ url: '/teachingunitcontent/kcTeachingUnitContentOne/getAllList', params: { rwbh, xnxq: xqxn, createBy: teano } }).then((res) => {
  //   console.log('🤦‍♀️', res);
  //   dataKhnr.value = res;
  // });
}

/**
 * 作业详情查询
 */
function searchQueryZyxq() {
  selectedRowKeys.value = [];

  // queryParam.value.mainId = zyInfo.value.id;
  queryParam.value.queryType = queryType.value;
  reload();
}

//新增一次作业
function handleAddOne() {
  defHttp.post({ url: '/zyInfo/zyInfo/addOne', params: { rwbh, xnxq: xqxn, teano, zyLeixing: '0' } }).then((res) => {
    handleSuccess2();
  });
}

//撤回发布
function handleNoScoreFabu(record: Recordable) {
  createConfirm({
    iconType: 'warning',
    title: '撤回发布',
    content: '<span style="color:red;font-size:16px">您已面向学生发布，是否确定撤回评分</span>',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      defHttp.post({ url: '/zyInfoStudent/zyInfoStudent/editFabu', params: { id: record.id, scoreFabu: '0' } }).then((res) => {
        handleSuccess();
      });
    },
  });
}

//设置样本
function handleSzyb(record: Recordable) {
  SzybStudentModalpage.value.disabled = false;
  SzybStudentModalpage.value.edit(record);
}
//下载
function handleDown(text) {
  downloadFile(text);
}
//预览
function yulanFile(record) {
  console.log('🙇‍♀️', record);
  if (record.pdfPath) {
    var url2 = getFileAccessHttpUrl(record.pdfPath);
    let url = baseApiUrl + '/generic/web/viewer.html?file=' + encodeURIComponent(url2);
    window.open(url, '_blank');
  } else {
    const parts = record.filePath.split('.');
    const filetype = parts[parts.length - 1];
    if (filetype == 'jpg' || filetype == 'png' || filetype == 'jpeg' || filetype == 'xls' || filetype == 'xlsx' || filetype == 'text') {
      imgvisible.value = true;
      var url2 = getFileAccessHttpUrl(record.filePath);
      console.log('👀', url2);
      ylimgurl.value = url2;
      // var file = baseApiUrl + "/"+record.filePath;
      // console.log('🤬', file);
      // window.open('https://jxdd.nenu.edu.cn/onlinePreview/onlinePreview?url=' + encodeURIComponent(encryptByBase64(file)));

      // var url2 = getFileAccessHttpUrl(record.filePath);
      // let url = baseApiUrl + '/generic/web/viewer.html?file=' + encodeURIComponent(url2);
      // window.open(url, '_blank');
    } else if (filetype == 'doc' || filetype == 'docx' || filetype == 'pdf') {
      var url2 = getFileAccessHttpUrl(record.pdfPath);
      let url = baseApiUrl + '/generic/web/viewer.html?file=' + encodeURIComponent(url2);
      window.open(url, '_blank');
    } else {
      createMessage.error('当前作业不支持预览，请下载后查阅！');
    }
  }
}
//驳回
function handleBohui(record: Recordable) {
  createConfirm({
    iconType: 'warning',
    title: '驳回',
    content: '您确定驳回此作业吗，驳回后需要学生重新提交？',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      defHttp.post({ url: '/zyInfoStudent/zyInfoStudent/editBohui', params: { id: record.id } }).then((res) => {
        handleSuccess();
      });
    },
  });
}
//填写评分
function handleScore(record: Recordable) {
  registerScoreModal.value.disableSubmit = false;
  registerScoreModal.value.edit(record);
}
//发布确定评分
function handleScoreFabu(record: Recordable) {
  //判断
  if (!record.score) {
    createMessage.warn('请填写评分！');
    return;
  }
  defHttp.post({ url: '/zyInfoStudent/zyInfoStudent/editFabu', params: { id: record.id, scoreFabu: '1' } }).then((res) => {
    handleSuccess();
  });
}
//教师批阅作业
function handlepiyue(record: Recordable) {
  registerPiyueModal.value.disableSubmit = true;
  registerPiyueModal.value.edit(record);
}

/**
 * 操作栏
 */
function getTableAction(record) {
  if (record.filePath) {
    if (record.scoreFabu == '1') {
      let list = [
        {
          label: '撤回发布',
          onClick: handleNoScoreFabu.bind(null, record),
        },
        // {
        //   label: '标记作业',
        //   onClick: handleSzyb.bind(null, record),
        // },
        {
          label: '下载',
          onClick: handleDown.bind(null, record.filePath),
        },
        {
          label: '预览',
          onClick: yulanFile.bind(null, record),
        },
      ];
      return list;
    } else {
      let list = [
        {
          label: '驳回',
          onClick: handleBohui.bind(null, record),
        },
        {
          label: '批阅',
          onClick: handlepiyue.bind(null, record),
        },
        // {
        //   label: record.score ? '修改评分' : '评分',
        //   onClick: handleScore.bind(null, record),
        // },
        // {
        //   label: '发布评分',
        //   onClick: handleScoreFabu.bind(null, record),
        // },
        {
          label: '下载',
          onClick: handleDown.bind(null, record.filePath),
        },
        {
          label: '预览',
          onClick: yulanFile.bind(null, record),
        },
      ];
      return list;
    }
  } else {
    let list = [];
    return list;
  }
}

//发布作业评分
async function batchHandleFabu() {
  console.log('🧐', { id: zyInfo.value.id });
  defHttp.post({ url: '/zyInfoStudent/zyInfoStudent/getNoScore', params: { id: zyInfo.value.id } }).then((res) => {
    console.log('🦴', res);
    var list = res;
    console.log('🧚‍♀️', list.length);
    if (list.length > 0) {
      var studentName = '';
      for (var i = 0; i < list.length; i++) {
        studentName = studentName + list[i].studentName + '、';
      }
      createConfirm({
        iconType: 'warning',
        title: '确认发布',
        content: '当前学生：' + studentName + '没有给与评分，<span style="color:red;font-size:14px;font-weight:700;">若继续发布成绩，学生成绩为0</span>，是否发布成绩数据',
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          batchFabu2({ id: zyInfo.value.id }, handleBatchSuccess);
        },
      });
    } else {
      createConfirm({
        iconType: 'warning',
        title: '确认发布',
        content: '是否发布成绩数据',
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          batchFabu2({ id: zyInfo.value.id }, handleBatchSuccess);
        },
      });
    }
    // handleSuccess();
  });

  // if (selectedRowKeys.value.length == 0) {
  //   createMessage.warn('请勾选要发布的数据！');
  //   return;
  // }

  // var datapar2 = rowSelection.selectedRows;
  // console.log('👌', datapar2);
  // var sfjx = '0';
  // for (var i = 0; i < datapar2.length; i++) {
  //   var score = datapar2[i].score;
  //   if (!score) {
  //     sfjx = '1';
  //     break;
  //   }
  // }
  // if (sfjx == '1') {
  //   createMessage.warning('您有未填写的评分信息，不可一键发布，请检查您的评分数据！');
  //   return;
  // } else {
  //   await batchFabu({ ids: selectedRowKeys.value }, reload);
  // }
}

function handleBatchSuccess() {
  //正常刷新列表
  reload();
  //提交校内查重记录
  defHttp.post({ url: '/zyInfoStudent/zyInfoStudent/xnccBatchWeipu', params: { id: zyInfo.value.id } }).then((res) => {});
}

function batchHandleKhcl() {
  if (selectedRowKeys.value.length == 0) {
    createMessage.warn('请勾选要上传的数据！');
    return;
  }
  batchKhcl({ ids: selectedRowKeys.value }, reload);
}

//
//表单验证
const validatorRules = {
  title: [{ required: true, message: '请输入作业名称!' }],
  endTime: [{ required: true, message: '请输入结束时间!' }],
  pfbz: [{ required: true, message: '请输入评分标准!' }],
};
const { resetFields, validate, validateInfos } = useForm(zyInfo, validatorRules, { immediate: true });
const labelCol = reactive({
  xs: { span: 24 },
  sm: { span: 4 },
});
const wrapperCol = reactive({
  xs: { span: 24 },
  sm: { span: 16 },
});
const labelCol2 = reactive({
  sm: { span: 6 },
});
const wrapperCol2 = reactive({
  sm: { span: 18 },
});
const labelCol3 = reactive({
  sm: { span: 4 },
});
const wrapperCol3 = reactive({
  sm: { span: 20 },
});
const labelCol4 = reactive({
  sm: { span: 10 },
});
const wrapperCol4 = reactive({
  sm: { span: 12 },
});
//作业要求切换
function handleZyyqShow(type) {
  if (type == 1) {
    zyyqShow.value = true;
  } else {
    zyyqShow.value = false;
  }
}
//评分标准切换
function handlePfbzShow(type) {
  if (type == 1) {
    pfbzShow.value = true;
  } else {
    pfbzShow.value = false;
  }
}
//尚未布置作业题目及具体要求
function handleSzzynr(record) {
  zyInfo.value = record;
  dataKhnr.value = [];
  handleShowType(2);
}
//批量进行保存
function handleBatchAdd() {
  var list = tableData.value;
  var sfjx = 0; //是否继续
  var cjbfb = qmkszb.value; //成绩百分比
  var cjbfb2 = ktcyzb.value; //成绩百分比
  var zcj = 0;

  var score22 = 0;
  if (list.length == 0) {
    createMessage.error('作业次数不能为空！');
    return;
  }
  for (var i = 0; i < list.length; i++) {
    console.log('🥵', list);
    var score = list[i].score;
    if (score == null || score + '' == '') {
      createMessage.error('第' + (i + 1) + '次作业总成绩的百分比不能为空！');
      sfjx = 1;
      break;
    }
    if (score < 0 || score > 100) {
      createMessage.error('作业成绩百分比必须在0-100之间！');
      sfjx = 1;
      break;
    }
    score22 = parseInt(score22) + parseInt(score);
    if (score22 > 100) {
      createMessage.error('作业总的百分比（课程作业占比+期末考试占比+课堂测验占比）已经超过100%，请重新输入');
      sfjx = 1;
      break;
    }
  }

  zcj = parseInt(score22) + parseInt(cjbfb) + parseInt(cjbfb2);

  if (zcj > 100) {
    createMessage.error('作业总的百分比（课程作业占比+期末考试占比+课堂测验占比）已经超过100%，请重新输入');
    sfjx = 1;
  }
  if (sfjx == 1) {
    return;
  }

  createConfirm({
    iconType: 'warning',
    title: '确认保存',
    content: '设置完课程作业次数后，需要对每次作业的内容和要求进行设置，然后进行发布',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      defHttp.post({ url: '/zyInfo/zyInfo/batchAdd', data: list }).then((res) => {
        reloadZy();
      });
    },
  });
}

function handleSzzycs(val) {
  defHttp.get({ url: '/zyInfo/zyInfo/zyzb', params: { rwbh, xqxn, teano, zyLeixing: '1' } }).then((res) => {
    console.log('😥', res);
    var list = res;
    for (var i = 0; i < list.length; i++) {
      if (list[i].zyLeixing == '0') {
        kczyzb.value = list[i].score;
      } else if (list[i].zyLeixing == '1') {
        qmkszb.value = list[i].score;
      } else if (list[i].zyLeixing == '2') {
      } else if (list[i].zyLeixing == '3') {
        ktcyzb.value = list[i].score;
      }
    }
  });
  handleShowType(1);
}

//显示第几个类型模块
function handleShowType(val) {
  if (tableData.value.length > 0) {
    zycsDisabled.value = true;
  } else {
    zycsDisabled.value = false;
  }
  console.log('👩‍👩‍👧‍👧', zycsDisabled);

  showType.value = val;
}
//新增一次作业，再最后面添加
function handleAddZycs() {
  var changeZycs = zycs.value;
  zycs.value = changeZycs + 1;
  handleZycs();
}
//删除指定第几次作业
function handleDelZycs(index) {
  var dataList = tableData.value;
  dataList.splice(index - 1, 1);
  tableData.value = dataList;
  zycs.value = dataList.length;
  handleZycs();
}
//动态添加作业次数
function handleZycs() {
  var dataList = tableData.value;
  var changeZycs = zycs.value;
  if (changeZycs > dataList.length) {
    for (var i = dataList.length; i < changeZycs; i++) {
      dataList.push({
        sort: i + 1,
        lstitle: '第' + (i + 1) + '次作业',
        score: '',
        rwbh: rwbh,
        xqxn: xqxn,
        createBy: teano,
      });
    }
  } else if (changeZycs < dataList.length) {
    for (var i = dataList.length; i > changeZycs; i--) {
      dataList.pop();
    }
  } else {
    for (let i = 0; i < dataList.length; i++) {
      var ppar = dataList[i];
      ppar.sort = i + 1;
      dataList[i] = ppar;
    }
  }
  tableData.value = dataList;
}

/**
 * 提交数据
 */
async function submitForm() {
  // 触发表单验证
  await validate();
  confirmLoading.value = true;
  const isUpdate = ref<boolean>(false);
  //时间格式化
  let model = zyInfo.value;
  if (model.id) {
    isUpdate.value = true;
  }
  //循环数据
  for (let data in model) {
    //如果该数据是数组并且是字符串类型
    if (model[data] instanceof Array) {
      let valueType = getValueType(formRef.value.getProps, data);
      //如果是字符串类型的需要变成以逗号分割的字符串
      if (valueType === 'string') {
        model[data] = model[data].join(',');
      }
    }
  }
  console.log('👕', model);

  var xshpkg = model.xshpkg;
  if (xshpkg == '1') {
    var sfzzcj = model.sfzzcj;
    if (!sfzzcj) {
      createMessage.warning('请先设置互评成绩是否为最终成绩！');
      confirmLoading.value = false;
      return;
    }
    var xssfck = model.xssfck;
    if (!xssfck) {
      createMessage.warning('请先设置是否允许学生看到互评成绩！');
      confirmLoading.value = false;
      return;
    }
    var xshpkssj = model.xshpkssj;
    if (!xshpkssj) {
      createMessage.warning('请先设置互评开始时间！');
      confirmLoading.value = false;
      return;
    }
    var xshpjssj = model.xshpjssj;
    if (!xshpjssj) {
      createMessage.warning('请先设置互评结束时间！');
      confirmLoading.value = false;
      return;
    }
  }

  var wwtgl = model.wwtgl;
  var wwcc = model.wwcc;
  var xncc = model.xncc;
  var nwcc = model.nwcc;
  var aigccc = model.aigccc;
  var sfcc = model.sfcc;
  console.log('🚶‍♂️', model);
  if (sfcc == '1') {
    //开启查重再进行验证，否则不进行验证
    if (wwtgl) {
      if ((wwcc == false && xncc == false && nwcc == false && aigccc == false) || (!wwcc && !xncc && !nwcc && !aigccc)) {
        createMessage.warning('您设置了检测通过率，但您没有设置查重比对库，请先设置查重比对库！');
        confirmLoading.value = false;
        return;
      }
      console.log('1111111111', wwtgl, wwcc, xncc, aigccc);
    } else {
      console.log('22222222222', wwtgl, wwcc, xncc, aigccc);
      if (wwcc == true || xncc == true || nwcc == true || aigccc == true || wwcc == 'true' || xncc == 'true' || nwcc == 'true' || aigccc == 'true') {
        createMessage.warning('您设置了查重比对库，但您没设置检测通过率，请先设置检测通过率');
        confirmLoading.value = false;
        return;
      }
    }
  } else {
    //如果不进行查重，则强制清空查重配置数据
    model.wwtgl = null;
    model.wwcc = null;
    model.xncc = null;
    model.nwcc = null;
    model.aigccc = null;
  }

  var xshpkssj = model.xshpkssj;
  var xshpjssj = model.xshpjssj;
  if (xshpkssj && xshpjssj) {
    var xshpkssjTimestamp = Date.parse(xshpkssj);
    var xshpjssjTimestamp = Date.parse(xshpjssj);
    if (xshpkssjTimestamp > xshpjssjTimestamp) {
      createMessage.warning('作业截止时间不能大于互评结束时间！');
      confirmLoading.value = false;
      return;
    }
  }

  var endTime = model.endTime;
  var startTime = model.startTime;
  if (endTime && startTime) {
    var endTimestamp = Date.parse(endTime);
    var startTimestamp = Date.parse(startTime);
    if (endTimestamp < startTimestamp) {
      createMessage.warning('作业发布时间不能大于作业截止时间！');
      confirmLoading.value = false;
      return;
    }
  }

  if (xshpkssj && endTime) {
    var endTimestamp = Date.parse(xshpkssj);
    var startTimestamp = Date.parse(endTime);
    if (endTimestamp < startTimestamp) {
      createMessage.warning('互评开始间不能小于作业截止时间！');
      confirmLoading.value = false;
      return;
    }
  }

  await saveOrUpdate(model, isUpdate.value)
    .then((res) => {
      if (res.success) {
        createMessage.success(res.message);
        reloadZy();
      } else {
        createMessage.warning(res.message);
      }
    })
    .finally(() => {
      confirmLoading.value = false;
    });
}

const columns = [
  {
    title: '序号',
    dataIndex: 'sort',
    key: 'sort',
  },
  {
    title: '作业次数',
    dataIndex: 'lstitle',
    key: 'lstitle',
  },
  {
    title: '本次作业占总成绩的百分比',
    dataIndex: 'score',
    key: 'score',
  },
  {
    title: '操作',
    key: 'action',
  },
];

const columnsCcjg = [
  {
    title: '序号',
    dataIndex: 'no',
    key: 'no',
    customRender: (text) => {
      return text.index + 1;
    },
    width: 80,
  },
  {
    title: '学生姓名',
    dataIndex: 'stuName',
    key: 'stuName',
  },
  {
    title: '学生学号',
    dataIndex: 'stuNo',
    key: 'stuNo',
  },

  {
    title: '比对库',
    dataIndex: 'bdkname',
    key: 'bdkname',
  },
  {
    title: '是否查重',
    dataIndex: 'ccType',
    key: 'ccType',
    customRender: (text) => {
      return '是';
    },
  },
  {
    title: '查重率（%）',
    dataIndex: 'percentage',
    key: 'percentage',
  },
  {
    title: '操作',
    key: 'action',
  },
];

const columnsXshp = [
  {
    title: '序号',
    dataIndex: 'no',
    key: 'no',
    customRender: (text) => {
      return text.index + 1;
    },
    width: 80,
  },
  {
    title: '学生姓名',
    dataIndex: 'stuName',
    key: 'stuName',
  },
  {
    title: '学生学号',
    dataIndex: 'stuId',
    key: 'stuId',
  },

  {
    title: '互评时间',
    dataIndex: 'createTime',
    key: 'createTime',
  },
  {
    title: '互评分数',
    dataIndex: 'stuScore',
    key: 'stuScore',
  },
];

const columnsKhnr = [
  {
    title: '序号',
    dataIndex: 'no',
    key: 'no',
    customRender: (text) => {
      return text.index + 1;
    },
    width: 80,
  },
  {
    title: '章次',
    dataIndex: 'title',
    key: 'title',
  },
  {
    title: '节次',
    dataIndex: 'twoTitle',
    key: 'twoTitle',
  },
];

function classFun(type) {
  if (type == '0') {
    return 'background: #fe1a1a';
  } else if (type == '1') {
    return 'background: #c6c209';
  } else if (type == '2') {
    return 'background: #18a689';
  }
}
/**
 * 新增事件
 */
function handleAdd() {
  registerModal.value.disableSubmit = false;
  registerModal.value.add();
}

function handleChehui(record) {
  createConfirm({
    iconType: 'warning',
    title: '撤回作业',
    content: '您确认撤回此次作业吗？',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      defHttp
        .post({
          url: '/zyInfo/zyInfo/editChehui',
          params: { id: record.id },
        })
        .then((res) => {
          createMessage.success(res.message);
          handleSuccess2();
        });
    },
  });
}

/**
 * 编辑事件
 */
function handleEdit(record, type) {
  if (!record.sturead) {
    record.sturead = '1';
  }
  if (!record.xshpkg) {
    record.xshpkg = '1';
  }
  if (!record.sfzzcj) {
    record.sfzzcj = '1';
  }
  if (!record.sfcc) {
    record.sfcc = '1';
  }
  if (!record.xssfck) {
    record.xssfck = '1';
  }
  editDisabled.value = type;
  zyInfo.value = record;
  console.log('👨‍👦', zyInfo.value);
  if (zyInfo.value.xncc == 'false') {
    zyInfo.value.xncc = null;
  }
  if (zyInfo.value.nwcc == 'false') {
    zyInfo.value.nwcc = null;
  }
  if (zyInfo.value.wwcc == 'false') {
    zyInfo.value.wwcc = null;
  }
  if (zyInfo.value.aigccc == 'false') {
    zyInfo.value.aigccc = null;
  }
  dataKhnr.value = [];
  var kcnr = zyInfo.value.kcnr;
  if (kcnr) {
    defHttp.get({ url: '/teachingunitcontent/kcTeachingUnitContentOne/getAllList', params: { id: kcnr } }).then((res) => {
      dataKhnr.value = res;
    });
  }
  handleShowType(2);
}

function handleBjzy(record) {
  registerEditModal.value.disableSubmit = false;
  registerEditModal.value.edit(record);
}

/**
 * 详情
 */
function handleDetail(record: Recordable) {
  registerDetialModal.value.disableSubmit = true;
  registerDetialModal.value.edit(record);
}

//批阅作业信息
function handleZyxx(record, type) {
  if (type == '1') {
    if (!record.wtjnum || record.wtjnum == '0') {
      createMessage.error('当前人数为0，不能进行查询');
      return;
    }
  } else if (type == '2') {
    if (!record.ytjnum || record.ytjnum == '0') {
      createMessage.error('当前人数为0，不能进行查询');
      return;
    }
  } else if (type == '3') {
    if (!record.wpynum || record.wpynum == '0') {
      createMessage.error('当前人数为0，不能进行查询');
      return;
    }
  } else if (type == '4') {
    if (!record.ypynum || record.ypynum == '0') {
      createMessage.error('当前人数为0，不能进行查询');
      return;
    }
  } else if (type == '4') {
    if (!record.dpynum || record.dpynum == '0') {
      createMessage.error('当前人数为0，不能进行查询');
      return;
    }
  }

  zyInfo.value = record;
  handleShowType(3);
  queryType.value = type;
  rowSelection.value = [];
  selectedRowKeys.value = [];
  console.log('🧟‍♀️', rowSelection);
  queryParam.value = {};
  queryParam.value.ywid = record.id;
  queryParam.value.rwbh = rwbh;
  queryParam.value.queryType = type;
  reload();
}

//获取选课人数
function openXkrs(record) {
  console.log(`🚀 ~ openXkrs ~ record:`, record);
  XxhbbksListModalPage.value.disableSubmit = true;
  XxhbbksListModalPage.value.init(record);
}

/**
 * 删除事件
 */
async function handleDelete(record) {
  if (record.endTime) {
    createConfirm({
      iconType: 'warning',
      title: '删除',
      content: '您已经对作业的内容和要求进行了设置，如果继续删除，内容和要求将一并删除，确认进行删除吗？',
      okText: '确认',
      cancelText: '取消',
      onOk: () => {
        deleteOne({ id: record.id }, handleSuccess2);
      },
    });
  } else {
    deleteOne({ id: record.id }, handleSuccess2);
  }
}

//发布作业
async function handleFabu(record) {
  createConfirm({
    iconType: 'warning',
    title: '确认发布',
    content: '是否发布作业数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      var url = '/zyInfo/zyInfo/release';
      var params = { id: record.id, zyStatus: '1' };
      defHttp.post({ url: url, params }).then((res) => {
        handleZySuccess(record.id);
      });
    },
  });
}

/**
 * 成功回调,用于删除
 */
function handleSuccess2() {
  total.value = 1;
  handlePageChange(1);
}

/**
 * 成功回调，用于增加、修改、发布和撤回
 */
function handleSuccess() {
  searchQueryZyxq();
}

function handleZySuccess(zyid) {
  setTimeout(() => {
    handleSuccess2();
  }, 1500);
  var url = '/zyInfo/zyInfo/editStudent';
  defHttp.get({ url: url, params: { id: zyid } }).then((res) => {});

  defHttp.get({ url: '/zyInfo/zyInfo/sendZyWechat', params: { id: zyid } }).then((res) => {});
}

/**
 * 查询
 */
function searchQuery() {
  total.value = 1;
  handlePageChange(1);
}

/**
 * 重置
 */
function searchReset() {
  queryParam.value = {};
  queryParam.value.queryType = queryType.value;
  queryParam.value.rwbh = rwbh;
  queryParam.value.ywid = zyInfo.value.id;
  console.log(`🚀 ~ searchReset ~ rwbh:`, rwbh);
  total.value = 1;
  searchQueryZyxq();
}

//查询列表数据
function reloadZy() {
  queryParamZy.value.pageNo = current.value;
  queryParamZy.value.pageSize = pageSize.value;
  queryParamZy.value.rwbh = rwbh;
  queryParamZy.value.xnxq = xqxn;
  // queryParamZy.value.teano = teano;
  queryParamZy.value.zyLeixing = '0';
  // queryParamZy.value.column = 'a.sort';
  // queryParamZy.value.order = 'asc';
  defHttp.get({ url: '/zyInfo/zyInfo/list', params: queryParamZy.value }).then((res) => {
    console.log(`🚀 ~ defHttp.get ~ res:`, res);

    total.value = res.total;
    pageNo.value = res.pages;
    current.value = res.current;
    tableData.value = res.records;
    zycs.value = tableData.value.length;
    if (tableData.value.length > 0) {
      showType.value = 999;
    } else {
      showType.value = 0;
    }
  });
}

function handlePageChange(record) {
  current.value = record;
  reloadZy();
}

onMounted(() => {
  searchQuery();
});
</script>

<style lang="less" scoped>
.title {
  margin-left: 20px;
  font-size: 16px;
  font-weight: bold;
}
.title2 {
  font-size: 16px;
  font-weight: bold;
}
.ant-divider-horizontal {
  display: flex;
  clear: both;
  width: 100%;
  min-width: 100%;
  margin: 3px 0 5px;
}
.tishi {
  width: 100%;
  font-size: 12px;
  color: #fd8f02;
  margin-top: -4px;
  background: #fffbf2;
  text-align: center;
  padding: 6px 0;
}
.cardClass {
  min-height: 200px;
}
.sznrClass {
  line-height: 40px;
  text-align: center;
}
.ant-card {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  color: rgb(0 0 0);
  font-size: 14px;
  font-variant: tabular-nums;
  line-height: 1.5715;
  list-style: none;
  font-feature-settings: tnum;
  position: relative;
  border-radius: 5px;
  border: 1px solid #f0f0f0;
  background: #f7f7f7;
}
.ant-card:hover {
  box-sizing: border-box;
  box-shadow: 2px 2px 10px 1px #d4d4d4;
}
.ant-card-head {
  min-height: 48px;
  margin-bottom: -1px;
  padding: 0 24px;
  color: rgba(0, 0, 0, 0.85);
  font-weight: 500;
  font-size: 16px;
  background: transparent;
  border-bottom: 1px solid #dadada;
  border-radius: 2px 2px 0 0;
}
.ellipsis {
  overflow: hidden; /* 确保超出容器的内容被裁剪 */
  white-space: nowrap; /* 确保文本在一行内显示 */
  text-overflow: ellipsis; /* 超出部分显示省略号 */
}
.ellip-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: -10px;
}
.elli-title {
  font-size: 16px;
  font-weight: bold;
}
.ellip-word {
  font-size: 12px;
  color: #666666;
  margin-right: 10px;
}
.ellip-word2 {
  font-size: 12px;
  color: #333;
  font-weight: bold;
}
.zuanqu:hover {
  cursor: pointer;
  color: #18a689;
  background: #eff6f4;
}
.data-suggest {
  display: flex;
  flex-direction: column;
  text-align: center;
  width: 25%;
  margin-right: 5px;
  padding: 8px 3px;
  border-radius: 5px;
  background: #f7f7f7;
  margin-top: 10px;
}
.data-suggest span:nth-child(1) {
  font-size: 16px;
  font-weight: bold;
}
.data-suggest span:nth-child(2) {
  font-size: 12px;
}
.work-img {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 80px;
  margin-bottom: 30px;
}
.work-img-img {
  width: 180px;
  height: 139px;
}
.buttonClass {
  background: #1ab394;
  font-weight: 600;
  color: #fff;
  border-radius: 3px;
  border: none;
}
.mar-right20 {
  margin-right: 14px;
}
.button-zhta {
  color: #666666;
  cursor: pointer;
}
.button-zhta:hover {
  cursor: pointer;
  color: #18a689;
}
.sear-distance {
  padding: 0 10px;
}
.ant-form-item {
  box-sizing: border-box;
  margin: 10px 0;
  padding: 0;
  color: rgba(0, 0, 0, 0.85);
  font-size: 14px;
  font-variant: tabular-nums;
  line-height: 1.5715;
  list-style: none;
  font-feature-settings: tnum;
  /* margin-bottom: 24px; */
  vertical-align: top;
}
.bled-countenance {
  color: #666;
}
.bled-countenance2 {
  color: #999999;
  font-size: 12px;
}
.region {
  margin: 6px 12px;
  padding-bottom: 20px;
  background: #fff;
  border-radius: 5px;
  border: 1px solid #e6e6e6;
}
.region:hover {
  margin: 6px 12px;
  padding-bottom: 20px;
  background: #fff;
  border-radius: 5px;
  border: 1px solid #e6e6e6;
  box-shadow: 2px 2px 10px 1px #d4d4d4;
}
.region-title {
  font-size: 16px;
  color: #333;
  height: 50px;
  line-height: 50px;
  border-bottom: 1px solid #e1e4eb;
  margin-bottom: 20px;
  display: flex;
}
.region-title-headline {
  display: block;
  width: 5px;
  height: 16px;
  background: #18a689;
  border-radius: 6px;
  margin-top: 18px;
  margin-right: 20px;
}
.module-bg {
  background: #fff;
  border-radius: 6px;
  border: 1px solid #e6e6e6;
}
.home-status {
  color: #1ab394;
}
.home-status:hover {
  color: #333;
}
.card-label {
  background: #81cbbc;
  border-radius: 4px;
  color: #fff;
  padding: 2px 6px;
}
.card-label2 {
  background: #84c4fa;
  border-radius: 4px;
  color: #fff;
  padding: 2px 6px;
}
.card-label3 {
  background: #fabe84;
  border-radius: 4px;
  color: #fff;
  padding: 2px 6px;
}
.zbClass {
  margin-left: 15px;
}
.image-container {
  padding: 10px;
  width: 100%; /* 设置容器宽度 */
  height: auto; /* 设置容器高度 */
  overflow: hidden; /* 隐藏溢出的部分 */
  display: flex;
  align-items: center;
  justify-content: center;
}

.rotated-image {
  max-width: 100%; /* 最大宽度为容器宽度 */
  max-height: 100%; /* 最大高度为容器高度 */
  object-fit: contain; /* 保持图片内容不失真 */
  transform: rotate(90deg); /* 假设图片已经旋转90度 */
}
</style>