提交 fd250010 authored 作者: pengxiaohui's avatar pengxiaohui

update: 优化使用手册,设置只读和编辑两种模式;角色管理添加用户错误提示

上级 2f2dce8e
......@@ -2,13 +2,14 @@
<app-card>
<el-tabs v-model="tabsActive" type="card">
<el-tab-pane label="使用说明" name="INSTRUCTIONS">
<Tinymce v-if="tinymceFlag" ref="editor" v-model="intro_content" :height="600" />
<Tinymce v-if="tinymceFlag" :readonly="isReadonly" ref="editor" v-model="intro_content" :height="600" />
</el-tab-pane>
<el-tab-pane label="常见问题" name="COMMON_PROBLEM">
<Tinymce v-if="tinymceFlag" ref="editor" v-model="ques_content" :height="600" />
<Tinymce v-if="tinymceFlag" :readonly="isReadonly" ref="editor" v-model="ques_content" :height="600" />
</el-tab-pane>
</el-tabs>
<el-button type="primary" @click="fetchSubmitManual" size="mini" style="margin-top:20px;" :disabled="btnDisabled">保存</el-button>
<el-button class="readonly" type="primary" @click="isReadonly = !isReadonly" size="mini">{{isReadonly ? '编 辑' : '只 读'}}</el-button>
</app-card>
</template>
<script>
......@@ -22,6 +23,7 @@ export default {
tabsActive: 'INSTRUCTIONS',
intro_content: '',
ques_content: '',
isReadonly: true,
btnDisabled: false,
tinymceFlag: false
}
......@@ -68,4 +70,14 @@ export default {
}
}
}
</script>
\ No newline at end of file
</script>
<style scoped>
.app-card{
position:relative;
}
.app-card .readonly{
position:absolute;
right:50px;
top:20px;
}
</style>
\ No newline at end of file
......@@ -62,6 +62,9 @@ export default {
if (res.code === 0 && res.data && res.data.status) {
this.$message.success('添加用户成功')
this.$emit('update')
} else {
this.$message.error(res.message || '添加用户失败')
this.$emit('update')
}
})
}
......
......@@ -39,6 +39,7 @@ import AppCard from '@/components/base/AppCard.vue'
import UserSearch from '../components/UserSearch.vue'
// api
import { getUserList, addUser, batchDeleteUser } from '../api'
import { dateFormat } from '@/utils/util'
export default {
components: { AppCard, AppList, UserSearch },
data() {
......@@ -70,7 +71,18 @@ export default {
{ prop: 'sso_user.nickname', label: '用户昵称', minWidth: '100px' },
{ prop: 'sso_user.email', label: '邮箱地址', minWidth: '160px' },
{ prop: 'roles', label: '角色', minWidth: '120px', slots: 'table-role' },
{ prop: 'updated_at', label: '更新时间', minWidth: '160px' }
{
prop: 'last_login_time',
label: '最后登录时间',
minWidth: '160px',
computed({ row }) {
if (row.last_login_time === 0) {
return '-'
} else {
return dateFormat(row.last_login_time)
}
}
}
]
}
}
......
......@@ -163,7 +163,6 @@ export default {
}).catch(() => {})
},
handleRemarkEdit(val) {
console.log(val)
this.remarkDialogVisible = true
this.form.remark = val.remark
this.selectedId = val.id
......
......@@ -25,4 +25,62 @@ export function splitStrLast(str, split) {
const fileNameArr = str.split(split)
const last = fileNameArr[fileNameArr.length - 1]
return last
}
/**
* 将时间字符串、时间戳转成日期对象
* @param {(object|string|number)} time
* @returns {Date Object}
*/
export function formatToDate(time) {
let date
if (typeof time === 'object') {
date = time
} else {
if (typeof time === 'string') {
if (/^[0-9]+$/.test(time)) {
// support "1548221490638"
time = parseInt(time)
} else {
// support safari
// https://stackoverflow.com/questions/4310953/invalid-date-in-safari
time = time.replace(new RegExp(/-/gm), '/')
}
}
if (typeof time === 'number' && time.toString().length === 10) {
time = time * 1000
}
date = new Date(time)
}
return date
}
/**
* 将时间戳转成年月日时分秒
* @param {(Object|string|number)} time
* @param {string} cFormat
* @returns {string | null}
*/
export function dateFormat(time, cFormat) {
if (arguments.length === 0 || !time) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
const date = formatToDate(time)
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const timeStr = format.replace(/{([ymdhisa])+}/g, (result, key) => {
const value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') {
return ['日', '一', '二', '三', '四', '五', '六'][value]
}
return value.toString().padStart(2, '0')
})
return timeStr
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论