export const tableOption = {
  border: true,
  menuAlign: 'center',
  searchMenuSpan: 6,
  editBtn: false,
  delBtn: false,
  dialogClickModal: false,
  align: 'center',
  addBtn: false,
  rowKey: 'planId',
  rowParentKey: 'parentId',
  selection: false,
  selectable: (row, index) => {
    return row.planState === 'INIT' && row.parentId == 0;
  },
  column: [
    {
      label: '序号',
      prop: 'index'
    },
    {
      label: '目标名称',
      prop: 'planName',
      search: true,
      width: 400
    },
    {
      label: '目标分值',
      prop: 'planScore'
    },
    {
      type: 'select',
      label: '目标类型',
      prop: 'planType',
      search: true,
      dicData: [
        {
          label: '年度计划',
          value: 'ANN'
        },
        {
          label: '季度计划',
          value: 'QRT'
        },
        {
          label: '月度计划',
          value: 'MON'
        }
      ]
    },
    {
      label: '目标周期',
      prop: 'planIssue',
      formatter(row) {
        return row.planIssue + ' 至 ' + row.planExpiry;
      }
    },
    {
      label: '目标周期',
      prop: 'period',
      search: true,
      searchSpan: 12,
      hide: true,
      searchslot: true,
      type: 'monthrange'
    },
    {
      label: '创建周期',
      prop: 'createTime',
      search: true,
      searchSpan: 12,
      searchslot: true,
      type: 'monthrange'
    },
    {
      label: '承接对象',
      prop: 'consigneeName'
    },
    {
      label: '承接对象',
      prop: 'consigneeId',
      hide: true,
      search: true,
      type: 'select',
      label: '承接对象',
      addDisplay: true,
      editDisplay: true,
      viewDisplay: true,
      search: true,
      dicUrl: '/admin/dept/list/descendant',
      props: {
        label: 'name',
        value: 'deptId'
      },
      formatter: function(row) {
        return Number(row.consigneeId);
      }
    },
    {
      label: '下发状态',
      prop: 'actionState',
      type: 'select',
      search: true,
      hide: true,
      dicUrl: '/admin/dict/type/impl_plan_act_state'
    },
    {
      label: '下发状态',
      prop: 'planState',
      type: 'select',
      dicUrl: '/admin/dict/type/impl_plan_state',
      formatter: function(row) {
        const map = {
          INIT: '待营销中心分管领导审批',
          REJECTED: '拒绝',
          IN_PROGRESS: '执行中'
        };

        if (row.planState === 'INIT') {
          if (row.parentId == 0) {
            return '待营销中心分管领导审批';
          } else {
            return '待运营管理员审批';
          }
        }
        if (row.planState === 'PASSED') {
          return row.planScore != row.availScore ? '审核通过已下发' : '审核通过待下发';
        } else {
          return map[row.planState];
        }
      }
    },
    // {
    //   label: '拆解状态',
    //   prop: 'detailsActionState',
    //   type: 'select',
    //   search: true,
    //   hide: true,
    //   dicData: [
    //     {
    //       label: '审核通过',
    //       value: 'PASSED'
    //     },
    //     {
    //       label: '审核拒绝',
    //       value: 'REJECTED'
    //     },
    //     {
    //       label: '待区域管理员审核',
    //       value: 'INIT'
    //     },
    //     {
    //       label: '待商务组审核',
    //       value: 'CKT1'
    //     },
    //     {
    //       label: '待分管领导审核',
    //       value: 'CKT2'
    //     },
    //     {
    //       label: '待拆解',
    //       value: 'PENDING'
    //     }
    //   ]
    // },
    {
      label: '拆解状态',
      prop: 'planDetails',
      formatter: function(row) {
        if (row.parentId == 0) return '--';
        if (!row.planDetails) {
          return '待拆解';
        } else {
          if (row.planDetails.detailsState === 'INIT') {
            return '待区域管理员审核';
          } else if (row.planDetails.detailsState === 'CKT1') {
            return '待商务组审核';
          } else if (row.planDetails.detailsState === 'CKT2') {
            return '待分管领导审核';
          } else if (row.planDetails.detailsState === 'PASSED') {
            return '审核通过';
          } else if (row.planDetails.detailsState === 'REJECTED') {
            return '审核拒绝';
          }
        }
        // return row.planDetails ? "已拆解" : "待拆解";
      }
    },

    {
      label: '已下发积分值',
      prop: 'execScoreValue'
    }
  ]
};
