Commit 15eaa0f7 authored by co_dengxiongwen's avatar co_dengxiongwen

点位维护页面调整

parent 90b3a6e0
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
el-button(type='primary' size='mini' icon='el-icon-plus',style='float:right;transform:translateY(6px);margin-right:20px;' v-if="isAuth('sys:points:save')" :disabled="flag" @click='addOrUpdateHandle()') 新增 el-button(type='primary' size='mini' icon='el-icon-plus',style='float:right;transform:translateY(6px);margin-right:20px;' v-if="isAuth('sys:points:save')" :disabled="flag" @click='addOrUpdateHandle()') 新增
div(slot='content') div(slot='content')
table-list(:tableColums='tableHeader' :tableData='dataList' :opNum='2') table-list(:tableColums='tableHeader' :tableData='dataList' :opNum='2')
template(#type='data')
font(v-if='data.scope.type == 1') 查询点位
font(v-if='data.scope.type == 2') 控制点位
template(#functionCodeType='data') template(#functionCodeType='data')
font(v-if='data.scope.functionCodeType == 1') 读线圈 font(v-if='data.scope.functionCodeType == 1') 读线圈
font(v-if='data.scope.functionCodeType == 2') 读离散量输入 font(v-if='data.scope.functionCodeType == 2') 读离散量输入
...@@ -52,14 +55,21 @@ ...@@ -52,14 +55,21 @@
el-form-item(label="资源点ID:" prop="resourceId" v-if='false') el-form-item(label="资源点ID:" prop="resourceId" v-if='false')
el-input(v-model='ruleForm.resourceId' placeholder="" clearable v-if='false') el-input(v-model='ruleForm.resourceId' placeholder="" clearable v-if='false')
el-col(:span='24') el-col(:span='24')
el-form-item(label="网关IP:" prop="addressIp")
el-input(v-model='ruleForm.addressIp' placeholder="请输入网关IP" clearable )
el-col(:span='12')
el-form-item(label="点位类型:" prop="type")
el-select.mywidth(v-model="ruleForm.type" placeholder="请选择点位类型" clearable)
el-option(v-for="(item,index) in typeList" :key="index" :label="item.name" :value="item.id" :code="item.id")
el-col(:span='12')
el-form-item(label="点位名称:" prop="name") el-form-item(label="点位名称:" prop="name")
el-input(v-model='ruleForm.name' placeholder="请输入点位名称" clearable ) el-input(v-model='ruleForm.name' placeholder="请输入点位名称" clearable )
el-col(:span='12') el-col(:span='12')
el-form-item(label="从机ID:" prop="slaveId") el-form-item(label="从机ID:" prop="slaveId")
el-input(v-model.number='ruleForm.slaveId' placeholder="请输从入机ID" clearable ) el-input(v-model.number='ruleForm.slaveId' placeholder="请输从入机ID" clearable )
el-col(:span='12') el-col(:span='12')
el-form-item(label="地址:" prop="registerAddress") el-form-item(label="位置:" prop="registerAddress")
el-input(v-model.number='ruleForm.registerAddress' placeholder="请输入地址" clearable ) el-input(v-model.number='ruleForm.registerAddress' placeholder="请输入位置" clearable )
el-col(:span='12') el-col(:span='12')
el-form-item(label="功能码:" prop="functionCodeType") el-form-item(label="功能码:" prop="functionCodeType")
el-select.mywidth(v-model="ruleForm.functionCodeType" placeholder="请选择功能码" clearable) el-select.mywidth(v-model="ruleForm.functionCodeType" placeholder="请选择功能码" clearable)
...@@ -83,7 +93,7 @@ import tablePagination from '@/pages/components/tablePagination' ...@@ -83,7 +93,7 @@ import tablePagination from '@/pages/components/tablePagination'
export default { export default {
data() { data() {
let validateNumber = (rule, value, callback) => { let validateNumber = (rule, value, callback) => {
if (value <= 0) { if (value < 0) {
callback(new Error('只能输入正整数')) callback(new Error('只能输入正整数'))
} else if (value > 99999999) { } else if (value > 99999999) {
callback(new Error('排序值超出范围')) callback(new Error('排序值超出范围'))
...@@ -101,6 +111,10 @@ export default { ...@@ -101,6 +111,10 @@ export default {
label: 'name', label: 'name',
level: 'level' level: 'level'
}, },
typeList: [
{ id: 1, name: '查询点位' },
{ id: 2, name: '控制点位' }
],
functionCodeTypeList: [ functionCodeTypeList: [
{ id: 1, name: '读线圈' }, { id: 1, name: '读线圈' },
{ id: 2, name: '读离散量输入' }, { id: 2, name: '读离散量输入' },
...@@ -128,6 +142,10 @@ export default { ...@@ -128,6 +142,10 @@ export default {
}, },
rules: { rules: {
//添加规则 //添加规则
addressIp: [
{ required: true, message: '网关IP不能为空', trigger: 'blur' },
{ min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur' }
],
name: [ name: [
{ required: true, message: '点位名称不能为空', trigger: 'blur' }, { required: true, message: '点位名称不能为空', trigger: 'blur' },
{ min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur' } { min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur' }
...@@ -138,10 +156,17 @@ export default { ...@@ -138,10 +156,17 @@ export default {
{ validator: validateNumber, trigger: ['blur', 'change'] } { validator: validateNumber, trigger: ['blur', 'change'] }
], ],
registerAddress: [ registerAddress: [
{ required: true, message: '地址不能为空' }, { required: true, message: '位置不能为空' },
{ type: 'number', message: '地址必须为数字' }, { type: 'number', message: '位置必须为数字' },
{ validator: validateNumber, trigger: ['blur', 'change'] } { validator: validateNumber, trigger: ['blur', 'change'] }
], ],
type: [
{
required: true,
message: '点位类型不能为空',
trigger: ['blur', 'change']
}
],
functionCodeType: [ functionCodeType: [
{ {
required: true, required: true,
...@@ -163,10 +188,12 @@ export default { ...@@ -163,10 +188,12 @@ export default {
checkList: [], //筛选数据 checkList: [], //筛选数据
tableHeader: [ tableHeader: [
{ label: '点位名称', prop: 'name' }, { label: '点位名称', prop: 'name' },
{ label: '点位类型', prop: 'type', slot: true},
{ label: '网关IP', prop: 'addressIp' },
{ label: '从机ID', prop: 'slaveId' }, { label: '从机ID', prop: 'slaveId' },
{ label: '功能码', prop: 'functionCodeType', slot: true }, { label: '功能码', prop: 'functionCodeType', slot: true },
{ label: '数据类型', prop: 'dataType', slot: true }, { label: '数据类型', prop: 'dataType', slot: true },
{ label: '寄存器地址', prop: 'registerAddress' } { label: '位置', prop: 'registerAddress' }
], ],
tableOption: { tableOption: {
border: false, //是否边框 border: false, //是否边框
......
...@@ -9,59 +9,59 @@ import isPlainObject from 'lodash/isPlainObject' ...@@ -9,59 +9,59 @@ import isPlainObject from 'lodash/isPlainObject'
// 创建一个错误 // 创建一个错误
function errorCreat (msg) { function errorCreat (msg) {
const err = new Error(msg) const err = new Error(msg)
errorLog(err) errorLog(err)
return err return err
// throw err // throw err
} }
function requestFit (config) { function requestFit (config) {
let USERNAME = 'suntray' let USERNAME = 'suntray'
let PASSWORD = 'suntray' let PASSWORD = 'c3VudHJheQ=='
config.headers.Authorization = 'Basic ' + btoa(USERNAME + ':' + PASSWORD) config.headers.Authorization = 'Basic ' + btoa(USERNAME + ':' + PASSWORD)
// 数据处理 // 数据处理
let defaults = { let defaults = {
't': new Date().getTime() 't': new Date().getTime()
// 'access_token': Vue.cookie.get('token') // 'access_token': Vue.cookie.get('token')
} }
if (config.method === 'get') { if (config.method === 'get') {
config.params = isPlainObject(config.params) || !config.params ? merge(defaults, config.params) : config.params config.params = isPlainObject(config.params) || !config.params ? merge(defaults, config.params) : config.params
} else if (config.method === 'post') { } else if (config.method === 'post') {
config.data = isPlainObject(config.data) || !config.data ? merge(defaults, config.data) : config.data config.data = isPlainObject(config.data) || !config.data ? merge(defaults, config.data) : config.data
config.data = /^application\/json/.test(config.headers['Content-Type'] || config.headers.post['Content-Type']) ? JSON.stringify(config.data) : qs.stringify(config.data) config.data = /^application\/json/.test(config.headers['Content-Type'] || config.headers.post['Content-Type']) ? JSON.stringify(config.data) : qs.stringify(config.data)
} }
return config return config
} }
// 记录和显示错误 // 记录和显示错误
function errorLog (err) { function errorLog (err) {
// 添加到日志 // 添加到日志
store.dispatch('d2admin/log/add', { store.dispatch('d2admin/log/add', {
type: 'error', type: 'error',
err, err,
info: '数据请求异常' info: '数据请求异常'
}) })
// 打印到控制台 // 打印到控制台
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
util.log.danger('>>>>>> Error >>>>>>') util.log.danger('>>>>>> Error >>>>>>')
// console.log(err) // console.log(err)
} }
// 显示提示 // 显示提示
if (document.getElementsByClassName('el-message').length < 1) { if (document.getElementsByClassName('el-message').length < 1) {
Message({ Message({
showClose: true, showClose: true,
message: err.message, message: err.message,
type: 'error', type: 'error',
duration: 5 * 1000 duration: 5 * 1000
}) })
} }
} }
// 创建一个 axios 实例 // 创建一个 axios 实例
const service = axios.create({ const service = axios.create({
baseURL: process.env.VUE_APP_TEST, baseURL: process.env.VUE_APP_TEST,
timeout: 1000 * 300, timeout: 1000 * 300,
withCredentials: false withCredentials: false
}) })
/** /**
...@@ -69,38 +69,38 @@ const service = axios.create({ ...@@ -69,38 +69,38 @@ const service = axios.create({
* @param {*} actionName action方法名称 * @param {*} actionName action方法名称
*/ */
service.adornUrl = (actionName) => { service.adornUrl = (actionName) => {
// 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截! // 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截!
// return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName // return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName
return window.CONFIG.requestPath + '/admin' + actionName return window.CONFIG.requestPath + '/admin' + actionName
} }
service.rtAdornUrl = (actionName) => { service.rtAdornUrl = (actionName) => {
// 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截! // 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截!
// return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName // return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName
return window.CONFIG.requestPath + '/admin/routes' + actionName return window.CONFIG.requestPath + '/admin/routes' + actionName
} }
service.adornUrlEq = (actionName) => { service.adornUrlEq = (actionName) => {
// 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截! // 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截!
// return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName // return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName
return window.CONFIG.requestPath + '/equipment' + actionName return window.CONFIG.requestPath + '/equipment' + actionName
} }
service.adornUrlAlarm = (actionName) => { service.adornUrlAlarm = (actionName) => {
// 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截! // 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截!
// return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName // return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName
return window.CONFIG.requestPath + '/alram' + actionName return window.CONFIG.requestPath + '/alram' + actionName
} }
service.rtAdornUrlAlarm = (actionName) => { service.rtAdornUrlAlarm = (actionName) => {
// 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截! // 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截!
// return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName // return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName
return window.CONFIG.requestPath + '/alram/routes' + actionName return window.CONFIG.requestPath + '/alram/routes' + actionName
} }
/** /**
* 认证处理 * 认证处理
* @param {*} actionName action方法名称 * @param {*} actionName action方法名称
*/ */
service.authUrl = (actionName) => { service.authUrl = (actionName) => {
// 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截! // 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截!
// return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName // return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName
return window.CONFIG.requestPath + '/authorization' + actionName return window.CONFIG.requestPath + '/authorization' + actionName
} }
/** /**
* get请求参数处理 * get请求参数处理
...@@ -108,10 +108,10 @@ service.authUrl = (actionName) => { ...@@ -108,10 +108,10 @@ service.authUrl = (actionName) => {
* @param {*} openDefultParams 是否开启默认参数? * @param {*} openDefultParams 是否开启默认参数?
*/ */
service.adornParams = (params = {}, openDefultParams = true) => { service.adornParams = (params = {}, openDefultParams = true) => {
let defaults = { let defaults = {
't': new Date().getTime() 't': new Date().getTime()
} }
return openDefultParams ? merge(defaults, params) : params return openDefultParams ? merge(defaults, params) : params
} }
/** /**
...@@ -123,129 +123,129 @@ service.adornParams = (params = {}, openDefultParams = true) => { ...@@ -123,129 +123,129 @@ service.adornParams = (params = {}, openDefultParams = true) => {
* form: 'application/x-www-form-urlencoded; charset=utf-8' * form: 'application/x-www-form-urlencoded; charset=utf-8'
*/ */
service.adornData = (data = {}, openDefultdata = true, contentType = 'json') => { service.adornData = (data = {}, openDefultdata = true, contentType = 'json') => {
let defaults = { let defaults = {
't': new Date().getTime() 't': new Date().getTime()
} }
data = openDefultdata ? merge(defaults, data) : data data = openDefultdata ? merge(defaults, data) : data
return contentType === 'json' ? JSON.stringify(data) : qs.stringify(data) return contentType === 'json' ? JSON.stringify(data) : qs.stringify(data)
} }
// 请求拦截器 // 请求拦截器
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
//如果没有站点id跳转至登录页 //如果没有站点id跳转至登录页
const localId = localStorage.getItem('stationId') const localId = localStorage.getItem('stationId')
if (!localId) { if (!localId) {
router.push({ path: '/login' }) router.push({ path: '/login' })
} }
// 在请求发送之前做一些处理 // 在请求发送之前做一些处理
const token = sessionStorage.getItem('token') const token = sessionStorage.getItem('token')
const authorization = util.cookies.get('authorization') const authorization = util.cookies.get('authorization')
config.headers.stationId = localStorage.getItem('stationId') config.headers.stationId = localStorage.getItem('stationId')
if (token && token !== 'undefined') { if (token && token !== 'undefined') {
config.headers['token'] = token // 请求头带上token config.headers['token'] = token // 请求头带上token
config.headers['Content-Type'] = config.headers['Content-Type'] ? config.headers['Content-Type'] : 'application/json; charset=utf-8' config.headers['Content-Type'] = config.headers['Content-Type'] ? config.headers['Content-Type'] : 'application/json; charset=utf-8'
} }
if (authorization && authorization !== 'undefined') { if (authorization && authorization !== 'undefined') {
config.headers.Authorization = 'Bearer ' + authorization config.headers.Authorization = 'Bearer ' + authorization
} }
if (config.url.indexOf('authorization') !== -1) { if (config.url.indexOf('authorization') !== -1) {
config = requestFit(config) config = requestFit(config)
} }
return config return config
} }
// , // ,
// error => { // error => {
// // 发送失败 // // 发送失败
// //console.log(error) // //console.log(error)
// //Promise.reject(error) // //Promise.reject(error)
// } // }
) )
// 响应拦截器 // 响应拦截器
service.interceptors.response.use( service.interceptors.response.use(
response => { response => {
// dataAxios 是 axios 返回数据中的 data // dataAxios 是 axios 返回数据中的 data
const dataAxios = response.data const dataAxios = response.data
localStorage.setItem('headers', JSON.stringify(response.headers)) localStorage.setItem('headers', JSON.stringify(response.headers))
// 这个状态码是和后端约定的 // 这个状态码是和后端约定的
let code = dataAxios.code let code = dataAxios.code
// 根据 code 进行判断 // 根据 code 进行判断
if (code === undefined) { if (code === undefined) {
// 如果没有 code 代表这不是项目后端开发的接口 比如可能是 SuntrayAdmin 请求最新版本 // 如果没有 code 代表这不是项目后端开发的接口 比如可能是 SuntrayAdmin 请求最新版本
return dataAxios return dataAxios
} else { } else {
// 有 code 代表这是一个后端接口 可以进行进一步的判断 // 有 code 代表这是一个后端接口 可以进行进一步的判断
switch (code) { switch (code) {
case 0: case 0:
case 1: case 1:
case 2: case 2:
case 3: case 3:
// [ 示例 ] code === 0 代表没有错误 // [ 示例 ] code === 0 代表没有错误
return dataAxios return dataAxios
case 401: case 401:
// [ 示例 ] 其它和后台约定的 code // [ 示例 ] 其它和后台约定的 code
//errorCreat(`[ code: 401 ] ${dataAxios.msg}: ${response.config.url}`) //errorCreat(`[ code: 401 ] ${dataAxios.msg}: ${response.config.url}`)
// 删除cookie // 删除cookie
util.cookies.remove('token') util.cookies.remove('token')
util.cookies.remove('uuid') util.cookies.remove('uuid')
util.cookies.remove('authorization') util.cookies.remove('authorization')
// 跳转路由 // 跳转路由
router.push({ router.push({
name: 'login' name: 'login'
}) })
break break
default: default:
// 不是正确的 code // 不是正确的 code
errorCreat(`${dataAxios.msg}`) errorCreat(`${dataAxios.msg}`)
break break
} }
} }
}, },
error => { error => {
if (error && error.response) { if (error && error.response) {
// if (error.response.status === 401) { // if (error.response.status === 401) {
// // // 删除cookie // // // 删除cookie
// util.cookies.remove('token') // util.cookies.remove('token')
// util.cookies.remove('uuid') // util.cookies.remove('uuid')
// util.cookies.remove('authorization') // util.cookies.remove('authorization')
// // 跳转路由 // // 跳转路由
// router.push({ name: 'login' }) // router.push({ name: 'login' })
// return // return
// } // }
switch (error.response.status) { switch (error.response.status) {
case 401: case 401:
error.message = '登录超时,请先登录' error.message = '登录超时,请先登录'
// 删除cookie // 删除cookie
util.cookies.remove('token') util.cookies.remove('token')
util.cookies.remove('uuid') util.cookies.remove('uuid')
util.cookies.remove('authorization') util.cookies.remove('authorization')
localStorage.removeItem('sysSystem') localStorage.removeItem('sysSystem')
localStorage.removeItem('stationId') localStorage.removeItem('stationId')
localStorage.removeItem('headers') localStorage.removeItem('headers')
localStorage.removeItem('sysSign') localStorage.removeItem('sysSign')
localStorage.removeItem('userId') localStorage.removeItem('userId')
sessionStorage.removeItem('menuList') sessionStorage.removeItem('menuList')
sessionStorage.removeItem('permissions') sessionStorage.removeItem('permissions')
sessionStorage.removeItem('routerList') sessionStorage.removeItem('routerList')
sessionStorage.removeItem('takeover') sessionStorage.removeItem('takeover')
sessionStorage.removeItem('token') sessionStorage.removeItem('token')
sessionStorage.removeItem('uuid') sessionStorage.removeItem('uuid')
if (this) { if (this) {
this.$parent.getDateList() this.$parent.getDateList()
//清空接管提示框 //清空接管提示框
this.$store.dispatch('d2admin/takeover/setTakeover', null) this.$store.dispatch('d2admin/takeover/setTakeover', null)
} }
// 跳转路由 // 跳转路由
router.push({ router.push({
name: 'login' name: 'login'
}) })
break break
default: default:
error.message = '服务器网络故障,请联系运维人员' error.message = '服务器网络故障,请联系运维人员'
break break
} }
} }
errorLog(error) errorLog(error)
return Promise.reject(error) return Promise.reject(error)
} }
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment