| | |
| | | } |
| | | 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"); |
| | | } |
| | |
| | | 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") |
| | |
| | | } |
| | | if (times%2 == 0) { |
| | | sb.append(" <ProForm.Group>\n"); |
| | | has = true;init=true; |
| | | } |
| | | |
| | | String itemType = "ProFormText"; |
| | |
| | | if (!Cools.isEmpty(precision) && Cools.isEmpty(column.getEnums())) { |
| | | sb.append(" fieldProps={{ precision: ").append(precision).append(" }}\n"); |
| | | } |
| | | if ("Date".equals(column.getType()) || !Cools.isEmpty(column.getEnums()) || !Cools.isEmpty(column.getForeignKeyMajor())){ |
| | | // 时间、枚举 格式化 主键修饰 |
| | | sb.append(" placeholder=\"请选择\"\n"); |
| | | } else { |
| | | sb.append(" placeholder=\"请输入\"\n"); |
| | | } |
| | | |
| | | // 非空 |
| | | if (column.isNotNull()) { |
| | | sb.append(" rules={[{ required: true, message: \"").append(column.getComment()).append("不能为空!\" }]}\n"); |
| | | sb.append(" rules={[{ required: true }]}\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(" }}\n"); |
| | | 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"); |
| | | sb.append(" />\n"); |
| | | |
| | | if (times%2 == 0) { |
| | | if (times%2 != 0) { |
| | | sb.append(" </ProForm.Group>\n"); |
| | | has = false; |
| | | } |
| | | times++; |
| | | } |
| | | if (init && has) { |
| | | sb.append(" </ProForm.Group>\n"); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |