WafRuleStatement.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <a-card class="mb-3" style="flex: 1 1 auto">
  3. <!-- 类型 -->
  4. <a-form-item :label="$t('network.text_249')" v-bind="formLayout">
  5. <a-select v-if="isEdit" v-model="data.type">
  6. <a-select-option v-for="item in wafRuleTypeOptions" :value="item.value" :key="item.value">
  7. {{item.label}}
  8. </a-select-option>
  9. </a-select>
  10. <box-show v-else :value="ruleTypeValue" />
  11. </a-form-item>
  12. <!-- 条件 -->
  13. <component :is="type" :type="type" :statement="data" :wafBrand="wafBrand" :isEdit="isEdit" />
  14. </a-card>
  15. </template>
  16. <script>
  17. import WindowsMixin from '@/mixins/windows'
  18. import WafMixin from '../mixins/waf'
  19. import BoxShow from './statementComponents/BoxShow'
  20. import ByteMatch from './statementList/ByteMatch'
  21. import IPSet from './statementList/IPSet'
  22. import Size from './statementList/Size'
  23. import ManagedRuleGroup from './statementList/ManagedRuleGroup'
  24. import GeoMatch from './statementList/GeoMatch'
  25. import RegexSet from './statementList/RegexSet'
  26. import Rate from './statementList/Rate'
  27. import RuleGroup from './statementList/RuleGroup'
  28. import SqliMatch from './statementList/SqliMatch'
  29. import XssMatch from './statementList/XssMatch'
  30. import LabelMatch from './statementList/LabelMatch'
  31. export default {
  32. name: 'WafList',
  33. components: {
  34. BoxShow,
  35. ByteMatch,
  36. IPSet,
  37. Size,
  38. ManagedRuleGroup,
  39. GeoMatch,
  40. RegexSet,
  41. Rate,
  42. RuleGroup,
  43. SqliMatch,
  44. XssMatch,
  45. LabelMatch,
  46. },
  47. mixins: [WindowsMixin, WafMixin],
  48. props: {
  49. data: Object,
  50. // 条件类型
  51. type: String,
  52. isEdit: Boolean,
  53. // waf的平台
  54. wafBrand: String,
  55. },
  56. data () {
  57. return {
  58. formLayout: {
  59. wrapperCol: {
  60. span: 20,
  61. },
  62. labelCol: {
  63. span: 4,
  64. },
  65. },
  66. wafRuleTypeOptions: [],
  67. }
  68. },
  69. computed: {
  70. ruleTypeValue () {
  71. const ruleType = this.wafRuleTypeOptions.filter(item => item.value === this.data.type)
  72. if (ruleType && ruleType.length) {
  73. return ruleType[0].label
  74. } else {
  75. return this.data.type || ''
  76. }
  77. },
  78. },
  79. watch: {
  80. wafRuleTypeMap: {
  81. handler: function (val) {
  82. if (val) {
  83. const wafRuleTypesKeys = Object.keys(val || {})
  84. this.wafRuleTypeOptions = wafRuleTypesKeys.map(key => {
  85. return val[key]
  86. })
  87. }
  88. },
  89. immediate: true,
  90. },
  91. },
  92. created () {
  93. },
  94. methods: {
  95. },
  96. }
  97. </script>