import { message } from 'ant-design-vue';
import { FormSchema } from '/@/components/Table';
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '控制活动编号',
    field: 'caNo',
    dynamicDisabled: true,
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 8},},wrapperCol:{xs: {span: 24},sm: {span: 16},}},
    component: 'Input',
  },
  {
    label: '控制活动名称',
    field: 'caName',
    dynamicDisabled: true,
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 8},},wrapperCol:{xs: {span: 24},sm: {span: 16},}},
    component: 'Input',
  },
  {
    label: '检查内容',
    field: 'checkContent',
    component: 'InputTextArea',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 4},},wrapperCol:{xs: {span: 24},sm: {span: 20},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入检查内容!'},
      ];
    },
  },
  // {
  //   label: '检查方法',
  //   field: 'checkMethod',
  //   component: 'InputTextArea',
  //   itemProps:{labelCol:{xs: {span: 24},sm: {span: 4},},wrapperCol:{xs: {span: 24},sm: {span: 20},}},
  //   dynamicRules: ({model,schema}) => {
  //     return [
  //            { required: true, message: '请输入检查方法!'},
  //     ];
  //   },
  // },
  {
    label: '询问',
    field: 'checkAsk',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 8},},wrapperCol:{xs: {span: 24},sm: {span: 16},}},
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_position,name,code"
    },
    // dynamicRules: ({model,schema}) => {
    //   return [
    //          { required: true, message: '请选择询问!'},
    //   ];
    // },
    helpMessage: '向适合的人员询问有关控制运作的资料。'
  },
  {
    label: '交叉/确证寻问',
    field: 'checkCross',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 8},},wrapperCol:{xs: {span: 24},sm: {span: 16},}},
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_position,name,code"
    },
    // dynamicRules: ({model,schema}) => {
    //   return [
    //          { required: true, message: '请选择交叉/确证寻问!'},
    //   ];
    // },
    helpMessage: '除实施适当测试手段外，通过询问企业内其他人员，验证控制的执行情况'
  },
  {
    label: '观察',
    field: 'checkObserve',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 8},},wrapperCol:{xs: {span: 24},sm: {span: 16},}},
    component: 'Input',
    // dynamicRules: ({model,schema}) => {
    //   return [
    //          { required: true, message: '请输入观察!'},
    //   ];
    // },
    helpMessage: '观察控制运行的实际情况。'
  },
  {
    label: '审阅',
    field: 'checkReview',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 8},},wrapperCol:{xs: {span: 24},sm: {span: 16},}},
    component: 'JTreeDict',
    componentProps: {
      field: 'code',
      parentCode:'B05',
      placeholder: '请选择审阅'
    },
    // dynamicRules: ({model,schema}) => {
    //   return [
    //          { required: true, message: '请选择审阅!'},
    //   ];
    // },
    helpMessage: '检查控制生成的记录和文件，作为控制设计和执行情况的证据。'
  },
  {
    label: '重新运行',
    field: 'checkRerun',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 4},},wrapperCol:{xs: {span: 24},sm: {span: 20},}},
    component: 'InputTextArea',
    helpMessage: '重新履行某些控制程序，以证明其运行是正确的。'
  },
  {
    label: '能力评估',
    field: 'checkAbility',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 4},},wrapperCol:{xs: {span: 24},sm: {span: 20},}},
    component: 'InputTextArea',
    helpMessage: '综合运用询问、文件检查、重新履行等手段，可以测试某个管理人员在某一领域的知识及其实施某项控制程序的胜任能力。'
  },
  {
    label: '系统验证',
    field: 'checkSysValid',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 8},},wrapperCol:{xs: {span: 24},sm: {span: 16},}},
    component: 'Input',
    helpMessage: '测试信息系统中的自动化控制是否按设计要求运行。'
  },
  {
    label: '数据验证',
    field: 'checkDataValid',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 8},},wrapperCol:{xs: {span: 24},sm: {span: 16},}},
    component: 'Input',
    helpMessage: '直接抽取数据进行完整性与准确性的验证。'
  },
  {
    label: '穿行性测试',
    field: 'checkTrajection',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 4},},wrapperCol:{xs: {span: 24},sm: {span: 20},}},
    component: 'InputTextArea',
    helpMessage: '追踪交易在信息系统/业务流程中的处理过程，以证实所了解的流程与控制。'
  },
  {
    label: '分析性复核',
    field: 'checkAnReview',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 4},},wrapperCol:{xs: {span: 24},sm: {span: 20},}},
    component: 'InputTextArea',
    helpMessage: '分析重要的比率或趋势，调查这些比率或趋势的异常变动及其与预期数额和相关信息的差异。'
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
	  label: '',
	  field: 'projectCreId',
	  component: 'Input',
	  show: false
	},
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

export const formSchemaPlan: FormSchema[] = [
  {
    label: '访谈部门',
    field: 'interviewDepId',
    component: 'JSelectDept',
    componentProps: ({ schema, tableAction, formActionType, formModel }) => {
      return {
        multiple: false,
        allowClear: false,
        onChange: (e: any) => {
          const { updateSchema } = formActionType;
          if(e === undefined||e===''){
            formModel.interviewDepId = null
            formModel.userNo = null
            updateSchema({
              field: 'dutyCode',
              componentProps: {
                dict: "listDuty",
                onclick: (e:any) => {
                  if(!formModel.interviewDepId){
                    message.warn("请先选择责任部门！")
                    return
                 }
                }
              },
            });
            return
          }
           if(formModel.interviewDepId!=e[0]){
            formModel.userNo = null
          }
          updateSchema({
            field: 'userNo',
            componentProps: {
              dict: "listDuty",
              depCode: e[0],
              onclick: (e:any) => {
                if(!formModel.interviewDepId){
                  message.warn("请先选择责任部门！")
                  return
                }
              }
            },
          });
        }
      }
    },
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择责任部门!'},
      ];
    },
  },
  {
    label: '访谈人员',
    field: 'userNo',
    component: 'JSearchSelectDuty',
    componentProps: ({ schema, tableAction, formActionType, formModel }) => {
      return {
        dict: "listDuty",
        onclick: (e:any) => {
          if(!formModel.interviewDepId){
            formModel.userNo = null
             message.warn("请先选择责任部门！")
             return
          }
       }
      }
    },
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择责任人!'},
      ];
    },
  },
  {
    label: '访谈内容',
    field: 'interviewContent',
    component: 'InputTextArea',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入访谈内容!'},
      ];
    },
  },
  {
    label: '访谈日期',
    field: 'interviewDate',
    component: 'DatePicker',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择访谈日期!'},
      ];
    },
  },
  {
    label: '备注',
    field: 'des',
    component: 'InputTextArea',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
  },
  {
	  label: '',
	  field: 'projectCreId',
	  component: 'Input',
	  show: false
	},
  {
	  label: '',
	  field: 'ids',
	  component: 'Input',
	  show: false
	},
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
]