fill.rule.data.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import { BasicColumn, FormSchema } from '/@/components/Table';
  2. import { duplicateCheck } from '/@/views/system/user/user.api';
  3. export const columns: BasicColumn[] = [
  4. {
  5. title: '规则名称',
  6. dataIndex: 'ruleName',
  7. width: 200,
  8. align: 'center',
  9. },
  10. {
  11. title: '规则编码',
  12. dataIndex: 'ruleCode',
  13. width: 200,
  14. align: 'center',
  15. },
  16. {
  17. title: '规则实现类',
  18. dataIndex: 'ruleClass',
  19. width: 300,
  20. align: 'center',
  21. },
  22. {
  23. title: '规则参数',
  24. dataIndex: 'ruleParams',
  25. width: 200,
  26. align: 'center',
  27. },
  28. ];
  29. export const searchFormSchema: FormSchema[] = [
  30. {
  31. field: 'ruleName',
  32. label: '规则名称',
  33. component: 'Input',
  34. colProps: { span: 6 },
  35. },
  36. {
  37. field: 'ruleCode',
  38. label: '规则编码',
  39. component: 'Input',
  40. colProps: { span: 6 },
  41. },
  42. ];
  43. export const formSchema: FormSchema[] = [
  44. {
  45. label: '',
  46. field: 'id',
  47. component: 'Input',
  48. show: false,
  49. },
  50. {
  51. field: 'ruleName',
  52. label: '规则名称',
  53. component: 'Input',
  54. required: true,
  55. colProps: { span: 24 },
  56. },
  57. {
  58. field: 'ruleCode',
  59. label: '规则编码',
  60. component: 'Input',
  61. colProps: { span: 24 },
  62. dynamicDisabled: ({ values }) => {
  63. return !!values.id;
  64. },
  65. dynamicRules: ({ model }) => {
  66. return [
  67. {
  68. required: true,
  69. validator: (_, value) => {
  70. return new Promise((resolve, reject) => {
  71. if (!value) {
  72. return reject('请输入规则编码!');
  73. }
  74. let params = {
  75. tableName: 'sys_fill_rule',
  76. fieldName: 'rule_code',
  77. fieldVal: value,
  78. dataId: model.id,
  79. };
  80. duplicateCheck(params)
  81. .then((res) => {
  82. res.success ? resolve() : reject('规则编码已存在!');
  83. })
  84. .catch((err) => {
  85. reject(err.message || '校验失败');
  86. });
  87. });
  88. },
  89. },
  90. ];
  91. },
  92. },
  93. {
  94. field: 'ruleClass',
  95. label: '规则实现类',
  96. component: 'Input',
  97. required: true,
  98. colProps: { span: 24 },
  99. },
  100. {
  101. field: 'ruleParams',
  102. label: '规则参数',
  103. colProps: { span: 24 },
  104. component: 'JAddInput',
  105. componentProps: {
  106. min: 0,
  107. },
  108. },
  109. ];