import { useDictionaryStore } from "@/store";
const { dicts } = useDictionaryStore();
import dictDataUtil from "@/common/configs/dictDataUtil";
export const tableConfig = {
  MARTERIAL: {
    url: "/api/v1/base/material",
    column: [
      { label: "物料编码", prop: "materialCode", search: true },
      { label: "物料名称", prop: "materialName", search: true },
      { label: "保质期", prop: "qualityGuaranteePeriod" },

      { label: "物料规格", prop: "spec" },

      {
        label: "物料属性",
        prop: "attributeDictValue",
        search: true,
        filterable: true,
        type: "select",
        dataType: "string",
        dicData: dicts.material_properties,
        props: { label: "dictLabel", value: "dictValue" },
      },
      {
        label: "是否工装",
        prop: "frock",
        filterable: true,
        type: "radio", //类型为单选框
        dicData: [
          {
            label: "否",
            value: 0,
          },
          {
            label: "是",
            value: 1,
          },
        ],
        value: 0,
      },
      {
        label: "质检方案",
        prop: "inspectDictValue",
        search: true,
        filterable: true,
        type: "select",
        dataType: "string",
        dicData: dicts.quality_testing_plan,
        props: { label: "dictLabel", value: "dictValue" },
      },
      {
        label: "物料级别",
        prop: "levelDictValue",
        search: true,
        filterable: true,
        type: "select",
        dataType: "string",
        dicData: dicts.material_level,
        props: { label: "dictLabel", value: "dictValue" },
      },
      {
        label: "封装方法",
        prop: "packageDictValue",
        search: true,
        filterable: true,
        type: "select",
        dataType: "string",
        dicData: dicts.packaging_method,
        props: { label: "dictLabel", value: "dictValue" },
      },
      {
        label: "质量等级",
        prop: "qualityLevelDictValue",
        search: true,
        filterable: true,
        type: "select",
        dataType: "string",
        dicData: dicts.quality_grade,
        props: { label: "dictLabel", value: "dictValue" },
      },
      {
        label: "选用类型",
        prop: "selectionDictValue",
        search: true,
        filterable: true,
        type: "select",
        dataType: "string",
        dicData: dicts.selection_type,
        props: { label: "dictLabel", value: "dictValue" },
      },
      {
        label: "阶段",
        prop: "stageDictValue",
        search: true,
        filterable: true,
        type: "select",
        dataType: "string",
        dicData: dicts.stage,
        props: { label: "dictLabel", value: "dictValue" },
      },
      {
        label: "物料单位",
        prop: "unitDictValue",
        search: true,
        filterable: true,
        type: "select",
        dataType: "string",
        dicData: dicts.danwei_type,
        props: { label: "dictLabel", value: "dictValue" },
      },
      { label: "备注", prop: "remark", type: "textarea" },
    ],
  },

  FACTORY: {
    url: "/api/v1/base/workShop",
    column: [
      {
        label: "车间名称",
        prop: "name",
        search: true,
      },
      {
        label: "车间负责人",
        prop: "manager",
        rules: [
          {
            required: true,
            message: "请选择厂区负责人",
            trigger: "blur",
          },
        ],
        type: "select",
        dicUrl: import.meta.env.VITE_APP_BASE_API + "/api/v1/sys/user/list",
        dicMethod: "post",
        props: {
          label: "userName", // 下拉菜单显示的字段
          value: "userName", // 下拉菜单值的字段
        },
      },
      {
        label: "车间位置",
        prop: "position",
      },
      {
        label: "所属工厂",
        prop: "factoryName",
        display: false,
      },
      {
        label: "车间描述",
        prop: "remark",
      },
      {
        label: "创建人",
        prop: "creator",
        display: false,
      },
      {
        label: "创建时间",
        prop: "created",
        display: false,
      },
    ],
  },

  PRODUCTIONLINE: {
    url: "/api/v1/base/productionLine/list",
    column: [
      {
        label: "产线名称",
        prop: "name",
        search: true,
        rules: [
          {
            required: true,
            message: "请填写产线名称",
            trigger: "blur",
          },
        ],
      },
      {
        label: "产线负责人",
        prop: "manager",
        rules: [
          {
            required: true,
            message: "请选择产线负责人",
            trigger: "blur",
          },
        ],
        type: "select",
        dicUrl: import.meta.env.VITE_APP_BASE_API + "/api/v1/sys/user/list",
        dicMethod: "post",
        props: {
          label: "userName", // 下拉菜单显示的字段
          value: "userName", // 下拉菜单值的字段
        },
      },
      {
        label: "产线位置",
        prop: "position",
      },
      {
        label: "所属车间",
        prop: "workShopName",
        display: false,
      },
      {
        label: "产线描述",
        prop: "remark",
      },
      {
        label: "创建人",
        prop: "creator",
        display: false,
      },
      {
        label: "创建时间",
        prop: "created",
        display: false,
      },
    ],
  },

  STATION: {
    url: "/api/v1/base/station",
    column: [
      {
        label: "工位编号",
        prop: "stationCode",
        search: true,
        rules: [
          {
            required: true,
            message: "请填写工位编号",
            trigger: "blur",
          },
        ],
      },
      {
        label: "工位名称",
        prop: "name",
        search: true,
        rules: [
          {
            required: true,
            message: "请填写工位名称",
            trigger: "blur",
          },
        ],
      },
      {
        label: "工位类型",
        prop: "stationDictValue",
        search: true,
        rules: [
          {
            required: true,
            message: "请选择工位类型",
            trigger: "blur",
          },
        ],
        type: "select",
        dicData: dicts.station_type,
        searchClearable: false, //可清空的输入框,默认为true
        filterable: true, //添加filterable属性即可启用搜索功能
        props: {
          label: "dictLabel", // 下拉菜单显示的字段
          value: "dictValue", // 下拉菜单值的字段
        },
      },
      {
        label: "工位操作方式",
        prop: "operateDictValue",
        rules: [
          {
            required: true,
            message: "请选择工位方式",
            trigger: "blur",
          },
        ],
        type: "select",
        dicData: dicts.station_operate_type,
        props: {
          label: "dictLabel", // 下拉菜单显示的字段
          value: "dictValue", // 下拉菜单值的字
        },
      },
      {
        label: "工位负责人",
        prop: "manager",
        rules: [
          {
            required: true,
            message: "请选择工位负责人",
            trigger: "blur",
          },
        ],
        type: "select",
        dicUrl: import.meta.env.VITE_APP_BASE_API + "/api/v1/sys/user/list",
        dicMethod: "post",
        props: {
          label: "userName", // 下拉菜单显示的字段
          value: "userName", // 下拉菜单值的字段
        },
      },
      {
        label: "所属产线",
        prop: "productionLineName",
        display: false,
      },
      {
        label: "工位地址",
        prop: "position",
        rules: [
          {
            required: true,
            message: "请填写工位地址",
            trigger: "blur",
          },
        ],
      },
      {
        label: "工位IP地址",
        prop: "stationIp",
        rules: [
          {
            required: true,
            message: "请填写工位IP地址",
            trigger: "blur",
          },
        ],
      },
      {
        label: "工位描述",
        prop: "remark",
        type: "textarea",
        span: 24,
      },
      {
        label: "创建人",
        prop: "creator",
        display: false,
      },
      {
        label: "创建时间",
        prop: "created",
        display: false,
      },
    ],
  },

  DEVICE: {
    url: "/api/v1/device",
    column: [
      {
        label: "设备编号",
        prop: "deviceNo",
        search: true,
        rules: [
          {
            required: true,
            message: "设备编号不能为空",
            trigger: "trigger",
          },
        ],
      },
      {
        label: "设备名称",
        prop: "deviceName",
        search: true,
        rules: [
          {
            required: true,
            message: "设备名称不能为空",
            trigger: "trigger",
          },
        ],
      },
      {
        label: "设备类型",
        prop: "deviceType",
        type: "select",
        search: true,
        dicData: dicts.device_type,
        props: {
          label: "dictLabel",
          value: "dictValue",
        },
      },
      {
        label: "负责人",
        prop: "head",
      },
      {
        label: "设备位置",
        prop: "devicePosition",
      },
      {
        label: "规格",
        prop: "specifications",
      },
      {
        label: "品牌",
        prop: "brand",
      },
      {
        label: "设备状态",
        prop: "state",
        type: "select",
        dicData: [
          {
            label: "启用",
            value: "0",
          },
          {
            label: "停用",
            value: "1",
          },
        ],
      },
    ],
  },
  OPERATION: {
    url: "/api/v1/op/baseOperation",
    column: [
      {
        label: "工序名称",
        prop: "operationName",
        span: 12,
        search: true,
        rules: [
          {
            required: true,
            message: "工序名称不能为空",
            trigger: "blur",
          },
        ],
      },
      {
        label: "工序编码",
        prop: "operationCode",
        span: 12,
        search: true,
        rules: [
          {
            required: true,
            message: "工序编码不能为空",
            trigger: "blur",
          },
        ],
      },
      {
        label: "工段",
        prop: "workSection",
        type: "select",
        search: true,
        dicData: dicts.workshop_section,
        props: {
          label: "dictLabel",
          value: "dictValue",
        },
        span: 12,
        rules: [
          {
            required: true,
            message: "请选择工段",
            trigger: "change",
          },
        ],
      },
      {
        label: "工序类型",
        prop: "operationType",
        type: "select",
        search: true,
        dicData: dicts.process_type,
        props: {
          label: "dictLabel",
          value: "dictValue",
        },
        span: 12,
        rules: [
          {
            required: true,
            message: "请选择工序类型",
            trigger: "change",
          },
        ],
      },
      {
        label: "工艺条件",
        prop: "processAsk",
        span: 12,
        rules: [
          {
            required: true,
            message: "工艺条件不能为空",
            trigger: "blur",
          },
        ],
      },
      {
        label: "技能要求",
        prop: "skillAsk",
        span: 12,
        type: "select",
        search: true,
        filterable: true,
        dicData: dicts.skill_requirements,
        props: {
          label: "dictLabel",
          value: "dictValue",
        },
        rules: [
          {
            required: true,
            message: "请选择技能要求",
            trigger: "change",
          },
        ],
      },
      {
        label: "后置时间(分)",
        prop: "forceTime",
        type: "number",
        span: 12,
        rules: [
          {
            required: true,
            message: "后置时间不能为空",
            trigger: "blur",
          },
        ],
      },
      /*{
        label: "标准机时",
        prop: "timeingNum",
        type: "number",
        span: 12,
        rules: [
          {
            required: true,
            message: "标准机时不能为空",
            trigger: "blur",
          },
        ],
      },*/
      {
        label: "标准工时(分)",
        prop: "standardWorktime",
        type: "number",
        span: 12,
        rules: [
          {
            required: true,
            message: "标准工时不能为空",
            trigger: "blur",
          },
        ],
      },
      // {
      //   label: '岗位',
      //   prop: 'type',
      //   type: 'select',
      //   dicData: [
      //     {
      //       label: '岗位1',
      //       value: 'position1',
      //     },
      //   ],
      //   props: {
      //     label: 'label',
      //     value: 'value',
      //   },
      //   span: 12,
      // },
      {
        label: "工位类型",
        prop: "stanType",
        search: true,
        type: "select",
        dicData: dicts.station_type,
        props: {
          label: "dictLabel",
          value: "dictValue",
        },
        span: 12,
        row: true,
        rules: [
          {
            required: true,
            message: "请选择工位类型",
            trigger: "blur",
          },
        ],
      },
      //  {
      //    label: "是否外协",
      //    prop: "externalCooperation",
      //    span: 8,
      // hide: true,
      //    type: "switch",
      //    dicData: switchOp,
      //    value: 0,
      //  },
      /*{
        label: "是否首检",
        prop: "firstCheck",
        span: 8,
        hide: true,
        type: "switch",
        dicData: switchOp,
        value: 0,
      },*/
      /*{
        label: "是否巡检",
        prop: "inspection",
        span: 8,
        hide: true,
        type: "switch",
        dicData: switchOp,
        value: 0,
      },
      {
        label: "是否自检",
        prop: "selfCheck",
        span: 8,
        hide: true,
        type: "switch",
        dicData: switchOp,
        value: 0,
      },*/
      //  {
      //    label: "是否工艺数量",
      //    prop: "common",
      //    span: 8,
      // hide: true,
      //    type: "switch",
      //    dicData: switchOp,
      //    value: 0,
      //  },
      //  {
      //    label: "是否分批",
      //    prop: "batch",
      //    span: 8,
      // hide: true,
      //    type: "switch",
      //    dicData: switchOp,
      //    value: 0,
      //  },
      /*{
        label: "是否委外",
        prop: "outsourcing",
        span: 8,
        hide: true,
        type: "switch",
        dicData: switchOp,
        // click: ({ column,value }) => {
        //  if(value == 0){
        // console.log('column',column)
        //  }
        // },
        //联动隐藏
        control: (val, form) => {
          return {
            outTime: {
              display: val == 1 ? true : false,
            },
          };
        },
        value: 0,
      },*/
      {
        label: "分批数量",
        prop: "batchNum",
        span: 5,
        display: false,
        hide: true,
        value: 0,
        // slot:true, // 自定义列
      },
      {
        label: "委外时间",
        prop: "outTime",
        span: 5,
        display: false,
        hide: true,
        value: 0,
        // slot:true, // 自定义列
      },
      {
        label: "工序描述",
        prop: "operationDesc",
        hide: true,
        span: 24,
        type: "textarea",
      },
    ],
  },
  MARTERIAL_BOM: {
    url: "/api/v1/base/materialBom/list",
    column: [
      {
        label: "物料版本",
        prop: "bomVersion",
        search: true,
        type: "select",
      },
      {
        label: "物料编码",
        prop: "materialCode",
        hide: true,
      },

      {
        label: "物料名称",
        prop: "materialName",
        overHidden: true,
        hide: true,
      },

      {
        label: "物料编码",
        prop: "bomMaterialCode",
      },
      {
        label: "物料名称",
        prop: "bomMaterialName",
        overHidden: true,
      },
      {
        label: "物料属性",
        prop: "bomMaterialAttribute",
        type: "select",
        dicData: dicts.material_properties,
        props: { label: "dictLabel", value: "dictValue" },
      },
      {
        label: "物料数量",
        prop: "bomMaterialNumber",
        min: 0,
        slot: true,
        cell: true,
        type: "number",
        precision: 2,
      },
      { label: "物料规格", prop: "spec", search: true },
    ],
  },

  OP_CHECK: {
    url: "/api/v1/op/base/check",
    column: [
      {
        label: "点检项名称",
        prop: "checkName",
        span: 12,
        labelWidth: "150",
        search: true,
        editDisabled: true,
      },
      {
        label: "点检项编码",
        prop: "checkCode",
        labelWidth: "150",
        editDisabled: true,
        span: 12,
        search: true,
      },
      {
        label: "内容",
        prop: "content",
        span: 12,
        search: false,
      },
    ],
  },

  ESOP: {
    url: "/api/v1/base/drawing",
    column: [
      {
        label: "图纸编码",
        prop: "drawingCode",
        span: 12,
        labelWidth: "150",
        search: true,
        editDisabled: true,
      },
      {
        label: "标题",
        prop: "drawingTitle",
        labelWidth: "150",
        editDisabled: true,
        span: 12,
        search: false,
      },
      {
        label: "版本号",
        prop: "drawingVersion",
        span: 12,
        search: false,
      },
      /*{
			  label: "图纸",
			  prop: "drawingPath",
			  span: 24,
			  display: false,
			  slot: true,
			  // formatter: (row, column, cellValue, index) => {
			  //   return `${row.drawingPath}`;
			  // },
			}*/
    ],
  },

  USERS: {
    url: "/api/v1/sys/employeeSkill/users",
    column: [
      {
        label: "员工编码",
        prop: "employeeCode",
        search: true,
      },
      {
        label: "用户id",
        prop: "id",
        /*display:false,*/
      },
      {
        label: "用户名",
        prop: "userName",
        search: true,
        width: "120",
      },
      {
        label: "用户电话",
        prop: "phone",
        search: true,
      },

      {
        label: "所属机构",
        prop: "deptName",
        overHidden: true,
        disabled: true,
      },
      /* {
        label: "所属机构",
        prop: "institution",
        filterable: true,
        type: "select",
        width: 100,
        overHidden: true,
        dicUrl: dictDataUtil.dept_list_url,
        dicMethod: "post",
        props: { label: "deptName", value: "id" },
        disabled: true,
      },*/
    ],
  },

  FAULT: {
    url: "/api/v1/process/escalationFault/order",
    column: [
      {
        label: "不合格审理单号",
        prop: "trackingNumber",
        search: true,
        width: 120,
        overHidden: true,
      },
      {
        label: "工单号",
        prop: "workOrderCode",
        width: 120,
        overHidden: true,
        search: true,
      },
      {
        label: "订单编号",
        prop: "orderCode",
        width: 120,
        overHidden: true,
        search: true,
      },
      {
        label: "不合格数量",
        prop: "unqualifiedNum",
        width: 100,
        overHidden: true,
      },

      {
        label: "序列号",
        prop: "seqNo",
        overHidden: true,
      },
      {
        label: "报故人",
        prop: "creator",
        width: 100,
      },

      {
        label: "产品编码",
        prop: "materialCode",
        width: 120,
        overHidden: true,
      },
      {
        label: "产品名称",
        prop: "materialName",
        width: 100,
        overHidden: true,
      },
      {
        label: "规格",
        prop: "spec",
        width: 150,
        overHidden: true,
      },
    ],
  },
};
