Transformations.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div>
  3. <a-form-item v-if="transformations && transformations.length" :label="$t('network_waf_statement.label.transformations')" v-bind="formLayout">
  4. <template v-for="(transformation, index) in transformations">
  5. <a-select v-if="isEdit" v-model="transformations[index]" :key="index">
  6. <a-select-option v-for="item in transformationOptions" :value="item.value" :key="item.value">
  7. {{item.label}}
  8. </a-select-option>
  9. </a-select>
  10. <box-show v-else :value="getShowValue(index)" :key="index" />
  11. </template>
  12. </a-form-item>
  13. </div>
  14. </template>
  15. <script>
  16. import WafMixin from '../../mixins/waf'
  17. import BoxShow from './BoxShow'
  18. import WindowsMixin from '@/mixins/windows'
  19. export default {
  20. name: 'TransformationsStatement',
  21. components: {
  22. BoxShow,
  23. },
  24. mixins: [WindowsMixin, WafMixin],
  25. props: {
  26. type: String,
  27. isEdit: Boolean,
  28. valueList: {
  29. type: Array,
  30. default: () => [],
  31. },
  32. },
  33. data () {
  34. return {
  35. transformations: this.valueList,
  36. formLayout: {
  37. wrapperCol: {
  38. span: 20,
  39. },
  40. labelCol: {
  41. span: 4,
  42. },
  43. },
  44. }
  45. },
  46. computed: {
  47. transformationOptions () {
  48. // 根据不同type返回 Azure不同 TODO
  49. return [
  50. { label: this.$t('network_waf_statement.transformation.CompressWithSpace'), value: 'CompressWithSpace' },
  51. { label: this.$t('network_waf_statement.transformation.HtmlEntityDecode'), value: 'HtmlEntityDecode' },
  52. { label: this.$t('network_waf_statement.transformation.Lowercase'), value: 'Lowercase' },
  53. { label: this.$t('network_waf_statement.transformation.CmdLine'), value: 'CmdLine' },
  54. { label: this.$t('network_waf_statement.transformation.UrlDecode'), value: 'UrlDecode' },
  55. { label: this.$t('network_waf_statement.transformation.UrlEncode'), value: 'UrlEncode' },
  56. { label: this.$t('network_waf_statement.transformation.Trim'), value: 'Trim' },
  57. { label: this.$t('network_waf_statement.transformation.RemoveNulls'), value: 'RemoveNulls' },
  58. ]
  59. },
  60. },
  61. watch: {
  62. },
  63. created () {
  64. },
  65. methods: {
  66. getShowValue (index) {
  67. const transformations = this.transformationOptions.filter(item => item.value === this.valueList[index])
  68. if (transformations && transformations.length) {
  69. return transformations[0].label
  70. } else {
  71. return this.valueList[index] || this.$t('network.waf.match_null')
  72. }
  73. },
  74. },
  75. }
  76. </script>