<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="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 style="margin-top: 30px" class="ant-btn buttonClass"><a @click="handleShowType(1)">填写教学大纲内容</a></div>
        </a-col>
      </a-row>
    </div>
    <div v-if="showType == 1">
      <a-row>
        <a-col :span="24">
          <span class="title">填写教学大纲内容</span>
          <a-button type="primary" @click="init" style="float: right; margin-right: 8px; margin-top: -1px">
            <Icon icon="ant-design:export-outlined" />返回
          </a-button>
          <a-divider />
        </a-col>
        <a-col :span="24">
          <a-row>
            <a-col :span="24">
              <div style="width: 100%; padding: 2px 20px; font-size:12px; color:#18a689; border-left:3px solid #18a689;"
                ><span>请选择填写的教学大纲版本</span></div
              >
            </a-col>
            <a-col :span="24" class="borderstyle">
              <a-table :columns="jxdgbbColumns" :dataSource="jxdgbbDataSource" :pagination="false">
                <template #bodyCell="{ column, record }">
                  <template v-if="column.key === 'action'">
                    <a-button type="primary" @click="handleCheckBanben(record)">选择</a-button>
                  </template>
                </template>
              </a-table>
            </a-col>
          </a-row>
        </a-col>
        <a-col>
          <a-row>
            <a-col
              :span="23"
              v-for="(item, index) in zyJxdgMainTable.dataSource"
              :key="index"
              class="borderstyle"
            >
              <a-row>
                <a-col :span="24" style="height: 40px; line-height: 40px; background-color: #f0f7f6">
                  <span class="title">{{ item.title }}</span>
                </a-col>
                <!-- 单行文本	1	 -->
                <a-col v-if="item.type === '1'" :span="24">
                  <a-input placeholder="请输入内容" v-model:value="item.content" style="width: 100%;" @blur="handleGlxm(item)"></a-input>
                </a-col>
                <!-- 多行文本	2	 -->
                <a-col v-else-if="item.type === '2'" :span="24">
                  <a-textarea placeholder="请输入内容" v-model:value="item.content" style="width: 100%;"></a-textarea>
                </a-col>
                <!-- 富文本	3	 -->
                <a-col v-else-if="item.type === '3'" :span="24">
                  <j-editor placeholder="请输入内容" v-model:value="item.content" :disabled="disabled" />
                </a-col>
                <!-- 固定表单（基础信息）	4	 -->
                <a-col v-else-if="item.type === '4'" v-model:value="item.content" :span="24" >
                  <a-form v-bind="formItemLayout">
                    <a-row>
                      <a-col v-for="(item2, index2) in item.zyJxdgPzxxList" :key="index2" :span="12">
                        <a-form-item :label="item2.title"
                          ><a-input :placeholder="`请输入` + item2.title" v-model:value="item2.content" 
                        /></a-form-item>
                      </a-col>
                    </a-row>
                  </a-form>
                </a-col>
                <!-- 自增表格	5	 -->
                <a-col v-else-if="item.type === '5'" :span="24">
                  <a-table :columns="getTableColumns(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
                    <template #bodyCell="{ column, record }">
                      <a-input placeholder="请输入内容" v-model:value="record[column.key]" style="width: 80%;"></a-input>
                    </template>
                  </a-table>
                </a-col>
                <!-- 自增单行文本	6	 -->
                <a-col v-else-if="item.type === '6'" :span="24">
                  <a-row>
                    <a-col>
                      <a-button type="primary" @click="handleDhwb(item)" class="increase" preIcon="ant-design:plus-outlined">添加</a-button>
                    </a-col>
                    <a-col v-for="(item2, index2) in item.list" :key="index2">
                      <a-input
                        placeholder="请输入内容"
                        v-model:value="item2.title"
                        class="form-pattern"
                        style="width:90%; "
                        @blur="handleGlxm(item)"
                      ></a-input>
                      <button @click="handleDhwbDel(item, index2)" class="ant-btn">删除</button>
                    </a-col>
                  </a-row>
                </a-col>
                <!-- 自增富文本	7	 -->
                <a-col v-else-if="item.type === '7'" :span="24">
                  <a-row>
                    <a-col>
                      <a-button type="primary" @click="handleDhfwb(item)" class="increase" preIcon="ant-design:plus-outlined">添加</a-button>
                    </a-col>
                    <a-col v-for="(item2, index2) in item.list" :key="index2" style="text-align: right;">
                      <j-editor placeholder="请输入内容" v-model:value="item2.title" :disabled="disabled" />
                      <button @click="handleDhfwbDel(item, index2)" class="ant-btn" style="margin: 8px 0 ">删除</button>
                    </a-col>
                  </a-row>
                </a-col>
                <!-- 自增多行文本	8  -->
                <a-col v-else-if="item.type === '8'" :span="24">
                  <a-row>
                    <a-col>
                      <a-button type="primary" @click="handleDhwbArea(item)" class="increase" preIcon="ant-design:plus-outlined">添加</a-button>
                    </a-col>
                    <a-col v-for="(item2, index2) in item.list" :key="index2" style="text-align: right;">
                      <a-textarea placeholder="请输入内容" v-model:value="item2.title" :disabled="disabled" />
                      <button @click="handleDhwbAreaDel(item, index2)" class="ant-btn" style="margin: 8px 0">删除</button>
                    </a-col>
                  </a-row>
                </a-col>

                <!-- 自增表格	9  -->
                <a-col v-else-if="item.type === '9' || item.type === '15'" :span="24">
                  <div><a-button type="primary" @click="handleZzbg(item)" class="increase" preIcon="ant-design:plus-outlined">新增</a-button> </div>
                  <a-table :columns="getTableZzColumns(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
                    <template #bodyCell="{ column, record }">
                      <template v-if="column.key === 'action'">
                        <button @click="handleZzbgDel(item.list, record.sort)" class="ant-btn">删除</button>
                      </template>
                      <template v-else>
                        <a-input placeholder="请输入内容" v-model:value="record[column.key]" style="width: 100%"></a-input>
                      </template>
                    </template>
                  </a-table>
                </a-col>
                <!-- 自增表格（两列关联）	10 -->
                <a-col v-else-if="item.type === '10'" :span="24">
                  <div><a-button type="primary" @click="handleZzbg(item)" class="increase" preIcon="ant-design:plus-outlined">新增</a-button> </div>
                  <a-table :columns="getTableZzColumns(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
                    <template #bodyCell="{ column, record }">
                      <template v-if="column.key === 'action'">
                        <button @click="handleZzbgDel(item.list, record.sort)" class="ant-btn">删除</button>
                      </template>
                      <template v-else>
                        <a-input
                          placeholder="请输入内容"
                          v-model:value="record[column.key]"
                          @blur="handleTwoGlxm(item)"
                          style="width: 100%;"
                        ></a-input>
                      </template>
                    </template>
                  </a-table>
                </a-col>
                <!-- 自增表格（两列关联）	10 -->
                <a-col v-else-if="item.type === '11'" :span="24">
                  <div><a-button type="primary" @click="handleZzbg(item)" class="increase" preIcon="ant-design:plus-outlined">新增</a-button> </div>
                  <a-table :columns="getTableZzColumns(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
                    <template #bodyCell="{ column, record }">
                      <template v-if="column.key === 'action'">
                        <button @click="handleZzbgDel(item.list, record.sort)" class="ant-btn">删除</button>
                      </template>
                      <template v-else>
                        <a-input
                          placeholder="请输入内容"
                          v-model:value="record[column.key]"
                          @blur="handleTwoGlxm(item)"
                          style="width: 100%"
                        ></a-input>
                      </template>
                    </template>
                  </a-table>
                </a-col>
                <!-- --------------------------------------20240824------------------------------------------------------ -->
                <!-- 课程目标	12	 -->
                <a-col v-else-if="item.type === '12'" :span="24">
                  <a-row>
                    <a-col>
                      <a-button type="primary" @click="handleKcmbZzbg(item)" class="increase" preIcon="ant-design:plus-outlined">添加</a-button>
                    </a-col>
                    <a-col style="margin-bottom: 15px"></a-col>
                    <a-col v-for="(item2, index2) in item.list2Map" :key="index2">
                      <!-- -{{ item2 }}- -->
                      <a-row style="margin:10px">
                        <a-col v-for="(item3, index3) in item2" :span="index3 == 0 ? '5' : '16'" :key="index3" >
                          <!-- -{{ item3 }}- -->
                          <span>
                            <a-input
                              placeholder="请输入内容"
                              v-model:value="item3.title"
                              class="Sheet"
                              style="width:95%; "
                              :disabled="index3 == 0"
                              @blur="handle2Glxm(item)"
                            ></a-input>
                          </span>
                        </a-col>
                        <a-col :span="2">
                          <button @click="handleKcmbZzbgDel(item, index2)" class="ant-btn" >删除</button>
                        </a-col>
                      </a-row>
                    </a-col>
                  </a-row>
                </a-col>

                <!-- 教学内容、重难点和课时安排	13	 -->
                <a-col v-else-if="item.type === '13'" :span="24">
                  <a-row>
                    <a-col>
                      <a-button type="primary" @click="handle13Zzbg(item)" class="increase" preIcon="ant-design:plus-outlined">添加</a-button>
                    </a-col>
                    <a-col style="margin-bottom: 15px"></a-col>
                    <a-col>
                      <!-- -{{ item.list}}- -->
                      <a-row v-for="(item2, index2) in item.list" :key="index2">
                        <a-col v-for="(item3, index3) in item2.list" :key="index3" style="line-height: 40px">
                          <a-row>
                            <a-col style="text-align:right; color:#777;" :span="6"> {{ item3.title }}: </a-col>
                            <a-col :span="18">
                              <span v-if="item3.type === '1'">
                                <a-input v-model:value="item3.content" style="width:97%; margin-left:10px; text-align: left"></a-input>
                              </span>
                              <span v-if="item3.type === '2'">
                                <a-select
                                  :placeholder="`请选择` + item3.title"
                                  v-model:value="item3.content"
                                  mode="tags"
                                  :disabled="disabled"
                                  style="width:97%; text-align:left;margin-left:10px;"
                                >
                                  <a-select-option value="">{{ `请选择` + item3.title }}</a-select-option>
                                  <a-select-option :value="peizhi.title" v-for="(peizhi, index2) in kcmbDataSource" :key="index2">{{
                                    peizhi.title
                                  }}</a-select-option>
                                </a-select>
                              </span>
                            </a-col>
                          </a-row>
                        </a-col>
                        <a-col style="text-align: right; margin-right:9px;">
                          <button class="ant-btn" @click="handle13DelZzbg(item, index2)" style="margin:5px 0">删除</button>
                        </a-col>
                      </a-row>
                    </a-col>
                  </a-row>
                </a-col>
                <!-- 课程目标的评价方式	14 -->
                <!-- <a-col v-else-if="item.type === '14'" :span="24"> -->
                <a-col v-else-if="item.type === '14'" :span="24">
                  <a-row>
                    <a-col>
                      <a-button type="primary" @click="handle14Zzbg(item)" class="increase" preIcon="ant-design:plus-outlined">添加</a-button>
                    </a-col>
                    <a-col v-if="kcmbShow">
                      <a-row>
                        <a-col :span="10">
                          <a-select :placeholder="`请选择课程目标`" v-model:value="checkKcmb" :disabled="disabled" style="width: 90%; margin:10px 0">
                            <a-select-option value="">请选择课程目标</a-select-option>
                            <a-select-option :value="peizhi.title" v-for="(peizhi, index2) in kcmbDataSource" :key="index2">{{
                              peizhi.title
                            }}</a-select-option>
                          </a-select>
                        </a-col>
                        <a-col :span="10">
                          <a-select :placeholder="`请选择考核方式`" v-model:value="checkKhfs" :disabled="disabled" mode="tags" style="width: 90%;margin:10px 0">
                            <a-select-option value="">请选择考核方式</a-select-option>
                            <a-select-option :value="peizhi.title" v-for="(peizhi, index2) in khmbDataSource" :key="index2">{{
                              peizhi.title
                            }}</a-select-option>
                          </a-select>
                        </a-col>
                        <a-col :span="4">
                          <button class="ant-btn" @click="handleKhmbqueren(item)" style="margin:10px 0">确认</button>
                        </a-col>
                      </a-row>
                    </a-col>
                    <a-col>
                      <a-table :columns="getTableZzColumns(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
                        <template #bodyCell="{ column, record }">
                          <template v-if="column.key === 'action'">
                            <button @click="handleZzbgDel(item.list, record.sort)" class="ant-btn">删除</button>
                          </template>
                          <template v-else>
                            <a-input
                              placeholder="请输入内容"
                              v-model:value="record[column.key]"
                              @blur="handleTwoGlxm(item)"
                              style="width: 100%"
                            ></a-input>
                          </template>
                        </template>
                      </a-table>
                    </a-col>
                  </a-row>
                </a-col>

                <!-- --------------------------------------20240824------------------------------------------------------ -->

                <a-col v-else> </a-col>

                <a-col :span="24" v-if="item.tsy">
                  <span class="tishi">
                    <span>{{ item.tsy }}</span>
                  </span>
                </a-col>
              </a-row>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="24" style="text-align: center" v-if="jxdgInfo.banbenId">
          <a-button type="primary" @click="submitForm">保存</a-button>
        </a-col>
      </a-row>
    </div>
    <div v-if="showType == 999">
      <a-row>
        <a-col :span="24">
          <span class="title">教学大纲内容</span>
          <a-button type="primary" @click="handleShowType(2)" style="float: right; margin-right: 8px">
            <Icon icon="ant-design:form-outlined" />编辑
          </a-button>
          <a-button type="primary" @click="handleFabu(1)" style="float: right; margin-right: 8px" v-if="jxdgInfo.sffb == '0'">
            <Icon icon="ant-design:check-outlined" />发布
          </a-button>
          <a-button type="primary" @click="handleFabu(0)" style="float: right; margin-right: 8px" v-if="jxdgInfo.sffb == '1'">
            <Icon icon="ant-design:export-outlined" />撤销</a-button
          >
          <a-divider />
        </a-col>
        <a-col
          :span="23"
          v-for="(item, index) in zyJxdgMainTable.dataSource"
          :key="index"
          class="borderstyle"
        >
          <a-row>
            <a-col :span="24" style="height: 40px; line-height: 40px; background-color: #f7fbfa">
              <span class="title">{{ item.title }}</span>
            </a-col>
            <!-- 单行文本	1	 -->
            <a-col v-if="item.type === '1'" :span="24" style="margin: 10px;">
              <span class="Text-Content" v-text="item.content"></span>
            </a-col>
            <!-- 多行文本	2	 -->
            <a-col v-else-if="item.type === '2'" :span="24" style="margin: 10px">
              <span class="Text-Content" v-text="item.content"></span>
            </a-col>
            <!-- 富文本	3	 -->
            <a-col v-else-if="item.type === '3'" :span="24">
              <div class="Text-Content" v-html="item.content"></div>
            </a-col>
            <!-- 固定表单（基础信息）	4	 -->
            <a-col v-else-if="item.type === '4'" v-model:value="item.content" :span="24">
              <a-form v-bind="formItemLayout">
                <a-row>
                  <a-col v-for="(item2, index2) in item.zyJxdgPzxxList" :key="index2" :span="12">
                    <a-form-item :label="item2.title">
                      <span class="Text-Content" v-text="item2.content"></span>
                    </a-form-item>
                  </a-col>
                </a-row>
              </a-form>
            </a-col>
            <!-- 自增表格	5	 -->
            <a-col v-else-if="item.type === '5'" :span="24">
              <a-table :columns="getTableColumns(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
                <!-- <template #bodyCell="{ column, record }">
                  <a-input placeholder="请输入内容" v-model:value="record[column.key]" style="width: 80%"></a-input>
                </template> -->
              </a-table>
            </a-col>
            <!-- 自增单行文本	6	 -->
            <a-col v-else-if="item.type === '6'" :span="24">
              <a-row>
                <a-col v-for="(item2, index2) in item.list" :key="index2" style="margin: 10px">
                  <span class="Text-Content" v-text="item2.title"></span>
                </a-col>
              </a-row>
            </a-col>
            <!-- 自增富文本	7	 -->
            <a-col v-else-if="item.type === '7'" :span="24">
              <a-row>
                <a-col v-for="(item2, index2) in item.list" :key="index2">
                  <div class="Text-Content" v-html="item2.title"></div>
                </a-col>
              </a-row>
            </a-col>
            <!-- 自增多行文本	8  -->
            <a-col v-else-if="item.type === '8'" :span="24">
              <a-row>
                <a-col v-for="(item2, index2) in item.list" :key="index2" style="margin: 10px">
                  <span class="Text-Content" v-text="item2.title"></span>
                </a-col>
              </a-row>
            </a-col>

            <!-- 自增表格	9  -->
            <a-col v-else-if="item.type === '9' || item.type === '15'" :span="24">
              <a-table :columns="getTableZzColumns2(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">  </a-table>
            </a-col>
            <!-- 自增表格（两列关联）	10 -->
            <a-col v-else-if="item.type === '10'" :span="24">
              <a-table :columns="getTableZzColumns2(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false"> </a-table>
            </a-col>
            <!-- 自增表格（两列关联）	11 -->
            <a-col v-else-if="item.type === '11'" :span="24">
              <a-table :columns="getTableZzColumns2(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false"> </a-table>
            </a-col>

            <!-- --------------------------------------20240824------------------------------------------------------ -->
            <!-- 课程目标	12	 -->
            <a-col v-else-if="item.type === '12'" :span="24">
              <a-row>
                <a-col v-for="(item2, index2) in item.list2Map" :key="index2">
                  <!-- -{{ item2 }}- -->
                  <a-row>
                    <a-col v-for="(item3, index3) in item2" :span="index3 == 0 ? '5' : '16'" :key="index3">
                      <!-- -{{ item3 }}- -->
                      <span style="line-height: 40px; margin-left: 15px;" v-if="index3 == 0"> {{ item3.title }}: </span>
                      <span style="line-height: 40px" v-else>
                        {{ item3.title }}
                      </span>
                    </a-col>
                  </a-row>
                </a-col>
              </a-row>
            </a-col>

            <!-- 教学内容、重难点和课时安排	13	 -->
            <a-col v-else-if="item.type === '13'" :span="24">
              <a-row>
                <a-col>
                  <a-row v-for="(item2, index2) in item.list" :key="index2" class="dhxg">
                    <a-col v-for="(item3, index3) in item2.list" :key="index3" style="line-height: 40px;">
                      <a-row style="padding:5px; ">
                        <a-col style="text-align: left" :span="7"> {{ item3.title }}: </a-col>
                        <a-col :span="15">
                          {{ item3.content }}
                        </a-col>
                      </a-row>
                    </a-col>
                    <a-col style="height: 20px"> &nbsp; </a-col>
                  </a-row>
                </a-col>
              </a-row>
            </a-col>
            <!-- 课程目标的评价方式	14 -->
            <!-- <a-col v-else-if="item.type === '14'" :span="24"> -->
            <a-col v-else-if="item.type === '14'" :span="24">
              <a-row>
                <a-col>
                  <a-table :columns="getTableZzColumns2(item.zyJxdgPzxxList)" :dataSource="item.list" :pagination="false">
                    <!-- <template #bodyCell="{ column, record }">
                          <template v-if="column.key === 'action'">
                            <button @click="handleZzbgDel(item.list, record.sort)" class="ant-btn">删除</button>
                          </template>
                          <template v-else>
                            <a-input
                              placeholder="请输入内容"
                              v-model:value="record[column.key]"
                              @blur="handleTwoGlxm(item)"
                              style="width: 100%"
                            ></a-input>
                          </template>
                        </template> -->
                  </a-table>
                </a-col>
              </a-row>
            </a-col>

            <!-- --------------------------------------20240824------------------------------------------------------ -->

            <a-col v-else> </a-col>

            <a-col :span="24" v-if="item.tsy">
              <span class="tishi">
                <span>{{ item.tsy }}</span>
              </span>
            </a-col>
          </a-row>
        </a-col>
      </a-row>
    </div>
  </div>
</template>

<script lang="ts" name="zyJxdgBanben-zyJxdgBanben" setup>
import { ref, reactive, computed, unref, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import {
  queryZyJxdgMainListByMainId,
  queryDataById,
  saveOrUpdate2,
  queryZyJxdgMainListByMainId2,
  queryZyJxdgMainListByMainId3,
} from '/@/views/kc/zyJxdgBanben/ZyJxdgBanben.api';
import JEditor from '/@/components/Form/src/jeecg/components/JEditor.vue';
import { Item } from 'ant-design-vue/lib/menu';

//当前路由信息
const { currentRoute } = useRouter();
const { query } = unref(currentRoute);
const { rwbh, xqxn, type, teano } = query; //获取传递参数
const showType = ref<number>(0);
const jxdgInfo = ref<any>({});
const kechengInfo = ref<any>({});
const jxdgbbDataSource = ref<any>([]);
const disabled = ref<boolean>(false);
const { createMessage, createConfirm } = useMessage();

let kcmbDataSource = ref<{ title: any }[]>([]);
const checkKcmb = ref<string>('');
const checkKhfs = ref<any>([]);
const khmbDataSource = ref<any>([]);
const kcmbShow = ref<boolean>(false);

const zyJxdgMainTable = reactive<Record<string, any>>({
  loading: false,
  dataSource: [],
});

const formItemLayout = {
  labelCol: { xs: { span: 24 }, sm: { span: 8 } },
  wrapperCol: { xs: { span: 24 }, sm: { span: 13 } },
};

//关联项目计算方法
function handleGlxm(item) {
  var sfsglxm = item.sfsglxm;
  if (sfsglxm == '1') {
    //判断是否是关联项目
    var list1 = item.list; //课程目标集合
    if (list1 != null) {
      //关联项目是否有值
      var sort = item.sort; //第几个关联项目
      var alllist = zyJxdgMainTable.dataSource; //获取全部的数据
      for (var j = 0; j < alllist.length; j++) {
        for (var i = 0; i < list1.length; i++) {
          var item1 = list1[i];
          var title = item1.title; //具体信息
          var item2 = alllist[j]; //具体数据
          item2.list = item2.list || [];
          if (item2.guanlian == sort) {
            //关联项目等于当前数据
            if (i == 0) {
              //判断第一回将原来的清空重新赋值
              item2.list = [];
            }
            //判断当前项是否等于关联项
            var item3 = item2.zyJxdgPzxxList;
            if (item3 != null && item3.length > 0) {
              if (item2.type == '11') {
                item2.list.push({ [item3[0].id]: '', [item3[1].id]: title });
              } else {
                item2.list.push({ [item3[0].id]: title });
              }
            }
          }
        }
      }
    }
  }
}
function handleFabu(sffb) {
  if (sffb == '1') {
    var par = jxdgInfo.value;
    var title = '《' + par.kcmc + '》教学大纲（' + par.banbenName + '）';
    createConfirm({
      iconType: 'warning',
      title: '确认发布',
      content: title + '是否作为' + par.xqxn + '季学期的执行教学大纲，面向学生发布？',
      okText: '确认',
      cancelText: '取消',
      onOk: () => {
        defHttp.post({ url: '/zyJxdgTeacherMain/zyJxdgTeacherMain/edit', params: { sffb, id: jxdgInfo.value.id, fbName: title } }).then((res) => {
          init();
        });
      },
    });
  } else {
    createConfirm({
      iconType: 'warning',
      title: '确认撤回',
      content: '确认撤回已发布的执行大纲吗？',
      okText: '确认',
      cancelText: '取消',
      onOk: () => {
        defHttp.post({ url: '/zyJxdgTeacherMain/zyJxdgTeacherMain/edit', params: { sffb, id: jxdgInfo.value.id, fbName: title } }).then((res) => {
          init();
        });
      },
    });
  }
}
//两列关联项目计算方法
function handleTwoGlxm(item) {
  var sfsglxm = item.sfsglxm;
  if (sfsglxm == '1') {
    //判断是否是关联项目
    var list1 = item.list; //课程目标集合
    if (list1 != null) {
      //关联项目是否有值
      var sort = item.sort; //第几个关联项目
      var alllist = zyJxdgMainTable.dataSource; //获取全部的数据
      for (var j = 0; j < alllist.length; j++) {
        for (var i = 0; i < list1.length; i++) {
          var item1 = list1[i];
          var item2 = alllist[j]; //具体数据
          item2.list = item2.list || [];

          if (item2.guanlian == sort) {
            //判断当前项是否等于关联项
            var item3 = item.zyJxdgPzxxList;
            var item4 = item2.zyJxdgPzxxList;
            var title1 = item1[item3[0].id];
            var title2 = item1[item3[1].id];
            //关联项目等于当前数据
            if (i == 0) {
              //判断第一回将原来的清空重新赋值
              item2.list = [];
            }
            if (item3 != null && item3.length > 0) {
              item2.list.push({ [item4[0].id]: title1, [item4[1].id]: title2 });
            }
          }
        }
      }
    }
  }
}
//新增单行文本
function handleDhwb(item) {
  item.list = item.list || [];
  item.list.push({
    title: '',
    sort: item.list.length + 1,
  });
}
//删除单行文本
function handleDhwbDel(item, index) {
  item.list.splice(index, 1);
  for (var i = 0; i < item.list.length; i++) {
    item.list[i].sort = i;
  }
}

//新增多行富文本
function handleDhfwb(item) {
  item.list = item.list || [];
  item.list.push({
    title: '',
    sort: item.list.length + 1,
  });
}
//删除多行富文本
function handleDhfwbDel(item, index) {
  item.list.splice(index, 1);
  for (var i = 0; i < item.list.length; i++) {
    item.list[i].sort = i;
  }
}

//新增多行富文本
function handleDhwbArea(item) {
  item.list = item.list || [];
  item.list.push({
    title: '',
    sort: item.list.length + 1,
  });
}
//删除多行富文本
function handleDhwbAreaDel(item, index) {
  item.list.splice(index, 1);
  for (var i = 0; i < item.list.length; i++) {
    item.list[i].sort = i;
  }
}

//新增自增表格
function handleZzbg(item) {
  item.list = item.list || [];
  item.list.push({
    title: '',
    sort: item.list.length,
  });
}
//删除自增表格
function handleZzbgDel(list, record) {
  list.splice(record, 1);
  for (var i = 0; i < list.length; i++) {
    list[i].sort = i;
  }
}
//获取列表列表头
function getTableColumns(list) {
  let columns = reactive<any>([]);
  for (var i = 0; i < list.length; i++) {
    var par = list[i];
    var inePar = {
      title: par.title,
      dataIndex: par.id,
      key: par.id,
    };
    columns.push(inePar);
  }
  return columns;
}
//获取自增列表列表头
function getTableZzColumns(list) {
  let columns = reactive<any>([]);
  for (var i = 0; i < list.length; i++) {
    var par = list[i];
    var inePar = {
      title: par.title,
      dataIndex: par.id,
      key: par.id,
    };
    columns.push(inePar);
  }
  var inePar2 = {
    title: '操作',
    dataIndex: 'action',
    key: 'action',
  };
  columns.push(inePar2);
  return columns;
}

//获取自增列表列表头
function getTableZzColumns2(list) {
  let columns = reactive<any>([]);
  for (var i = 0; i < list.length; i++) {
    var par = list[i];
    var inePar = {
      title: par.title,
      dataIndex: par.id,
      key: par.id,
    };
    columns.push(inePar);
  }
  return columns;
}

//选择教学大纲版本
async function handleCheckBanben(record) {
  jxdgInfo.value.banbenId = record.id;
  jxdgInfo.value.rwbh = rwbh;
  jxdgInfo.value.teacherNo = teano;
  console.log('👨‍👧', jxdgInfo.value);

  //子表数据
  var id = record.id;

  var params = {
    mainId: id,
    rwbh: rwbh,
    teacherNo: teano,
  };
  //子表数据
  let zyJxdgMainDataList = await queryZyJxdgMainListByMainId3(params);

  await defHttp.get({ url: '/ktgl/kcKechengbiao/getKcxxByRwbhXqxn', params: { rwbh, xqxn } }).then((res) => {
    console.log('🙅‍♀️', res);
    kechengInfo.value = res;
  });
  var list = zyJxdgMainDataList;
  console.log('👯‍♀️', list);
  for (var i = 0; i < list.length; i++) {
    var par = list[i];
    console.log('👕', par);
    if (par.type == '4') {
      var list1 = par.zyJxdgPzxxList;
      for (var j = 0; j < list1.length; j++) {
        var par2 = list1[j];
        if (par2.title == '课程编码') {
          par2.content = kechengInfo.value.kcbh;
        } else if (par2.title == '课程名称') {
          par2.content = kechengInfo.value.kcmc;
        } else if (par2.title == '学分') {
          par2.content = kechengInfo.value.xf;
        }
      }

      break;
    }
  }
  zyJxdgMainDataList = list;
  zyJxdgMainTable.dataSource = [...zyJxdgMainDataList];
}
async function submitForm() {
  const alllist = zyJxdgMainTable.dataSource;
  var values = {
    id: jxdgInfo.value.id,
    rwbh: rwbh,
    banbenId: jxdgInfo.value.banbenId,
    teacherNo: teano,
    sffb: '0',
    list: alllist,
  };
  console.log('表单提交数据', values);
  const isUpdate = values.id ? true : false;
  await saveOrUpdate2(values, isUpdate);
  setTimeout(() => {
    init();
  }, 1000);
}
//切换显示模块
function handleShowType(type) {
  console.log('🤛', type);
  if (type == 1) {
    jxdgInfo.value = {};
    zyJxdgMainTable.dataSource = [];
    defHttp.get({ url: '/zyJxdgBanben/zyJxdgBanben/list', params: { sfsy: '1', pageNo: -1 } }).then((res) => {
      jxdgbbDataSource.value = res.records;
    });
  } else if (type == 2) {
    type = 1;

    defHttp.get({ url: '/zyJxdgBanben/zyJxdgBanben/list', params: { sfsy: '1', pageNo: -1 } }).then((res) => {
      jxdgbbDataSource.value = res.records;
    });

    var teacherNo = teano;
    zyJxdgMainTable.dataSource = [];
    defHttp.get({ url: '/zyJxdgTeacherMain/zyJxdgTeacherMain/queryByRwbhList', params: { rwbh, teacherNo } }).then((res) => {
      zyJxdgMainTable.dataSource = [...res];
      console.log('👩‍💼', zyJxdgMainTable.dataSource);

      for (var i = 0; i < zyJxdgMainTable.dataSource.length; i++) {
        var par = zyJxdgMainTable.dataSource[i];
        console.log('👅', par);
        if (par.type == '12') {
          var list = par.list2Map;
          console.log('🧔', list);
          var list1 = ref<{ title: any }[]>([]);
          for (var j = 0; j < list.length; j++) {
            var ppa = list[j][0].title;
            console.log('👧', ppa);
            list1.value.push({ title: ppa });
          }
          kcmbDataSource.value = list1.value;
        }
      }
    });
  }
  showType.value = type;
}

//初始化查询
async function init() {
  console.log('rwbh--->', rwbh);
  defHttp.get({ url: '/zyJxdgTeacherMain/zyJxdgTeacherMain/queryByRwbh', params: { rwbh, xqxn, teacherNo: teano } }).then((res) => {
    if (res) {
      jxdgInfo.value = res;
      showType.value = 999;
      var teacherNo = teano;
      defHttp.get({ url: '/zyJxdgTeacherMain/zyJxdgTeacherMain/queryByRwbhList', params: { rwbh, teacherNo } }).then((res) => {
        zyJxdgMainTable.dataSource = [...res];
      });
    } else {
      showType.value = 0;
    }
  });
}

const jxdgbbColumns = [
  {
    title: '版本',
    align: 'center',
    dataIndex: 'title',
  },
  {
    title: '课程类型',
    align: 'center',
    dataIndex: 'twoTitle_dictText',
  },
  {
    title: '操作',
    align: 'action',
    key: 'action',
  },
];

//--------------------------------------20240824------------------------------------------------------
//新增课程目标自增表格
function handleKcmbZzbg(item) {
  item.list2Map = item.list2Map || [];

  var item3 = item.zyJxdgPzxxList;
  console.log('😁', item3);
  var oneId = '';
  var twoId = '';
  for (var i = 0; i < item3.length; i++) {
    if (i == 0) {
      oneId = item3[i].id;
    } else if (i == 1) {
      twoId = item3[i].id;
    }
  }

  item.list2Map.push([
    {
      title: '课程目标' + (item.list2Map.length + 1),
      key: oneId,
      sort: item.list2Map.length,
    },
    {
      title: '',
      key: twoId,
      sort: item.list2Map.length,
    },
  ]);
  var list1 = ref<{ title: any }[]>([]);
  for (var i = 0; i < item.list2Map.length; i++) {
    var ppa = item.list2Map[i][0].title;
    list1.value.push({ title: ppa });
  }
  kcmbDataSource.value = list1.value;
}
//删除课程目标自增表格
function handleKcmbZzbgDel(item, index) {
  item.list2Map.splice(index, 1);
  for (var i = 0; i < item.list2Map.length; i++) {
    var item2 = item.list2Map[i];
    item2.forEach((item3, index2) => {
      if (index2 == 0) {
        item3.title = '课程目标' + (i + 1);
      }
      item3.sort = i;
    });
  }
}
//关联项目计算方法
function handle2Glxm(item) {
  var listtt = ref<{ title: any }[]>([]);
  for (var i = 0; i < item.list2Map.length; i++) {
    var ppa = item.list2Map[i][0].title;
    listtt.value.push({ title: ppa });
  }
  kcmbDataSource.value = listtt.value;

  console.log('👳‍♀️', item);
  var sfsglxm = item.sfsglxm;
  console.log('👱‍♀️', sfsglxm);
  if (sfsglxm == '1') {
    //判断是否是关联项目
    var list1 = item.list2Map; //课程目标集合
    console.log('👑', list1);
    if (list1 != null) {
      //关联项目是否有值
      var sort = item.sort; //第几个关联项目
      var alllist = zyJxdgMainTable.dataSource; //获取全部的数据
      for (var j = 0; j < alllist.length; j++) {
        for (var i = 0; i < list1.length; i++) {
          var item1 = list1[i][0];
          var title = item1.title; //具体信息
          var item2 = alllist[j]; //具体数据
          item2.list = item2.list || [];
          if (item2.guanlian == sort) {
            //关联项目等于当前数据
            if (i == 0) {
              //判断第一回将原来的清空重新赋值
              item2.list = [];
            }
            //判断当前项是否等于关联项
            var item3 = item2.zyJxdgPzxxList;
            console.log('👶', item3);
            if (item3 != null && item3.length > 0) {
              if (item2.type == '11') {
                item2.list.push({ [item3[0].id]: '', [item3[1].id]: title });
              } else {
                item2.list.push({ [item3[0].id]: title });
              }
            }
          }
        }
      }
    }
  }
  // handleGlxm(item);
}

function handle13Zzbg(record) {
  console.log('👎', record);
  var list2 = record.zyJxdgPzxxList; //课程目标集合
  var list3: { title: any; type: string; content: string; key: string }[] = [];
  for (var i = 0; i < list2.length; i++) {
    var par = list2[i];
    var type = '1';
    if (i == 1) {
      type = '2';
    }
    list3.push({
      title: par.title,
      type,
      content: '',
      key: par.id,
    });
  }
  console.log('🦹', list3);
  record.list.push({ list: list3 });
  console.log('👩‍🔧', record);
}

//删除课程目标自增表格
function handle13DelZzbg(item, index) {
  item.list.splice(index, 1);
}

function handle14Zzbg(item) {
  console.log('🤧item', item);
  kcmbShow.value = true;
  khmbDataSource.value = [];
  var guanlian = item.guanlian.split(',');
  var khmbSort = guanlian[1];
  console.log('👱‍♀️khmbSort', khmbSort);
  var alllist = zyJxdgMainTable.dataSource[khmbSort - 1]; //获取全部的数据
  var item2 = alllist.list;
  var item3 = alllist.zyJxdgPzxxList[0];
  console.log('item2', item2);
  console.log('item3', item3);
  for (var i = 0; i < item2.length; i++) {
    var item1 = item2[i];
    console.log('👩‍👩‍👦item1', item1[item3.id]);
    khmbDataSource.value.push({ title: item1[item3.id] });
  }
  console.log('😒khmbDataSource', khmbDataSource.value);
}

function handleKhmbqueren(record) {
  console.log('👩‍👦record', record);
  var a1 = checkKcmb.value; //选择的课程目标
  var a2 = checkKhfs.value; //选择的考核方式集合
  let columns = reactive<any>([]);
  var list2 = record.zyJxdgPzxxList;
  for (var i = 0; i < list2.length; i++) {
    var par = list2[i];
    columns.push(par.id);
  }
  for (var i = 0; i < a2.length; i++) {
    var khfsmc = a2[i]; //考核方式名称
    record.list.push({ [columns[0]]: a1, [columns[1]]: khfsmc });
  }
  handleTwoGlxm(record);
  kcmbShow.value = false;
}

//--------------------------------------20240824------------------------------------------------------

onMounted(() => {
  init();
});
</script>
<style lang="less" scoped>
.title {
  height: 35px;
  line-height: 35px;
  margin-left: 20px;
  font-size: 16px;
}
.title2 {
  font-size: 16px;
  font-weight: bold;
}
.ant-divider-horizontal {
  display: flex;
  clear: both;
  width: 100%;
  min-width: 100%;
  margin: 3px 0 5px;
}
.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 #dadada;
  background: #f7f7f7;
}
.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;
}
.data-suggest {
  display: flex;
  flex-direction: column;
  text-align: center;
  width: 25%;
  margin-right: 3px;
  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: 6px 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;
  background: #fafafa ;
}
.bled-countenance {
  color: #333333;
}
.bled-countenance2 {
  color: #999999;
  font-size: 12px;
}
.region {
  margin: 5px 10px;
  padding-bottom: 20px;
  background: #fff;
  border-radius: 5px;
}
.region-title {
  font-size: 16px;
  color: #029c88;
  padding: 8px 20px;
  border-left: 5px solid #029c88;
  margin-bottom: 20px;
}

.tishi {
  display: flex;
  flex-direction: column;
  text-align: left;
  margin: 5px;
  background: #fff8ef;
  color: #fd8f02;
}
.tishi span {
  font-size: 12px;
  color: #fd8f02;
  text-indent: 10px;
  padding: 8px;
}
.increase {
  position: absolute;
  right: 6px;
  top: -36px;
}
.place-dele {
  margin: 10px 0;
}
.form-pattern {
  color: #666;
}
.Text-Content {
  padding: 10px;
  color: #777;
}
.dhxg {
  padding: 15px;
  border: 1px solid #f0f0f0;
  margin: 15px;
  border-radius: 10px;
}

.dhxg:before {
  border: 4px solid #fd8f02; /* 初始边框颜色 */
  padding: 15px;
  margin: 13px;
  border-radius: 10px;
}

.dhxg:after {
  border: 4px solid #000; /* 初始边框颜色 */
  padding: 15px;
  margin: 17px;
  border-radius: 10px;
}
.borderstyle{
  margin:8px auto;
  border:1px solid #f0f0f0;
  padding:12px;
  background:#fff;
  border-radius:5px;
}
.borderstyle:hover{
  margin:8px auto;
  border:1px solid #f0f0f0;
  padding:12px;
  background:#fff;
  border-radius:5px;
  box-shadow: 2px 2px 10px 1px #d4d4d4;
}
</style>