import { ref, reactive, computed, toRefs } from "vue";
import { SaletaskMx } from "./interface";
import { ColumnProps, SearchProps } from "@/components/LjVxeTable/interface";
import type { u_cus_price } from "@/typings/business";
/**
 * @description 表格多选数据操作
 * @param {String} rowKey 当表格可以多选时，所指定的 id
 * */
export const useCusPrice = (t: any) => {
  const state = reactive<SaletaskMx.SaletaskMxStateProps>({
    vxeTableRef: null,
    requestData: [],
    selectList: [],
    currentRecord: null,
    reason: ""
  });

  // 表格配置项
  const columns: ColumnProps<u_cus_price>[] = [
    { type: "seq", title: "#", fixed: "left", width: 80 },
    {
      title: "有效",
      field: "ifcancel",
      table: "u_cus_price",
      render: scope => {
        let _data: any = scope.row ?? scope;
        if (!_data) return "";
        switch (_data.ifcancel) {
          case 1:
            return (
              <>
                <el-checkbox class={"el-checkbox__disabled-checked"} checked={true} disabled={true} />
              </>
            );
          default:
            return (
              <>
                <el-checkbox class={"el-checkbox__disabled-checked"} checked={false} disabled={true} />
              </>
            );
        }
      }
    },
    {
      title: "币种",
      field: "name",
      table: "cw_currency"
    },
    {
      title: "产品编码",
      field: "mtrlcode",
      table: "u_mtrldef"
    },
    {
      title: "产品名称",
      field: "mtrlname",
      table: "u_mtrldef"
    },
    {
      title: "规格",
      field: "mtrlmode",
      table: "u_mtrldef"
    },
    {
      title: "单位",
      field: "unit",
      table: "u_mtrldef"
    },
    {
      title: "销售单价",
      field: "fprice",
      table: "u_cus_price"
    },
    {
      title: "销售折扣",
      field: "zqrate",
      table: "u_cus_price"
    },
    {
      title: "销售实价",
      field: "price",
      table: "u_cus_price"
    },
    {
      title: "报价单价",
      field: "fprice_bj",
      table: "u_cus_price"
    },
    {
      title: "报价折扣",
      field: "zqrate_bj",
      table: "u_cus_price"
    },
    {
      title: "报价实价",
      field: "price_bj",
      table: "u_cus_price"
    },
    {
      title: "标准销售价",
      field: "stsaleprice",
      table: "u_cus_price"
    },
    {
      title: "数量下限",
      field: "qty",
      table: "u_cus_price"
    },
    {
      title: "数量上限",
      field: "qty1",
      table: "u_cus_price"
    },
    {
      title: "配置",
      field: "status",
      table: "u_cus_price"
    },
    {
      title: "配置1",
      field: "woodcode",
      table: "u_cus_price"
    },
    {
      title: "配置2",
      field: "pcode",
      table: "u_cus_price"
    },
    {
      title: "备注",
      field: "dscrp",
      table: "u_cus_price"
    },
    {
      title: "类别",
      field: "mtrltype",
      table: "u_cus_price"
    },
    {
      title: "标准面料",
      field: "mtrlsectype",
      table: "u_mtrldef"
    },
    {
      title: "自定义2",
      field: "zxmtrlmode",
      table: "u_mtrldef"
    },
    {
      title: "自定义3",
      field: "usermtrlmode",
      table: "u_mtrldef"
    },
    {
      title: "对应价格表",
      field: "pricelistid",
      table: "u_cus_price"
    },
    {
      title: "价格表中存在",
      field: "ifpricelist",
      table: "u_cus_price"
    },
    {
      title: "客户产品编码",
      field: "cusmtrlcode",
      table: "u_cusmtrlname"
    },
    {
      title: "客户产品名称",
      field: "cusmtrlname",
      table: "u_cusmtrlname"
    },
    {
      title: "客户产品规格",
      field: "cusmtrlmode",
      table: "u_cusmtrlname"
    },
    {
      title: "配置码",
      field: "configcode",
      table: "u_mtrldef"
    },
    {
      title: "配置说明",
      field: "configname",
      table: "u_mtrldef"
    },
    {
      title: "颜色",
      field: "mtrlcolor",
      table: "u_mtrldef"
    },
    {
      title: "客户简称",
      field: "simplename",
      table: "u_mtrldef"
    },
    {
      title: "产品状态",
      field: "isuse",
      table: "u_mtrldef"
    },
    {
      title: "云端同步时间",
      field: "fx_sync_time",
      table: "u_cus_price"
    },
    {
      title: "客户价格 更新时间",
      field: "sys_changetime",
      table: "u_cus_price"
    },
    {
      title: "已同步云端",
      field: "ifsync",
      table: "u_cus_price"
    },
    {
      title: "单位",
      field: "unit",
      table: "u_cus_price"
    }
  ];

  return {
    ...toRefs(state),
    columns
  };
};
