import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
import { getPosGroupList } from '@/api/demo/system';

export const columns: BasicColumn[] = [
  {
    title: '任务名称',
    dataIndex: 'taskName',
  },
  {
    title: '备注/说明',
    dataIndex: 'taskRemark',
  },
  {
    title:"领取时间",
    dataIndex:"reciveTime",
  },
  {
    title: '图斑数量',
    dataIndex: 'tubanNum',
  }, 
  {
    title: '任务状态',
    dataIndex: 'status',
    width: 80,
    customRender: ({ record }) => {
      const enable = record.isComplate;
      const color = enable ? 'green' : 'red';
      const text = enable ? '已完成' : '未完成';
      return h(Tag, { color: color }, () => text);
    },
  },{
    title:"操作",
    dataIndex:"action",
    width: 150,
    fixed: 'right',
  }
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'key',
    label: '任务名称',
    component: 'Input',
    colProps: { span: 8 },
  }
];

export const formGroupSchema: FormSchema[] = [
  {
    field: 'posGroupId',
    component: 'ApiSelect',
    label: '职级组',
    required: true,
    componentProps: ({ formActionType, formModel }) => {
      return {
        api: getPosGroupList, // 接口
        // 接口参数
        resultField: 'result',
        labelField: 'name',
        valueField: 'id',
      };
    },
  },
];

const updateShpae=()=>{
  alert(123);
}

window.updateShpae = updateShpae


export const formSchema: FormSchema[] = [
  {
    field: 'shpId',
    label: '选择AI解译成果',
    component: 'Select',
    componentProps: {
      fieldNames: {
        label: 'shpName',
        key: 'id',
        value: 'id',
      },
      onChange:(value)=>{
        console.log(value)
      },
      getPopupContainer: () => document.body,
    },
    required: true,
    suffix: () => h('span', {style:"background:#0960BD;padding:8px 10px;border-radius:4px;color:#fff;cursor:pointer;", class: 'update-button',onclick:"updateShpae()"}, '更新数据'),
  },
  {
    field: 'previousPhase',
    label: '选择前时项',
    component: 'TreeSelect',
    componentProps: {
      multiple:true,
      fieldNames: {
        label: 'name',
        key: 'id',
        value: 'id',
      },
      onChange:(value)=>{
        console.log(value)
      },
      getPopupContainer: () => document.body,
    },
    required: true,
    suffix: () => h('span', {style:"background:#0960BD;padding:8px 10px;border-radius:4px;color:#fff;cursor:pointer;", class: 'update-button',onclick:"updateShpae()"}, '更新数据'),
  },
  {
    field: 'laterPhase',
    label: '选择后时项',
    component: 'TreeSelect',
    componentProps: {
      multiple:true,
      fieldNames: {
        label: 'name',
        key: 'id',
        value: 'id',
      },
      onChange:(value)=>{
        console.log(value)
      },
      getPopupContainer: () => document.body,
    },
    required: true,
    suffix: () => h('span', {style:"background:#0960BD;padding:8px 10px;border-radius:4px;color:#fff;cursor:pointer;", class: 'update-button',onclick:"updateShpae()"}, '更新数据'),
  },
  {
    field: 'taskName',
    label: '任务名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'remark',
    label: '备注/说明',
    component: 'InputTextArea',
    required: false,
  }
];
