columns.js 5.69 KB
Newer Older
TZW's avatar
TZW committed
1 2
import { doFetch } from '@/utils/doFetch';
import { Switch } from 'antd';
TZW's avatar
TZW committed
3 4
import fieldsDetail from '@/utils/fieldsDetail';

TZW's avatar
TZW committed
5
function getcolumns(ifs) {
wuhao's avatar
wuhao committed
6 7
  return [
    {
TZW's avatar
TZW committed
8 9 10
      title: '供应商编号',
      dataIndex: 'supplierNo',
      key: 'supplierNo',
TZW's avatar
TZW committed
11
      width: 120,
wuhao's avatar
wuhao committed
12 13
    },
    {
TZW's avatar
TZW committed
14 15 16
      title: '供应商名称',
      dataIndex: 'supplierName',
      key: 'supplierName',
TZW's avatar
TZW committed
17
      width: 150,
wuhao's avatar
wuhao committed
18 19 20
      formItemProps: {
        rules: [
          {
TZW's avatar
TZW committed
21
            required: true,
wuhao's avatar
wuhao committed
22 23 24 25 26 27
            message: '此项为必填项',
          },
        ],
      },
    },
    {
TZW's avatar
TZW committed
28 29 30 31 32
      title: '公司官网',
      dataIndex: 'officialWebsite',
      key: 'officialWebsite',
      hideInTable: true,
      search: false,
wuhao's avatar
wuhao committed
33 34 35 36 37 38 39 40 41 42
      formItemProps: {
        rules: [
          {
            required: false,
            message: '此项为必填项',
          },
        ],
      },
    },
    {
TZW's avatar
TZW committed
43 44 45
      title: '联系电话',
      dataIndex: 'telephone',
      key: 'telephone',
wuhao's avatar
wuhao committed
46 47 48 49 50 51 52 53 54 55
      formItemProps: {
        rules: [
          {
            required: false,
            message: '此项为必填项',
          },
        ],
      },
    },
    {
TZW's avatar
TZW committed
56 57 58
      title: '邮箱',
      dataIndex: 'email',
      key: 'email',
TZW's avatar
TZW committed
59 60 61 62 63 64 65 66
      formItemProps: {
        rules: [
          {
            required: false,
            message: '此项为必填项',
          },
        ],
      },
wuhao's avatar
wuhao committed
67 68
    },
    {
TZW's avatar
TZW committed
69 70 71
      title: '地址',
      dataIndex: 'address',
      key: 'address',
TZW's avatar
TZW committed
72
      search: false,
TZW's avatar
TZW committed
73
      width: 320,
TZW's avatar
TZW committed
74 75 76 77 78 79 80
      formItemProps: {
        rules: [
          {
            required: false,
            message: '此项为必填项',
          },
        ],
wuhao's avatar
wuhao committed
81
      },
TZW's avatar
TZW committed
82
    },
TZW's avatar
TZW committed
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
    {
      title: '状态',
      dataIndex: 'status',
      valueType: 'radio',
      key: 'status',
      options: [
        {
          label: '启用',
          value: 1,
        },
        {
          label: '禁用',
          value: 2,
        },
      ],
      hideInTable: true,
      hideInForm: true,
    },
TZW's avatar
TZW committed
101 102 103 104 105
    {
      title: '状态',
      dataIndex: 'status',
      key: 'status',
      valueType: 'radio',
TZW's avatar
TZW committed
106
      search: false,
wuhao's avatar
wuhao committed
107 108 109 110 111 112 113 114
      formItemProps: {
        rules: [
          {
            required: false,
            message: '此项为必填项',
          },
        ],
      },
TZW's avatar
TZW committed
115 116 117 118 119 120 121 122 123 124
      options: [
        {
          label: '启用',
          value: 1,
        },
        {
          label: '禁用',
          value: 2,
        },
      ],
TZW's avatar
TZW committed
125 126 127
      fieldProps: {
        disabled: ifs,
      },
TZW's avatar
TZW committed
128 129 130 131 132 133
      render: (text, row) => {
        return (
          <Switch
            checkedChildren="启用"
            unCheckedChildren="禁用"
            defaultChecked={row.status == 1}
TZW's avatar
TZW committed
134
            disabled={row?.statusChangeable == 1 ? false : true}
TZW's avatar
TZW committed
135
            onChange={(flag) => {
TZW's avatar
TZW committed
136
              // //console.log(e);
TZW's avatar
TZW committed
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
              if (flag) {
                doFetch({
                  url: '/asset/equipmentSupplier/update/status',
                  params: { id: row.id, status: '1' },
                });
              } else {
                doFetch({
                  url: '/asset/equipmentSupplier/update/status',
                  params: { id: row.id, status: '2' },
                });
              }
            }}
          />
        );
      },
wuhao's avatar
wuhao committed
152
    },
TZW's avatar
TZW committed
153 154 155 156
    {
      title: '评分',
      dataIndex: 'score',
      key: 'score',
TZW's avatar
TZW committed
157
      width: 50,
TZW's avatar
TZW committed
158
      valueType: 'rate',
TZW's avatar
TZW committed
159
      searchValueType: 'digit',
TZW's avatar
TZW committed
160
      fieldProps: {
TZW's avatar
TZW committed
161
        defaultValue: 0,
TZW's avatar
TZW committed
162 163
        max: 5,
        precision: 1,
TZW's avatar
TZW committed
164 165 166 167 168 169 170 171 172 173 174 175 176 177
      },
      formItemProps: {
        rules: [
          {
            required: false,
            message: '此项为必填项',
          },
        ],
      },
    },
    {
      title: '备注',
      dataIndex: 'remark',
      key: 'remark',
TZW's avatar
TZW committed
178
      search: false,
TZW's avatar
TZW committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
      valueType: 'textarea',
      width: 300,
      fieldProps: {
        placeholder: '请输入',
        showCount: true,
        maxLength: 255,
      },
      formItemProps: {
        rules: [
          {
            required: false,
            message: '此项为必填项',
          },
        ],
      },
    },
    {
      title: '联系信息',
      valueType: 'formList',
      dataIndex: 'list',
      key: 'supplierUserList',
      initialValue: [
        {
          state: 'all',
          title: '标题',
        },
      ],
      colProps: {
        xs: 24,
        sm: 24,
      },
      columns: [
        {
          title: '联系人',
          dataIndex: 'userName',
          key: 'userName',
          formItemProps: {
            rules: [
              {
                required: true,
                message: '此项为必填项',
              },
            ],
          },
          colProps: {
            sm: 6,
          },
        },
        {
          title: '手机号码',
          dataIndex: 'telephone',
          key: 'telephone',
          colProps: {
            sm: 6,
          },
TZW's avatar
TZW committed
234 235 236 237 238 239 240 241 242
          formItemProps: {
            rules: [
              {
                required: false,
                message: '此项为必填项',
              },
              { pattern: new RegExp(/^1[3456789]\d{9}$/, 'g'), message: '' },
            ],
          },
TZW's avatar
TZW committed
243 244 245 246 247 248 249 250 251 252 253 254 255 256
        },
        {
          title: '邮箱',
          dataIndex: 'email',
          key: 'email',
          colProps: {
            sm: 6,
          },
        },
        {
          title: '职务',
          dataIndex: 'title',
          key: 'title',
          fieldProps: {
TZW's avatar
TZW committed
257
            placeholder: '请输入',
TZW's avatar
TZW committed
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
          },
          formItemProps: {
            rules: [
              {
                required: false,
                message: '此项为必填项',
              },
            ],
          },
          colProps: {
            sm: 6,
          },
        },
      ],
      search: false,
      hideInTable: true,
    },
wuhao's avatar
wuhao committed
275 276 277 278
  ];
}

export default getcolumns;