export const TableColumns = [
  { key: "code", title: "订单生成单号", width: 250 },
  {
    key: "status",
    title: "状态",
    inputType: "Select",
    referName: "purchase_task_status",
  },
  { key: "demandCode", title: "需求单号", width: 250 },
  { key: "materialCode", title: "物料编码" },
  { key: "materialName", title: "物料名称" },
  // { key: "material", title: "物料" },
  { key: "materialDesc", title: "物料描述" },
  { key: "manufacturerName", title: "生产厂家" },
  { key: "puQty", title: "采购数量" },
  { key: "executeQty", title: "已执行数量" },
  { key: "residueQty", title: "未执行数量" },
  {
    key: "priceType",
    title: "价格类型",
    inputType: "Select",
    referName: "sys_price_type",
  },
  { key: "puUnitName", title: "采购单位" },
  // { key: "id", title: "主键" },

  // { key: "manufacturer", title: "生产厂家" },
  // { key: "buyer", title: "采购员" },
  { key: "buyerName", title: "采购员" },
  // { key: "supplier", title: "建议供应商" },
  { key: "supplierName", title: "建议供应商" },
  // { key: "puOrg", title: "采购组织" },
  {
    key: "puOrgName",
    title: "采购组织",
  },
  // { key: "currency", title: "币种" },
  { key: "currencyName", title: "币种" },
  { key: "billYpe", title: "交易类型" },
  { key: "source", title: "需求来源" },
  // { key: "customer", title: "收货客户" },
  { key: "customerName", title: "收货客户" },
  // { key: "puUnit", title: "采购单位" },

  { key: "demandDate", title: "需求时间" },
  { key: "projectName", title: "项目名称" },
  // { key: "demandPersonal", title: "需求人" },
  {
    key: "demandPersonalName",
    title: "需求人",
  },
  // { key: "demandOrg", title: "需求组织" },
  { key: "demandOrgName", title: "需求组织" },
  // { key: "demandDept", title: "需求部门" },
  { key: "demandDeptName", title: "需求部门" },
  {
    key: "isBack",
    title: "是否退回",
    inputType: "Select",
    referName: "sys_yes_no",
  },
  { key: "baskCause", title: "退回原因" },
  { key: "backDate", title: "退回日期" },
  // { key: "assignSupplier", title: "指定供应商" },
  { key: "assignSupplierName", title: "指定供应商" },
  // { key: "unit", title: "单位" },
  { key: "unitName", title: "单位" },
  // { key: "file", title: "附件" },
  // { key: "tenantId", title: "租户号" },
  // { key: "revision", title: "乐观锁" },
  // { key: "delFlag", title: "删除标记" },
];

export const SearchColumns = [
  {
    key: "classIds",
    title: "物料分类",
    inputType: "PopoverTreeSelect",
    multiple: true,
    valueKey: "id",
    referName: "MATERIALCLASSIFY_PARAM",
    readonly: true,
    dataMapping: {},
  },
  {
    key: "materialCodes",
    title: "物料编码",
    inputType: "PopoverSelect",
    multiple: true,
    valueKey: "code",
    referName: "MATERIAL_PARAM",
    readonly: true,
    dataMapping: {},
  },
  { key: "materialDesc", title: "物料描述", inputType: "Input" },
  { key: "code", title: "单据号", inputType: "Input" },
  {
    key: "puOrgIds",
    title: "采购组织",
    inputType: "PopoverSelect",
    multiple: true,
    valueKey: "id",
    referName: "ORG_PARAM",
    readonly: true,
    dataMapping: {},
  },
  {
    key: "status",
    title: "状态",
    inputType: "Select",
    referName: "purchase_task_status",
    value: "0",
    clearable: true,
  },
  {
    key: "date",
    title: "创建时间",
    inputType: "DatePicker",
    type: "daterange",
    unlinkPanels: true,
    rangeSeparator: "至",
    valueFormat: "yyyy-MM-dd",
    endPlaceholder: "结束日期",
    startPlaceholder: "开始日期",
    pickerOptions: pickerOptions,
    value: [],
  },
  {
    key: "buyers",
    title: "采购员",
    inputType: "PopoverSelect",
    multiple: true,
    valueKey: "code",
    referName: "CONTACTS_PARAM",
    readonly: true,
    dataMapping: {},
  },
  {
    key: "documentsCodes",
    title: "需求来源",
    inputType: "Input",
    placeholder: "请输入来源单据号，多个用,分隔",
    span: 12,
  },
];

const pickerOptions = {
  shortcuts: [
    {
      text: "昨天",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 1);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近三天",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 3);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近一周",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近一个月",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近三个月",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近半年",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 180);
        picker.$emit("pick", [start, end]);
      },
    },
  ],
};
