123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472 |
- <template>
- <div id="project">
- <el-container>
- <el-main>
- <div style="margin-bottom: 10px">
- <el-button size="medium" icon="el-icon-back" type="text" @click="back">返回</el-button>
- <span style="margin-left: 20px; font-size: 18px">网关列表</span>
- </div>
- <div style="margin-bottom: 12px">
- <span style="margin-left: 3px; font-size: 16px; color: #545c64">项目编号:{{projectData.number}}</span>
- <span style="margin-left: 20px; font-size: 16px;color: #545c64">项目名称:{{projectData.name}}</span>
- </div>
- <el-button size="medium" icon="el-icon-search" style="margin-bottom: 15px" @click="search(searchFormData)">
- 查询
- </el-button>
- <el-button size="medium" icon="el-icon-plus" @click="showAdd" style="margin-left: 0">新增</el-button>
- <div style="padding: 10px;background-color: white">
- <el-form :inline="true" :model="searchFormData" style="background-color: white;">
- <el-form-item label="编号">
- <el-input placeholder="编号" size="mini" v-model="searchFormData.number"></el-input>
- </el-form-item>
- <el-form-item label="网关ip">
- <el-input placeholder="网关ip" size="mini" v-model="searchFormData.ip"></el-input>
- </el-form-item>
- <el-form-item label="定位">
- <el-input placeholder="定位" size="mini" v-model="searchFormData.location"></el-input>
- </el-form-item>
- <!-- <el-form-item label="运营商编号" style="margin-top: 6px" size="mini">-->
- <!-- <el-select v-model="searchFormData.operatorNumber" placeholder="运营商编号" style="width: 180px" clearable>-->
- <!-- <el-option :value="i.number" v-for="(i,index) in operators" :key="index" :label="i.number"></el-option>-->
- <!-- </el-select>-->
- <!-- </el-form-item>-->
- <el-dialog title="网关" :visible.sync="dialogFormVisible" style="width: 70% ; margin-left: 300px ;">
- <el-form label-position="left" :model="formData">
- <el-row style="margin-left: 15px">
- <el-form-item label="编号" style="margin-right: 50px;margin-left: 22px">
- <el-input v-model="formData.number"></el-input>
- </el-form-item>
- <el-form-item label="网关ip">
- <el-input v-model="formData.ip"></el-input>
- </el-form-item>
- </el-row>
- <el-row style="margin-left: 15px">
- <el-form-item label="定位" style="margin-right: 20px;margin-left: 22px">
- <el-input v-model="formData.location"></el-input>
- </el-form-item>
- <el-form-item label="运营商编号">
- <el-select v-model="formData.operatorNumber" placeholder="运营商编号" style="width: 202px">
- <el-option :value="i.number" v-for="(i,index) in operators" :key="index"
- :label="i.number"></el-option>
- </el-select>
- </el-form-item>
- </el-row>
- <el-form-item label="项目编号">
- <el-select v-model="formData.projectNumber" placeholder="项目编号" style="width: 202px">
- <el-option :value="i.number" v-for="(i,index) in projects" :key="index"
- :label="i.number"></el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer" style="text-align: center">
- <el-button @click="cancel()">取 消</el-button>
- <el-button type="primary" @click="addOrEditMehtond()">确 定</el-button>
- </div>
- </el-dialog>
- </el-form>
- <el-table :data="tableData">
- <el-table-column type="selection"></el-table-column>
- <el-table-column prop="number" label="编号"></el-table-column>
- <el-table-column prop="ip" label="网关ip"></el-table-column>
- <el-table-column prop="location" label="定位"></el-table-column>
- <el-table-column label="网关状态">
- <template slot-scope="scope">
- {{ String(scope.row.useStatus) === '0' ? '已禁用' : '正常' }}
- </template>
- </el-table-column>
- <el-table-column label="操作">
- <template slot-scope="scope">
- <el-button type="text" size="medium" @click="showEdit(scope.row)">编辑</el-button>
- <el-button type="text" size="medium" @click="gatewayList(scope.row)">设备</el-button>
- <el-button type="text" size="medium" @click="del(scope.row)" style="color: #c01920">删除</el-button>
- <el-button
- style="color: #c01920"
- type="text"
- size="medium"
- class="delBut non"
- @click="statusHandle(scope.row)"
- >
- {{ scope.row.useStatus == '1' ? '禁用' : '启用' }}
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- style="margin-top: 15px;text-align: center"
- background
- layout="prev, pager, next"
- :page-size="pager.pageSize"
- :current-page="pager.pageIndex"
- :total="pager.itemCount"
- @current-change="handleCurrentChange"
- >
- </el-pagination>
- </div>
- </el-main>
- </el-container>
- </div>
- </template>
- <script>
- export default {
- name: 'project',
- data() {
- return {
- operators: [],
- projects: [],
- api: {
- list: this.$api.gateway.list,
- delete: this.$api.gateway.delete,
- add: this.$api.gateway.add,
- update: this.$api.gateway.update,
- },
- projectData:{
- name:'',
- number:'',
- code:'',
- },
- value: true,
- addOrEdit: 1,
- dialogFormVisible: false,
- pager: {
- pageSize: 2,
- pageIndex: 1,
- itemCount: 0,
- },
- tableData:
- [{
- number: '',
- ip: '',
- location: '',
- useStatus: '1'
- }],
- formData: {
- number: '',
- ip: '',
- location: '',
- useStatus: '1',
- operatorNumber: '',
- projectNumber: ''
- },
- searchFormData:
- {
- number: '',
- ip: '',
- location: '',
- useStatus: '1',
- operatorNumber: '',
- projectNumber: ''
- }
- }
- },
- created: function () {
- this.getOperatorNumber();
- this.getProjectNumber();
- this.loadData();
- },
- methods: {
- //切换页码
- handleCurrentChange(index) {
- this.loadData(index)
- },
- loadData(index) {
- var row = this.$route.query.row;
- console.log(row)
- this.projectData = row
- console.log(this.projectData.name)
- const vm = this;
- vm.$http.get(vm.api.list, {
- params: {
- pageSize: 5,
- pageIndex: index ? index : 1,
- number: this.searchFormData.number,
- ip: this.searchFormData.ip,
- location: this.searchFormData.location,
- projectNumber: this.projectData.number,
- }
- })
- .then((response) => {
- // vm.paper = response.data.data.paper;
- console.log(response.data.data);
- vm.pager = response.data.data.pager
- vm.tableData = response.data.data.gateways;
- })
- },
- getOperatorNumber() {
- const vm = this;
- vm.$http.get(vm.$api.operator.list, {
- params: {
- number: this.searchFormData.operatorNumber,
- }
- }).then((resp) => {
- console.log(resp.data.data.operators)
- vm.operators = resp.data.data.operators
- })
- },
- getProjectNumber() {
- const vm = this;
- vm.$http.get(vm.$api.project.list, {
- params: {
- number: this.searchFormData.projectNumber,
- }
- }).then((resp) => {
- console.log(resp.data.data.projects)
- vm.projects = resp.data.data.projects
- })
- },
- search() {
- //console.log(this.searchFormData)
- this.loadData();
- },
- showAdd() {
- this.dialogFormVisible = true;
- this.formData.number = '',
- this.formData.ip = '',
- this.formData.location = '',
- this.formData.operatorNumber = '',
- this.formData.projectNumber = ''
- },
- showEdit(row) {
- this.dialogFormVisible = true;
- this.editRow = JSON.parse(JSON.stringify(row));
- this.formData = this.editRow
- this.addOrEdit = 2
- }
- ,
- addOrEditMehtond() {
- const vm = this;
- if (this.addOrEdit == 2) {
- vm.$http.get(vm.api.update, {
- params: {
- number: this.formData.number,
- ip: this.formData.ip,
- location: this.formData.location,
- useStatus: this.formData.useStatus,
- operatorNumber: this.formData.operatorNumber,
- projectNumber: this.formData.projectNumber,
- operatorCode: this.formData.operatorCode,
- projectCode: this.formData.projectCode,
- }
- })
- .then((response) => {
- console.log(response)
- if (response.data.status == 200) {
- this.$message({
- type: 'success',
- showClose: true,
- message: response.data.desc
- })
- }
- this.dialogFormVisible = false;
- this.loadData();
- })
- .catch(() => {
- });
- }
- if (this.addOrEdit == 1) {
- vm.$http.get(vm.api.add, {
- params: {
- number: this.formData.number,
- ip: this.formData.ip,
- location: this.formData.location,
- useStatus: this.formData.useStatus,
- operatorNumber: this.formData.operatorNumber,
- projectNumber: this.formData.projectNumber,
- operatorCode: this.formData.operatorCode,
- projectCode: this.formData.projectCode,
- }
- })
- .then((response) => {
- if (response.data.status == 200) {
- this.dialogFormVisible = false;
- this.$message({
- type: 'success',
- showClose: true,
- message: response.data.desc
- })
- this.loadData();
- }
- })
- }
- },
- del(row) {
- const vm = this;
- this.$confirm('确认删除', '提示', {
- type: 'warning'
- }).then(() => {
- vm.$http.get(vm.api.delete, {
- params: {
- code: row.code,
- }
- })
- .then((response) => {
- console.log(response)
- if (response.data.status == 200) {
- this.$message({
- type: 'success',
- showClose: true,
- message: response.data.desc
- })
- }
- this.loadData();
- })
- })
- .catch(() => {
- this.$message({
- type: 'info',
- showClose: true,
- message: '取消删除'
- })
- });
- },
- cancel() {
- this.$message({
- message: '操作取消',
- showClose: true,
- type: 'info'
- });
- this.dialogFormVisible = false;
- },
- //启用/停用网关
- statusHandle(row) {
- const vm = this;
- this.$confirm('是否进行此操作', '提示', {
- type: 'warning'
- }).then(() => {
- vm.$http.get(vm.api.update, {
- params: {
- number: row.number,
- ip: row.ip,
- location: row.location,
- operatorNumber: row.operatorNumber,
- projectNumber: row.projectNumber,
- operatorCode: row.operatorCode,
- projectCode: row.projectCode,
- code: row.code,
- valid: row.valid,
- useStatus: row.useStatus == 1 ? 0 : 1,
- }
- })
- .then((response) => {
- console.log(row)
- // console.log(response)
- if (response.data.status == 200) {
- this.$message({
- type: 'success',
- showClose: true,
- message: response.data.desc
- })
- }
- this.loadData();
- })
- })
- .catch(() => {
- this.$message({
- type: 'info',
- showClose: true,
- message: '操作取消'
- })
- });
- },
- gatewayList(row) {
- let vm = this;
- vm.$router.push({
- path: '/gatewayList',
- query: {row: row}
- })
- },
- back() {
- let vm = this;
- vm.$router.back()
- }
- }
- }
- </script>
- <style scoped>
- .el-form-item {
- margin-right: 10px;
- margin-left: 10px;
- margin-bottom: 10px;
- margin-top: 0px;
- }
- </style>
|