|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724 |
- <template>
- <div class="app-container">
- <div style="margin-bottom:10px">
- <el-button type="success" @click="addBtn">新增</el-button>
- <el-button type="success" @click="importBtn">导入</el-button>
- <el-button type="success" @click="exportTempBtn">模版下载</el-button>
- </div>
- <!--搜索-->
- <el-form class="mt_15" ref="form" inline size="small">
- <el-form-item label="所属国家简称">
- <el-input v-model.trim="searchParm.contntryShort" clearable placeholder='所属国家简称'></el-input>
- </el-form-item>
- <el-form-item label="IP地址">
- <el-input v-model.trim="searchParm.ipAddress" clearable placeholder='IP地址'></el-input>
- </el-form-item>
- <el-form-item label="父ip地址">
- <el-input v-model.trim="searchParm.parentIpAddress" clearable placeholder='父ip地址'></el-input>
- </el-form-item>
- <el-form-item label="端口">
- <el-input v-model.trim="searchParm.port" clearable placeholder='端口'></el-input>
- </el-form-item>
- <el-form-item label="名称">
- <el-input v-model.trim="searchParm.name" clearable placeholder='名称'></el-input>
- </el-form-item>
- <el-form-item label="密码">
- <el-input v-model.trim="searchParm.pwd" clearable placeholder='密码'></el-input>
- </el-form-item>
- <el-form-item label="mac地址">
- <el-input v-model.trim="searchParm.mac" clearable placeholder='mac地址'></el-input>
- </el-form-item>
- <el-form-item label="VPS类型">
- <el-select v-model.trim="searchParm.vpsType" placeholder="请选择">
- <el-option
- v-for="item in searchVpsTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="经销商">
- <el-select v-model.trim="searchParm.dealer" placeholder="请选择">
- <el-option
- v-for="item in searchDealerList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="状态">
- <el-select v-model.trim="searchParm.status" placeholder="请选择">
- <el-option
- v-for="item in searchStatusList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="goSearch">搜索</el-button>
- <el-button type="warning" @click="resetForm">重置</el-button>
- </el-form-item>
- </el-form>
- <!--表格渲染-->
- <el-table ref="table" border size="small" :data="list" :header-cell-style="{textAlign:'center'}" :cell-style="{textAlign:'center'}">
- <el-table-column label="序号" type="index" width="50" />
- <el-table-column label="所属国家简称" prop="contntryShort" />
- <el-table-column label="IP地址" prop="ipAddress" />
- <el-table-column label="父ip地址" prop="parentIpAddress" />
- <el-table-column label="端口" prop="port" />
- <el-table-column label="名称" prop="name" />
- <el-table-column label="密码" prop="pwd" />
- <el-table-column label="VPS类型" prop="vpsType">
- <template slot-scope="scope">
- {{ scope.row.vpsType | getVpsType}}
- </template>
- </el-table-column>
- <el-table-column label="经销商" prop="dealer">
- <template slot-scope="scope">
- {{ scope.row.dealer | getDealer}}
- </template>
- </el-table-column>
- <el-table-column label="mac地址" prop="mac" />
- <el-table-column label="状态" prop="status">
- <template slot-scope="scope">
- {{ scope.row.status | getStatus}}
- </template>
- </el-table-column>
- <el-table-column label="创建时间" prop="createdAt" />
- <el-table-column label="修改时间" prop="updatedAt" />
- <el-table-column label="操作" width="220">
- <template slot-scope="scope">
- <el-button type="info" @click="getBtnById(scope.row.id)">查看</el-button>
- <el-button type="warning" @click="editById(scope.row)">修改</el-button>
- <el-button type="danger" @click="delById(scope.row.id)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <!--分页-->
- <div class="mt_15">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="searchParm.page"
- :page-sizes="[10, 20, 30, 40, 50]"
- :page-size="searchParm.pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total">
- </el-pagination>
- </div>
-
- <!--新增弹窗-->
- <el-dialog :visible.sync="dialogAddVisible" :title="dialogAddTitle" center width="45%">
- <div class="dialog-content">
- <el-form ref="addParm" size="small" :model="addParm" :rules="rules" label-width="130px">
- <el-form-item label="所属国家简称" prop="contntryShort">
- <el-input v-model.trim="addParm.contntryShort" clearable></el-input>
- </el-form-item>
- <el-form-item label="IP地址" prop="ipAddress">
- <el-input v-model.trim="addParm.ipAddress" clearable></el-input>
- </el-form-item>
- <el-form-item label="父ip地址" prop="parentIpAddress">
- <el-input v-model.trim="addParm.parentIpAddress" clearable></el-input>
- </el-form-item>
- <el-form-item label="端口" prop="port">
- <el-input v-model.trim="addParm.port" clearable></el-input>
- </el-form-item>
- <el-form-item label="名称" prop="name">
- <el-input v-model.trim="addParm.name" clearable></el-input>
- </el-form-item>
- <el-form-item label="密码" prop="pwd">
- <el-input v-model.trim="addParm.pwd" clearable></el-input>
- </el-form-item>
- <el-form-item label="mac地址" prop="mac">
- <el-input v-model.trim="addParm.mac" clearable></el-input>
- </el-form-item>
- <el-form-item label="link" prop="link">
- <el-input v-model.trim="addParm.link" clearable></el-input>
- </el-form-item>
- <el-form-item label="VPS类型">
- <el-select v-model.trim="addParm.vpsType" placeholder="请选择">
- <el-option
- v-for="item in vpsTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>`
- </el-form-item>
- <el-form-item label="经销商">
- <el-select v-model.trim="addParm.dealer" placeholder="请选择">
- <el-option
- v-for="item in dealerList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer">
- <el-button type="info" @click="sureAddCancle('addParm')">取消</el-button>
- <el-button type="primary" @click="sureAdd('addParm')">确认</el-button>
- </span>
- </el-dialog>
-
-
- <!--修改弹窗-->
- <el-dialog :visible.sync="dialogEditVisible" :title="dialogEditTitle" center width="45%">
- <div class="dialog-content">
- <el-form ref="editParm" size="small" :model="editParm" :rules="rules" label-width="130px">
- <el-form-item label="所属国家简称" prop="contntryShort">
- <el-input v-model.trim="editParm.contntryShort" clearable></el-input>
- </el-form-item>
- <el-form-item label="IP地址" prop="ipAddress">
- <el-input v-model.trim="editParm.ipAddress" clearable></el-input>
- </el-form-item>
- <el-form-item label="父ip地址" prop="parentIpAddress">
- <el-input v-model.trim="editParm.parentIpAddress" clearable></el-input>
- </el-form-item>
- <el-form-item label="端口" prop="port">
- <el-input v-model.trim="editParm.port" clearable></el-input>
- </el-form-item>
- <el-form-item label="名称" prop="name">
- <el-input v-model.trim="editParm.name" clearable></el-input>
- </el-form-item>
- <el-form-item label="密码" prop="pwd">
- <el-input v-model.trim="editParm.pwd" clearable></el-input>
- </el-form-item>
- <el-form-item label="mac地址" prop="mac">
- <el-input v-model.trim="editParm.mac" clearable></el-input>
- </el-form-item>
- <el-form-item label="link" prop="link">
- <el-input v-model.trim="editParm.link" clearable></el-input>
- </el-form-item>
- <el-form-item label="VPS类型">
- <el-select v-model.trim="editParm.vpsType" placeholder="请选择">
- <el-option
- v-for="item in vpsTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>`
- </el-form-item>
- <el-form-item label="经销商">
- <el-select v-model.trim="editParm.dealer" placeholder="请选择">
- <el-option
- v-for="item in dealerList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="状态">
- <el-select v-model.trim="editParm.status" placeholder="请选择">
- <el-option
- v-for="item in statusList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer">
- <el-button type="info" @click="sureEditCancle(editParm)">取消</el-button>
- <el-button type="primary" @click="sureEdit('editParm')">确认</el-button>
- </span>
- </el-dialog>
-
- <!--详情弹窗-->
- <el-dialog :visible.sync="dialogDetailVisible" :title="dialogDetailTitle" center width="45%">
- <div class="dialog-content">
- <el-form ref="form" size="small" label-width="130px">
- <el-form-item label="所属国家简称" prop="contntryShort">
- <el-input v-model.trim="detailParm.contntryShort" :disabled="true"></el-input>
- </el-form-item>
- <el-form-item label="IP地址" prop="ipAddress">
- <el-input v-model.trim="detailParm.ipAddress" :disabled="true"></el-input>
- </el-form-item>
- <el-form-item label="父ip地址" prop="parentIpAddress">
- <el-input v-model.trim="detailParm.parentIpAddress" :disabled="true"></el-input>
- </el-form-item>
- <el-form-item label="端口" prop="port">
- <el-input v-model.trim="detailParm.port" :disabled="true"></el-input>
- </el-form-item>
- <el-form-item label="名称" prop="name">
- <el-input v-model.trim="detailParm.name" :disabled="true"></el-input>
- </el-form-item>
- <el-form-item label="密码" prop="pwd">
- <el-input v-model.trim="detailParm.pwd" :disabled="true"></el-input>
- </el-form-item>
- <el-form-item label="mac地址" prop="mac">
- <el-input v-model.trim="detailParm.mac" :disabled="true"></el-input>
- </el-form-item>
- <el-form-item label="link" prop="link">
- <el-input v-model.trim="detailParm.link" :disabled="true"></el-input>
- </el-form-item>
- <el-form-item label="VPS类型">
- <el-select v-model.trim="detailParm.vpsType" disabled>
- <el-option
- v-for="item in vpsTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>`
- </el-form-item>
- <el-form-item label="经销商">
- <el-select v-model.trim="detailParm.dealer" disabled placeholder="请选择">
- <el-option
- v-for="item in dealerList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="状态" prop="status">
- <el-select v-model.trim="detailParm.status" disabled placeholder="请选择">
- <el-option
- v-for="item in statusList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- </div>
- </el-dialog>
-
- <!--Vpn信息导入 importBtn-->
- <el-dialog :visible.sync="dialogImportVisible" :title="dialogImportTitle" center width="23%">
- <div class="dialog-content">
- <el-upload
- class="upload-demo"
- drag
- ref="upload"
- :action="uploadFileUrl"
- :headers="uploadHeaders"
- :show-file-list = "false"
- :on-success="uploadSuccess"
- :before-upload="beforeAvatarUpload"
- multiple>
- <i class="el-icon-upload"></i>
- <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
- <div class="el-upload__tip" slot="tip">只能上传xlsl文件,且不超过10M</div>
- </el-upload>
- </div>
- </el-dialog>
-
- </div>
- </template>
- <script>
- import { getList, add, delById, getById, editById} from '@/api/group/vpn'
- export default {
- filters: {
- getVpsType: function (value) {
- if(value == 1) {
- return '传统';
- }
- },
- getDealer: function (value) {
- if(value == 1) {
- return 'V2';
- }
- },
- getStatus: function (value) {
- if(value == 1) {
- return '可用';
- } else if (value == 2) {
- return '禁用';
- }
- }
- },
- // 数据
- data() {
- return {
- searchParm: {
- page: 1,
- pageSize: 10,
- sort:'created_at',
- order:'desc',
- contntryShort:null,
- ipAddress:null,
- parentIpAddress:null,
- port:null,
- name:null,
- pwd:null,
- vpsType:null,
- dealer:null,
- mac:null,
- status:null,
- },
- total:0,
- list: [],
- uploadHeaders:{ Authorization: this.$store.getters.token },
- dialogAddVisible: false,
- dialogAddTitle: '新增',
- dialogDetailVisible: false,
- dialogDetailTitle: '详情',
- dialogEditVisible: false,
- dialogEditTitle: '修改',
- dialogImportVisible: false,
- dialogImportTitle:'导入',
- uploadFileUrl: process.env.VUE_APP_BASE_API + '/api/ctVpn/import',
- tempUrl: process.env.VUE_APP_BASE_API + '/api/ctVpn/exportTemp',
- vpsTypeList:[
- {
- value:1,
- label:"传统"
- }],
- searchVpsTypeList:[{
- value: null,
- label: '全部'
- },
- {
- value:1,
- label:"传统"
- }],
- searchDealerList:[{
- value: null,
- label: '全部'
- },
- {
- value: 1,
- label: 'V2'
- }],
- dealerList:[
- {
- value: 1,
- label: 'V2'
- }],
- searchStatusList:[{
- value: null,
- label: '全部'
- },
- {
- value: 1,
- label: '可用'
- },
- {
- value: 2,
- label: '禁用'
- }],
- statusList:[{
- value: 1,
- label: '可用'
- },
- {
- value: 2,
- label: '禁用'
- }],
- addParm: {
- id:null,
- contntryShort:null,
- ipAddress:null,
- parentIpAddress:null,
- port:null,
- name:null,
- pwd:null,
- vpsType:null,
- dealer:null,
- mac:null,
- link:null,
- status:null,
- },
- detailParm: {
- id:null,
- contntryShort:null,
- ipAddress:null,
- parentIpAddress:null,
- port:null,
- name:null,
- pwd:null,
- vpsType:null,
- dealer:null,
- mac:null,
- link:null,
- status:null,
- },
- editParm: {
- id:null,
- contntryShort:null,
- ipAddress:null,
- parentIpAddress:null,
- port:null,
- name:null,
- pwd:null,
- vpsType:null,
- dealer:null,
- mac:null,
- link:null,
- status:null,
- },
- rules: {
- contntryShort: [
- { required: true, message: '请输入国家简称', trigger: 'blur' }
- ],
- ipAddress: [
- { required: true, message: '请输入IP地址', trigger: 'blur' }
- ],
- parentIpAddress: [
- { required: true, message: '请输入父ip地址', trigger: 'blur' }
- ],
- port: [
- { required: true, message: '请输入端口', trigger: 'blur' },
- {pattern: /^[+]?(0|([1-9]\d*))?$/, message: "请输入正确数字", trigger: "blur"}
- ],
- name: [
- { required: true, message: '请输入名称', trigger: 'blur' }
- ],
- pwd: [
- { required: true, message: '请输入密码', trigger: 'blur' }
- ],
- vpsType: [
- { required: true, message: '请输入VPS类型', trigger: 'blur' }
- ],
- dealer: [
- { required: true, message: '请输入经销商', trigger: 'blur' }
- ],
- mac: [
- { required: true, message: '请输入mac地址', trigger: 'blur' }
- ],
- link: [
- { required: true, message: '请输入Link信息', trigger: 'blur' }
- ],
- status: [
- { required: true, message: '请输入状态', trigger: 'blur' }
- ]
- }
- }
- },
- // 调用
- created() {
- this.goSearch()
- },
- //方法
- methods: {
- //重置
- resetForm() {
- this.searchParm.contntryShort = null;
- this.searchParm.ipAddress = null;
- this.searchParm.parentIpAddress = null;
- this.searchParm.port = null;
- this.searchParm.name = null;
- this.searchParm.pwd = null;
- this.searchParm.vpsType = null;
- this.searchParm.dealer = null;
- this.searchParm.mac = null;
- this.searchParm.status = null;
- this.goSearch()
- },
- // 查询
- goSearch() {
- this.searchParm.page=1
- this.getDataList()
- },
- //导入成功
- uploadSuccess(res, file) {
- this.dialogImportVisible = false;
- if(res.code==200) {
- console.log(res.data);
- if(res.data != null) {
- window.location.href = res.data;
- this.$message.error('导入失败!');
- }
- else{
- this.$message.success('导入成功!');
- }
-
- }
- this.goSearch();
- },
- beforeAvatarUpload(file) {
- console.log(file);
- const isLt10M = file.size / 1024 / 1024 <10;
- if (!isLt10M) {
- this.$message.error('上传Excel文件大小不能超过 10MB!');
- }
- return isLt10M;
- },
- // 导入
- importBtn() {
- this.dialogImportVisible = true
- },
- //vpn模板
- exportTempBtn() {
- console.log(this.tempUrl)
- window.location.href = this.tempUrl;
- },
- // 新增
- addBtn(){
- this.addParm = {
- id:null,
- contntryShort:'',
- ipAddress:'',
- parentIpAddress:'',
- port:'',
- name:'',
- pwd:'',
- vpsType:null,
- dealer:null,
- mac:'',
- link:'',
- status:null,
- }
- this.dialogAddTitle='新增'
- this.dialogAddVisible = true;
- this.$refs.addParm.clearValidate();
- },
- // 根据id删除
- delById(id){
- this.$confirm('确认删除?','提示',{
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- delById({id}).then(res => {
- if(res.code==200) {
- this.$message.success('删除成功!')
- this.getDataList()
- }
- }).catch(err => {
- console.log(err)
- })
- }).catch(() => {
- this.$message.info('取消删除')
- })
- },
- // 修改
- editById(data){
- getById({id: data.id}).then(res => {
- if(res.code==200) {
- this.editParm.id = res.data.id;
- this.editParm.contntryShort = res.data.contntryShort;
- this.editParm.ipAddress = res.data.ipAddress;
- this.editParm.parentIpAddress = res.data.parentIpAddress;
- this.editParm.port = res.data.port;
- this.editParm.name = res.data.name;
- this.editParm.pwd = res.data.pwd;
- this.editParm.vpsType = res.data.vpsType;
- this.editParm.dealer = res.data.dealer;
- this.editParm.mac = res.data.mac;
- this.editParm.link = res.data.link;
- this.editParm.status = res.data.status;
- this.dialogEditVisible = true;
- this.$refs.editParm.clearValidate();
- }
- }).catch(err => {
- console.log(err)
- })
- },
- // 确认修改
- sureEdit(editParm){
- this.$refs[editParm].validate((valid) => {
- if (valid) {
- editById(this.editParm).then(res => {
- if(res.code==200) {
- console.log(res);
- this.$refs.editParm.clearValidate();
- this.dialogEditVisible = false
- this.$message.success('修改成功!');
- this.getDataList();
- }
- }).catch(err => {
- console.log(err)
- })
- } else {
- console.log('error submit!!');
- return false;
- }
- });
- },
- // 确认新增
- sureAdd(addParm){
-
- this.$refs[addParm].validate((valid) => {
- if (valid) {
- add(this.addParm).then(res => {
- if(res.code==200) {
- this.dialogAddVisible = false
- this.$message.success('新增成功!');
- this.$refs.addParm.clearValidate();
- this.getDataList()
- }
- }).catch(err => {
- console.log(err)
- })
- } else {
- console.log('error submit!!');
- return false;
- }
- });
- },
- sureAddCancle(addParm) {
- this.dialogAddVisible=flase;
- this.$refs.addParm.clearValidate();
- },
- sureEditCancle(editParm) {
- this.dialogEditVisible=false;
- this.$refs.editParm.clearValidate();
- },
- // 查看根据id
- getBtnById(id){
- getById({id}).then(res => {
- if(res.code==200) {
- this.detailParm.id = res.data.id;
- this.detailParm.contntryShort = res.data.contntryShort;
- this.detailParm.ipAddress = res.data.ipAddress;
- this.detailParm.parentIpAddress = res.data.parentIpAddress;
- this.detailParm.port = res.data.port;
- this.detailParm.name = res.data.name;
- this.detailParm.pwd = res.data.pwd;
- this.detailParm.vpsType = res.data.vpsType;
- this.detailParm.dealer = res.data.dealer;
- this.detailParm.mac = res.data.mac;
- this.detailParm.link = res.data.link;
- this.detailParm.status = res.data.status;
- this.dialogDetailVisible = true
-
- }
- }).catch(err => {
- console.log(err)
- })
- },
- // 分页获取表格数据
- getDataList(){
- getList(this.searchParm).then(res => {
- console.log(res)
- if(res.code==200) {
- console.log(res)
- this.list = res.data.list;
- this.total = res.data.total;
- }
- }).catch(err => {
- console.log(err)
- })
- },
-
- // 分页
- handleSizeChange(val) {
- console.log(`每页 ${val} 条`);
- this.searchParm.pageSize = val;
- this.getDataList();
- },
- handleCurrentChange(val) {
- console.log(`当前页: ${val}`);
- this.searchParm.page = val;
- this.getDataList();
- }
- }
- }
- </script>
-
- <style rel="stylesheet/scss" lang="scss" scoped>
- </style>
|