0.0.6 • Published 3 years ago

enniot-lan-conf v0.0.6

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

目录结构

── enniot-lan-conf
    ├── lan.vue
    ├── README.md
    ├── lan-model.json
    ├── LanDefaultValue.json
    └── package.json

Props

参数说明类型可选值默认值
ref用于父组件调用子组件的变量和方法stringlanFormlanForm
data用于将后台读取以及手动输入的数据填入 form 组件;设置默认值;object
schematable 新增以及编辑 form 框中的数据格式的渲染json

Data

参数说明类型可选值默认值
idLAN 的 id (可去掉)int11
gateway_id网关 id(可去掉)int11
ip_addressip 地址string"0.0.0.0"-"255.255.255.255"
mask子网掩码string"0.0.0.0"-"255.255.255.255"
primary_dns主 DNSstring"0.0.0.0"-"255.255.255.255"
assist_dns辅 DNSstring"0.0.0.0"-"255.255.255.255"
default_gateway缺省网关string"0.0.0.0"-"255.255.255.255"

Usage

<template>
  <el-row
    :gutter="20"
    class="page-box"
  >
    <el-col>
      <Breadcrumb
        :breadcrumbs="[{
          label: 'LAN',
        }]"
      />
    </el-col>
    <el-col>
      <el-tabs
              v-model="lanActiveName"
              :tab-position="tabPosition"
              @tab-click="handleLanClick"
            >
              <el-tab-pane
                v-for="index in lanNum"
                :key="index"
                :label="'LAN'+ index"
                :name="String(index-1)"
              >
                <Lan
                  v-if="comType==='second'"
                  ref="lanData"
                  :data="lanForm"
                  style="width: 50%"
                />
                <el-button
                  type="primary"
                  style="margin-left: 44%"
                  @click="onLanSubmit(index-1)"
                >
                  保存
                </el-button>
              </el-tab-pane>
            </el-tabs>
    </el-col>
  </el-row>
</template>

<script>
import Breadcrumb from '@/component/breadcrumb.vue';
import axios from 'axios';
import baseUrl from '@/service/api';
import LAN from './lan.vue';
import LanDefaultValue from './LanDefaultValue.json'; // wanDefaultValue是form的默认值
import deviceConf from '../../../../device-conf.js';

export default {
  components: {
    Breadcrumb,
    LAN,
  },
  data() {
    const {lan, serial} = deviceConf;
    return {
      lanNum: lan.num,
      lanForm: {},
    };
  },
  async created() {
    await this.fetchData();
  },
  methods: {
    //  LAN的查询
    async onGetLanForm(id) {
      const api = `${baseUrl}/api/lan/${id}`;
      const res = await this.$api.get(api);
      this.lanForm = res;
    },
    //  LAN的修改
    async onLanSubmit(index) {
      const isValid = await this.$refs.lanData[index].validate();
      if (isValid) {
        const api = `${baseUrl}/api/lan/${Number(index)}`;
        await this.$api.post(api, this.lanForm);
        await this.onGetLanForm(index);
      }
    },
  },
};
</script>

其中 $api 中封装的有 get、post、patch、put、delete 五种请求。

0.0.6

3 years ago

0.0.5

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago