Browse Source

增加起始频率设置

master
lihua 5 years ago
parent
commit
ca4161d275
  1. 4
      package.json
  2. 2
      src/api/data.js
  3. 6
      src/libs/axios.js
  4. 42
      src/libs/util.js
  5. 10
      src/libs/vue-db.js
  6. 2
      src/router/index.js
  7. 2
      src/store/module/info.js
  8. 4
      src/store/module/user.js
  9. 36
      src/view/ADvanced/index.vue
  10. 58
      src/view/account/index.vue
  11. 139
      src/view/gateway-config/index.vue
  12. 8
      src/view/login/login.vue
  13. 42
      src/view/single-page/home/home.vue
  14. 8
      vue.config.js

4
package.json

@ -58,11 +58,11 @@
},
"lint-staged": {
"*.js": [
"vue-cli-service lint",
"git add"
],
"*.vue": [
"vue-cli-service lint",
"git add"
]
}

2
src/api/data.js

@ -128,4 +128,4 @@ export const getTreeSelectData = () => {
url: 'get_tree_select_data',
method: 'get'
})
}
}

6
src/libs/axios.js

@ -26,7 +26,7 @@ class HttpRequest {
const config = {
baseURL: this.baseUrl,
headers: {
"Content-type": "text/html"
'Content-type': 'text/html'
}
}
return config
@ -54,7 +54,7 @@ class HttpRequest {
} else {
console.log(res)
Notice.error({ title: '错误 ' + res.error, desc: res.msg || '错误!' })
if(res.error === 401) {
if (res.error === 401) {
store.dispatch('handleLogOut').then(res => {
router.push({ name: 'login' })
})
@ -74,7 +74,7 @@ class HttpRequest {
}
}
addErrorLog(errorInfo)
if(errorInfo.status === 401) {
if (errorInfo.status === 401) {
store.dispatch('handleLogOut').then(res => {
router.push({ name: 'login' })
})

42
src/libs/util.js

@ -398,27 +398,27 @@ export const setTitle = (routeItem, vm) => {
window.document.title = resTitle
}
//加法
export function accAdd(arg1, arg2) {
var r1, r2, m;
try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
// 加法
export function accAdd (arg1, arg2) {
var r1, r2, m
try { r1 = arg1.toString().split('.')[1].length } catch (e) { r1 = 0 }
try { r2 = arg2.toString().split('.')[1].length } catch (e) { r2 = 0 }
m = Math.pow(10, Math.max(r1, r2))
return (Math.round(arg1 * m) + Math.round(arg2 * m)) / m
}
//减法
export function accSub(arg1, arg2) {
var r1, r2, m, n;
try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
m = Math.pow(10, Math.max(r1, r2));
n = (r1 >= r2) ? r1 : r2;
return ((arg1 * m - arg2 * m) / m).toFixed(n);
}
//乘法
export function accMul(arg1, arg2) {
var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
try { m += s1.split(".")[1].length } catch (e) { }
try { m += s2.split(".")[1].length } catch (e) { }
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
}
// 减法
export function accSub (arg1, arg2) {
var r1, r2, m, n
try { r1 = arg1.toString().split('.')[1].length } catch (e) { r1 = 0 }
try { r2 = arg2.toString().split('.')[1].length } catch (e) { r2 = 0 }
m = Math.pow(10, Math.max(r1, r2))
n = (r1 >= r2) ? r1 : r2
return ((arg1 * m - arg2 * m) / m).toFixed(n)
}
// 乘法
export function accMul (arg1, arg2) {
var m = 0, s1 = arg1.toString(), s2 = arg2.toString()
try { m += s1.split('.')[1].length } catch (e) { }
try { m += s2.split('.')[1].length } catch (e) { }
return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m)
}

10
src/libs/vue-db.js

@ -1,5 +1,5 @@
class VueDB {
constructor(key){
constructor (key) {
this.key = key
}
@ -10,7 +10,6 @@ class VueDB {
if (window.sessionStorage) {
window.sessionStorage.setItem(key, value)
}
}
@ -44,7 +43,7 @@ class VueDB {
}
}
setDB(key, value){
setDB (key, value) {
let idStr = this.getItem(key).toString()
if (!idStr) {
idStr = Date.now().toString(36) + Math.random().toString(36).substr(3)
@ -60,7 +59,7 @@ class VueDB {
let hexCharCode = []
hexCharCode.push('0x')
for (var i = 0; i < str.length; i++) {
hexCharCode.push((str.charCodeAt(i)).toString(16));
hexCharCode.push((str.charCodeAt(i)).toString(16))
}
return hexCharCode.join('')
}
@ -86,11 +85,10 @@ class VueDB {
return this.getItem(idStr).toJson() || this.getItem(idStr).toString()
}
removeDB(key){
removeDB (key) {
let idStr = this.hexCharCodeToStr(this.getItem(key).toString())
this.removeItem(idStr)
this.removeItem(key)
}
}
export default VueDB

2
src/router/index.js

@ -9,7 +9,7 @@ const { homeName } = config
Vue.use(Router)
const router = new Router({
routes,
routes
// mode: 'history'
})
const LOGIN_PAGE_NAME = 'login'

2
src/store/module/info.js

@ -28,6 +28,6 @@ export default {
delAccount,
addAccount,
setFactory,
setReboot,
setReboot
}
}

4
src/store/module/user.js

@ -17,7 +17,7 @@ export default {
avatarImgPath: require('@/assets/images/defult_header_img.jpg'),
token: getToken(),
access: '',
hasGetInfo: DB.getDB('user-name') ? true:false,
hasGetInfo: !!DB.getDB('user-name'),
unreadCount: 0,
messageUnreadList: [],
messageReadedList: [],
@ -71,7 +71,7 @@ export default {
messageUnreadCount: state => state.messageUnreadList.length,
messageReadedCount: state => state.messageReadedList.length,
messageTrashCount: state => state.messageTrashList.length,
userName: state => state.userName,
userName: state => state.userName
},
actions: {
// 登录

36
src/view/ADvanced/index.vue

@ -38,7 +38,7 @@
</template>
<script>
import { mapActions } from 'vuex';
import { mapActions } from 'vuex'
export default {
name: '',
data () {
@ -47,48 +47,48 @@ export default {
isModal: false,
modalArr: [
{ t: 'restart', type: 'success' },
{ t: 'RestoreSettings', type: 'warning' },
{ t: 'RestoreSettings', type: 'warning' }
],
modalObj: { t: 'restart', type: 'success' }
}
},
methods: {
...mapActions(['upgradeFile', 'setFactory', 'setReboot']),
getData(type) {
this.modalObj = this.modalArr[type || 0];
this.isModal = true;
getData (type) {
this.modalObj = this.modalArr[type || 0]
this.isModal = true
},
onSubmit() {
let key = 'setReboot';
if(this.modalObj.type === 'warning') {
key = 'setFactory';
onSubmit () {
let key = 'setReboot'
if (this.modalObj.type === 'warning') {
key = 'setFactory'
}
this.loading = true;
this.loading = true
this[key]().then(res => {
this.isModal = this.loading = false;
this.isModal = this.loading = false
this.$Message.success({
content: '指令发送成功!请耐心等待' + this.$t(this.modalObj.t),
duration: 5
});
})
}).catch(err => {
this.loading = false;
this.loading = false
this.$Message.info({
content: this.$t(this.modalObj.t) + '失败! 状态码:' + err.response.status,
duration: 10
});
})
})
},
onSuccess() {
onSuccess () {
this.$Message.success({
content: '升级配置上传成功!',
duration: 5
});
})
},
onError() {
onError () {
this.$Message.success({
content: '文件上传失败!',
duration: 5
});
})
}
}
}

58
src/view/account/index.vue

@ -53,18 +53,22 @@ export default {
list: [],
columns: [
{ title: '账户', key: 'username' },
{ title: '密码', key: 'password',
{ title: '密码',
key: 'password',
render: (h, params) => {
return h('span', this.isAdmin ? params.row.password:'******')
return h('span', this.isAdmin ? params.row.password : '******')
}
},
{ title: '操作', key: 'action', width: 160, align: 'center',
{ title: '操作',
key: 'action',
width: 160,
align: 'center',
render: (h, params) => {
return h('div', [
h('Button', {
props: {
type: 'primary',
shape: "circle",
shape: 'circle',
icon: 'md-open',
disabled: !this.isAdmin
},
@ -73,8 +77,8 @@ export default {
},
on: {
click: () => {
this.handleReset('formInline');
this.formInline.id = true;
this.handleReset('formInline')
this.formInline.id = true
this.formInline.username = params.row.username
this.formInline.password = params.row.password
this.openDrawer()
@ -84,18 +88,18 @@ export default {
h('Button', {
props: {
type: 'error',
shape: "circle",
shape: 'circle',
icon: 'md-close',
disabled: !this.isAdmin
},
on: {
click: () => {
this.formInline = JSON.parse(JSON.stringify(params.row));
this.formInline = JSON.parse(JSON.stringify(params.row))
this.isDel = true
}
}
})
]);
])
}
}
],
@ -117,54 +121,54 @@ export default {
},
methods: {
...mapActions(['getAccountList', 'delAccount', 'addAccount', 'changeAccount']),
getData(flag) {
this.loading = true;
getData (flag) {
this.loading = true
this.getAccountList().then(res => {
if(flag) {
this.$Message.success(this.$t('freshen'));
if (flag) {
this.$Message.success(this.$t('freshen'))
}
this.loading = false;
this.loading = false
let list = JSON.parse(res)
this.list = list.user
})
},
deleteAccount() {
this.modal_loading = true;
deleteAccount () {
this.modal_loading = true
this.delAccount(this.formInline)
.then(res => {
this.modal_loading = this.isDel = false;
this.modal_loading = this.isDel = false
this.getData()
})
},
openDrawer(flag) {
if(flag) {
openDrawer (flag) {
if (flag) {
this.formInline = { id: false, username: '', password: '' }
}
this.isDrawer = !this.isDrawer
},
handleSubmit(name) {
handleSubmit (name) {
this.$refs[name].validate((valid) => {
if (valid) {
this.modal_loading = true;
this.modal_loading = true
let key = 'changeAccount'
if(!this.formInline.id) {
if (!this.formInline.id) {
key = 'addAccount'
}
this[key](this.formInline).then(res => {
this.modal_loading = this.isDrawer = false;
this.modal_loading = this.isDrawer = false
this.getData()
this.$Message.success('成功!');
this.$Message.success('成功!')
})
} else {
this.$Message.error('Fail!');
this.$Message.error('Fail!')
}
})
},
handleReset (name) {
this.$refs[name].resetFields();
this.$refs[name].resetFields()
}
},
mounted() {
mounted () {
this.isAdmin = this.userName === 'admin'
this.getData()
},

139
src/view/gateway-config/index.vue

@ -53,7 +53,7 @@
<!-- <Col span="8">
<div class="switch-4g">
<div class="switch-4g-label">GPS</div>
true-value="1" true-false="0"
true-value="1" true-false="0"
<i-switch size="large" v-model="info.gps_enable" :true-value="1" :true-false="0">
<span slot="open">开启</span>
<span slot="close">关闭</span>
@ -105,21 +105,19 @@
<Col span="8">
<div class="switch-4g">
<div class="switch-4g-label">网关接收频率</div>
<Select v-model="freq" @on-change="group = 1;freqChange()" placement="top">
<Select v-model="freq" @on-change="freqChange" placement="top">
<Option v-for="item in freqs" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select>
</div>
</Col>
<Col span="8">
<div class="switch-4g">
<div class="switch-4g-label">接收频率组</div>
<Select v-model="group" @on-change="freqChange" placement="top">
<Option v-for="idx in groups" :value="idx" :key="idx">{{ '' + idx + '' }}</Option>
</Select>
<div class="switch-4g-label">起始频率</div>
<Input-number style="width: 200px" size="large" :max="max" :step="step" v-model="start" @keyup.enter.native="startFreqChange" @on-blur="startFreqChange"></Input-number>
</div>
</Col>
<Col span="8">
<Alert type="success">当前频率段{{init + '~' + end}}</Alert>
<Alert type="success">当前频率段:{{start}}M~{{end}}M,步长:{{step}}M,通道数:8</Alert>
</Col>
</Row>
<!-- <Row :gutter="10">
@ -221,8 +219,8 @@
</template>
<script>
import { mapActions, mapGetters } from 'vuex'
import { accAdd, accMul } from '@/libs/util'
import { mapActions } from 'vuex'
import { accAdd, accSub, accMul } from '@/libs/util'
export default {
name: 'gateway',
data () {
@ -232,81 +230,120 @@ export default {
wifi: false,
modal_loading: false,
freq: '',
group: 0,
groups: 0,
freqs: [
{ value: 'CN470', label: 'CN470', init: 470.3, len: 12 },
{ value: 'CN779', label: 'CN779', init: 779.5, len: 5 },
{ value: 'EU433', label: 'EU433', init: 433.175, len: 1 },
{ value: 'EU868', label: 'EU868', init: 864.1, len: 1 },
{ value: 'US915', label: 'US915', init: 902.3, len: 8 }
{ value: 'EU868', label: 'EU868', init: 863.1, cnt: 16, interval: 0.2 },
{ value: 'US915', label: 'US915', init: 902.3, cnt: 64, interval: 0.2 },
// { value: 'US915-500', label: 'US915-500', init: 903, cnt: 8, interval: 1.6 },
{ value: 'CN779', label: 'CN779', init: 779.5, cnt: 36, interval: 0.2 },
{ value: 'EU433', label: 'EU433', init: 433.175, cnt: 16, interval: 0.2 },
{ value: 'AU915', label: 'AU915', init: 915.2, cnt: 64, interval: 0.2 },
// { value: 'AU915-500', label: 'AU915-500', init: 915.9, cnt: 8, interval: 1.6 },
{ value: 'KR920', label: 'KR920', init: 920.9, cnt: 16, interval: 0.2 },
{ value: 'CN470', label: 'CN470', init: 470.3, cnt: 96, interval: 0.2 },
{ value: 'IN865', label: 'IN865', init: 865.0625, cnt: 16, interval: 0.34 },
{ value: 'RU864', label: 'RU864', init: 868.9, cnt: 8, interval: 0.2 },
{ value: 'AS923', label: 'AS923', init: 923.2, cnt: 16, interval: 0.2 }
],
info: null,
init: '',
end: ''
init: 0,
initFreq: '',
start: 0,
min: 0,
max: 0,
step: 0
}
},
mounted() {
mounted () {
this.getData()
},
computed: {
end () {
return accAdd(this.start, 7 * this.step)
}
},
methods: {
...mapActions(['getGatewayConfig', 'saveGatewayConfig', 'setReboot']),
getData(isRefresh) {
this.loading = true;
getData (isRefresh) {
this.loading = true
this.getGatewayConfig().then(res => {
this.loading = false;
if(isRefresh) {
this.$Message.success(this.$t('freshen'));
}
let obj = JSON.parse(res);
if(obj.gw_rx_freq && obj.gw_rx_freq.split('-').length) {
this.freq = obj.gw_rx_freq.split('-')[0];
this.group = parseInt(obj.gw_rx_freq.split('-')[1]);
this.freqChange()
this.loading = false
if (isRefresh) {
this.$Message.success(this.$t('freshen'))
}
this.info = obj;
let obj = JSON.parse(res)
this.initFreq = obj.gw_rx_freq
this.freq = obj.gw_rx_freq
this.init = obj.gw_rx_freq1 / 1000000
this.freqChange()
this.start = this.init
this.info = obj
console.log(obj)
})
.catch(err => {
this.loading = false;
this.loading = false
this.$Message.error({
content: '刷新失败!' + ' 状态码:' + err.response.status,
duration: 10
});
})
})
},
freqChange() {
freqChange () {
this.freqs.forEach(r => {
if(r.value === this.freq) {
this.groups = r.len;
this.init = accAdd(r.init, accMul((this.group - 1), 1.6));
this.end = accAdd(this.init, 1.4) * 1000000;
this.init = this.init * 1000000;
if (r.value === this.freq) {
this.max = r.init + ((r.cnt - 8) * r.interval)
this.min = r.init
this.step = r.interval
this.start = r.init
}
})
},
onSave() {
startFreqChange () {
const r = accSub(this.start, this.min)
if (r < 0) {
this.$Notice.error({
title: '起始频率配置错误',
desc: '该频段的最小值为:' + this.min,
duration: 5
})
if (this.initFreq === this.freq) {
this.start = this.init
} else {
this.start = this.min
}
} else if (accMul(r, 1000000) % accMul(this.step, 1000000)) {
this.$Notice.error({
title: '起始频率配置错误',
desc: '起始频率=:' + this.min + '(最小频率)' + ' + ' + this.step + '(步长)' + ' * n(n为自然数)',
duration: 15
})
if (this.initFreq === this.freq) {
this.start = this.init
} else {
this.start = this.min
}
}
},
onSave () {
let params = JSON.parse(JSON.stringify(this.info))
params.gw_rx_freq1 = this.init;
params.gw_rx_freq2 = this.end;
this.modal_loading = true;
for(let k in params) {
params[k]+=''
params.gw_rx_freq = this.freq
params.gw_rx_freq1 = this.start * 1000000
params.gw_rx_freq2 = this.end * 1000000
this.modal_loading = true
for (let k in params) {
params[k] += ''
}
console.log(params)
this.saveGatewayConfig(params).then(res => {
this.modal_loading = this.isSave = false;
this.modal_loading = this.isSave = false
// console.log(res)
this.$Message.success({
content: '保存成功',
duration: 10
});
})
// this.setReboot()
}).catch(err => {
this.modal_loading = false
})
.catch(err => {
this.modal_loading = false;
})
}
}
}

8
src/view/login/login.vue

@ -40,12 +40,12 @@ export default {
name: this.$config.homeName
})
})
.catch(err => {
this.loading = false
})
.catch(err => {
this.loading = false
})
}
},
mounted() {
mounted () {
this.getUserInfo().then(r => {
this.$router.push({
name: this.$config.homeName

42
src/view/single-page/home/home.vue

@ -52,7 +52,7 @@ export default {
name: 'home',
components: {
InforCard,
CountTo,
CountTo
// ChartPie,
// ChartBar,
// Example
@ -61,15 +61,15 @@ export default {
return {
loading: false,
inforCardData: [
{ title: '公司名称', icon: 'md-contacts', count: 0, color: '#2d8cf0', key:'name' },
{ title: '网关型号', icon: 'ios-closed-captioning', count: 0, color: '#19be6b', key:'type' },
{ title: '网关序列号', icon: 'md-barcode', count: 0, color: '#ff9900', key:'serial' },
{ title: '开始统计时间', icon: 'ios-time', count: 0, color: '#ed3f14', key:'starttime' },
{ title: '结束统计时间', icon: 'ios-alarm', count: 0, color: '#E46CBB', key:'endtime' },
{ title: '上行数据包', icon: 'md-arrow-dropup-circle', count: 0, color: '#9A66E4', key:'recpacket' },
{ title: 'CRC正确率', icon: 'ios-checkmark-circle', count: 0, color: '#3874B3', key:'crcok' },
{ title: 'CRC错误率', icon: 'ios-close-circle', count: 0, color: '#93BB4F', key:'crcerror' },
{ title: '下发数据包', icon: 'md-arrow-dropdown-circle', count: 0, color: '#318D8F', key:'sendpacket' }
{ title: '公司名称', icon: 'md-contacts', count: 0, color: '#2d8cf0', key: 'name' },
{ title: '网关型号', icon: 'ios-closed-captioning', count: 0, color: '#19be6b', key: 'type' },
{ title: '网关序列号', icon: 'md-barcode', count: 0, color: '#ff9900', key: 'serial' },
{ title: '开始统计时间', icon: 'ios-time', count: 0, color: '#ed3f14', key: 'starttime' },
{ title: '结束统计时间', icon: 'ios-alarm', count: 0, color: '#E46CBB', key: 'endtime' },
{ title: '上行数据包', icon: 'md-arrow-dropup-circle', count: 0, color: '#9A66E4', key: 'recpacket' },
{ title: 'CRC正确率', icon: 'ios-checkmark-circle', count: 0, color: '#3874B3', key: 'crcok' },
{ title: 'CRC错误率', icon: 'ios-close-circle', count: 0, color: '#93BB4F', key: 'crcerror' },
{ title: '下发数据包', icon: 'md-arrow-dropdown-circle', count: 0, color: '#318D8F', key: 'sendpacket' }
],
pieData: [
{ value: 335, name: '直接访问' },
@ -91,32 +91,32 @@ export default {
},
methods: {
...mapActions(['getGatewayInfo']),
getGateway(flag, timer) {
if(!timer) this.loading = true;
getGateway (flag, timer) {
if (!timer) this.loading = true
this.getGatewayInfo().then(res => {
if(flag) {
this.$Message.success(this.$t('freshen'));
if (flag) {
this.$Message.success(this.$t('freshen'))
}
let obj = JSON.parse(res);
let obj = JSON.parse(res)
this.inforCardData.forEach(r => {
r.count = obj[r.key];
r.count = obj[r.key]
})
this.loading = false;
this.loading = false
})
}
},
mounted () {
this.getGateway();
if(this.timer) {
this.getGateway()
if (this.timer) {
clearInterval(this.timer)
} else {
this.timer = setInterval(() => {
this.getGateway(false, true)
}, 5000);
}, 5000)
}
},
//
destroyed() {
destroyed () {
clearInterval(this.timer)
}
}

8
vue.config.js

@ -35,12 +35,12 @@ module.exports = {
port: 8080,
proxy: {
'/cgi-bin': {
target: 'http://192.168.0.22',
changeOrigin: true,
target: 'http://192.168.0.250',
changeOrigin: true
// pathRewrite: {
// '^/cgi-bin': 'http://192.168.0.22'
// }
},
}
}
},
}
}

Loading…
Cancel
Save