| | |
| | | } |
| | | sb.append("',\n") |
| | | .append(" valueType: 'text',\n") |
| | | .append(" hidden: false,\n"); |
| | | .append(" hidden: false,\n") |
| | | .append(" width: 140,\n"); |
| | | if (column.isMajor()) { |
| | | sb.append(" copyable: true,\n"); |
| | | } |
| | | sb.append(" filterDropdown: (props) => <").append(getAntProFilterType(column)).append("\n") |
| | | .append(" name='").append(column.getHumpName()).append("'\n") |
| | | .append(" {...props}\n") |
| | | .append(" name='").append(column.getHumpName()).append("'\n"); |
| | | |
| | | if (!Cools.isEmpty(column.getForeignKey())) { |
| | | sb.append(" major='").append(GeneratorUtils.firstCharConvert(column.getForeignKey())).append("'\n"); |
| | | } |
| | | |
| | | sb.append(" {...props}\n") |
| | | .append(" actionRef={actionRef}\n") |
| | | .append(" setSearchParam={setSearchParam}\n"); |
| | | if (!Cools.isEmpty(column.getEnums())) { |
| | |
| | | private String createFormEditColumns() { |
| | | StringBuilder sb = new StringBuilder(); |
| | | int times = 0; |
| | | boolean has = false;boolean init = false; |
| | | for (Column column : columns) { |
| | | if (column.isPrimaryKey() |
| | | || column.getHumpName().equals("deleted") |
| | |
| | | ) { |
| | | continue; |
| | | } |
| | | |
| | | if (times%2 == 0) { |
| | | |
| | | sb.append(" <ProForm.Group>\n"); |
| | | has = true;init=true; |
| | | } |
| | | |
| | | String itemType = "ProFormText"; |
| | | String precision = ""; |
| | | switch (column.getType()) { |
| | | case "Boolean": |
| | | itemType = "ProFormText"; |
| | | break; |
| | | case "Short": |
| | | itemType = "ProFormDigit"; |
| | | precision = "0"; |
| | | break; |
| | | case "Integer": |
| | | itemType = "ProFormDigit"; |
| | | precision = "0"; |
| | | break; |
| | | case "Long": |
| | | itemType = "ProFormDigit"; |
| | | precision = "0"; |
| | | break; |
| | | case "Double": |
| | | itemType = "ProFormDigit"; |
| | | precision = "2"; |
| | | break; |
| | | case "String": |
| | | itemType = "ProFormText"; |
| | | break; |
| | | case "Date": |
| | | itemType = "ProFormDateTimePicker"; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | if (!Cools.isEmpty(column.getEnums())) { |
| | | itemType = "ProFormSelect"; |
| | | } |
| | | if (!Cools.isEmpty(column.getForeignKey())) { |
| | | itemType = "ProFormSelect"; |
| | | } |
| | | |
| | | sb.append(" <").append(itemType).append("\n") |
| | | .append(" name=\"").append(column.getHumpName()).append("\"\n") |
| | | .append(" label=\"").append(column.getComment()).append("\"\n") |
| | | .append(" colProps={{ md: 12, xl: 12 }}\n"); |
| | | // 数字小数点 |
| | | if (!Cools.isEmpty(precision) && Cools.isEmpty(column.getEnums())) { |
| | | sb.append(" fieldProps={{ precision: ").append(precision).append(" }}\n"); |
| | | } |
| | | |
| | | // 非空 |
| | | if (column.isNotNull()) { |
| | | sb.append(" rules={[{ required: true }]}\n"); |
| | | } |
| | | |
| | | // 枚举 |
| | | if (!Cools.isEmpty(column.getEnums())) { |
| | | sb.append(" options={[\n"); |
| | | for (Map<String, Object> map : column.getEnums()) { |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | sb.append(" { label: '").append(entry.getValue()).append("', value: ").append(entry.getKey()).append(" },\n"); |
| | | } |
| | | } |
| | | sb.append(" ]}\n"); |
| | | } |
| | | |
| | | // 时间 |
| | | if ("Date".equals(column.getType())) { |
| | | sb.append(" transform={(value) => moment(value).toISOString()}\n"); |
| | | } |
| | | |
| | | // 关联表 |
| | | if (!Cools.isEmpty(column.getForeignKey())) { |
| | | sb.append(" showSearch\n") |
| | | .append(" debounceTime={300}\n") |
| | | .append(" request={async ({ keyWords }) => {\n") |
| | | .append(" const resp = await Http.doPostForm('api/").append(GeneratorUtils.firstCharConvert(column.getForeignKey())).append("/query', { condition: keyWords });\n") |
| | | .append(" return resp.data;\n") |
| | | .append(" }}\n"); |
| | | } |
| | | |
| | | sb.append(" />\n"); |
| | | |
| | | if (times%2 != 0) { |
| | | sb.append(" </ProForm.Group>\n"); |
| | | has = false; |
| | | } |
| | | times++; |
| | | } |
| | | if (init && has) { |
| | | sb.append(" </ProForm.Group>\n"); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |