Wired.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="c-grid-form">
  3. <span class="c-grid-form__label u-bold">网口:</span>
  4. <schema-select
  5. :value="eth"
  6. :schema="ethSchema"
  7. @change="onChange"
  8. />
  9. <span class="c-grid-form__label u-bold">IP配置方式:</span>
  10. <schema-select
  11. v-model="wired.mode"
  12. :schema="modeSchema"
  13. />
  14. <template v-if="isMaunal">
  15. <!-- <span class="c-grid-form__label u-bold">IPv4:</span>
  16. <div class="l-flex--row c-grid-form__option">
  17. <el-switch
  18. v-model="wired.ip4.enable"
  19. active-color="#13ce66"
  20. inactive-color="#ff4949"
  21. />
  22. </div> -->
  23. <template v-if="wired.ip4.enable">
  24. <span class="c-grid-form__label required">IP地址:</span>
  25. <el-input
  26. v-model.trim="wired.ip4.address"
  27. placeholder="192.168.0.100"
  28. maxlength="15"
  29. />
  30. <span class="c-grid-form__label required">子网掩码:</span>
  31. <el-input
  32. v-model.trim="wired.ip4.mask"
  33. placeholder="255.255.255.0"
  34. maxlength="15"
  35. />
  36. <span class="c-grid-form__label">网关:</span>
  37. <el-input
  38. v-model.trim="wired.ip4.gateway"
  39. placeholder="192.168.0.1"
  40. maxlength="15"
  41. />
  42. <span class="c-grid-form__label">主DNS:</span>
  43. <el-input
  44. v-model.trim="wired.ip4.dns1"
  45. placeholder="192.168.0.10"
  46. maxlength="15"
  47. />
  48. <span class="c-grid-form__label">备DNS:</span>
  49. <el-input
  50. v-model.trim="wired.ip4.dns2"
  51. placeholder="192.168.0.11"
  52. maxlength="15"
  53. />
  54. </template>
  55. <!-- <span class="c-grid-form__label u-bold">IPv6:</span>
  56. <div class="l-flex--row c-grid-form__option">
  57. <el-switch
  58. v-model="wired.ip6.enable"
  59. active-color="#13ce66"
  60. inactive-color="#ff4949"
  61. />
  62. </div>
  63. <template v-if="wired.ip6.enable">
  64. <span class="c-grid-form__label required">IP地址:</span>
  65. <el-input
  66. v-model.trim="wired.ip4.address"
  67. placeholder="ffff:0000:0000:0000:0000:0000:0000:0000"
  68. maxlength="39"
  69. />
  70. <span class="c-grid-form__label required">子网前缀:</span>
  71. <el-input-number
  72. v-model="wired.ip6.mask"
  73. :min="1"
  74. :max="32"
  75. step-strictly
  76. />
  77. <span class="c-grid-form__label">网关:</span>
  78. <el-input
  79. v-model.trim="wired.ip6.gateway"
  80. placeholder="ffff:0000:0000:0000:0000:0000:0000:0000"
  81. maxlength="39"
  82. />
  83. <span class="c-grid-form__label">主DNS:</span>
  84. <el-input
  85. v-model.trim="wired.ip6.dns1"
  86. placeholder="ffff:0000:0000:0000:0000:0000:0000:0000"
  87. maxlength="39"
  88. />
  89. <span class="c-grid-form__label">备DNS:</span>
  90. <el-input
  91. v-model.trim="wired.ip6.dns2"
  92. placeholder="ffff:0000:0000:0000:0000:0000:0000:0000"
  93. maxlength="39"
  94. />
  95. </template> -->
  96. </template>
  97. </div>
  98. </template>
  99. <script>
  100. export default {
  101. name: 'Wired',
  102. props: {
  103. eth: {
  104. type: String,
  105. required: true
  106. },
  107. eths: {
  108. type: Array,
  109. required: true
  110. }
  111. },
  112. data () {
  113. return {
  114. modeSchema: {
  115. options: [
  116. { value: 'dhcp', label: '自动(DHCP)' },
  117. { value: 'manual', label: '手动' }
  118. ]
  119. }
  120. }
  121. },
  122. computed: {
  123. ethSchema () {
  124. return {
  125. options: this.eths.map(({ name }, index) => {
  126. return {
  127. value: `${index}`,
  128. label: name
  129. }
  130. })
  131. }
  132. },
  133. wired () {
  134. return this.eths[this.eth]
  135. },
  136. isMaunal () {
  137. return this.wired.mode === 'manual'
  138. }
  139. },
  140. methods: {
  141. onChange (val) {
  142. this.$emit('update:eth', val)
  143. }
  144. }
  145. }
  146. </script>