columns.js 4.98 KB
Newer Older
TZW's avatar
TZW committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
import dayjs from 'dayjs';

function getcolumns(setdrawer) {
  const disabledDateOfDay = (current) => {
    // Can not select days before today and today
    return current && current < dayjs().endOf('day');
  };
  return {
    columns: [
      {
        dataIndex: 'equipmentNo',
        valueType: 'input',
        title: '设备编号',
        key: 'equipmentNo',
        hideInForm: true,
      },
      {
        dataIndex: 'equipmentName',
        valueType: 'input',
        title: '设备名称',
        key: 'equipmentName',
        hideInForm: true,
      },
      {
        dataIndex: 'installPosition',
        valueType: 'input',
        title: '安装部位',
        key: 'installPosition',
        hideInForm: true,
      },
      {
        dataIndex: 'sparePartNo',
        valueType: 'input',
        title: '备件料号',
        key: 'sparePartNo',
        hideInForm: true,
      },
      {
        dataIndex: 'sparePartName',
        valueType: 'input',
        title: '备件名称',
        key: 'sparePartName',
        hideInForm: true,
      },
      {
        dataIndex: 'supplierNo',
        valueType: 'input',
        title: '供应商编号',
        key: 'supplierNo',
        hideInForm: true,
      },
      {
        dataIndex: 'supplierName',
        valueType: 'input',
        title: '供应商名称',
        key: 'supplierName',
        hideInForm: true,
      },
      {
        dataIndex: 'equipmentId',
        valueType: 'select',
        title: '选择设备',
        key: 'equipmentId',
        hideInDescriptions: true,
        hideInSearch: true,
        hideInTable: true,
        mode: 'radio',
        options: {
          path: '/asset/equipment/selection/user/shop',
          params: {},
        },
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
      },
      {
        dataIndex: 'lifePieceStandardId',
        valueType: 'select',
        title: '选择部位-寿命件',
        key: 'lifePieceStandardId',
        hideInDescriptions: true,
        hideInSearch: true,
        hideInTable: true,
        mode: 'radio',
        options: {
          path: '/sparepart/lifePieceStandard/querySelectByEquipmentId',
          linkParams: { equipmentId: '' },
        },
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
      },
      {
        dataIndex: 'supplierId',
        valueType: 'select',
        title: '选择供应商',
        key: 'supplierId',
        hideInDescriptions: true,
        hideInSearch: true,
        hideInTable: true,
        mode: 'radio',
        options: {
          path: '/sparepart/sparePartSupplier/queryOnSelect',
          params: {},
        },
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
      },
      {
        dataIndex: 'installNum',
        valueType: 'digit',
        searchValueType: 'input',
        title: '安装数量',
        key: 'installNum',
TZW's avatar
TZW committed
131
        hideInSearch: true,
TZW's avatar
TZW committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
        hideInTable: false,
        fieldProps: {
          precision: 0,
        },

        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
      },

      {
        dataIndex: 'nextReplaceDate',
        title: '下次更换日期',
        valueType: 'date',
        key: 'nextReplaceDateList',
        fieldProps: {
          disabledDate: disabledDateOfDay,
        },
TZW's avatar
TZW committed
155
        hideInSearch: true,
TZW's avatar
TZW committed
156 157 158 159 160 161 162 163 164
        hideInTable: false,
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
TZW's avatar
TZW committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
        render: (text, row, _, action) => {
          return (
            <span
              style={{
                color: `${
                  dayjs(row.nextReplaceDate).valueOf() <
                  dayjs(dayjs().format('YYYY-MM-DD')).valueOf()
                    ? '#f50'
                    : 'rgba(0, 0, 0, 0.85)'
                }`,
              }}
            >
              {row.nextReplaceDate}
            </span>
          );
        },
TZW's avatar
TZW committed
181
      },
TZW's avatar
TZW committed
182 183 184 185 186 187 188 189 190
      {
        dataIndex: 'nextReplaceDate',
        title: '下次更换日期',
        valueType: 'dateRange',
        key: 'nextReplaceDateList',
        hideInForm: true,
        hideInTable: true,
        hideInDescriptions: true,
      },
TZW's avatar
TZW committed
191 192 193 194 195 196 197 198
    ],
    pathconfig: {
      enableadd: true,
      enableedit: true,
      enabledelete: true,
      enabledetail: false,
      add: '/sparepart/lifePieceAccount/initialization',
      edit: '/sparepart/lifePieceAccount/initialization',
TZW's avatar
TZW committed
199
      list: '/sparepart/lifePieceAccount/queryList',
TZW's avatar
TZW committed
200 201 202 203 204 205
      delete: '/sparepart/lifePieceAccount/deleteById',
      detail: '',
    },
  };
}
export default getcolumns;