Negation.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <div>
  3. <a-form-item :label="label || $t('network_waf_statement.label.compute')" v-bind="formLayout">
  4. <a-radio-group v-if="isEdit" v-model="value">
  5. <a-radio-button v-for="item of negationOpts" :key="item.value" :value="item.value">{{item.label}}</a-radio-button>
  6. </a-radio-group>
  7. <box-show v-else :value="showValue" />
  8. </a-form-item>
  9. </div>
  10. </template>
  11. <script>
  12. import WafMixin from '../../mixins/waf'
  13. import BoxShow from './BoxShow'
  14. import WindowsMixin from '@/mixins/windows'
  15. export default {
  16. name: 'NegationStatement',
  17. components: {
  18. BoxShow,
  19. },
  20. mixins: [WindowsMixin, WafMixin],
  21. props: {
  22. label: String,
  23. type: String,
  24. value: String,
  25. wafBrand: String,
  26. selectOptions: Array,
  27. },
  28. data () {
  29. return {
  30. formLayout: {
  31. wrapperCol: {
  32. span: 20,
  33. },
  34. labelCol: {
  35. span: 4,
  36. },
  37. },
  38. }
  39. },
  40. computed: {
  41. negationOpts () {
  42. if (this.selectOptions) return this.selectOptions
  43. return [
  44. { label: this.$t('network_waf_statement.negation.in'), value: true },
  45. { label: this.$t('network_waf_statement.negation.notin'), value: false },
  46. ]
  47. },
  48. showValue () {
  49. const negation = this.negationOpts.filter(item => item.value === this.value)
  50. if (negation && negation.length) {
  51. return negation[0].label
  52. } else {
  53. return this.value
  54. }
  55. },
  56. },
  57. }
  58. </script>