use-procedure.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import { useI18n } from 'vue-i18n'
  18. import type { IJsonItem } from '../types'
  19. export function useProcedure(model: { [field: string]: any }): IJsonItem[] {
  20. const { t } = useI18n()
  21. return [
  22. {
  23. type: 'editor',
  24. field: 'method',
  25. name: t('project.node.procedure_method'),
  26. validate: {
  27. trigger: ['input', 'trigger'],
  28. required: true,
  29. message: t('project.node.procedure_method_tips')
  30. }
  31. },
  32. {
  33. type: 'custom-parameters',
  34. field: 'localParams',
  35. name: t('project.node.custom_parameters'),
  36. children: [
  37. {
  38. type: 'input',
  39. field: 'prop',
  40. span: 6,
  41. props: {
  42. placeholder: t('project.node.prop_tips'),
  43. maxLength: 256
  44. },
  45. validate: {
  46. trigger: ['input', 'blur'],
  47. required: true,
  48. validator(validate: any, value: string) {
  49. if (!value) {
  50. return new Error(t('project.node.prop_tips'))
  51. }
  52. const sameItems = model.localParams.filter(
  53. (item: { prop: string }) => item.prop === value
  54. )
  55. if (sameItems.length > 1) {
  56. return new Error(t('project.node.prop_repeat'))
  57. }
  58. }
  59. }
  60. },
  61. {
  62. type: 'select',
  63. field: 'direct',
  64. span: 4,
  65. options: DIRECT_LIST,
  66. value: 'IN'
  67. },
  68. {
  69. type: 'select',
  70. field: 'type',
  71. span: 6,
  72. options: TYPE_LIST,
  73. value: 'VARCHAR'
  74. },
  75. {
  76. type: 'input',
  77. field: 'value',
  78. span: 6,
  79. props: {
  80. placeholder: t('project.node.value_tips'),
  81. maxLength: 256
  82. }
  83. }
  84. ]
  85. }
  86. ]
  87. }
  88. export const TYPE_LIST = [
  89. {
  90. value: 'VARCHAR',
  91. label: 'VARCHAR'
  92. },
  93. {
  94. value: 'INTEGER',
  95. label: 'INTEGER'
  96. },
  97. {
  98. value: 'LONG',
  99. label: 'LONG'
  100. },
  101. {
  102. value: 'FLOAT',
  103. label: 'FLOAT'
  104. },
  105. {
  106. value: 'DOUBLE',
  107. label: 'DOUBLE'
  108. },
  109. {
  110. value: 'DATE',
  111. label: 'DATE'
  112. },
  113. {
  114. value: 'TIME',
  115. label: 'TIME'
  116. },
  117. {
  118. value: 'TIMESTAMP',
  119. label: 'TIMESTAMP'
  120. },
  121. {
  122. value: 'BOOLEAN',
  123. label: 'BOOLEAN'
  124. }
  125. ]
  126. export const DIRECT_LIST = [
  127. {
  128. value: 'IN',
  129. label: 'IN'
  130. },
  131. {
  132. value: 'OUT',
  133. label: 'OUT'
  134. }
  135. ]