import { useDictionaryStore } from "@/store";
const { dicts } = useDictionaryStore();

export const getTableConfig = (id: string) => {
  return {
    // 获取工序记录项信息信息
    jiluxiang: {
      url: `/api/v1/op/operationRecord`,
      column: [
        {
          label: "工序id",
          prop: "operationId",
          display: false,
          hide: true,
          value: id,
        },
        { label: "记录项", prop: "thName" },
        {
          label: "单位",
          prop: "unit",
          search: true,
          filterable: true,
          type: "select",
          dataType: "string",
          dicData: dicts.danwei_type,
          props: { label: "dictLabel", value: "dictValue" },
        },
        { label: "标准值", prop: "standard" },
        { label: "上限值", prop: "upper" },
        { label: "下限值", prop: "lower" },
      ],
    },
    //工序物料
    wuliaocaiji: {
      url: "/api/v1/op/operationItem",
      column: [
        {
          label: "工序id",
          prop: "operationId",
          display: false,
          hide: true,
          value: id,
        },
        {
          label: "物料名称",
          prop: "itemName",
          addDisabled: true,
          editDisabled: true,
        },
        {
          label: "物料版本号",
          prop: "recordVersion",
          addDisabled: true,
          editDisabled: true,
          precision: 1,
        },
        {
          label: "物料编码",
          prop: "itemCode",
          addDisabled: true,
          editDisabled: true,
        },
        {
          label: "物料规格",
          prop: "itemModel",
          addDisabled: true,
          editDisabled: true,
        },
        { label: "所需数量", prop: "num" },
        {
          label: "追溯类型",
          prop: "traceType",
          search: true,
          filterable: true,
          type: "select",
          dataType: "string",
          dicData: dicts.trace_type,
          props: { label: "dictLabel", value: "dictValue" },
        },
        {
          label: "单位",
          prop: "unit",
          search: true,
          filterable: true,
          type: "select",
          dataType: "string",
          dicData: dicts.danwei_type,
          props: { label: "dictLabel", value: "dictValue" },
        },
        {
          label: "是否需要",
          prop: "isTrace",
          type: "radio", //类型为单选框
          dicData: [
            {
              label: "需采集物料",
              value: 1,
            },
            {
              label: "非必须采集物料",
              value: 0,
            },
          ],
          value: 1,
          rules: [
            {
              required: true,
              message: "是否需要",
              trigger: "blur",
            },
          ],
        },
      ],
    },
    dianjian: {
      url: `/api/v1/op/operationCheck`,
      column: [
        {
          label: "工序id",
          prop: "operationId",
          display: false,
          hide: true,
          value: id,
        },
        {
          label: "点检名称",
          prop: "checkName",
          addDisabled: true,
          editDisabled: true,
        },
        {
          label: "点检编码",
          prop: "checkCode",
          addDisabled: true,
          editDisabled: true,
        },
        { label: "内容", prop: "content" },
        {
          label: "单位",
          prop: "unit",
          search: true,
          filterable: true,
          type: "select",
          dataType: "string",
          dicData: dicts.danwei_type,
          props: { label: "dictLabel", value: "dictValue" },
        },
        { label: "标准值", prop: "standard" },
        { label: "上限值", prop: "upper" },
        { label: "下限值", prop: "lower" },
      ],
    },
    shebeijilu: {
      url: "/api/v1/op/operationEquit",
      column: [
        {
          label: "工序id",
          prop: "operationId",
          display: false,
          hide: true,
          value: id,
        },
        { label: "精度要求", prop: "accuracy",labelWidth: 150,},
        { label: "所需数量", prop: "num", display: false, hide: true },
        {
          label: "设备类型",
          prop: "equitType",
          search: true,
          labelWidth: 150,
          filterable: true,
          type: "select",
          dataType: "string",
          dicData: dicts.device_type,
          props: { label: "dictLabel", value: "dictValue" },
          rules: [
            {
              required: true,
              message: "设备类型",
              trigger: "blur",
            },
          ],
        },
        {
          label: "必须采集",
          prop: "collection",
          labelWidth: 150,
          type: "radio", //类型为单选框
          dicData: [
            {
              label: "必须",
              value: 1,
            },
            {
              label: "非必须",
              value: 0,
            },
          ],
          value: 1,
          rules: [
            {
              required: true,
              message: "是否必须采集",
              trigger: "blur",
            },
          ],
        },
        { label: "标准机时(分)", prop: "standTime",
          type: "number",
          labelWidth: 150,
          min: 1,
          rules: [
            {
              required: true,
              message: "标准机时",
              trigger: "blur",
            },
          ],
        },
      ],
    },
    ESOP: {
      url: "/api/v1/op/esop",
      column: [
        {
          label: "工序id",
          prop: "operationId",
          display: false,
          hide: true,
          value: id,
        },

        { label: "标题", prop: "title", addDisabled: true, editDisabled: true },
        { label: "展示页数", prop: "showAppointPageNum", type: "number" },
        {
          label: "总页数",
          prop: "pageNum",
          type: "number",
          hide: true,
          display: false,
        },
        {
          label: "版本号",
          prop: "recordVersion",
          type: "number",
          addDisabled: true,
          editDisabled: true,
          precision: 1,
          rules: [
            {
              required: true,
              message: "版本号",
              trigger: "blur",
            },
          ],
        },
        {
          label: "图纸编码",
          prop: "drawingCode",
          hide: true,
          addDisabled: true,
          editDisabled: true,
        },
        {
          label: "内容",
          prop: "content",
          hide: true,
          addDisabled: true,
          editDisabled: true,
        },
        {
          label: "排序",
          prop: "sortNum",
          hide: true,
          addDisabled: true,
          editDisabled: true,
        },
        {
          label: "文件",
          prop: "filePath",
          span: 24,
          type: "img",
          slot: true,
          viewDisplay: false,
          addDisabled: true,
          editDisabled: true,
        },
      ],
    },
  };
};

// 工艺工序组件路径的组件类别
interface comType {
  compentName: string;
  compentType: string;
}
export const comTypes: comType[] = [
  {
    compentName: "记录项",
    compentType: "jiluxiang",
  },
  {
    compentName: "物料采集",
    compentType: "wuliaocaiji",
  },
  {
    compentName: "ESOP",
    compentType: "ESOP",
  },
  {
    compentName: "点检",
    compentType: "dianjian",
  },
  {
    compentName: "设备记录",
    compentType: "shebeijilu",
  },
  {
    compentName: "紧固",
    compentType: "jingu",
  },
  {
    compentName: "调试配对",
    compentType: "tiaoshipipei",
  },
  /*{
		compentName: "铭牌绑定",
		compentType: "mingpai",
	},*/
  {
    compentName: "多媒体采集",
    compentType: "duomeiticaiji",
  },
  {
    compentName: "测试记录",
    compentType: "ceshijilu",
  },
  {
    compentName: "工序表单",
    compentType: "operationExcel",
  },
  {
    compentName: "数据采集",
    compentType: "screwdriver",
  },
];
