columns.js 4.88 KB
Newer Older
wuhao's avatar
wuhao committed
1
import { Switch } from 'antd';
wuhao's avatar
wuhao committed
2
import AutoTable from '@/components/AutoTable/mtable';
wuhao's avatar
wuhao committed
3

TZW's avatar
TZW committed
4
function getcolumns(setdrawer, changeState) {
wuhao's avatar
wuhao committed
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
  let columns = [
    {
      title: '联系人名称',
      dataIndex: 'userName',
      key: 'userName',
      formItemProps: {
        rules: [
          {
            required: true,
            message: '此项为必填项',
          },
        ],
      },
      colProps: {
        sm: 6,
      },
    },
    {
      title: '联系电话',
      dataIndex: 'telephone',
      key: 'telephone',
      colProps: {
        sm: 6,
      },
    },
    {
      title: '邮箱',
      dataIndex: 'email',
      key: 'email',
      colProps: {
        sm: 6,
      },
    },
    {
      title: '职务',
      dataIndex: 'title',
      key: 'title',
      colProps: {
        sm: 6,
      },
    },
  ];
wuhao's avatar
wuhao committed
47 48 49 50 51 52
  return {
    columns: [
      {
        title: '供应商编号',
        dataIndex: 'supplierNo',
        key: 'supplierNo',
TZW's avatar
TZW committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
        render: (_, row) => {
          return (
            <a
              onClick={() => {
                setdrawer((s) => ({
                  ...s,
                  open: true,
                  item: row,
                  title: '详情',
                  val: 'detail',
                  title: '详细信息',
                }));
              }}
            >
              {row?.supplierNo}
            </a>
          );
        },
wuhao's avatar
wuhao committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
      },
      {
        title: '供应商名称',
        dataIndex: 'supplierName',
        key: 'supplierName',
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
      },
      {
        title: '官网',
        dataIndex: 'officialWebsite',
        key: 'officialWebsite',
        hideInSearch: true,
wuhao's avatar
wuhao committed
90
        hideInTable: true,
wuhao's avatar
wuhao committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
      },
      {
        title: '联系电话',
        dataIndex: 'telephone',
        key: 'telephone',
      },
      {
        title: '邮箱',
        dataIndex: 'email',
        key: 'email',
      },
      {
        title: '地址',
        dataIndex: 'address',
        key: 'address',
        hideInSearch: true,
      },
wuhao's avatar
wuhao committed
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
      {
        title: '备注',
        dataIndex: 'remark',
        key: 'remark',
        colProps: {
          span: 24,
        },
        valueType: 'textarea',
        hideInSearch: true,
      },
      {
        title: '评分',
        dataIndex: 'score',
        key: 'score',
        valueType: 'rate',
      },
wuhao's avatar
wuhao committed
124 125 126 127
      {
        title: '状态',
        dataIndex: 'statusName',
        key: 'status',
TZW's avatar
TZW committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
        hideInSearch: true,
        hideInTable: true,
        hideInForm: true,
        valueType: 'select',
        mode: 'radio',
        options: [
          {
            label: '启用',
            value: 1,
          },
          {
            label: '停用',
            value: 2,
          },
        ],
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
      },
      {
        title: '状态',
        dataIndex: 'statusName',
        key: 'status',
        hideInDescriptions: true,
wuhao's avatar
wuhao committed
157 158 159 160 161
        valueType: 'select',
        mode: 'radio',
        options: [
          {
            label: '启用',
wuhao's avatar
wuhao committed
162
            value: 1,
wuhao's avatar
wuhao committed
163 164 165
          },
          {
            label: '停用',
wuhao's avatar
wuhao committed
166
            value: 2,
wuhao's avatar
wuhao committed
167 168 169 170 171 172 173 174 175 176
          },
        ],
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
wuhao's avatar
wuhao committed
177 178 179 180 181 182 183 184 185 186 187
        render: (text, row) => {
          return (
            <Switch
              checked={row?.status == 1}
              checkedChildren="启用"
              unCheckedChildren="停用"
              onChange={(e) => {
                changeState({ id: row.id, status: e ? 1 : 2 });
              }}
            />
          );
wuhao's avatar
wuhao committed
188 189
        },
      },
TZW's avatar
TZW committed
190

wuhao's avatar
wuhao committed
191
      {
wuhao's avatar
wuhao committed
192
        title: '联系信息',
wuhao's avatar
wuhao committed
193 194
        valueType: 'formList',
        dataIndex: 'userList',
TZW's avatar
TZW committed
195
        span: 3,
wuhao's avatar
wuhao committed
196 197 198 199
        colProps: {
          xs: 24,
          sm: 24,
        },
wuhao's avatar
wuhao committed
200
        columns,
wuhao's avatar
wuhao committed
201 202
        hideInSearch: true,
        hideInTable: true,
wuhao's avatar
wuhao committed
203 204 205 206 207 208 209 210 211 212 213 214
        render: (text, row) => {
          return (
            <AutoTable
              columns={columns?.map((it) => ({
                ...it,
                hideInSearch: true,
              }))}
              dataSource={row?.userList}
              resizeable={false}
            />
          );
        },
wuhao's avatar
wuhao committed
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
      },
    ],
    pathconfig: {
      enableadd: true,
      enableedit: true,
      enabledelete: true,
      enabledetail: true,
      add: '/sparepart/sparePartSupplier/save',
      edit: '/sparepart/sparePartSupplier/save',
      list: '/sparepart/sparePartSupplier/queryList',
      delete: '/sparepart/sparePartSupplier/deleteById',
      detail: '/sparepart/sparePartSupplier/queryDetails',
    },
  };
}
export default getcolumns;