 <template>
  <div>
    <div class="d-flex flex-between pt7">
      <div>
        <el-button type="primary" @click="exportAll">导出打印</el-button>
        <!-- <el-button type="primary" @click="addData">添加</el-button>
      <el-button
        type="danger"
        @click="delData"
        :disabled="multipleSelection.length == 0"
        >删除</el-button
      > -->
      </div>
      <el-form :inline="true">
        <!-- <el-form-item class="mr10" prop="keyword" label="学生姓名：">
        <el-input
          placeholder="输入学生姓名"
          v-model="keyword"
          clearable
          @clear="getListData"
        ></el-input>
      </el-form-item>
      <el-form-item class="mr10" prop="xdx_xsxh" label="学籍号：">
        <el-input
          v-model="xdx_xsxh"
          placeholder="输入学籍号"
          clearable
          @clear="getListData"
        ></el-input>
      </el-form-item>
      <el-form-item class="mr10" prop="xdx_lxfs" label="手机号码：">
        <el-input
          v-model="xdx_lxfs"
          clearable
          @clear="getListData"
          placeholder="输入手机号码"
        ></el-input>
      </el-form-item>
      <el-form-item class="mr10" prop="class_name" label="班级：">
        <el-input
          v-model="class_name"
          clearable
          @clear="getListData"
          placeholder="输入班级"
        ></el-input>
      </el-form-item> -->
        <el-form-item label="" style="margin-bottom: 10px">
          <el-select
            v-model="firstForm.team"
            placeholder="请选择学年学期"
            clearable
            @change="getListData"
            
          >
            <el-option
              v-for="item in teamList"
              :label="item.team_name"
              :value="item.team_id"
              :key="item.team_id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-button type="primary" class="ml5" @click="getListData"
          >搜索</el-button
        >
        <!-- <el-button type="primary" class="ml5" @click="clearData"
          >清空</el-button
        > -->
      </el-form>
    </div>

    <el-table
      :data="tableData"
      tooltip-effect="dark"
      v-loading="loading"
      ref="multipleTable"
      @selection-change="handleSelectionChange"
      style="width: 100%"
    >
      <el-table-column type="selection" align="center" width="55">
      </el-table-column>

      <el-table-column label="学生姓名" prop="xdx_xsxm" width="150">
      </el-table-column>
      <el-table-column label="学籍号" prop="xdx_xsxh" width="auto">
      </el-table-column>
      <el-table-column label="性别" prop="xdx_xb" width="180">
      </el-table-column>
      <el-table-column label="年龄" prop="xdx_nl" width="180">
      </el-table-column>
      <el-table-column label="联系方式" prop="xdx_lxfs" width="200">
      </el-table-column>
      <el-table-column label="备注" prop="xdx_yddqzt" width="180">
        <template slot-scope="scope">
          <span class="text-red">{{ scope.row.xdx_yddqzt }}</span>
        </template>
      </el-table-column>
      <el-table-column label="班级" prop="class_name" width="180">
      </el-table-column>
      <el-table-column label="学籍卡" width="100">
        <template slot-scope="scope">
          <el-button type="text" @click="detailData(scope.row)"
            >查看
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button type="text" @click="editData(scope.row)">编辑 </el-button>
        </template>
      </el-table-column>
    </el-table>

    <footer
      class="flex-item-none"
      style="display: flex; justify-content: flex-end; margin-top: 30px"
    >
      <el-pagination
        background
        layout="total,prev, pager, next"
        :page-size="limit"
        :total="total"
        :current-page.sync="cur_page"
        @current-change="handleCurrentChange"
      ></el-pagination>
    </footer>

    <el-dialog :title="title" :visible.sync="dialogFormVisible" width="700px">
      <el-form :inline="true" :model="dialogForm" label-width="100px">
        <h4 class="mb20 ml20 font-size-15 color-2">基本信息</h4>
        <el-form-item class="mr75" label="学生姓名" prop="xsxm">
          <el-input v-model="dialogForm.xsxm"></el-input>
        </el-form-item>
        <el-form-item class="mr10" label="学籍号" prop="xsxh">
          <el-input v-model="dialogForm.xsxh"></el-input>
        </el-form-item>
        <el-form-item class="mr75" label="年龄" prop="nl">
          <el-input v-model="dialogForm.nl"></el-input>
        </el-form-item>

        <el-form-item class="mr10" label="班级" prop="bj">
          <el-select
            class="mr10"
            clearable
            v-model="dialogForm.bj"
            placeholder="选择班级"
          >
            <el-option
              v-for="(item, index) in classData"
              :key="index"
              :label="item.class_name"
              :value="item.class_name"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item class="mr75" label="证件类型" prop="zjlx">
          <el-input v-model="dialogForm.zjlx"></el-input>
        </el-form-item>
        <el-form-item class="mr10" label="身份号码" prop="sfhm">
          <el-input v-model="dialogForm.sfhm"></el-input>
        </el-form-item>
        <el-form-item class="mr75" label="籍贯" prop="jg">
          <el-input v-model="dialogForm.jg"></el-input>
        </el-form-item>
        <el-form-item class="mr10" label="出生年月" prop="csny">
          <el-date-picker
            style="width: 191px"
            v-model="dialogForm.csny"
            type="date"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item class="mr75" label="曾用名" prop="cym">
          <el-input v-model="dialogForm.cym"></el-input>
        </el-form-item>
        <el-form-item class="mr75" label="性别" prop="xb">
          <el-radio-group v-model="dialogForm.xb">
            <el-radio label="1">男</el-radio>
            <el-radio label="2">女</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item class="mr75" label="血型" prop="xx">
          <el-input v-model="dialogForm.xx"></el-input>
        </el-form-item>
        <el-form-item class="mr75" label="民族" prop="mz">
          <el-input v-model="dialogForm.mz"></el-input>
        </el-form-item>
        <el-form-item class="mr10" label="政治面貌" prop="zzmm">
          <el-input v-model="dialogForm.zzmm"></el-input>
        </el-form-item>
        <el-form-item class="mr75" label="文化程度" prop="whcd">
          <el-input v-model="dialogForm.whcd"></el-input>
        </el-form-item>
        <el-form-item class="mr10" label="入党时间" prop="rdsj">
          <el-date-picker
            style="width: 191px"
            v-model="dialogForm.rdsj"
            type="date"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item class="mr75" label="所在支部" prop="szzb">
          <el-input v-model="dialogForm.szzb"></el-input>
        </el-form-item>
        <el-form-item class="mr10" label="所在党小组" prop="szdxz">
          <el-input v-model="dialogForm.szdxz"></el-input>
        </el-form-item>
        <el-form-item class="mr75" label="家庭住址" prop="jtzz">
          <el-input v-model="dialogForm.jtzz"></el-input>
        </el-form-item>
        <el-form-item class="mr75" label="详细地址" prop="xxdz">
          <el-input v-model="dialogForm.xxdz"></el-input>
        </el-form-item>
        <el-form-item label="联系方式" prop="lxfs">
          <el-input v-model="dialogForm.lxfs"></el-input>
        </el-form-item>
        <el-form-item label="上传照片" prop="sczp">
          <FileUpload
            v-if="dialogFormVisible"
            :limit="1"
            :full.sync="dialogForm.sczp"
            :key="timestamp"
            accept=".jpg,.png,.jpeg"
          >
            <div slot="tip" class="el-upload__tip">
              支持文件类型:jpg,png,jpeg格式。
            </div>
          </FileUpload>
        </el-form-item>

        <el-form-item label="爱好特长:" prop="ahtc">
          <el-input
            type="textarea"
            style="width: 500px"
            v-model="dialogForm.ahtc"
          ></el-input>
        </el-form-item>
        <el-form-item label="备注:" prop="bz">
          <el-input
            type="textarea"
            style="width: 500px"
            v-model="dialogForm.bz"
          ></el-input>
        </el-form-item>
        <div class="total mb-5">
          <el-form-item label-width="0">
            <div class="flex justify-between">
              <div class="w-80px">
                <h4 class="mb20 ml20 font-size-15 color-2">家庭主要</h4>
              </div>
              <div v-for="(children, ci) in childrenData" :key="ci">
                <div class="d-flex flex-between mh25">
                  <div class="title">
                    <span>家庭成员</span>
                    <span v-if="childrenData.length > 1">{{ ci + 1 }}</span>
                  </div>
                  <el-button
                    v-if="childrenData.length > 1"
                    type="primary"
                    size="small"
                    plain
                    @click="handleRemoveCy(childrenData, ci)"
                  >
                    删除
                  </el-button>
                </div>
                <div class="mb20">
                  <el-form-item
                    class="mv15"
                    v-for="(item, index) in children.data"
                    :key="index"
                    :label="item.name"
                    :prop="item.key"
                  >
                    <el-input v-model="item.value" />
                  </el-form-item>
                </div>
              </div>
              <el-button
                style="margin: 20px 30px"
                type="primary"
                size="small"
                plain
                @click="handleAddCy(children)"
              >
                添加成员
              </el-button>
            </div>
          </el-form-item>
        </div>

        <h4 class="mb20 ml20 font-size-15 color-2">获奖荣誉</h4>

        <el-form-item label="是否获奖" prop="sfhj" class="w100">
          <el-radio-group v-model="dialogForm.sfhj">
            <el-radio label="1">是</el-radio>
            <el-radio label="2">否</el-radio>
          </el-radio-group>
          <div>
            <div class="d-flex flex-v-mid">
              <el-input v-model="dialogForm.xdx_hjry" class="mr10"></el-input>
              <el-button type="primary" size="small" @click="handleAddRymc">
                添加荣誉
              </el-button>
            </div>
            <div>
              <div
                class="d-flex flex-v-mid"
                v-for="(val, i) in rymcData"
                :key="i"
              >
                <span class="mr10">{{ val.xdxr_shrymc }}</span>
                <i
                  class="el-icon-close"
                  style="color: #3f8cff"
                  @click="handleRemoveRymc(val)"
                ></i>
              </div>
            </div>
          </div>
        </el-form-item>
        <h4 class="mb20 ml20 font-size-15 color-2">异动管理</h4>
        <el-form-item class="mr75" label="当前状态" prop="yddqzt">
          <el-radio-group v-model="dialogForm.yddqzt">
            <el-radio label="1">退学</el-radio>
            <el-radio label="2">转班</el-radio>
            <el-radio label="3">休学</el-radio>
            <el-radio label="4">复学</el-radio>
            <el-radio label="5">开除</el-radio>
            <!-- <el-radio label="6">其他</el-radio> -->
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注:" prop="ydbz">
          <el-input
            type="textarea"
            style="width: 500px"
            v-model="dialogForm.ydbz"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="text-center">
        <el-button @click="formCancel">取 消</el-button>
        <el-button type="primary" @click="formSubmit">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="detailDialogFormVisible" width="700px">
      <div id="printBox">
        <h3 class="text-center mb45">XXX学校高等教育学生学籍卡</h3>
        <el-form ref="form" :model="dialogForm" label-width="0px">
          <table class="form-table" cellpadding="0" cellspacing="0">
            <tr>
              <td>
                <h3 class="font-size-14">学生姓名</h3>
              </td>
              <td>
                <div class="font-size-14">
                  {{ detailInfo.xdx_xsxm }}
                </div>
              </td>
              <td>
                <h3 class="font-size-14">性别</h3>
              </td>
              <td>
                <div class="font-size-14">{{ detailInfo.xdx_xb_option_n }}</div>
              </td>

              <td rowspan="5" class="text-center">
                <img
                  v-if="detailInfo.xdx_sczp"
                  style="width: 120px; height: 160px"
                  :src="detailInfo.xdx_sczp"
                  alt=""
                />
              </td>
            </tr>
            <tr>
              <td>
                <h3 class="font-size-14">民族</h3>
              </td>
              <td>
                <div class="font-size-14">{{ detailInfo.xdx_mz }}</div>
              </td>
              <td>
                <h3 class="font-size-14">出生年月</h3>
              </td>
              <td>
                <div class="font-size-14">{{ detailInfo.xdx_csrq }}</div>
              </td>
            </tr>
            <tr>
              <td>
                <h3 class="font-size-14">身份证号</h3>
              </td>
              <td>
                <div class="font-size-14">{{ detailInfo.xdx_zjhm }}</div>
              </td>
              <td>
                <h3 class="font-size-14">政治面貌</h3>
              </td>
              <td>
                <div class="font-size-14">{{ detailInfo.xdx_zzmm }}</div>
              </td>
            </tr>
            <tr>
              <td>
                <h3 class="font-size-14">籍贯</h3>
              </td>
              <td>
                <div class="font-size-14">{{ detailInfo.xdx_jg }}</div>
              </td>
              <td>
                <h3 class="font-size-14">家庭住址</h3>
              </td>
              <td>
                <div class="font-size-14">{{ detailInfo.xdx_jtzz }}</div>
              </td>
            </tr>
            <tr>
              <td>
                <h3 class="font-size-14" style="height: 53px">爱好</h3>
              </td>
              <td colspan="3">
                <div class="font-size-14" style="height: 53px">
                  {{ detailInfo.xdx_ahtc }}
                </div>
              </td>
            </tr>
          </table>
          <table class="form-table-two" cellpadding="0" cellspacing="0">
            <tr v-if="jtcyDetailInfo.length > 0">
              <td rowspan="3" class="w20">
                <h3 class="font-size-14">家庭主要</h3>
              </td>
              <td class="w10">
                <h3 class="font-size-14">称谓</h3>
              </td>
              <td class="w10">
                <h3 class="font-size-14">姓名</h3>
              </td>
              <td class="w15">
                <h3 class="font-size-14">政治面貌</h3>
              </td>
              <td class="w20">
                <h3 class="font-size-14">工作单位</h3>
              </td>
              <td class="w10">
                <h3 class="font-size-14">职务</h3>
              </td>
              <td class="w20">
                <h3 class="font-size-14">手机号码</h3>
              </td>
            </tr>

            <tr v-for="(item, index) in jtcyDetailInfo" :key="index">
              <td>
                <div class="font-size-14">{{ item.xdxj_cw }}</div>
              </td>
              <td>
                <div class="font-size-14">{{ item.xdxj_xm }}</div>
              </td>
              <td>
                <div class="font-size-14">{{ item.xdxj_zzmm }}</div>
              </td>
              <td>
                <div class="font-size-14">{{ item.xdxj_gzdw }}</div>
              </td>
              <td>
                <div class="font-size-14">{{ item.xdxj_zw }}</div>
              </td>
              <td>
                <div class="font-size-14">{{ item.xdxj_sjhm }}</div>
              </td>
            </tr>
          </table>
        </el-form>
      </div>
      <div slot="footer" class="text-center">
        <el-button @click="formCancel">取 消</el-button>
        <el-button type="primary" @click="printHTML">打印</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  hmc_list,
  hmc_add,
  hmc_edit,
  hmc_del,
  hmc_detail,
  team_search,
  bjgl_list,
  family_list,
  family_edit,
  family_add,
  family_del,
  ry_list,
  ry_add,
  ry_del,
} from "./api";

import { useUserStore } from "@/stores/user";
const { token } = useUserStore();
import FileUpload from "@/components/FileUpload/index.vue";
export default {
  name: "index",
  components: {
    FileUpload,
  },
  data() {
    return {
      limit: 10,
      total: 12,
      cur_page: 1,
      keyword: "",
      xdx_xsxh: "",
      xdx_lxfs: "",
      class_name: "",
      firstForm: {
        team: "",
      },

      tableData: [],
      teamList: [],
      gradeList: [],

      inputVisible: false,
      inputValue: "",
      title: "",

      id: "",
      loading: false,
      isEdit: false,
      dialogImageUrl: "",
      dialogVisible: false,
      dialogFormVisible: false,
      detailDialogFormVisible: false,
      detailInfo: {},
      multipleSelection: [],
      // 导入导出
      import_type_url:
        window.globalVariables.api +
        "/xddy/dygl_xsxjk/import?issubmit=1&token=" +
        token,
      import_type_data: {},
      btnLoading: false,
      timestamp: Date.now(),
      classData: "",

      dialogForm: {
        xsxm: "",
        xsxh: "",
        xb: "",
        nl: "",
        lxfs: "",
        bz: "",
        bj: "",
        sczp: "",
        yddqzt: "",
        ydbz: "",
        jg: "",
        jtzz: "",
        xxdz: "",
        xx: "",
        sfhm: "",
        csny: "",
        mz: "",
        ahtc: "",
        zzmm: "",
        zjlx: "",
        csrq: "",
        cym: "",
        whcd: "",
        rdsj: "",
        szzb: "",
        szdxz: "",
        xdx_hjry: "",
        xdx_jtcy: "",
      },
      memberData: [
        {
          xdxj_cw: "",
          xdxj_xm: "",
          xdxj_zzmm: "",
          xdxj_gzdw: "",
          xdxj_zw: "",
          xdxj_sjhm: "",
        },
      ],

      rymcData: [],
      xdxr_shrymc: "",
      jtcyDetailInfo: [],
      childrenData: [],
      children: [
        {
          name: "称谓",
          key: "xdxj_cw",
        },
        {
          name: "姓名",
          key: "xdxj_xm",
        },
        {
          name: "政治面貌",
          key: "xdxj_zzmm",
        },
        {
          name: "工作单位",
          key: "xdxj_gzdw",
        },
        {
          name: "职位",
          key: "xdxj_zw",
        },
        {
          name: "手机号码",
          key: "xdxj_sjhm",
        },
      ],
    };
  },
  methods: {
    printHTML() {
      this.$print({
        printable: "printBox",
        type: "html",
        header: "",
        targetStyles: ["*"], // 打印内容使用所有HTML样式，没有设置这个属性/值，设置分页打印没有效果
      });
    },
    handleAddCy(value) {
      const data = JSON.parse(JSON.stringify(value));
      data.map((val) => {
        val.value = "";
      });
      console.log(data, "data");
      this.childrenData.push({
        xdxj_id: "",
        data,
      });
      console.log(this.childrenData, "childrenData");
    },
    handleRemoveCy(data, i) {
      if (data[i].xdxj_id) {
        family_del({ xdxj_id: data[i].xdxj_id });
      }
      data.splice(i, 1);
    },
    handleAddRymc() {
      console.log(this.dialogForm.xsxh, " this.dialogForm.xsxh");
      if (this.dialogForm.xdx_hjry == "" || this.dialogForm.xdx_hjry == null) {
        this.$message({
          message: "请输入荣誉名称",
          type: "error",
        });
        return;
      }
      const obj = {
        xdxr_shrymc: this.dialogForm.xdx_hjry,
        xdxr_xsxh: this.dialogForm.xsxh,
      };
      console.log(obj, "obj");
      ry_add(obj).then((res) => {
        if (res.code == 1) {
          this.rymcData.unshift(obj);
          this.xdxr_shrymc = "";
        }
      });
    },
    handleRemoveRymc(i) {
      console.log(i, 1111);
      ry_del({ xdxr_id: i.xdxr_id }).then((res) => {
        this.rymcData.splice(i, 1);
      });
    },
    initRyData(xdx_xsxh) {
      ry_list({ xdxr_xsxh: xdx_xsxh }).then((res) => {
        if (res.code == 1) {
          this.rymcData = res.data.page_data;
          this.dialogForm.sfhj = this.rymcData.length != 0 ? "1" : "2";
        }
      });
    },
    //班级
    getClassData() {
      bjgl_list().then((res) => {
        this.classData = res.data.page_data;
      });
    },
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getListData();
    },
    getListData() {
      this.loading = true;
      let data = {
        page: this.cur_page,
        limit: this.limit,

        team_id: this.firstForm.team,
      };

      hmc_list(data).then((res) => {
        this.loading = false;
        this.tableData = res.data.page_data;
        this.cur_page = Number(res.data.page_now);
        this.total = Number(res.data.total_rows);
      });
    },
    jtcyData(id) {
      let data = {
        xdx_id: id,
      };
      family_list(data).then((res) => {
        this.loading = false;
        const data = res.data.page_data;
        this.childrenData = [];
        if (data.length != 0) {
          data.map((value) => {
            const children = JSON.parse(JSON.stringify(this.children));
            children.map((val) => {
              val.value = value[val.key];
            });
            this.childrenData.unshift({
              xdxj_id: value.xdxj_id,
              data: children,
            });
            console.log(id, this.childrenData, 99);
          });
        }
      });
    },
    addData() {
      this.title = "添加/申请";
      this.dialogForm = {
        xsxm: "",
        xsxh: "",
        xb: "",
        nl: "",
        lxfs: "",
        bz: "",
        bj: "",
        sczp: "",
        jg: "",
        jtzz: "",
        xxdz: "",
        xx: "",
        sfhm: "",
        csny: "",
        mz: "",
        ahtc: "",
        zzmm: "",
        yddqzt: "",
        ydbz: "",
        zjlx: "",
        csrq: "",
        cym: "",
        whcd: "",
        rdsj: "",
        szzb: "",
        szdxz: "",
        xdx_hjry: "",
        xdx_jtcy: "",
      };
      this.isEdit = false;
      this.dialogFormVisible = true;
    },
    delData() {
      this.$confirm("确认删除这些信息?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let data = {
            xdx_id: this.multipleSelection,
          };

          hmc_del(data).then((res) => {
            if (res.code == 1) {
              this.$message({
                message: "信息删除成功！",
                type: "success",
              });
              this.getListData();
            } else {
              this.$message({
                message: res.msg,
                type: "error",
              });
            }
          });
        })
        .catch(() => {});
    },

    handleSelectionChange(val) {
      this.multipleSelection = [];
      for (let i in val) {
        this.multipleSelection.push(val[i].xdx_id);
      }
    },
    editData(item) {
      this.title = "编辑信息";
      this.isEdit = true;
      this.dialogFormVisible = true;
      this.id = item.xdx_id;
      this.dialogForm.xsxm = item.xdx_xsxm;
      this.dialogForm.xsxh = item.xdx_xsxh;
      this.dialogForm.xb = item.xdx_xb_option_k;
      this.dialogForm.nl = item.xdx_nl;
      this.dialogForm.lxfs = item.xdx_lxfs;
      this.dialogForm.bz = item.xdx_bz;
      this.dialogForm.bj = item.class_name;
      this.dialogForm.sczp = item.xdx_sczp;
      this.dialogForm.jg = item.xdx_jg;
      this.dialogForm.jtzz = item.xdx_jtzz;
      this.dialogForm.xxdz = item.xdx_xxdz;
      this.dialogForm.xx = item.xdx_xx;
      this.dialogForm.sfhm = item.xdx_zjhm;
      this.dialogForm.csny = item.xdx_csrq;
      this.dialogForm.mz = item.xdx_mz;
      this.dialogForm.ahtc = item.xdx_ahtc;
      this.dialogForm.zzmm = item.xdx_zzmm;
      this.dialogForm.yddqzt = item.xdx_yddqzt_option_k;
      this.dialogForm.ydbz = item.xdx_ydbz;
      this.dialogForm.zjlx = item.xdx_zjlx;
      this.dialogForm.cym = item.xdx_zym;
      this.dialogForm.whcd = item.xdx_whcd;
      this.dialogForm.rdsj = item.xdx_rdsj;
      this.dialogForm.szzb = item.xdx_szzb;
      this.dialogForm.szdxz = item.xdx_szdxz;
      this.dialogForm.xdx_hjry = item.xdx_hjry;
      this.jtcyData(item.xdx_id);
      this.initRyData(item.xdx_xsxh);
    },

    formSubmit() {
      let data = {
        xdx_xsxm: this.dialogForm.xsxm,
        xdx_xsxh: this.dialogForm.xsxh,
        xdx_xb: this.dialogForm.xb,
        xdx_nl: this.dialogForm.nl,
        xdx_lxfs: this.dialogForm.lxfs,
        xdx_bz: this.dialogForm.bz,
        class_name: this.dialogForm.bj,
        xdx_sczp: this.dialogForm.sczp,
        xdx_jg: this.dialogForm.jg,
        xdx_jtzz: this.dialogForm.jtzz,
        xdx_xxdz: this.dialogForm.xxdz,
        xdx_xx: this.dialogForm.xx,
        xdx_zjhm: this.dialogForm.sfhm,
        xdx_csrq: this.dialogForm.csny,
        xdx_mz: this.dialogForm.mz,
        xdx_ahtc: this.dialogForm.ahtc,
        xdx_zzmm: this.dialogForm.zzmm,
        xdx_yddqzt: this.dialogForm.yddqzt,
        xdx_ydbz: this.dialogForm.ydbz,
        xdx_zjlx: this.dialogForm.zjlx,
        xdx_zym: this.dialogForm.cym,
        xdx_whcd: this.dialogForm.whcd,
        xdx_rdsj: this.dialogForm.rdsj,
        xdx_szzb: this.dialogForm.szzb,
        xdx_szdxz: this.dialogForm.szdxz,
        xdx_hjry: this.dialogForm.xdx_hjry,
        xdx_jtcy: this.dialogForm.xdx_jtcy,
      };
      if (!this.isEdit) {
        hmc_add(data).then((res) => {
          if (res.code == 1) {
            this.$message({
              message: "报表添加成功！",
              type: "success",
            });
            this.dialogFormVisible = false;
            this.getListData();
          } else {
            this.$message({
              message: res.msg,
              type: "error",
            });
          }
        });
      } else {
        data.xdx_id = this.id;
        hmc_edit(data).then((res) => {
          if (res.code == 1) {
            this.$message({
              message: "信息编辑成功！",
              type: "success",
            });

            this.dialogFormVisible = false;
            this.getListData();
          } else {
            this.$message({
              message: res.msg,
              type: "error",
            });
          }
        });
        if (this.childrenData) {
          console.log(this.childrenData, 444);
          this.childrenData.map((item) => {
            const obj = { xdx_id: this.id };
            item.data.map((val) => {
              obj[val.key] = val.value;
            });
            let data1 = {
              xddy_dygl_xsxjk_jtcy: obj,
            };
            console.log(data1, "data1");

            if (item.xdxj_id == "") {
              family_add(data1);
              this.jtcyData(this.id);
            } else {
              data1 = Object.assign({ xdxj_id: item.xdxj_id }, data1);
              family_edit(data1);
              this.jtcyData(this.id);
            }
          });
        }
      }
    },

    detailData(item) {
      this.title = "信息详情";
      this.detailDialogFormVisible = true;
      let data = {
        xdx_id: item.xdx_id,
        xdx_xsxh: item.xdx_xsxh,
      };
      hmc_detail(data).then((res) => {
        if (res.code == 1) {
          this.detailInfo = res.data.one_info;
          let a = this.detailInfo.xdx_sczp.indexOf("|");
          this.detailInfo.xdx_sczp = this.detailInfo.xdx_sczp.substring(0, a);
        }
      });
      let data1 = {
        xdx_id: item.xdx_id,
      };
      family_list(data1).then((res) => {
        if (res.code == 1) {
          this.jtcyDetailInfo = res.data.page_data;
        }
      });
    },

    teamListData() {
      let data = {
        page: 1,
        limit: 9999,
      };
      team_search(data).then((res) => {
        if (res.code == 1) {
          this.teamList = res.data.page_data;
          // let obj = {
          //   team_id: "",
          //   team_name: "全部",
          // };
          // this.teamList.unshift(obj);
        }
      });
    },
    formCancel() {
      this.dialogFormVisible = false;
      this.detailDialogFormVisible = false;
    },

    exportAll() {
      let link =
        window.globalVariables.api +
        "/xddy/dygl_xsxjk/index?api=xls&page=1&limit=10000&token=" +
        token +
        "&xdx_id=" +
        this.multipleSelection.join(",");
      console.log(link, 33333333);
      window.open(link, "_blank");
    },
    clearData() {
      this.firstForm.team = "";
    },
  },
  mounted() {
    this.getListData();
    this.teamListData();
    this.getClassData();
  },
};
</script>


<style lang="scss" scoped>
.form-table {
  width: 100%;
  border-collapse: collapse;
  padding: auto;
  td {
    width: 20%;
    height: 30px;
    line-height: 30px;
    padding: 4px 4px 5px 5px;
    border: 1px solid #dbdbdb;
  }
  td:nth-child(odd) {
    background-color: #f0f3f8;
  }
  td:nth-child(5) {
    background-color: #fff;
  }
}
.form-table-two {
  width: 100%;
  border-collapse: collapse;
  padding: auto;
  td {
    height: 30px;
    line-height: 30px;
    padding: 4px 4px 5px 5px;
    border: 1px solid #dbdbdb;
    border-top: none;
  }
  tr:first-child {
    background-color: #f0f3f8;
  }
}
::v-deep .el-input {
  width: 180px;
}
.title {
  color: #3f8cff;
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
}
</style>

