代码如下:
import { BasicColumn } from '/@/components/Table'; import { FormSchema } from '/@/components/Table'; import { h } from 'vue'; import { Tag } from 'ant-design-vue'; export const columns: BasicColumn[] = [<% foreach (var item in Model.PropertyGens) { var isPrimaryKey = item.IsPrimaryKey ? ",IsPrimaryKey = true" : ""; var isIdentity = item.IsIdentity ? ",IsIdentity = true" : ""; var isIgnore=(item.IsIgnore?",IsIgnore = true":""); var isJson=item.IsJson?",IsJson= true":"" ; var stringValue=item.PropertyType=="string"?"= null!;":""; var isShow=item.IsPrimaryKey || item.PropertyName.IndexOf("ID", StringComparison.OrdinalIgnoreCase) >= 0?"false":"true"; %> { <% if(item.PropertyName=="RowState") {%> title: '{{item.Description}}', dataIndex: 'RowState', customRender: ({ record }) => { let text = ''; let color = ''; if (record.RowState == 0) { text = '正常'; color = '#67C23B'; } else if (record.RowState == 1) { text = '停用'; color = '#F78989'; } return h(Tag, { color }, () => text); }, width: 40,<%}else{%> title: '{{item.Description}}', dataIndex: '{{item.PropertyName}}', width: 60, ifShow: {{isShow}},<%}%> },<%} %> ]; export const formFormSchema: FormSchema[] = [<% foreach (var item in Model.PropertyGens) { var isPrimaryKey = item.IsPrimaryKey ? ",IsPrimaryKey = true" : ""; var isIdentity = item.IsIdentity ? ",IsIdentity = true" : ""; var isIgnore=(item.IsIgnore?",IsIgnore = true":""); var isJson=item.IsJson?",IsJson= true":"" ; var stringValue=item.PropertyType=="string"?"= null!;":""; var isShow=item.IsPrimaryKey || item.PropertyName.IndexOf("ID", StringComparison.OrdinalIgnoreCase) >= 0?"false":"true"; if(item.PropertyName=="CreateUser"||item.PropertyName=="CreateTime"||item.PropertyName=="UpdateUser"||item.PropertyName=="UpdateTime"){continue;} %> { <% if(item.PropertyName=="RowState") {%> label: '{{item.Description}}', field: 'RowState', component: 'RadioButtonGroup', defaultValue: 0, componentProps: { options: [ { label: '正常', value: 0, }, { label: '停用', value: 1, }, ], }, <%}else{%> label: '{{item.Description}}', field: '{{item.PropertyName}}', component: 'Input', show: {{isShow}},<%}%> },<%} %> ]; export const searchFormSchema: FormSchema[] = [ ];