<template>
  <basic-container>
    <avue-crud :option="option"
               :table-loading="loading"
               :data="data"
               :page.sync="page"
               :permission="permissionList"
               :before-open="beforeOpen"
               v-model="form"
               ref="crud"
               @row-update="rowUpdate"
               @row-save="rowSave"
               @row-del="rowDel"
               @search-change="searchChange"
               @search-reset="searchReset"
               @selection-change="selectionChange"
               @current-change="currentChange"
               @size-change="sizeChange"
               @refresh-change="refreshChange"
               @on-load="onLoad">
      <template slot="menuLeft">
        <el-button type="primary"
                   size="small"
                   icon="el-icon-plus"
                   plain
                   v-if="permission.correctionalstaff_add"
                   @click="handleAdd">
          新 增</el-button>
        <el-button type="danger"
                   size="small"
                   icon="el-icon-delete"
                   plain
                   v-if="permission.correctionalstaff_delete"
                   @click="handleDelete">删 除
        </el-button>
      </template>
      <template slot="menu" slot-scope="scope">
        <el-button type="text" size="small" icon="el-icon-view"  @click.native="showDetail(scope.row)">查 看</el-button>
        <el-button type="text" size="small" icon="el-icon-edit"  @click.native="handleEdit(scope.row)">编 辑</el-button>
      </template>
    </avue-crud>
    <el-dialog v-if="detailVisible===true" :append-to-body="true" :close-on-click-modal="false" :modal-append-to-body="false" :visible.sync="detailVisible"
               title="详 情" width="70%">
      <avue-form :option="optiondetail" v-model="detailForm"></avue-form>
    </el-dialog>
    <el-dialog v-if="addVisible===true" :append-to-body="true" :close-on-click-modal="false" :modal-append-to-body="false" :visible.sync="addVisible"
               title="新 增" width="70%">
      <CorrectionalStaffForm :tag=tag :formCorrectionalStaff="null" :formBasic="null" @refreshChange="refreshChange" :close-fn="() => {addVisible = false}"></CorrectionalStaffForm>
    </el-dialog>
    <el-dialog v-if="editVisible===true" :append-to-body="true" :close-on-click-modal="false" :modal-append-to-body="false" :visible.sync="editVisible"
               title="编 辑" width="70%">
      <CorrectionalStaffForm :tag=tag :formCorrectionalStaff="formCorrectionalStaff" :formBasic="formBasic" @refreshChange="refreshChange" :close-fn="() => {editVisible = false}"></CorrectionalStaffForm>
    </el-dialog>
  </basic-container>
</template>

<script>
  import {getList, getDetail, add, update, remove,generatedetail} from "@/api/person/correctionalstaff";
  import {getDetail as getbasicDetail} from "@/api/person/basicinfo";
  import {DIC} from "@/api/util/nation"
  import CorrectionalStaffForm from '@/components/person-tags/correctionalStaff-form';
  import {mapGetters} from "vuex";
  import {validatePhone} from "../../util/validator";

  export default {
    components:{CorrectionalStaffForm},
    data() {
      return {
        detailVisible:false,
        addVisible:false,
        editVisible:false,
        form: {},
        tag:0,
        formBasic:{},
        formCorrectionalStaff:{},
        detailForm:{},
        query: {},
        loading: true,
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        },
        selectionList: [],
        option: {
          height:'auto',
          calcHeight: 30,
          tip: false,
          searchShow: true,
          searchMenuSpan: 6,
          border: true,
          index: true,
          viewBtn: false,
          editBtn:false,
          addBtn:false,
          selection: true,
          dialogClickModal: false,
          column: [
            {
              label: "基本表Id",
              prop: "parentId",
              hide:true,
              display:false,
              rules: [{
                required: false,
                message: "请输入基本表Id",
                trigger: "blur"
              }]
            },
            {
              label: "姓名",
              prop: "name",
              search:true,
              rules: [{
                required: true,
                message: "请输入姓名",
                trigger: "blur"
              }]
            },
            {
              label: "矫正类别",
              prop: "correctType",
              type:'select',
              dataType:'number',
              dicUrl:"/api/blade-system/dict-biz/dictionary?code=correct_type",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              search:true,
              rules: [{
                required: true,
                message: "请输入矫正类别",
                trigger: "blur"
              }]
            },
            {
              label: "矫正人员编号",
              prop: "correctPersonCode",
              hide:true,
              rules: [{
                required: false,
                message: "请输入矫正人员编号",
                trigger: "blur"
              }]
            },
            {
              label: "原羁押场所",
              prop: "detentionPlace",
              hide:true,
              rules: [{
                required: false,
                message: "请输入原羁押场所",
                trigger: "blur"
              }]
            },
            {
              label: "案件类型",
              prop: "caseType",
              hide:true,
              rules: [{
                required: false,
                message: "请输入案件类型",
                trigger: "blur"
              }]
            },
            {
              label: "具体罪名",
              prop: "specificCharges",
              hide:true,
              rules: [{
                required: false,
                message: "请输入具体罪名",
                trigger: "blur"
              }]
            },
            {
              label: "原判刑期",
              prop: "originalSentence",
              hide:true,
              rules: [{
                required: false,
                message: "请输入原判刑期",
                trigger: "blur"
              }]
            },
            {
              label: "原判刑开始日期",
              type:'date',
              valueFormat:"yyyy-MM-dd",
              prop: "startdateSentence",
              hide:true,
              rules: [{
                required: true,
                message: "请输入原判刑开始日期",
                trigger: "blur"
              }]
            },
            {
              label: "原判刑结束日期",
              prop: "enddateSentence",
              type:'date',
              valueFormat:"yyyy-MM-dd",
              hide:true,
              rules: [{
                required: true,
                message: "请输入原判刑结束日期",
                trigger: "blur"
              }]
            },
            {
              label: "矫正开始日期",
              prop: "startdateCorrection",
              type:'date',
              valueFormat:"yyyy-MM-dd",
              hide:true,
              rules: [{
                required: false,
                message: "请输入矫正开始日期",
                trigger: "blur"
              }]
            },
            {
              label: "矫正结束日期",
              prop: "enddateCorrection",
              type:'date',
              valueFormat:"yyyy-MM-dd",
              hide:true,
              rules: [{
                required: false,
                message: "请输入矫正开始日期",
                trigger: "blur"
              }]
            },
            {
              label: "报道方式",
              prop: "checkinMode",
              type: "select",
              dataType:'number',
              dicUrl: "/api/blade-system/dict-biz/dictionary?code=checkin_mode",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              rules: [{
                required: true,
                message: "请输入报道方式",
                trigger: "blur"
              }]
            },
            {
              label: "是否累惯犯",
              prop: "isRecidivist",
              type: "select",
              hide:true,
              dataType:'number',
              dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              rules: [{
                required: true,
                message: "请输入是否累惯犯",
                trigger: "blur"
              }]
            },
            {
              label: "“四史”情况",
              prop: "fourHistories",
              type: "select",
              dataType:'number',
              dicUrl: "/api/blade-system/dict-biz/dictionary?code=four_histories",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              rules: [{
                required: false,
                message: "请选择“四史”情况",
                trigger: "blur"
              }]
            },
            {
              label: "“五涉”情况",
              prop: "fiveSituation",
              type: "select",
              dataType:'number',
              dicUrl: "/api/blade-system/dict-biz/dictionary?code=five_situation",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              rules: [{
                required: false,
                message: "请输入“五涉”情况",
                trigger: "blur"
              }]
            },
            {
              label: "是否建立矫正小组",
              prop: "isTeamEstablished",
              type: "select",
              hide:true,
              dataType:'number',
              dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              rules: [{
                required: true,
                message: "请输入是否建立矫正小组",
                trigger: "blur"
              }]
            },
            {
              label: "矫正小组人员组成情况",
              prop: "teamComposition",
              type: "select",
              hide:true,
              dataType:'number',
              dicUrl: "/api/blade-system/dict-biz/dictionary?code=team_composition",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              rules: [{
                required: false,
                message: "请输入矫正小组人员组成情况",
                trigger: "blur"
              }]
            },
            {
              label: "矫正解除（终止）类型",
              prop: "reliefType",
              type: "select",
              hide:true,
              dataType:'number',
              dicUrl: "/api/blade-system/dict-biz/dictionary?code=relief_type",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              rules: [{
                required: false,
                message: "请输入矫正解除（终止）类型",
                trigger: "blur"
              }]
            },
            {
              label: "是否有脱管",
              prop: "isGetRid",
              type: "select",
              hide:true,
              dataType:'number',
              dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              rules: [{
                required: true,
                message: "请输入是否有脱管",
                trigger: "blur"
              }]
            },
            {
              label: "脱管原因",
              prop: "reasonGetRid",
              hide:true,
              rules: [{
                required: false,
                message: "请输入脱管原因",
                trigger: "blur"
              }]
            },
            {
              label: "检查监督托管情况",
              prop: "inspectGetRid",
              hide:true,
              rules: [{
                required: false,
                message: "请输入检查监督托管情况",
                trigger: "blur"
              }]
            },
            {
              label: "脱管纠正情况",
              prop: "correctGetRid",
              type:'textarea',
              hide:true,
              rules: [{
                required: false,
                message: "请输入脱管纠正情况",
                trigger: "blur"
              }]
            },
            {
              label: "是否有漏管",
              prop: "isUnmanaged",
              type: "select",
              hide:true,
              dataType:'number',
              dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              rules: [{
                required: false,
                message: "请输入是否有漏管",
                trigger: "blur"
              }]
            },
            {
              label: "漏管原因",
              prop: "reasonUnmanage",
              type:'textarea',
              hide:true,
              rules: [{
                required: false,
                message: "请输入漏管原因",
                trigger: "blur"
              }]
            },
            {
              label: "检查监督漏管情况",
              prop: "inspectUnmanage",
              type:'textarea',
              hide:true,
              rules: [{
                required: false,
                message: "请输入检查监督漏管情况",
                trigger: "blur"
              }]
            },
            {
              label: "漏管纠正情况",
              prop: "correctUnmanage",
              type:'textarea',
              hide:true,
              rules: [{
                required: false,
                message: "请输入漏管纠正情况",
                trigger: "blur"
              }]
            },
            {
              label: "奖惩情况（国标）",
              prop: "rewardsAndPunishments",
              type:'textarea',
              hide:true,
              rules: [{
                required: false,
                message: "请输入奖惩情况（国标）",
                trigger: "blur"
              }]
            },
            {
              label: "刑罚变更执行情况",
              prop: "penaltyChange",
              type:'textarea',
              hide:true,
              rules: [{
                required: false,
                message: "请输入刑罚变更执行情况",
                trigger: "blur"
              }]
            },
            {
              label: "是否重新犯罪",
              prop: "newCrime",
              type: "select",
              hide:true,
              dataType:'number',
              dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              rules: [{
                required: true,
                message: "请输入是否重新犯罪",
                trigger: "blur"
              }]
            },
            {
              label: "重新犯罪名称",
              prop: "nameOfRecidivism",
              hide:true,
              rules: [{
                required: false,
                message: "请输入重新犯罪名称",
                trigger: "blur"
              }]
            },
            {
              label: "刑法执行类别",
              prop: "categoryOfLaw",
              hide:true,
              rules: [{
                required: false,
                message: "请输入刑法执行类别",
                trigger: "blur"
              }]
            },
            {
              label: "管控等级",
              prop: "controlLevel",
              hide:true,
              rules: [{
                required: false,
                message: "请输入管控等级",
                trigger: "blur"
              }]
            },
            {
              label: "是否重点监控",
              prop: "isKeyMonitoring",
              type: "select",
              dataType:'number',
              dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              rules: [{
                required: true,
                message: "请输入是否重点监控",
                trigger: "blur"
              }]
            },
          ]
        },
        //详情option
        optiondetail:{
          submitBtn:false,
          emptyBtn:false,
          disabled: true,
          tabs:true,
          group:[
            {
              icon:'el-icon-info',
              label:'基础信息',
              prop:'group1',
              column:[
                {
                  label: "身份证号",
                  prop: "idCard",
                  search:true,
                  hide: true,
                  rules: [{
                    required: false,
                    message: "请输入身份证号码",
                    trigger: "blur"
                  }]
                },
                {
                  label: "姓名",
                  prop: "name",
                  search:true,
                  rules: [{
                    required: true,
                    message: "请输入姓名",
                    trigger: "blur"
                  }]
                },
                {
                  label: "性别",
                  prop: "sex",
                  type: 'select',
                  dataType:"number",
                  search:true,
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=sex",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请选择性别",
                    trigger: "blur"
                  }]
                },
                {
                  label: "照片",
                  prop: "imageUri",
                  type: 'upload',
                  hide:true,
                  listType: 'picture-img',
                  propsHttp: {
                    res: "data",
                    url: "link"
                  },
                  action: "/api/blade-resource/oss/endpoint/put-file",
                  tip: '只能生产jpg/png图片，且不超过500kb',
                  rules: [{
                    required: false,
                    message: "请上传入境证明url",
                    trigger: "blur"
                  }]
                },
                {
                  label: "所属社区",
                  prop: "agencyId",
                  search: true,
                  cascaderItem: ['residentialId'],
                  type: "select",
                  // remote: true,
                  dicUrl: "/api/cyzh-community/agency/list?size=9999",
                  dicFormatter:(res)=>{
                    return res.data.records;//返回字典的层级结构
                  },
                  props: {
                    label: "name",
                    value: "id"
                  },
                  rules: [{
                    required: true,
                    message: "请选择所属社区",
                    trigger: "blur"
                  }]
                },
                {
                  label: "所属小区",
                  prop: "residentialId",
                  type: "select",
                  search: true,
                  cascaderItem: ['buildingId'],
                  dicUrl: "/api/cyzh-community/residential/list?agencyId={{key}}",
                  dicFormatter:(res)=>{
                    return res.data.records;//返回字典的层级结构
                  },
                  // dicFlag: false,
                  filterable: true,
                  props: {
                    label: "name",
                    value: "id"
                  },
                  rules: [{
                    required: true,
                    message: "请选择所属小区",
                    trigger: "blur"
                  }]
                },
                {
                  label: "所属楼栋",
                  prop: "buildingId",
                  type: "select",
                  // slot:true,
                  search: true,
                  cascaderItem: ['unitId'],
                  dicUrl: "/api/cyzh-community/building/list?residentialId={{key}}",
                  dicFormatter:(res)=>{
                    return res.data.records;//返回字典的层级结构
                  },
                  // dicFlag: true,
                  // filterable: true,
                  props: {
                    label: "name",
                    value: "id"
                  },
                  rules: [{
                    required: true,
                    message: "请选择楼栋",
                    trigger: "blur"
                  }]
                },
                {
                  label: "所属单元",
                  prop: "unitId",
                  type: "select",
                  // slot:true,
                  search: true,
                  cascaderItem: ['floorId'],
                  dicUrl: "/api/cyzh-community/unit/list?buildingId={{key}}",
                  dicFormatter:(res)=>{
                    return res.data.records;//返回字典的层级结构
                  },
                  // dicFlag: false,
                  filterable: true,
                  props: {
                    label: "name",
                    value: "id"
                  },
                  rules: [{
                    required: true,
                    message: "请选择单元",
                    trigger: "blur"
                  }]
                },
                {
                  label: "所属楼层",
                  prop: "floorId",
                  type: "select",
                  // slot:true,
                  search: true,
                  cascaderItem: ['roomId'],
                  dicUrl: "/api/cyzh-community/floor/list?unitId={{key}}",
                  dicFormatter:(res)=>{
                    return res.data.records;//返回字典的层级结构
                  },
                  // dicFlag: false,
                  filterable: true,
                  props: {
                    label: "name",
                    value: "id"
                  },
                  rules: [{
                    required: true,
                    message: "请选择楼层d",
                    trigger: "blur"
                  }]
                },
                {
                  label: "所属房间",
                  prop: "roomId",
                  type: "select",
                  // slot:true,
                  search: true,
                  dicUrl: "/api/cyzh-community/room/list?floorId={{key}}",
                  dicFormatter:(res)=>{
                    return res.data.records;//返回字典的层级结构
                  },
                  // dicFlag: false,
                  filterable: true,
                  props: {
                    label: "name",
                    value: "id"
                  },
                  rules: [{
                    required: true,
                    message: "请选择房间",
                    trigger: "blur"
                  }]
                },
                {
                  label:'手机号码',
                  prop:'phone',
                  width:120,
                  rules: [{
                    required: true,
                    message: "请输入手机号码",
                    trigger: "blur"
                  }]
                },
                {
                  label: "生日",
                  prop: "birthday",
                  type:'date',
                  valueFormat:"yyyy-MM-dd",
                  hide: true,
                  rules: [{
                    required: false,
                    message: "请输入生日",
                    trigger: "blur"
                  }]
                },
                // {
                //   label: "民族",
                //   prop: "nation",
                //   hide:true,
                //   rules: [{
                //     required: true,
                //     message: "请输入民族",
                //     trigger: "blur"
                //   }]
                // },
                {
                  label: "民族",
                  prop: "nation",
                  type:'select',
                  dicData:DIC.VALUE,
                  filterable:true,
                  // searchFilterable:true,
                  hide:true,
                  rules: [{
                    required: true,
                    message: "请输入民族",
                    trigger: "blur"
                  }]
                },
                {
                  label: "籍贯",
                  prop: "nativePlace",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入籍贯",
                    trigger: "blur"
                  }]
                },
                {
                  label: "国籍",
                  prop: "nationality",
                  hide:true,
                  type:'select',
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=nationality",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "请输入国籍",
                    trigger: "blur"
                  }]
                },
                {
                  label: "政治面貌",
                  prop: "political",
                  hide:true,
                  type: 'select',
                  dataType:"number",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=political",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "请选择政治面貌",
                    trigger: "blur"
                  }]
                },
                {
                  label: "婚姻状况",
                  prop: "maritalStatus",
                  type: 'select',
                  dataType:"number",
                  hide:true,
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=marital-status",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "请选择婚姻状况",
                    trigger: "blur"
                  }]
                },
                {
                  label: "教育水平",
                  prop: "educationalLevel",
                  hide:true,
                  type: 'select',
                  dataType:"number",
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=educational-level",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "请选择教育水平",
                    trigger: "blur"
                  }]
                },
                {
                  label: "工作单位",
                  prop: "workplace",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入工作单位",
                    trigger: "blur"
                  }]
                },
                {
                  label: "小程序openId",
                  prop: "openId",
                  hide: true,
                  display: false,
                  rules: [{
                    required: false,
                    message: "请输入小程序openId",
                    trigger: "blur"
                  }]
                },
                {
                  label: "邮箱",
                  prop: "email",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入邮箱",
                    trigger: "blur"
                  }]
                },
                {
                  label:"是否会员",
                  prop:'isMember',
                  type:"select",
                  hide:true,
                  dataType:'number',
                  dicData:[
                    {
                      label:'是',
                      value:1
                    },{
                      label:'否',
                      value:0
                    },{
                      label:'暂无',
                      value:-1
                    }
                  ],
                },
                {
                  label: "人员标签",
                  prop: "tags",
                  type:'checkbox',
                  search:true,
                  multiple:true,
                  span: 24,
                  dataType:'string',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=person-tag",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入标签",
                    trigger: "blur"
                  }]
                },
                {
                  label: "备注",
                  prop: "remark",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入备注",
                    trigger: "blur"
                  }]
                },
              ]
            },{
              icon:'el-icon-s-custom',
              label:'矫正人员信息',
              prop:'group2',
              column: [
                {
                  label: "基本表Id",
                  prop: "parentId",
                  hide:true,
                  display:false,
                  rules: [{
                    required: false,
                    message: "请输入基本表Id",
                    trigger: "blur"
                  }]
                },
                {
                  label: "姓名",
                  prop: "name",
                  search:true,
                  rules: [{
                    required: true,
                    message: "请输入姓名",
                    trigger: "blur"
                  }]
                },
                {
                  label: "矫正类别",
                  prop: "correctType",
                  type:'select',
                  dataType:'number',
                  dicUrl:"/api/blade-system/dict-biz/dictionary?code=correct_type",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  search:true,
                  rules: [{
                    required: true,
                    message: "请输入矫正类别",
                    trigger: "blur"
                  }]
                },
                {
                  label: "矫正人员编号",
                  prop: "correctPersonCode",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入矫正人员编号",
                    trigger: "blur"
                  }]
                },
                {
                  label: "原羁押场所",
                  prop: "detentionPlace",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入原羁押场所",
                    trigger: "blur"
                  }]
                },
                {
                  label: "案件类型",
                  prop: "caseType",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入案件类型",
                    trigger: "blur"
                  }]
                },
                {
                  label: "具体罪名",
                  prop: "specificCharges",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入具体罪名",
                    trigger: "blur"
                  }]
                },
                {
                  label: "原判刑期",
                  prop: "originalSentence",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入原判刑期",
                    trigger: "blur"
                  }]
                },
                {
                  label: "原判刑开始日期",
                  type:'date',
                  valueFormat:"yyyy-MM-dd",
                  prop: "startdateSentence",
                  hide:true,
                  rules: [{
                    required: true,
                    message: "请输入原判刑开始日期",
                    trigger: "blur"
                  }]
                },
                {
                  label: "原判刑结束日期",
                  prop: "enddateSentence",
                  type:'date',
                  valueFormat:"yyyy-MM-dd",
                  hide:true,
                  rules: [{
                    required: true,
                    message: "请输入原判刑结束日期",
                    trigger: "blur"
                  }]
                },
                {
                  label: "矫正开始日期",
                  prop: "startdateCorrection",
                  type:'date',
                  valueFormat:"yyyy-MM-dd",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入矫正开始日期",
                    trigger: "blur"
                  }]
                },
                {
                  label: "矫正结束日期",
                  prop: "enddateCorrection",
                  type:'date',
                  valueFormat:"yyyy-MM-dd",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入矫正开始日期",
                    trigger: "blur"
                  }]
                },
                {
                  label: "报道方式",
                  prop: "checkinMode",
                  type: "select",
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=checkin_mode",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入报道方式",
                    trigger: "blur"
                  }]
                },
                {
                  label: "是否累惯犯",
                  prop: "isRecidivist",
                  type: "select",
                  hide:true,
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入是否累惯犯",
                    trigger: "blur"
                  }]
                },
                {
                  label: "“四史”情况",
                  prop: "fourHistories",
                  type: "select",
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=four_histories",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "请选择“四史”情况",
                    trigger: "blur"
                  }]
                },
                {
                  label: "“五涉”情况",
                  prop: "fiveSituation",
                  type: "select",
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=five_situation",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "请输入“五涉”情况",
                    trigger: "blur"
                  }]
                },
                {
                  label: "是否建立矫正小组",
                  prop: "isTeamEstablished",
                  type: "select",
                  hide:true,
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入是否建立矫正小组",
                    trigger: "blur"
                  }]
                },
                {
                  label: "矫正小组人员组成情况",
                  prop: "teamComposition",
                  type: "select",
                  hide:true,
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=team_composition",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "请输入矫正小组人员组成情况",
                    trigger: "blur"
                  }]
                },
                {
                  label: "矫正解除（终止）类型",
                  prop: "reliefType",
                  type: "select",
                  hide:true,
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=relief_type",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "请输入矫正解除（终止）类型",
                    trigger: "blur"
                  }]
                },
                {
                  label: "是否有脱管",
                  prop: "isGetRid",
                  type: "select",
                  hide:true,
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入是否有脱管",
                    trigger: "blur"
                  }]
                },
                {
                  label: "脱管原因",
                  prop: "reasonGetRid",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入脱管原因",
                    trigger: "blur"
                  }]
                },
                {
                  label: "检查监督托管情况",
                  prop: "inspectGetRid",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入检查监督托管情况",
                    trigger: "blur"
                  }]
                },
                {
                  label: "脱管纠正情况",
                  prop: "correctGetRid",
                  type:'textarea',
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入脱管纠正情况",
                    trigger: "blur"
                  }]
                },
                {
                  label: "是否有漏管",
                  prop: "isUnmanaged",
                  type: "select",
                  hide:true,
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "请输入是否有漏管",
                    trigger: "blur"
                  }]
                },
                {
                  label: "漏管原因",
                  prop: "reasonUnmanage",
                  type:'textarea',
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入漏管原因",
                    trigger: "blur"
                  }]
                },
                {
                  label: "检查监督漏管情况",
                  prop: "inspectUnmanage",
                  type:'textarea',
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入检查监督漏管情况",
                    trigger: "blur"
                  }]
                },
                {
                  label: "漏管纠正情况",
                  prop: "correctUnmanage",
                  type:'textarea',
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入漏管纠正情况",
                    trigger: "blur"
                  }]
                },
                {
                  label: "奖惩情况（国标）",
                  prop: "rewardsAndPunishments",
                  type:'textarea',
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入奖惩情况（国标）",
                    trigger: "blur"
                  }]
                },
                {
                  label: "刑罚变更执行情况",
                  prop: "penaltyChange",
                  type:'textarea',
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入刑罚变更执行情况",
                    trigger: "blur"
                  }]
                },
                {
                  label: "是否重新犯罪",
                  prop: "newCrime",
                  type: "select",
                  hide:true,
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入是否重新犯罪",
                    trigger: "blur"
                  }]
                },
                {
                  label: "重新犯罪名称",
                  prop: "nameOfRecidivism",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入重新犯罪名称",
                    trigger: "blur"
                  }]
                },
                {
                  label: "刑法执行类别",
                  prop: "categoryOfLaw",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入刑法执行类别",
                    trigger: "blur"
                  }]
                },
                {
                  label: "管控等级",
                  prop: "controlLevel",
                  hide:true,
                  rules: [{
                    required: false,
                    message: "请输入管控等级",
                    trigger: "blur"
                  }]
                },
                {
                  label: "是否重点监控",
                  prop: "isKeyMonitoring",
                  type: "select",
                  dataType:'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "请输入是否重点监控",
                    trigger: "blur"
                  }]
                },
              ]}
          ],
        },
        data: []
      };
    },
    computed: {
      ...mapGetters(["permission"]),
      permissionList() {
        return {
          addBtn: this.vaildData(this.permission.correctionalstaff_add, false),
          viewBtn: this.vaildData(this.permission.correctionalstaff_view, false),
          delBtn: this.vaildData(this.permission.correctionalstaff_delete, false),
          editBtn: this.vaildData(this.permission.correctionalstaff_edit, false)
        };
      },
      ids() {
        let ids = [];
        this.selectionList.forEach(ele => {
          ids.push(ele.id);
        });
        return ids.join(",");
      }
    },
    methods: {
      showDetail(row){
        console.log(row,'当前行数据');
        this.detailForm = row;
        this.detailVisible=true;
      },
      handleAdd(){
        this.tag=1;
        this.addVisible = true;
        console.log(this.addVisible,'addVisible')
      },
      handleEdit(row){
        console.log(row,'row')
        generatedetail(row.id).then(res => {
          this.formCorrectionalStaff = res.data.data;
          console.log(this.formCorrectionalStaff,'this.formCorrectionalStaff');
          getbasicDetail(this.formCorrectionalStaff.parentId).then(res =>{
            this.formBasic = res.data.data;
            console.log(this.formBasic,'this.formBasic')
          })
        });
        this.tag=2;
        this.editVisible = true;
      },
      rowSave(row, done, loading) {
        add(row).then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          loading();
          window.console.log(error);
        });
      },
      rowUpdate(row, index, done, loading) {
        update(row).then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          loading();
          console.log(error);
        });
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(row.id);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
        }
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(this.ids);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
            this.$refs.crud.toggleSelection();
          });
      },
      beforeOpen(done, type) {
        if (["edit", "view"].includes(type)) {
          getDetail(this.form.id).then(res => {
            this.form = res.data.data;
          });
        }
        done();
      },
      searchReset() {
        this.query = {};
        this.onLoad(this.page);
      },
      searchChange(params, done) {
        this.query = params;
        this.page.currentPage = 1;
        this.onLoad(this.page, params);
        done();
      },
      selectionChange(list) {
        this.selectionList = list;
      },
      selectionClear() {
        this.selectionList = [];
        this.$refs.crud.toggleSelection();
      },
      currentChange(currentPage){
        this.page.currentPage = currentPage;
      },
      sizeChange(pageSize){
        this.page.pageSize = pageSize;
      },
      refreshChange() {
        this.onLoad(this.page, this.query);
      },
      onLoad(page, params = {}) {
        this.loading = true;
        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
          const data = res.data.data;
          this.page.total = data.total;
          this.data = data.records;
          this.loading = false;
          this.selectionClear();
        });
      }
    }
  };
</script>

<style>
</style>
