0.0.2 • Published 3 years ago

enniot-firewall-conf v0.0.2

Weekly downloads
5
License
ISC
Repository
-
Last release
3 years ago

目录结构

── enniot-firewall-conf
    ├── firewall.vue
    ├── README.md
    ├── firewall.schema.json
    └── package.json

Props

参数说明类型可选值默认值
ref用于父组件调用子组件的变量和方法stringInStation/OutStation
modeltable 有关 api 的组件 url 参数以及重写方法的传入dataModel
schematable 新增以及编辑 form 框中的数据格式的渲染json

Fields

参数说明类型可选值默认值
idIDint11
gateway_id网关 id(可去掉)int11
enabled规则行为Booleantrue/false
card模块型号string"WAN"/"LAN"
ip_addressIP 地址string
server_type服务类型stringTELNET/SSH/TFTP/FTP/ICMP/TCP/UDP
direction_type策略类型string入站/出站

Usage

<template>
  <el-row
    :gutter="2"
    style="margin-left: 20px;"
  >
    <StationTable
      ref="Station"
      :schema="firwallSchema"
      :model="StationModel"
    >
      <template v-slot:action="{ record }">
        <span>
          <el-switch
            v-model="record.enabled"
            @change="ruleSwitched(record)"
          />
        </span>
      </template>
    </StationTable>
  </el-row>
</template>

<script>
import StationTable from '@/component/table.vue';
import DataModel from '@/component/data-model';
import baseUrl from '@/service/api';
import firwallSchema from './firewall.schema.json';

export default {
  name: 'Firewall',
  components: {
    StationTable,
  },
  data() {
    const StationModel = new DataModel({
      createApi: `${baseUrl}/api/firewall`,
      deleteApi: `${baseUrl}/api/firewall/:id`,
      updateApi: `${baseUrl}/api/firewall/:id`,
      getListApi: `${baseUrl}/api/firewall`,
    });
    return {
      firwallSchema,
      StationModel,
    };
  },
  methods: {
    async ruleSwitched(rule) {
      const ruleApi = `${baseUrl}/api/firewall/${rule.id}/enabled`;
      const rulForm = { enabled: rule.enabled };
      await this.$api.put(ruleApi, rulForm);
    },
  },
};
</script>

其中 data-model 中封装的有多种 api 的请求方法,可以接受重写函数作为参数的传入。