Commit 799ccc19 by 温丽香

根据文档修改

1 parent 0686f02e
Pipeline #4644 passed
in 2 minutes 14 seconds
......@@ -4,25 +4,6 @@
</div>
</template>
<script>
export default {
data() {
return {
formatData: [
{
label: 'test',
key: 'name',
type: 'input',
required: true,
validator: ['notEmpty', 'min2', 'max64', 'normName'],
placeholder: 'test',
},
],
}
},
}
</script>
<style>
#app {
font-family: PingFangSC-Regular, PingFang SC, Avenir, Helvetica, Arial, sans-serif;
......
......@@ -14,6 +14,18 @@ export default [
component: () => import('@views/register')
},
{
path: '/overview',
name: 'overview',
meta: { title: '总览页面', icon: 'icon-wendanggongju', hidden: true },
component: () => import('@layouts/basicLayout'),
children: [{
path: '/overview',
name: 'overview',
meta: { title: '总览页面' },
component: () => import('@views/overview')
}]
},
{
path: '/device',
name: 'device',
meta: { title: '设备列表', icon: 'icon-shebei' },
......
......@@ -128,7 +128,11 @@ export default {
showDialog: false,
submitType: 'create',
form: {},
userRoleOptions: [],
userRoleOptions: [
{ value: '管理员', label: '管理员' },
{ value: '操作员', label: '操作员' },
{ value: '观察员', label: '观察员' },
],
currentPage: 1,
currentSize: 10,
loadingStatus: false,
......
......@@ -25,8 +25,8 @@
</div>
<div slot="operate" slot-scope="row">
<span class="operate" v-if="row.ismainapp === 0" @click="setHostApp(row)">设置为主应用</span>
<span class="operate" v-else @click="cancelHostApp(row)">取消设置为主应用</span>
<span class="operate operate-delete" @click="handleDelete(row)">删除</span>
<!-- <span class="operate" v-else @click="cancelHostApp(row)">取消设置为主应用</span> -->
<span class="operate operate-delete" v-if="row.ismainapp === 0" @click="handleDelete(row)">删除</span>
</div>
</st-table>
</div>
......
<template>
<div class="data-list-common flex column main-content flex-1">
<div class="header">
<span class="title">{{'数据列表 / 编辑'}}</span>
<span class="title">{{'数据列表 / 编辑 / ' + $route.query.name}}</span>
</div>
<div class="page-content" @click="handleClick">
<div class="content-header">
......@@ -98,7 +98,7 @@ export default {
inputVal: '',
isBase64: false,
loadingStatus: false,
totalColumns: Number(this.$route.query.columns),
totalColumns: 0,
typeOptions: [{
value: 'base64',
label: 'base64'
......@@ -142,6 +142,7 @@ export default {
const str = decode.length > 64 ? 'blob' : isASCII(decode) ? decode : 'blob'
return str
})
this.totalColumns = item.binary.length
return item
})
this.total = res.data.table.total
......@@ -189,7 +190,7 @@ export default {
binaryItem.push(ite.value)
}
})
if (binaryItem.length === Number(this.$route.query.columns)) {
if (binaryItem.length === this.totalColumns) {
binaryData.push(binaryItem)
}
})
......@@ -209,7 +210,7 @@ export default {
},
addTableData() {
const binary = []
for (let i = 0; i < Number(this.$route.query.columns); i++) {
for (let i = 0; i < this.totalColumns; i++) {
binary.push({ type: '', value: '' })
}
this.insertData.push({
......@@ -252,7 +253,8 @@ export default {
if (this.agoCell !== cell) {
this.clearCell(this.agoCell)
}
this.columnIndex = Number(column.label.substring(1))
// 编辑行时扩展列
if (!row.id) this.columnIndex = Number(column.label.substring(1))
cell.getElementsByClassName('el-select')[0] && cell.getElementsByClassName('el-select')[0].classList.remove('none-display')
if (cell.getElementsByTagName('input')[0] && cell.getElementsByTagName('input')[1]) {
cell.getElementsByTagName('input')[0].classList.add('write')
......
......@@ -23,7 +23,7 @@
}"
:outerLoading="loadingStatus">
<div slot="operate" slot-scope="row">
<span class="operate" @click="$router.push({ path: '/data/edit', query: { name: row.name, columns: row.columns } })">编辑</span>
<span class="operate" @click="$router.push({ path: '/data/edit', query: { name: row.name } })">编辑</span>
<span class="operate operate-delete" @click="handleDelete(row)">删除</span>
</div>
</st-table>
......@@ -87,7 +87,7 @@ export default {
render: 'rows'
},
{
label: '容量',
label: '容量(kb)',
render: 'storage'
},
{
......
......@@ -34,12 +34,12 @@
<span v-if="row.type === 'number' || row.type === 'string'">{{row.value}}</span>
<span v-if="row.type === 'blob'" style="line-height: 28px">
<!-- TODO -->
<span style="float: left;margin-right: 10px">{{calculateByte(row.value)}}字节</span>
<span style="float: left;margin-right: 10px">{{parseInt(calculateByte(row.value))}}&nbsp;字节</span>
<el-image style="width: 42px; height: 28px;overflow: visible" :src="row.value" fit="fit">
<div slot="error" style="width: 80px; height: 28px;overflow: visible">(不可预览)</div>
</el-image>
</span>
<span v-if="row.type === 'table'" style="color: #409EFF; cursor: pointer" @click="$router.push({ path: '/data' })">{{row.value}}</span>
<span v-if="row.type === 'table'" style="color: #409EFF; cursor: pointer" @click="$router.push({ path: '/data/edit', query: { name: row.value } })">{{row.value}}</span>
</div>
</st-table>
</st-form-item>
......
......@@ -87,7 +87,7 @@
<div class="btn-box" v-if="scope.row.type === 'blob'">
<span class="upload-btn" v-if="!scope.row.value">Select File</span>
<input type="file" @blur="handleBlur" @change="(event) => handleUpload(event, scope.row)" class="input-btn" v-if="!scope.row.value">
<span v-if="scope.row.value" style="float: left;margin-right: 10px">{{calculateByte(scope.row.value)}}字节</span>
<span v-if="scope.row.value" style="float: left;margin-right: 10px">{{parseInt(calculateByte(scope.row.value))}}&nbsp;字节</span>
<el-image v-if="scope.row.value" style="width: 42px; height: 28px;overflow: visible" :src="scope.row.value" fit="fit">
<div slot="error" style="width: 80px; height: 28px;overflow: visible">(不可预览)</div>
</el-image>
......
......@@ -194,6 +194,8 @@ export default {
height: calc(100% - 60px)
.list-content
height: 100%
::v-deep .current-row td:last-child
border-right: 4px solid #409EFF
.table-box
height: 100%
::v-deep.el-table
......
......@@ -11,7 +11,20 @@
<st-form-item
style="margin-bottom:10px"
:label="'头像'+':'">
<el-image style="width: 80px; height: 80px" :src="userData.image" fit="fit"></el-image>
<el-upload
ref="mask-images"
accept=".jpg,.jpeg,.png,.bmp"
:class="{disabled: imageList.length >= 1}"
action=""
:limit="1"
:file-list="imageList"
list-type="picture-card"
:on-change="handleChange"
:on-remove="handleRemove"
:auto-upload="false">
<i class="el-icon-plus" ></i>
<!-- <span v-if="!imageList.length" style="position: absolute;top: 30px;left: 46px">上传照片</span> -->
</el-upload>
</st-form-item>
<st-form-item
style="margin-bottom:10px"
......@@ -43,28 +56,25 @@
<div slot="header" class="popup-header">{{'编辑'}}</div>
<div slot="body" class="popup-body">
<st-form
:label-width="type === 'password' ? '90px' : ''"
ref="form">
<st-form-item v-if="type === 'email'"
:label="'邮箱:'">
<st-input v-model="email"></st-input>
:label-width="type === 'password' ? '100px' : ''"
ref="form"
:model="form"
:rules="rules">
<st-form-item v-if="type === 'email'" :label="'邮箱:'" prop="email">
<st-input v-model="form.email"></st-input>
</st-form-item>
<st-form-item v-if="type === 'name'"
:label="'姓名:'">
<st-input v-model="name"></st-input>
<st-form-item v-if="type === 'name'" :label="'姓名:'" prop="name">
<st-input v-model="form.name"></st-input>
</st-form-item>
<div v-if="type === 'password'">
<st-form-item
:label="'当前密码:'">
<st-input v-model="password"></st-input>
<st-form-item :label="'当前密码:'" prop="password">
<st-input v-model="form.password" type="password"></st-input>
</st-form-item>
<st-form-item
:label="'新密码:'">
<st-input v-model="newPwd"></st-input>
<st-form-item :label="'新密码:'" prop="newPwd">
<st-input v-model="form.newPwd" type="password"></st-input>
</st-form-item>
<st-form-item
:label="'新密码:'">
<st-input v-model="confirmPwd"></st-input>
<st-form-item :label="'确认新密码:'" prop="confirmPwd">
<st-input v-model="form.confirmPwd" type="password"></st-input>
</st-form-item>
</div>
</st-form>
......@@ -78,28 +88,133 @@
</template>
<script>
import { editUser } from '@/axios'
import { getUser } from '@/utils/user'
import browserStorage from '@/services/local-storage'
export default {
data() {
const validatePassword = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入密码'))
} else if (!(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d\-_]{8,64}$/.test(value))) {
callback(new Error('密码必须包含大小写字母和数字,大于8位且小于64位'))
} else {
callback()
}
}
const validatePasswordConfirmation = (rule, value, callback) => {
if (value === '') {
callback(new Error('请确认密码'))
} else if (value !== this.confirmPwd) {
callback(new Error('密码与确认密码不一致'))
} else {
callback()
}
}
return {
showDialog: false,
userData: {},
form: {},
imageList: [],
type: '',
email: '',
name: '',
password: '',
newPwd: '',
confirmPwd: ''
confirmPwd: '',
rules: {
name: [
{ required: true, message: '请输入姓名' }
],
email: [
{ required: true, message: '请输入邮箱' },
{ type: 'email', message: '邮箱格式不正确' },
],
password: [
{ required: true, message: '请输入密码' },
{ validator: validatePassword, message: '密码必须包含大小写字母和数字,大于8位且小于64位' },
],
newPwd: [
{ required: true, message: '请输入密码' },
{ validator: validatePassword, message: '密码必须包含大小写字母和数字,大于8位且小于64位' },
],
confirmPwd: [
{ required: true, message: '请确认密码' },
{ validator: validatePasswordConfirmation, trigger: 'blur', message: '密码与确认密码不一致' },
],
}
}
},
mounted() {
this.userData = getUser().info
console.log(this.userData)
this.imageList = [{ url: browserStorage.getItem('image') }]
this.userData.email = browserStorage.getItem('email')
},
methods: {
submit() {
this.$refs.form.validate(async valid => {
if (valid) {
let res = {}
switch (this.type) {
case 'name': res = await editUser({ username: 'test', new_username: this.form.name, password: this.form.password })
break
case 'email': res = await editUser({ username: 'test', email: this.form.email })
if (res && res.data && res.data.code === 0) {
browserStorage.setItem('email', this.form.email)
this.userData.email = browserStorage.getItem('email')
Toast.success('操作成功')
}
break
case 'password': res = await editUser({ username: 'test', password: this.form.password, new_password: this.form.newPwd })
if (res && res.data && res.data.code === 0) {
Toast.success('操作成功')
}
break
default:
break
}
}
})
this.showDialog = false
},
fileToBase64(file) {
return new Promise((resolve, reject) => {
try {
const read = new FileReader()
read.onload = function(e) {
resolve(e.target.result)
}
read.readAsDataURL(file)
} catch (err) {
reject(err)
}
})
},
async handleChange(file, fileList) {
this.imageList = fileList
if (file.size > 64 * 1024) {
Toast.danger('图片大小不能超过64KB')
this.imageList = []
return
}
const base64 = await this.fileToBase64(file.raw)
const res = await editUser({ username: 'test', image: base64 })
if (res && res.data && res.data.code === 0) {
browserStorage.setItem('image', base64)
this.imageList[0].url = base64
} else {
this.imageList = []
}
},
async handleRemove(file, fileList) {
this.imageList = []
const res = await editUser({ username: 'test', image: '' })
if (res && res.data && res.data.code === 0) {
browserStorage.setItem('image', '')
} else {
this.imageList = [{ url: browserStorage.getItem('image') }]
}
},
cancelSubmit() {
this.showDialog = false
}
......@@ -108,6 +223,9 @@ export default {
</script>
<style lang="sass" scoped>
.disabled
::v-deep .el-upload--picture-card
display: none
.page-content
text-align: left
.btn-text
......
......@@ -293,7 +293,9 @@ export default {
// TokenId
browserStorage.setItem('token', res.data.token)
browserStorage.setItem('user', JSON.stringify(res.data))
this.$router.push({ path: '/params' })
browserStorage.setItem('image', res.data.image)
browserStorage.setItem('email', res.data.email)
this.$router.push({ path: '/overview' })
} else {
Toast.danger(res.data.msg)
}
......
<template>
<div class="data-list-common flex column main-content flex-1">
<div class="page-content">
<div class="apply">
<span style="margin-right: 30px">当前应用:<span v-if="applyInfo">{{applyInfo.appid}}</span></span><el-button type="primary" size="small">切换</el-button>
<div style="margin-left: 70px" v-if="applyInfo">{{applyInfo.description}}</div>
</div>
<div id="main"></div>
</div>
</div>
</template>
<script>
import { getApp } from '@/axios'
import * as echarts from 'echarts'
export default {
data() {
return {
applyInfo: {},
option: {
tooltip: {
trigger: 'item'
},
series: [
{
name: '设备状态',
type: 'pie',
radius: ['40%', '70%'],
avoidLabelOverlap: true,
labelLine: {
show: true
},
data: [
{ value: 580, name: '在线' },
{ value: 235, name: '离线' },
{ value: 100, name: '异常' },
]
}
]
}
}
},
mounted() {
const chartDom = document.getElementById('main')
const myChart = echarts.init(chartDom)
myChart.setOption(this.option)
this.getApply()
},
methods: {
async getApply() {
const res = await getApp({ pages: 0, pagesize: 100000000 })
if (res && res.data && res.data.code === 0) {
this.applyInfo = res.data.data.apps.filter(item => item.ismainapp === 1)[0]
}
},
}
}
</script>
<style lang="sass" scoped>
.apply
text-align: left
.box
width: 100%
height: 100%
#main
width: 100%
height: 100%
display: flex
justify-content: center
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!