优化代码&删除多余的请求
This commit is contained in:
@@ -8,7 +8,7 @@ export default ({ service, request, serviceForMock, requestForMock, mock, faker,
|
||||
VERIFY_SERVER (url) {
|
||||
return request({
|
||||
auth: {
|
||||
username: 'admin',
|
||||
username: 'admin',
|
||||
password: process.env.VUE_APP_HSLSERVER_PASSWORD
|
||||
},
|
||||
method: 'post',
|
||||
@@ -19,7 +19,7 @@ export default ({ service, request, serviceForMock, requestForMock, mock, faker,
|
||||
MODIFY_SERVER (url, data) {
|
||||
return request({
|
||||
auth: {
|
||||
username: 'admin',
|
||||
username: 'admin',
|
||||
password: process.env.VUE_APP_HSLSERVER_PASSWORD
|
||||
},
|
||||
data: data,
|
||||
@@ -50,7 +50,7 @@ export default ({ service, request, serviceForMock, requestForMock, mock, faker,
|
||||
GET_HSLSERVER_CONFIGURE (url) {
|
||||
return request({
|
||||
auth: {
|
||||
username: 'admin',
|
||||
username: 'admin',
|
||||
password: process.env.VUE_APP_HSLSERVER_PASSWORD
|
||||
},
|
||||
method: 'post',
|
||||
@@ -60,7 +60,7 @@ export default ({ service, request, serviceForMock, requestForMock, mock, faker,
|
||||
SET_HSLSERVER_CONFIGURE (url, data) {
|
||||
return request({
|
||||
auth: {
|
||||
username: 'admin',
|
||||
username: 'admin',
|
||||
password: process.env.VUE_APP_HSLSERVER_PASSWORD
|
||||
},
|
||||
data: data,
|
||||
@@ -75,7 +75,7 @@ export default ({ service, request, serviceForMock, requestForMock, mock, faker,
|
||||
GET_SERVE_DEVICE_MONITORING (url) {
|
||||
return request({
|
||||
auth: {
|
||||
username: 'admin',
|
||||
username: 'admin',
|
||||
password: process.env.VUE_APP_HSLSERVER_PASSWORD
|
||||
},
|
||||
url: url + '/Edge/DeviceData?data=/'
|
||||
@@ -88,37 +88,40 @@ export default ({ service, request, serviceForMock, requestForMock, mock, faker,
|
||||
GET_SERVER_DEVICE_STATUS (url) {
|
||||
return request({
|
||||
auth: {
|
||||
username: 'admin',
|
||||
username: 'admin',
|
||||
password: process.env.VUE_APP_HSLSERVER_PASSWORD
|
||||
},
|
||||
url: url + '/Edge/DeviceData?data=__status'
|
||||
})
|
||||
},
|
||||
GET_DEVICE_POINT_VALUE(url, deviceName, data, type){
|
||||
GET_DEVICE_POINT_VALUE (url, deviceName, data, type) {
|
||||
return request({
|
||||
validateStatus: (status) => {
|
||||
return status === 404 ? 200 : status
|
||||
},
|
||||
auth: {
|
||||
username: 'admin',
|
||||
username: 'admin',
|
||||
password: process.env.VUE_APP_HSLSERVER_PASSWORD
|
||||
},
|
||||
data: {
|
||||
'address':data
|
||||
address: data
|
||||
},
|
||||
method: 'post',
|
||||
url: url + '/'+ deviceName +'/Read'+ type +'32'
|
||||
url: url + '/' + deviceName + '/Read' + type + '32'
|
||||
})
|
||||
},
|
||||
SET_DEVICE_POINT_VALUE(url, deviceName, data, type, value){
|
||||
SET_DEVICE_POINT_VALUE (url, deviceName, data, type, value) {
|
||||
return request({
|
||||
auth: {
|
||||
username: 'admin',
|
||||
username: 'admin',
|
||||
password: process.env.VUE_APP_HSLSERVER_PASSWORD
|
||||
},
|
||||
data: {
|
||||
address:data,
|
||||
value:value
|
||||
address: data,
|
||||
value: value
|
||||
},
|
||||
method: 'post',
|
||||
url: url + '/'+ deviceName +'/Write'+ type +'32'
|
||||
url: url + '/' + deviceName + '/Write' + type + '32'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
<el-form :inline="true" size="mini" :model="deviceConfigureModelValue" ref="form" :rules="rules"
|
||||
label-position="right" class="demo-form-inline">
|
||||
<el-form-item label="设备">
|
||||
<el-select @change="deviceChange" v-model="defaultDeviceTypeNameValue" placeholder="请选择">
|
||||
<el-select @change="deviceChange" filterable v-model="defaultDeviceTypeNameValue" placeholder="请选择">
|
||||
<el-option v-for="item in deviceTypeData" :key="item" :label="item" :value="item">
|
||||
</el-option>
|
||||
</el-select>
|
||||
@@ -116,7 +116,7 @@ export default {
|
||||
})
|
||||
this.rules = rules
|
||||
this.deviceConfigureModelValue = assign(deviceConfigureModelValue, { '@ParentDeviceCode': '' })
|
||||
//this.deviceConfigureModelValue = this.choosable === 'true' ? assign(deviceConfigureModelValue, { parent_device_code: '' }) : deviceConfigureModelValue
|
||||
// this.deviceConfigureModelValue = this.choosable === 'true' ? assign(deviceConfigureModelValue, { parent_device_code: '' }) : deviceConfigureModelValue
|
||||
this.deviceConfigureFormItem = deviceConfigureFormItemData[e]
|
||||
},
|
||||
setDeviceDefaultFormItemValue (val) {
|
||||
@@ -124,7 +124,7 @@ export default {
|
||||
// if (this.choosable === 'true') {
|
||||
// deviceConfigureModelValue["@ParentDeviceCode"] = val["@ParentDeviceCode"]
|
||||
// }
|
||||
deviceConfigureModelValue["@ParentDeviceCode"] = val["@ParentDeviceCode"] || ''
|
||||
deviceConfigureModelValue['@ParentDeviceCode'] = val['@ParentDeviceCode'] || ''
|
||||
each(deviceConfigureFormItemData[this.defaultDeviceTypeNameValue], (item) => {
|
||||
if (item.type === 'time') {
|
||||
deviceConfigureModelValue[item.key] = val[item.key] ? val[item.key] : new Date()
|
||||
|
||||
@@ -195,7 +195,7 @@ export default {
|
||||
labelPosition: 'left',
|
||||
saveLoading: false,
|
||||
saveButtonText: '测试',
|
||||
saveButtonType: 'text',
|
||||
saveButtonType: 'text'
|
||||
},
|
||||
addRules: {
|
||||
deviceName: [{ required: true, type: 'string', message: '服务名称不可为空', trigger: 'blur' }],
|
||||
@@ -222,10 +222,10 @@ export default {
|
||||
}
|
||||
},
|
||||
handleDialogOpen ({ mode }) {
|
||||
if(mode === 'edit'){
|
||||
if (mode === 'edit') {
|
||||
this.formOptions.saveButtonText = '确定'
|
||||
this.formOptions.saveButtonType = 'text'
|
||||
}
|
||||
}
|
||||
},
|
||||
// 普通的新增
|
||||
addRow () {
|
||||
@@ -239,7 +239,7 @@ export default {
|
||||
// 定义测试动作
|
||||
if (this.formOptions.saveButtonText === '测试') {
|
||||
this.serverSettings = await this.$api.VERIFY_SERVER(
|
||||
'http://' + row.url + ':' + row.port,
|
||||
'http://' + row.url + ':' + row.port
|
||||
)
|
||||
if (this.serverSettings) {
|
||||
this.$message({
|
||||
@@ -289,8 +289,8 @@ export default {
|
||||
},
|
||||
async handleRowEdit ({ index, row }, done) {
|
||||
this.formOptions.saveLoading = true
|
||||
let serverSettings = await this.$api.VERIFY_SERVER(
|
||||
'http://' + row.url + ':' + row.port
|
||||
const serverSettings = await this.$api.VERIFY_SERVER(
|
||||
'http://' + row.url + ':' + row.port
|
||||
)
|
||||
serverSettings.Content.ServerInfoConfig.CaptureURL = row.address
|
||||
this.$api.MODIFY_SERVER(
|
||||
@@ -321,33 +321,31 @@ export default {
|
||||
done()
|
||||
},
|
||||
setServerExec ({ row }) {
|
||||
|
||||
this.$confirm('是否要重启动该服务', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
await this.$api.SET_SERVER_EXEC({
|
||||
action: 'exec',
|
||||
server_id: row.id,
|
||||
command: 'server_restart'
|
||||
})
|
||||
this.$message({
|
||||
message: '服务应用请求成功,请求动作已添加至请求队列中,请从服务监控页面查看结果',
|
||||
type: 'success'
|
||||
})
|
||||
this.getServers()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}).catch(() => {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
await this.$api.SET_SERVER_EXEC({
|
||||
action: 'exec',
|
||||
server_id: row.id,
|
||||
command: 'server_restart'
|
||||
})
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已重启动该服务'
|
||||
});
|
||||
});
|
||||
|
||||
message: '服务应用请求成功,请求动作已添加至请求队列中,请从服务监控页面查看结果',
|
||||
type: 'success'
|
||||
})
|
||||
this.getServers()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已重启动该服务'
|
||||
})
|
||||
})
|
||||
},
|
||||
handleDialogCancel (done) {
|
||||
this.$message({
|
||||
@@ -369,7 +367,7 @@ export default {
|
||||
},
|
||||
closeDrawer () {
|
||||
this.server = { id: 0, url: '', port: '' }
|
||||
if(this.$refs.deviceTemplate.timing){
|
||||
if (this.$refs.deviceTemplate.timing) {
|
||||
this.$refs.deviceTemplate.clearTime()
|
||||
}
|
||||
},
|
||||
|
||||
@@ -211,7 +211,7 @@ export default {
|
||||
},
|
||||
mounted () {
|
||||
this.getServe()
|
||||
setInterval(()=>{
|
||||
setInterval(() => {
|
||||
this.getServe()
|
||||
}, 30000)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user