Commit fa4c939b by 张立顺

theme-color-replacer 写法修改

1 parent 5172dd5f
Showing 139 changed files with 2400 additions and 1967 deletions
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'@vue/prettier'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
},
parserOptions: {
parser: 'babel-eslint'
}
}
module.exports = {
root: true,
env: {
node: true
},
extends: [
'plugin:vue/essential',
'@vue/prettier'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
},
parserOptions: {
parser: 'babel-eslint'
}
}
module.exports = {
root: true,
parserOptions: {
parser: '@babel/eslint-parser'
// parser: '@babel/eslint-parser'
ecmaVersion: 2020,
},
env: {
browser: true
browser: true,
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevent
......@@ -12,23 +13,27 @@ module.exports = {
// `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
'standard',
'plugin:vue/strongly-recommended',
'@vue/standard',
// '@vue/typescript/recommended'
],
// required to lint *.vue files
plugins: ['vue'],
globals: {
NODE_ENV: false,
_: false,
echarts: false
echarts: false,
},
rules: {
'arrow-spacing': [
2,
{
before: true,
after: true
}
after: true,
},
],
'no-var': 'off',
eqeqeq: 'off',
// 'no-eval': ['error', { allowIndirect: false }], // default is false
'no-eval': 'off', // default is false
......@@ -39,16 +44,16 @@ module.exports = {
2,
'1tbs',
{
allowSingleLine: true
}
allowSingleLine: true,
},
],
'comma-dangle': [2, 'never'],
'comma-spacing': [
2,
{
before: false,
after: true
}
after: true,
},
],
'comma-style': [2, 'last'],
curly: [2, 'multi-line'],
......@@ -57,29 +62,29 @@ module.exports = {
2,
2,
{
SwitchCase: 1
}
SwitchCase: 1,
},
],
'key-spacing': [
2,
{
beforeColon: false,
afterColon: true
}
afterColon: true,
},
],
'keyword-spacing': [
2,
{
before: true,
after: true
}
after: true,
},
],
'new-cap': [
2,
{
newIsCap: true,
capIsNew: false
}
capIsNew: false,
},
],
'no-extra-parens': [2, 'functions'],
'no-floating-decimal': 2,
......@@ -87,8 +92,8 @@ module.exports = {
'no-multiple-empty-lines': [
2,
{
max: 1
}
max: 1,
},
],
'no-trailing-spaces': 2,
quotes: [
......@@ -96,8 +101,8 @@ module.exports = {
'single',
{
avoidEscape: true,
allowTemplateLiterals: true
}
allowTemplateLiterals: true,
},
],
semi: [2, 'never'],
'space-before-blocks': [2, 'always'],
......@@ -109,10 +114,10 @@ module.exports = {
2,
{
words: true,
nonwords: false
}
nonwords: false,
},
],
'spaced-comment': [2, 'always'],
'prefer-const': 2
}
'prefer-const': 2,
},
}
No preview for this file type
This diff could not be displayed because it is too large.
......@@ -73,7 +73,7 @@
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-vue": "^8.0.3",
"eslint-plugin-vue": "^7.0.0",
"jest": "^27.1.0",
"postcss": "^8.4.16",
"postcss-loader": "^7.0.1",
......
......@@ -6,7 +6,7 @@
<script>
export default {
name: 'app',
name: 'App',
created() {
// console.log(abcd.efg)
......
......@@ -7,5 +7,5 @@ const req = require.context('./icons', false, /\.svg$/)
const iconMap = requireAll(req)
// console.log("iconMap",iconMap);
// e.slice(3) 老写法
Vue.prototype.$IconSvg = iconMap.map(e =>e.split('/')[1].split('.')[0] )
Vue.prototype.$IconSvg = iconMap.map(e => e.split('/')[1].split('.')[0])
// Vue.prototype.$IconSvg = iconMap.map(e =>console.log(e.default))
......@@ -16,7 +16,7 @@ export const Util = {
* confirmButtonColor 确认按钮颜色
* cancelButtonColor 取消按钮颜色
*/
msg: function(options) {
msg: function (options) {
MessageBox({
title: options.title || '',
type: options.type || 'error',
......@@ -28,7 +28,7 @@ export const Util = {
confirmButtonColor: options.confirmButtonColor || '#1989fa',
cancelButtonColor: options.cancelButtonColor || '#000',
dangerouslyUseHTMLString: true,
callback: function(action, done) {
callback: function (action, done) {
if (action == 'confirm') {
if (options.success) {
options.success(done)
......@@ -37,7 +37,7 @@ export const Util = {
console.log(done)
// done()
}
}
},
})
/* Vue.$vux.alert.show({
......@@ -55,55 +55,56 @@ export const Util = {
/**
* 提示框
*/
Info: function(options) {
Info: function (options) {
Message({
message: options.message || '提示',
type: options.type || 'error',
duration: options.time || 2000,
onClose: options.onClose || ''
onClose: options.onClose || '',
})
},
/**
* 轻提示
*/
Tips: function(options) {
Tips: function (options) {
Message({
message: options.message || '提示',
duration: options.duration || 3000,
type: options.type || 'text',
icon: options.icon || ''
icon: options.icon || '',
})
},
/**
* loading
*/
loading: function(message) {
loading: function (message) {
loadingInstance = Loading.service({
text: message || '加载中...'
text: message || '加载中...',
})
},
/**
* 关闭loading
*/
closeLoading: function() {
closeLoading: function () {
loadingInstance.close()
},
/**
* 校验手机号码格式
*/
checkPhone: function(mobile) {
const myreg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/
checkPhone: function (mobile) {
const myreg =
/^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/
return myreg.test(mobile)
},
/**
* 校验固定电话
*/
validationTel: function(tel) {
validationTel: function (tel) {
const reg = /^0[\d]{2,3}-[\d]{7,8}$/
return reg.test(tel)
},
......@@ -111,7 +112,7 @@ export const Util = {
/**
* 是否特殊字符
*/
isSpecialLetter: function(str) {
isSpecialLetter: function (str) {
const reg = new RegExp(
"[`~!@#$^&*=|{}':;',\\[\\]<>?~!@#¥……&*——|{}【】‘;:”“'。,、? ]"
)
......@@ -121,7 +122,7 @@ export const Util = {
/**
* 只能输入英文字母和数字,不能输入中文
*/
validationInput: function(str) {
validationInput: function (str) {
const reg = /[^\w\.\/]/gi // eslint-disable-line
return reg.test(str)
},
......@@ -129,21 +130,21 @@ export const Util = {
/**
* 获取当前时间
*/
getCurrentDate: function() {
getCurrentDate: function () {
const time = new Date()
const y = time.getFullYear()
const m = time.getMonth() + 1
const d = time.getDate()
return {
date: y + '/' + m + '/' + d
date: y + '/' + m + '/' + d,
}
},
/**
* 获取浏览器参数
*/
getUrlParams: function(name) {
getUrlParams: function (name) {
const vars = []
let hash
const oParams = {}
......@@ -166,7 +167,7 @@ export const Util = {
/**
* 根据当前时间,计算往后30天的日期
*/
getAfterDate: function(day) {
getAfterDate: function (day) {
const date1 = new Date()
const date2 = new Date(date1)
let time = 30
......@@ -182,14 +183,14 @@ export const Util = {
date: _date,
year: date2.getFullYear(),
month: date2.getMonth() + 1,
day: date2.getDate()
day: date2.getDate(),
}
},
/**
* 日期格式转换
*/
dateFormate: function(str, type) {
dateFormate: function (str, type) {
let txt = 'YYYY-MM-DD'
if (type) {
txt = type
......@@ -201,7 +202,7 @@ export const Util = {
/**
* 字段截取
*/
cutStr: function(str, num) {
cutStr: function (str, num) {
if (!str) {
return ''
}
......@@ -224,7 +225,7 @@ export const Util = {
* console.log(bar===foo) false
* @param {*} obj
*/
deepClone: function(obj) {
deepClone: function (obj) {
// Handle the 3 simple types, and null or undefined or function
if (obj == null || typeof obj !== 'object') return obj
// Handle Date
......@@ -237,7 +238,7 @@ export const Util = {
if ((obj instanceof Array) | (obj instanceof Object)) {
const copy = obj instanceof Array ? [] : {}
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) {
if (Object.prototype.hasOwnProperty.call(attr)) {
copy[attr] = Util.deepClone(obj[attr])
}
}
......@@ -250,7 +251,7 @@ export const Util = {
* url下载文件
*
*/
downLoadFile: function(url) {
downLoadFile: function (url) {
// console.log(row)
// return
const Temp = document.createElement('a')
......@@ -268,7 +269,7 @@ export const Util = {
* @param {Object} type: 默认不传 ==>全部小写;传1 ==>全部大写;传2 ==>首字母大写
* 将json的key值进行大小写转换
*/
jsonKeysToCase: function(json, type) {
jsonKeysToCase: function (json, type) {
if (typeof json == 'object') {
var tempJson = JSON.parse(JSON.stringify(json))
toCase(tempJson)
......@@ -280,7 +281,7 @@ export const Util = {
function toCase(json) {
if (typeof json == 'object') {
if (Array.isArray(json)) {
json.forEach(function(item) {
json.forEach(function (item) {
toCase(item)
})
} else {
......@@ -314,9 +315,9 @@ export const Util = {
},
// 判断字段为空时显示
fieldShow: function(field, show) {
fieldShow: function (field, show) {
return field || show
}
},
}
export const showModal = Util.msg
......
<template>
<el-dialog id="baseDialog"
top="30vh"
:close-on-click-modal="true"
:close-on-press-escape="true"
:title="dialogConfig.title"
:width="dialogConfig.width"
:visible.sync="visible"
:show-close="config.showClose"
class="noborder"
:append-to-body="config.appendToBody">
<slot></slot>
<div slot="footer"
v-if="config.isShowFooter">
<el-button type="primary"
@click="confirmBtn">
{{config.confirm_name}}
<el-dialog
id="baseDialog"
top="30vh"
:close-on-click-modal="true"
:close-on-press-escape="true"
:title="dialogConfig.title"
:width="dialogConfig.width"
:visible.sync="visible"
:show-close="config.showClose"
class="noborder"
:append-to-body="config.appendToBody"
>
<slot />
<div
slot="footer"
v-if="config.isShowFooter"
>
<el-button
type="primary"
@click="confirmBtn"
>
{{ config.confirm_name }}
</el-button>
<el-button @click="visible = false">
{{ config.cancel_name }}
</el-button>
</div>
</el-dialog>
</el-dialog>
</template>
<script>
export default {
name: 'baseDialog',
name: 'BaseDialog',
props: {
dialogConfig: {
required: false,
......
......@@ -64,7 +64,7 @@ export default {
* @param {*} btn
*/
const filter = btn =>
mapping ? mapping[data[mapping['field']]].includes(btn.label) : true
mapping ? mapping[data[mapping.field]].includes(btn.label) : true
const $store = _this.$store.getters['d2admin/auth/curBtns']
if (!$store) return h('div')
if (label) {
......
<template>
<div class="d2-container-card-bs">
<div v-if="$slots.header" class="d2-container-card-bs__header" ref="header">
<slot name="header"/>
</div>
<div class="d2-container-card-bs__body" ref="wrapper">
<div class="d2-container-card-bs__body-wrapper-inner">
<div class="d2-container-card-bs__body-card">
<slot/>
</div>
</div>
</div>
<div v-if="$slots.footer" class="d2-container-card-bs__footer" ref="footer">
<slot name="footer"/>
</div>
</div>
</template>
<script>
import bs from './mixins/bs'
export default {
name: 'd2-container-card-bs',
mixins: [
bs
]
}
</script>
<template>
<div class="d2-container-card-bs">
<div
v-if="$slots.header"
class="d2-container-card-bs__header"
ref="header"
>
<slot name="header" />
</div>
<div
class="d2-container-card-bs__body"
ref="wrapper"
>
<div class="d2-container-card-bs__body-wrapper-inner">
<div class="d2-container-card-bs__body-card">
<slot />
</div>
</div>
</div>
<div
v-if="$slots.footer"
class="d2-container-card-bs__footer"
ref="footer"
>
<slot name="footer" />
</div>
</div>
</template>
<script>
import bs from './mixins/bs'
export default {
name: 'D2ContainerCardBs',
mixins: [
bs
]
}
</script>
<template>
<div class="d2-container-card">
<div v-if="$slots.header" class="d2-container-card__header" ref="header">
<slot name="header"/>
</div>
<div class="d2-container-card__body" ref="body">
<div class="d2-container-card__body-card">
<slot/>
</div>
</div>
<div v-if="$slots.footer" class="d2-container-card__footer" ref="footer">
<slot name="footer"/>
</div>
</div>
</template>
<script>
import scroll from './mixins/normal'
export default {
name: 'd2-container-card',
mixins: [
scroll
],
mounted() {
// 增加滚动事件监听
this.addScrollListener()
},
beforeDestroy() {
// 移除滚动事件监听
this.removeScrollListener()
}
}
</script>
<template>
<div class="d2-container-card">
<div
v-if="$slots.header"
class="d2-container-card__header"
ref="header"
>
<slot name="header" />
</div>
<div
class="d2-container-card__body"
ref="body"
>
<div class="d2-container-card__body-card">
<slot />
</div>
</div>
<div
v-if="$slots.footer"
class="d2-container-card__footer"
ref="footer"
>
<slot name="footer" />
</div>
</div>
</template>
<script>
import scroll from './mixins/normal'
export default {
name: 'D2ContainerCard',
mixins: [
scroll
],
mounted() {
// 增加滚动事件监听
this.addScrollListener()
},
beforeDestroy() {
// 移除滚动事件监听
this.removeScrollListener()
}
}
</script>
<template>
<div class="d2-container-full-bs">
<div v-if="$slots.header" class="d2-container-full-bs__header" ref="header">
<slot name="header"/>
</div>
<div class="d2-container-full-bs__body" ref="wrapper">
<div class="d2-container-full-bs__body-wrapper-inner">
<slot/>
</div>
</div>
<div v-if="$slots.footer" class="d2-container-full-bs__footer" ref="footer">
<slot name="footer"/>
</div>
</div>
</template>
<script>
import bs from './mixins/bs'
export default {
name: 'd2-container-card-bs',
mixins: [
bs
]
}
</script>
<template>
<div class="d2-container-full-bs">
<div
v-if="$slots.header"
class="d2-container-full-bs__header"
ref="header"
>
<slot name="header" />
</div>
<div
class="d2-container-full-bs__body"
ref="wrapper"
>
<div class="d2-container-full-bs__body-wrapper-inner">
<slot />
</div>
</div>
<div
v-if="$slots.footer"
class="d2-container-full-bs__footer"
ref="footer"
>
<slot name="footer" />
</div>
</div>
</template>
<script>
import bs from './mixins/bs'
export default {
name: 'D2ContainerCardBs',
mixins: [
bs
]
}
</script>
<template>
<div class="d2-container-full">
<!-- <el-scrollbar> -->
<div v-if="$slots.header"
class="d2-container-full__header"
ref="header"
:class="this.active?'active':'close'">
<div
v-if="$slots.header"
class="d2-container-full__header"
ref="header"
:class="this.active?'active':'close'"
>
<slot name="header" />
<d2-header-switch />
</div>
<div class="d2-container-full__body"
ref="body">
<div
class="d2-container-full__body"
ref="body"
>
<slot />
</div>
<div v-if="$slots.footer"
class="d2-container-full__footer"
ref="footer">
<div
v-if="$slots.footer"
class="d2-container-full__footer"
ref="footer"
>
<slot name="footer" />
</div>
<!-- </el-scrollbar> -->
......@@ -24,7 +30,7 @@
<script>
import scroll from './mixins/normal'
export default {
name: 'd2-container-full',
name: 'D2ContainerFull',
mixins: [scroll],
components: {
d2HeaderSwitch: () => import('./d2-header-switch.vue')
......
<template>
<div class="d2-container-ghost-bs">
<div v-if="$slots.header" class="d2-container-ghost-bs__header" ref="header">
<slot name="header"/>
</div>
<div class="d2-container-ghost-bs__body" ref="wrapper">
<div>
<slot/>
</div>
</div>
<div v-if="$slots.footer" class="d2-container-ghost-bs__footer" ref="footer">
<slot name="footer"/>
</div>
</div>
</template>
<script>
import bs from './mixins/bs'
export default {
name: 'd2-container-card-bs',
mixins: [
bs
]
}
</script>
<template>
<div class="d2-container-ghost-bs">
<div
v-if="$slots.header"
class="d2-container-ghost-bs__header"
ref="header"
>
<slot name="header" />
</div>
<div
class="d2-container-ghost-bs__body"
ref="wrapper"
>
<div>
<slot />
</div>
</div>
<div
v-if="$slots.footer"
class="d2-container-ghost-bs__footer"
ref="footer"
>
<slot name="footer" />
</div>
</div>
</template>
<script>
import bs from './mixins/bs'
export default {
name: 'D2ContainerCardBs',
mixins: [
bs
]
}
</script>
<template>
<div class="d2-container-ghost">
<div v-if="$slots.header" class="d2-container-ghost__header" ref="header">
<slot name="header"/>
</div>
<div class="d2-container-ghost__body" ref="body">
<slot/>
</div>
<div v-if="$slots.footer" class="d2-container-ghost__footer" ref="footer">
<slot name="footer"/>
</div>
</div>
</template>
<script>
import scroll from './mixins/normal'
export default {
name: 'd2-container-ghost',
mixins: [
scroll
],
mounted() {
// 增加滚动事件监听
this.addScrollListener()
},
beforeDestroy() {
// 移除滚动事件监听
this.removeScrollListener()
}
}
</script>
<template>
<div class="d2-container-ghost">
<div
v-if="$slots.header"
class="d2-container-ghost__header"
ref="header"
>
<slot name="header" />
</div>
<div
class="d2-container-ghost__body"
ref="body"
>
<slot />
</div>
<div
v-if="$slots.footer"
class="d2-container-ghost__footer"
ref="footer"
>
<slot name="footer" />
</div>
</div>
</template>
<script>
import scroll from './mixins/normal'
export default {
name: 'D2ContainerGhost',
mixins: [
scroll
],
mounted() {
// 增加滚动事件监听
this.addScrollListener()
},
beforeDestroy() {
// 移除滚动事件监听
this.removeScrollListener()
}
}
</script>
<template>
<div v-if="show"
class="d2-header-switch"
:class="{ 'd2-header-switch--active': isActive }"
@click="handleClick">
<div
v-if="show"
class="d2-header-switch"
:class="{ 'd2-header-switch--active': isActive }"
@click="handleClick"
>
<d2-el-icon :name="name" />
<li :class="$store.state.d2admin.tsearch.active?'fa fa-compress':'fa fa-expand'"></li>
<li :class="$store.state.d2admin.tsearch.active?'fa fa-compress':'fa fa-expand'" />
</div>
</template>
......
<template>
<div
v-if="show"
class="d2-source"
:class="{ 'd2-source--active': isActive }"
@click="handleClick">
<d2-icon name="code"/> 本页源码
</div>
</template>
<script>
export default {
data() {
return {
isActive: false,
path: ''
}
},
computed: {
show() {
return process.env.VUE_APP_BUILD_MODE === 'TRAVIS' || process.env.NODE_ENV === 'development'
}
},
watch: {
$route: {
handler(to) {
this.path = _.get(_.last(to.matched), 'components.default.__source')
},
immediate: true
}
},
mounted() {
// 一秒后显示按钮
setTimeout(() => {
this.isActive = true
}, 500)
},
methods: {
// 点击按钮的时候跳转到源代码
handleClick() {
this.$open(`${process.env.VUE_APP_REPO}/blob/master/${this.path}`)
}
}
}
</script>
<style lang="scss" scoped>
.d2-source {
$borderRadius: 4px;
$paddingLR: 15px;
$paddingTB: 7px;
$fontSize: 12px;
$rightOuter: $paddingLR / 2;
opacity: 0;
position: fixed;
z-index: 9999;
right: - $borderRadius - $rightOuter;
bottom: 20px;
font-size: $fontSize;
line-height: $fontSize;
font-weight: bold;
border-radius: $borderRadius;
padding: $paddingTB $paddingLR;
padding-right: $borderRadius + $paddingLR;
background-color: rgba(#000, .7);
border: 1px solid #000;
color: #FFF;
transition: all .3s;
@extend %unable-select;
&.d2-source--active {
opacity: 1;
}
&:hover {
right: - $borderRadius;
background-color: rgba(#000, .9);
}
}
</style>
<template>
<div
v-if="show"
class="d2-source"
:class="{ 'd2-source--active': isActive }"
@click="handleClick"
>
<d2-icon name="code" /> 本页源码
</div>
</template>
<script>
export default {
data() {
return {
isActive: false,
path: ''
}
},
computed: {
show() {
return process.env.VUE_APP_BUILD_MODE === 'TRAVIS' || process.env.NODE_ENV === 'development'
}
},
watch: {
$route: {
handler(to) {
this.path = _.get(_.last(to.matched), 'components.default.__source')
},
immediate: true
}
},
mounted() {
// 一秒后显示按钮
setTimeout(() => {
this.isActive = true
}, 500)
},
methods: {
// 点击按钮的时候跳转到源代码
handleClick() {
this.$open(`${process.env.VUE_APP_REPO}/blob/master/${this.path}`)
}
}
}
</script>
<style lang="scss" scoped>
.d2-source {
$borderRadius: 4px;
$paddingLR: 15px;
$paddingTB: 7px;
$fontSize: 12px;
$rightOuter: $paddingLR / 2;
opacity: 0;
position: fixed;
z-index: 9999;
right: - $borderRadius - $rightOuter;
bottom: 20px;
font-size: $fontSize;
line-height: $fontSize;
font-weight: bold;
border-radius: $borderRadius;
padding: $paddingTB $paddingLR;
padding-right: $borderRadius + $paddingLR;
background-color: rgba(#000, .7);
border: 1px solid #000;
color: #FFF;
transition: all .3s;
@extend %unable-select;
&.d2-source--active {
opacity: 1;
}
&:hover {
right: - $borderRadius;
background-color: rgba(#000, .9);
}
}
</style>
// 组件
import d2ContainerFull from './components/d2-container-full.vue'
import d2ContainerFullBs from './components/d2-container-full-bs.vue'
import d2ContainerGhost from './components/d2-container-ghost.vue'
import d2ContainerGhostBs from './components/d2-container-ghost-bs.vue'
import d2ContainerCard from './components/d2-container-card.vue'
import d2ContainerCardBs from './components/d2-container-card-bs.vue'
// import d2Source from './components/d2-source.vue'
export default {
name: 'd2-container',
props: {
// 容器样式
type: {
type: String,
required: false,
default: 'full'
},
// 滚动优化
betterScroll: {
type: Boolean,
required: false,
default: false
}
},
computed: {
// 始终返回渲染组件
component() {
if (this.type === 'card' && !this.betterScroll) return d2ContainerCard
if (this.type === 'card' && this.betterScroll) return d2ContainerCardBs
if (this.type === 'ghost' && !this.betterScroll) return d2ContainerGhost
if (this.type === 'ghost' && this.betterScroll) return d2ContainerGhostBs
if (this.type === 'full' && !this.betterScroll) return d2ContainerFull
if (this.type === 'full' && this.betterScroll) return d2ContainerFullBs
else {
return 'div'
}
}
},
render(h) {
const slots = [ this.$slots.default ]
if (this.$slots.header) slots.push(h('template', { slot: 'header' }, [ this.$slots.header ]))
if (this.$slots.footer) slots.push(h('template', { slot: 'footer' }, [ this.$slots.footer ]))
return h('div', {
ref: 'container',
class: 'container-component'
}, [
h(this.component, {
ref: 'component',
props: this.$attrs,
on: {
scroll: e => this.$emit('scroll', e)
}
}, slots)
// h(d2Source)
])
},
methods: {
// 返回顶部
scrollToTop() {
this.$refs.component.scrollToTop()
// 如果开启了 better scroll 还需要手动触发一遍 scroll 事件
const bs = this.$refs.component.BS
if (bs) this.$refs.component.scroll()
},
// 用法同原生方法 scrollBy
scrollBy(x = 0, y = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
bs.scrollBy(-x, -y, time)
// 手动触发一遍 scroll 事件
this.$refs.component.scroll()
}
} else {
this.$refs.component.$refs.body.scrollBy(x, y)
}
},
// 用法同原生方法 scrollTo
scrollTo(x = 0, y = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
bs.scrollTo(-x, -y, time)
// 手动触发一遍 scroll 事件
this.$refs.component.scroll()
}
} else {
this.$refs.component.$refs.body.scrollTo(x, y)
}
},
// 用法同原生方法 scrollTop
scrollTop(top = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
bs.scrollTo(bs.x, -top, time)
// 手动触发一遍 scroll 事件
this.$refs.component.scroll()
}
} else {
this.$refs.component.$refs.body.scrollTop = top
}
}
}
}
// 组件
import d2ContainerFull from './components/d2-container-full.vue'
import d2ContainerFullBs from './components/d2-container-full-bs.vue'
import d2ContainerGhost from './components/d2-container-ghost.vue'
import d2ContainerGhostBs from './components/d2-container-ghost-bs.vue'
import d2ContainerCard from './components/d2-container-card.vue'
import d2ContainerCardBs from './components/d2-container-card-bs.vue'
// import d2Source from './components/d2-source.vue'
export default {
name: 'd2-container',
props: {
// 容器样式
type: {
type: String,
required: false,
default: 'full'
},
// 滚动优化
betterScroll: {
type: Boolean,
required: false,
default: false
}
},
computed: {
// 始终返回渲染组件
component() {
if (this.type === 'card' && !this.betterScroll) return d2ContainerCard
if (this.type === 'card' && this.betterScroll) return d2ContainerCardBs
if (this.type === 'ghost' && !this.betterScroll) return d2ContainerGhost
if (this.type === 'ghost' && this.betterScroll) return d2ContainerGhostBs
if (this.type === 'full' && !this.betterScroll) return d2ContainerFull
if (this.type === 'full' && this.betterScroll) return d2ContainerFullBs
else {
return 'div'
}
}
},
render(h) {
const slots = [this.$slots.default]
if (this.$slots.header) slots.push(h('template', { slot: 'header' }, [this.$slots.header]))
if (this.$slots.footer) slots.push(h('template', { slot: 'footer' }, [this.$slots.footer]))
return h('div', {
ref: 'container',
class: 'container-component'
}, [
h(this.component, {
ref: 'component',
props: this.$attrs,
on: {
scroll: e => this.$emit('scroll', e)
}
}, slots)
// h(d2Source)
])
},
methods: {
// 返回顶部
scrollToTop() {
this.$refs.component.scrollToTop()
// 如果开启了 better scroll 还需要手动触发一遍 scroll 事件
const bs = this.$refs.component.BS
if (bs) this.$refs.component.scroll()
},
// 用法同原生方法 scrollBy
scrollBy(x = 0, y = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
bs.scrollBy(-x, -y, time)
// 手动触发一遍 scroll 事件
this.$refs.component.scroll()
}
} else {
this.$refs.component.$refs.body.scrollBy(x, y)
}
},
// 用法同原生方法 scrollTo
scrollTo(x = 0, y = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
bs.scrollTo(-x, -y, time)
// 手动触发一遍 scroll 事件
this.$refs.component.scroll()
}
} else {
this.$refs.component.$refs.body.scrollTo(x, y)
}
},
// 用法同原生方法 scrollTop
scrollTop(top = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
bs.scrollTo(bs.x, -top, time)
// 手动触发一遍 scroll 事件
this.$refs.component.scroll()
}
} else {
this.$refs.component.$refs.body.scrollTop = top
}
}
}
}
<!-- 弹窗 -->
<template>
<div>
<el-dialog
:title="title"
:visible.sync="isVisible"
:show-close="showClose"
:before-close="handleClose"
:close-on-click-modal="false"
:width="width"
>
<span slot="title">
{{title}}
<span class="dialog-sub-title">
<slot name="sub-title"></slot>
</span>
</span>
<slot></slot>
<div slot="footer">
<slot name="btn-start"></slot>
<el-button
type="primary"
@click="handleConfirm"
:loading="$store.state.d2admin.loading.value"
>{{btnOkLabel}}</el-button>
<el-button
v-if="!noCancel"
@click="handleClose"
>取消</el-button>
<slot name="btn-middle"></slot>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'd2-dialog',
data() {
return {
}
},
props: {
title: {
type: String,
default: ''
},
isVisible: {
type: Boolean,
default: false
},
showClose: {
type: Boolean,
default: true
},
btnOkLabel: {
type: String,
default: '确定'
},
noCancel: {
type: Boolean,
default: false
},
width: {
type: String,
default: '580px'
}
},
methods: {
handleClose() {
this.$emit('closeDialog')
},
handleConfirm() {
this.$emit('confirmDialog')
}
}
}
</script>
<style scoped>
.dialog-sub-title {
font-size: 12px;
color: #666666;
}
</style>
<!-- 弹窗 -->
<template>
<div>
<el-dialog
:title="title"
:visible.sync="isVisible"
:show-close="showClose"
:before-close="handleClose"
:close-on-click-modal="false"
:width="width"
>
<span slot="title">
{{ title }}
<span class="dialog-sub-title">
<slot name="sub-title" />
</span>
</span>
<slot />
<div slot="footer">
<slot name="btn-start" />
<el-button
type="primary"
@click="handleConfirm"
:loading="$store.state.d2admin.loading.value"
>
{{ btnOkLabel }}
</el-button>
<el-button
v-if="!noCancel"
@click="handleClose"
>
取消
</el-button>
<slot name="btn-middle" />
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'D2Dialog',
data() {
return {
}
},
props: {
title: {
type: String,
default: ''
},
isVisible: {
type: Boolean,
default: false
},
showClose: {
type: Boolean,
default: true
},
btnOkLabel: {
type: String,
default: '确定'
},
noCancel: {
type: Boolean,
default: false
},
width: {
type: String,
default: '580px'
}
},
methods: {
handleClose() {
this.$emit('closeDialog')
},
handleConfirm() {
this.$emit('confirmDialog')
}
}
}
</script>
<style scoped>
.dialog-sub-title {
font-size: 12px;
color: #666666;
}
</style>
<template>
<i :class="`el-icon-${name}`" aria-hidden="true"></i>
</template>
<script>
export default {
name: 'd2-el-icon',
props: {
name: {
type: String,
required: false,
default: ''
}
}
}
</script>
<template>
<i
:class="`el-icon-${name}`"
aria-hidden="true"
/>
</template>
<script>
export default {
name: 'D2ElIcon',
props: {
name: {
type: String,
required: false,
default: ''
}
}
}
</script>
<!-- 编辑商品弹窗 -->
<template>
<d2-dialog title="添加绑定升级商品"
:isVisible.sync="relateProVisible"
btnOkLabel="关联"
width="950px"
@confirmDialog="handleRelateProConfirm"
@closeDialog="handleRelateProClose"
class="relatePro">
<d2-dialog
title="添加绑定升级商品"
:is-visible.sync="relateProVisible"
btn-ok-label="关联"
width="950px"
@confirmDialog="handleRelateProConfirm"
@closeDialog="handleRelateProClose"
class="relatePro"
>
<div class="relateProDialog flex">
<img v-show="proInfo.thumbUrl"
:src="proInfo.thumbUrl" />
<img v-show="!proInfo.thumbUrl"
src="./image/no-choice.png" />
<el-form :model="proInfo"
:rules="rules"
label-width="110px"
ref="proRuleForm1"
style="width: calc(100% - 180px);">
<img
v-show="proInfo.thumbUrl"
:src="proInfo.thumbUrl"
>
<img
v-show="!proInfo.thumbUrl"
src="./image/no-choice.png"
>
<el-form
:model="proInfo"
:rules="rules"
label-width="110px"
ref="proRuleForm1"
style="width: calc(100% - 180px);"
>
<div class="w-50">
<el-form-item label="选择产品"
prop="goodsCode">
<el-select style="width: 98%;"
v-model="proInfo.goodsCode"
placeholder="请选择一款作为升级商品"
value-key="goodsCode"
filterable
@change="handleChangeGood">
<el-option v-for="item in proList"
:key="item.goodsCode"
:label="item.goodsName"
:value="item.goodsCode"
:disabled="item.disabled"></el-option>
<el-form-item
label="选择产品"
prop="goodsCode"
>
<el-select
style="width: 98%;"
v-model="proInfo.goodsCode"
placeholder="请选择一款作为升级商品"
value-key="goodsCode"
filterable
@change="handleChangeGood"
>
<el-option
v-for="item in proList"
:key="item.goodsCode"
:label="item.goodsName"
:value="item.goodsCode"
:disabled="item.disabled"
/>
</el-select>
</el-form-item>
</div>
<div class="w-50">
<el-form-item label="分类">
<el-input disabled
placeholder="分类"
:value="proInfo.goodsTypeName"
class="dis-in-block"></el-input>
<el-input
disabled
placeholder="分类"
:value="proInfo.goodsTypeName"
class="dis-in-block"
/>
</el-form-item>
</div>
<div class="w-50">
</div>
<div class="w-50" />
<div class="w-50">
<el-form-item label="编号">
<el-input disabled
placeholder="编号"
:value="proInfo.sapCode"
class="dis-in-block"></el-input>
<el-input
disabled
placeholder="编号"
:value="proInfo.sapCode"
class="dis-in-block"
/>
</el-form-item>
</div>
<div class="w-50">
<el-form-item label="产品成本"
prop="shopPrice">
<el-input v-model="proInfo.shopPrice"
placeholder="请输入建议产品成本"
class="dis-in-block"
@input="handleShopPrice"
@blur="handleShopPriceBlur">
<i slot="suffix"
class="suffix">元</i>
<el-form-item
label="产品成本"
prop="shopPrice"
>
<el-input
v-model="proInfo.shopPrice"
placeholder="请输入建议产品成本"
class="dis-in-block"
@input="handleShopPrice"
@blur="handleShopPriceBlur"
>
<i
slot="suffix"
class="suffix"
>元</i>
</el-input>
</el-form-item>
</div>
<div class="w-50">
<el-form-item label="建议升级价格"
prop="upgradePrice">
<el-input v-model="proInfo.upgradePrice"
placeholder="请输入建议升级价格"
class="dis-in-block"
@input="handleUpgradePrice">
<i slot="suffix"
class="suffix">元</i>
<el-form-item
label="建议升级价格"
prop="upgradePrice"
>
<el-input
v-model="proInfo.upgradePrice"
placeholder="请输入建议升级价格"
class="dis-in-block"
@input="handleUpgradePrice"
>
<i
slot="suffix"
class="suffix"
>元</i>
</el-input>
</el-form-item>
</div>
<div class="w-50">
<el-form-item label="商品最低价"
prop="shopMinPrice">
<el-input v-model="proInfo.shopMinPrice"
placeholder="请输入商品最低价"
class="dis-in-block"
@input="handleShopMinPrice">
<i slot="suffix"
class="suffix">元</i>
<el-form-item
label="商品最低价"
prop="shopMinPrice"
>
<el-input
v-model="proInfo.shopMinPrice"
placeholder="请输入商品最低价"
class="dis-in-block"
@input="handleShopMinPrice"
>
<i
slot="suffix"
class="suffix"
>元</i>
</el-input>
</el-form-item>
</div>
<div class="w-50"
v-show="warrantyProList.includes(proInfo.goodsType)">
<el-form-item label="质保年限"
prop="warrantyPeriod">
<el-select style="width: 98%;"
:class="{ 'select-suffix': !!proInfo.warrantyPeriod }"
v-model="proInfo.warrantyPeriod">
<el-option v-for="item in warrantyPeriodList"
:key="item.confId"
:label="item.confLabel"
:value="item.confId"></el-option>
<div
class="w-50"
v-show="warrantyProList.includes(proInfo.goodsType)"
>
<el-form-item
label="质保年限"
prop="warrantyPeriod"
>
<el-select
style="width: 98%;"
:class="{ 'select-suffix': !!proInfo.warrantyPeriod }"
v-model="proInfo.warrantyPeriod"
>
<el-option
v-for="item in warrantyPeriodList"
:key="item.confId"
:label="item.confLabel"
:value="item.confId"
/>
</el-select>
</el-form-item>
</div>
......@@ -112,7 +155,7 @@
import _ from 'lodash'
import { limitPrice } from '@/common/constants'
export default {
name: 'relateProDialog',
name: 'RelateProDialog',
data() {
return {
goodVal: {},
......
<template>
<svg aria-hidden="true">
<use :xlink:href="icon"></use>
</svg>
</template>
<script>
export default {
name: 'd2-icon-svg',
props: {
name: {
type: String,
required: true
}
},
computed: {
icon() {
return `#d2-${this.name}`
}
}
}
</script>
<template>
<svg aria-hidden="true">
<use :xlink:href="icon" />
</svg>
</template>
<script>
export default {
name: 'D2IconSvg',
props: {
name: {
type: String,
required: true
}
},
computed: {
icon() {
return `#d2-${this.name}`
}
}
}
</script>
<template>
<i class="fa" :class="`fa-${name}`" aria-hidden="true"></i>
</template>
<script>
import './font-awesome-4.7.0/css/font-awesome.min.css'
export default {
name: 'd2-icon',
props: {
name: {
type: String,
required: false,
default: 'font-awesome'
}
}
}
</script>
<template>
<i
class="fa"
:class="`fa-${name}`"
aria-hidden="true"
/>
</template>
<script>
import './font-awesome-4.7.0/css/font-awesome.min.css'
export default {
name: 'D2Icon',
props: {
name: {
type: String,
required: false,
default: 'font-awesome'
}
}
}
</script>
<template>
<el-row class="table-header">
<el-col :span="leftSpan">
<span v-text="title"></span>
<slot name="left"></slot>
<span v-text="title" />
<slot name="left" />
</el-col>
<el-col :span="24 - leftSpan">
<slot></slot>
<slot />
</el-col>
</el-row>
</template>
<script>
export default {
name: 'd2-teble-header',
name: 'D2TebleHeader',
props: {
title: {
type: String,
......
<!-- 表格头部搜索 -->
<template>
<el-popover
placement="bottom"
title=""
width="150"
trigger="click"
v-model="isPopoverVisible"
>
<block>
<p class="flex">
<el-checkbox
:indeterminate="isIndeterminate"
v-model="checkAll"
@change="handleCheckAllChange"
>全选</el-checkbox>
<el-button
@click="handleConfirm"
type="text"
>确定</el-button>
</p>
<el-checkbox-group
v-model="checkedList"
@change="handleCheckedChange"
>
<el-checkbox
v-for="item in baseData[optionConfig.searchItemName]"
:label="item[optionConfig.optionId]"
:key="item[optionConfig.optionId]"
@change="handleCheckedChange"
>{{item[optionConfig.optionLabel]}}</el-checkbox>
</el-checkbox-group>
</block>
<img
slot="reference"
class="head-search"
src="./image/search.png"
@click="handleOpen"
/>
</el-popover>
</template>
<script>
import _ from 'lodash'
export default {
name: 'TableHeadSearch',
data() {
return {
isPopoverVisible: false,
checkAll: false,
checkedList: [],
isIndeterminate: false
}
},
props: {
// 原来的model值
searchForm: {
type: Array,
default: () => { }
},
optionConfig: {
type: Object,
default: () => { }
},
// 多选列表
// optionList: {
// type: Array,
// default: () => []
// },
// 多选列表Obj
baseData: {
type: Object,
default: () => { }
}
},
methods: {
handleOpen() {
this.checkedList = _.cloneDeep(this.searchForm[this.optionConfig.searchItemName])
this.handleCheckedChange(this.checkedList)
this.$nextTick()
},
handleCheckedChange(value) {
const checkedCount = value.length
this.checkAll = checkedCount === this.baseData[this.optionConfig.searchItemName].length
this.isIndeterminate = checkedCount > 0 && checkedCount < this.baseData[this.optionConfig.searchItemName].length
},
handleCheckAllChange(val) {
this.checkedList = val ? this.baseData[this.optionConfig.searchItemName].map(item => item[this.optionConfig.optionId]) : []
this.isIndeterminate = false
},
handleConfirm() {
this.isPopoverVisible = false
this.$emit('handleTableHeadChange', { searchItemName: this.optionConfig.searchItemName, checkedList: this.checkedList })
}
}
}
</script>
<style scoped>
.flex {
justify-content: space-between;
}
.head-search {
width: 12px;
height: 12px;
}
</style>
<!-- 表格头部搜索 -->
<template>
<el-popover
placement="bottom"
title=""
width="150"
trigger="click"
v-model="isPopoverVisible"
>
<block>
<p class="flex">
<el-checkbox
:indeterminate="isIndeterminate"
v-model="checkAll"
@change="handleCheckAllChange"
>
全选
</el-checkbox>
<el-button
@click="handleConfirm"
type="text"
>
确定
</el-button>
</p>
<el-checkbox-group
v-model="checkedList"
@change="handleCheckedChange"
>
<el-checkbox
v-for="item in baseData[optionConfig.searchItemName]"
:label="item[optionConfig.optionId]"
:key="item[optionConfig.optionId]"
@change="handleCheckedChange"
>
{{ item[optionConfig.optionLabel] }}
</el-checkbox>
</el-checkbox-group>
</block>
<img
slot="reference"
class="head-search"
src="./image/search.png"
@click="handleOpen"
>
</el-popover>
</template>
<script>
import _ from 'lodash'
export default {
name: 'TableHeadSearch',
data() {
return {
isPopoverVisible: false,
checkAll: false,
checkedList: [],
isIndeterminate: false
}
},
props: {
// 原来的model值
searchForm: {
type: Array,
default: () => { }
},
optionConfig: {
type: Object,
default: () => { }
},
// 多选列表
// optionList: {
// type: Array,
// default: () => []
// },
// 多选列表Obj
baseData: {
type: Object,
default: () => { }
}
},
methods: {
handleOpen() {
this.checkedList = _.cloneDeep(this.searchForm[this.optionConfig.searchItemName])
this.handleCheckedChange(this.checkedList)
this.$nextTick()
},
handleCheckedChange(value) {
const checkedCount = value.length
this.checkAll = checkedCount === this.baseData[this.optionConfig.searchItemName].length
this.isIndeterminate = checkedCount > 0 && checkedCount < this.baseData[this.optionConfig.searchItemName].length
},
handleCheckAllChange(val) {
this.checkedList = val ? this.baseData[this.optionConfig.searchItemName].map(item => item[this.optionConfig.optionId]) : []
this.isIndeterminate = false
},
handleConfirm() {
this.isPopoverVisible = false
this.$emit('handleTableHeadChange', { searchItemName: this.optionConfig.searchItemName, checkedList: this.checkedList })
}
}
}
</script>
<style scoped>
.flex {
justify-content: space-between;
}
.head-search {
width: 12px;
height: 12px;
}
</style>
<!-- 表格+分页 -->
<template>
<div class="d2-table">
<el-table :ref="tableParams.mutiSelectName + 'MutiTable' || 'mutiTable'"
:data="getListApi ? data : tableData"
:row-key="tableParams.mutiSelectUniqueKey || ''"
v-loading="loading"
border
:highlight-current-row="true"
@sort-change="sortChange"
@selection-change="handleSelect"
:tree-props="{children: 'upgradeGoodsList'}">
<el-table-column v-if="tableParams.mutiSelectUniqueKey && tableParams.mutiSelectName"
type="selection"
width="55"
:reserve-selection="true">
</el-table-column>
<el-table-column v-if="hasNum"
align="center"
width="60px"
label="序号"
type='index'
:index="index=>index+(pagination.currentPage - 1) * pagination.pageSize + 1">
</el-table-column>
<el-table-column v-for="(item, index) in tableParams.tableColumns"
:key="index"
:label="item.label"
:prop="item.prop"
:width="item.width"
:min-width="item.minWidth"
:align="item.align||'center'"
:sortable="item.sortable">
<el-table
:ref="tableParams.mutiSelectName + 'MutiTable' || 'mutiTable'"
:data="getListApi ? data : tableData"
:row-key="tableParams.mutiSelectUniqueKey || ''"
v-loading="loading"
border
:highlight-current-row="true"
@sort-change="sortChange"
@selection-change="handleSelect"
:tree-props="{children: 'upgradeGoodsList'}"
>
<el-table-column
v-if="tableParams.mutiSelectUniqueKey && tableParams.mutiSelectName"
type="selection"
width="55"
:reserve-selection="true"
/>
<el-table-column
v-if="hasNum"
align="center"
width="60px"
label="序号"
type="index"
:index="index=>index+(pagination.currentPage - 1) * pagination.pageSize + 1"
/>
<el-table-column
v-for="(item, index) in tableParams.tableColumns"
:key="index"
:label="item.label"
:prop="item.prop"
:width="item.width"
:min-width="item.minWidth"
:align="item.align||'center'"
:sortable="item.sortable"
>
<template slot="header">
<span>{{item.label}}</span>
<table-head-search v-if="item.optionConfig"
:searchForm="headSearchForm"
:optionConfig="item.optionConfig"
:baseData="baseData"
@handleTableHeadChange="handleTableHeadChange"></table-head-search>
<span>{{ item.label }}</span>
<table-head-search
v-if="item.optionConfig"
:search-form="headSearchForm"
:option-config="item.optionConfig"
:base-data="baseData"
@handleTableHeadChange="handleTableHeadChange"
/>
</template>
<template slot-scope="scope">
<slot v-if="item.addHtml"
:name="item.addHtml"
:scope="scope.row"
:prop="item.prop"
:width="item.width"></slot>
<slot
v-if="item.addHtml"
:name="item.addHtml"
:scope="scope.row"
:prop="item.prop"
:width="item.width"
/>
<template v-else-if="item.tagLabel">
<el-tag v-if="!item.tagName"
:type="tableParams.tag.type[scope.row[item.prop]]"
v-text="tableParams.tag.label[scope.row[item.prop]]">
</el-tag>
<el-tag v-else
:type="tableParams[item.tagName].type[scope.row[item.prop]]"
v-text="tableParams[item.tagName].label[scope.row[item.prop]]"></el-tag>
<el-tag
v-if="!item.tagName"
:type="tableParams.tag.type[scope.row[item.prop]]"
v-text="tableParams.tag.label[scope.row[item.prop]]"
/>
<el-tag
v-else
:type="tableParams[item.tagName].type[scope.row[item.prop]]"
v-text="tableParams[item.tagName].label[scope.row[item.prop]]"
/>
</template>
<template v-else-if="item.formatter">
<span v-if="item.html"
v-html="item.formatter(scope.row)"></span>
<span
v-if="item.html"
v-html="item.formatter(scope.row)"
/>
<template v-if="!item.html">
<span :class="item.className?item.className(scope.row):''"></span>
<span v-text="item.formatter(scope.row)"></span>
<span :class="item.className?item.className(scope.row):''" />
<span v-text="item.formatter(scope.row)" />
</template>
</template>
<template v-else-if="getListApi">
<span v-if="item.prefix">{{item.prefix}}</span>
<span v-if="item.prefix">{{ item.prefix }}</span>
<span
v-if="item.parentProp">{{scope.row[item.parentProp] ? scope.row[item.parentProp][item.prop] : ''}}</span>
<span v-else>{{scope.row[item.prop]}}</span>
v-if="item.parentProp"
>{{ scope.row[item.parentProp] ? scope.row[item.parentProp][item.prop] : '' }}</span>
<span v-else>{{ scope.row[item.prop] }}</span>
</template>
<template v-else>
<span v-text="tableData[scope.$index][item.prop]"></span>
<span v-text="tableData[scope.$index][item.prop]" />
</template>
<template v-if="item.addSymbol">
<span v-text="item.addSymbol"></span>
<span v-text="item.addSymbol" />
</template>
</template>
</el-table-column>
<el-table-column v-if="tableParams.tableOption"
label="操作"
fixed="right"
:align="tableParams.tableOption.align||'center'"
:width="tableParams.tableOption.width||'auto'">
<el-table-column
v-if="tableParams.tableOption"
label="操作"
fixed="right"
:align="tableParams.tableOption.align||'center'"
:width="tableParams.tableOption.width||'auto'"
>
<template slot-scope="scope">
<slot name="auth-button"
:scope="scope.row"></slot>
<slot name="auth-button-other"
:scope="scope.row"></slot>
<slot
name="auth-button"
:scope="scope.row"
/>
<slot
name="auth-button-other"
:scope="scope.row"
/>
</template>
</el-table-column>
</el-table>
<el-pagination v-if="hasPage"
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.currentPage"
:page-sizes="[10,20,30,40]"
:page-size="page.pageSize"
:total="getListApi ? total : tableTotal"
:layout="layout">
</el-pagination>
<el-pagination
v-if="hasPage"
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.currentPage"
:page-sizes="[10,20,30,40]"
:page-size="page.pageSize"
:total="getListApi ? total : tableTotal"
:layout="layout"
/>
</div>
</template>
<script>
import TableHeadSearch from './TableHeadSearch'
export default {
name: 'd2-table',
name: 'D2Table',
data() {
return {
loading: false,
......
......@@ -4,16 +4,16 @@ import d2Container from './d2-container'
import authButton from './d2-auth/d2-auth-btn.js'
// 注意 有些组件使用异步加载会有影响
Vue.component('d2-container', d2Container)
Vue.component('d2-icon', () => import('./d2-icon'))
Vue.component('d2-el-icon', () => import('./d2-el-icon'))
Vue.component('d2-icon-svg', () => import('./d2-icon-svg/index.vue'))
Vue.component('d2-table-header', () => import('./d2-table-header/index.vue'))
Vue.component('d2-table', () => import('./d2-table/index.vue'))
Vue.component('d2-dialog', () => import('./d2-dialog/index.vue'))
Vue.component('d2-form', () => import('./d2-form/index.vue'))
Vue.component('d2-search', () => import('./d2-search/index.vue'))
Vue.component('relateStoreDialog', () =>
Vue.component('D2Container', d2Container)
Vue.component('D2Icon', () => import('./d2-icon'))
Vue.component('D2ElIcon', () => import('./d2-el-icon'))
Vue.component('D2IconSvg', () => import('./d2-icon-svg/index.vue'))
Vue.component('D2TableHeader', () => import('./d2-table-header/index.vue'))
Vue.component('D2Table', () => import('./d2-table/index.vue'))
Vue.component('D2Dialog', () => import('./d2-dialog/index.vue'))
Vue.component('D2Form', () => import('./d2-form/index.vue'))
Vue.component('D2Search', () => import('./d2-search/index.vue'))
Vue.component('RelateStoreDialog', () =>
import('./d2-form/relateStoreDialog.vue')
)
// Vue.component([authButton.name], authButton)
......
<template>
<div
class="d2-contentmenu-list"
@click="rowClick">
<div
v-for="item in menulist"
:key="item.value"
:data-value="item.value"
class="d2-contentmenu-item"
flex="cross:center main:center">
<d2-el-icon
v-if="item.icon"
:name="item.icon"/>
<div
class="d2-contentmenu-item-title"
flex-box="1"
v-text="item.title">
</div>
</div>
</div>
</template>
<script>
export default {
name: 'd2-contextmenu-list',
props: {
menulist: {
type: Array,
default: () => []
}
},
methods: {
rowClick(event) {
let target = event.target
while (!target.dataset.value) {
target = target.parentNode
}
this.$emit('rowClick', target.dataset.value)
}
}
}
</script>
<style lang="scss">
.d2-contentmenu-list {
.d2-contentmenu-item {
padding: 8px 20px 8px 15px;
margin: 0;
font-size: 14px;
color: #606266;
cursor: pointer;
&:hover {
background: #ecf5ff;
color: #66b1ff;
}
.d2-contentmenu-item-title {
margin-left: 10px;
}
}
}
</style>
<template>
<div
class="d2-contentmenu-list"
@click="rowClick"
>
<div
v-for="item in menulist"
:key="item.value"
:data-value="item.value"
class="d2-contentmenu-item"
flex="cross:center main:center"
>
<d2-el-icon
v-if="item.icon"
:name="item.icon"
/>
<div
class="d2-contentmenu-item-title"
flex-box="1"
v-text="item.title"
/>
</div>
</div>
</template>
<script>
export default {
name: 'D2ContextmenuList',
props: {
menulist: {
type: Array,
default: () => []
}
},
methods: {
rowClick(event) {
let target = event.target
while (!target.dataset.value) {
target = target.parentNode
}
this.$emit('rowClick', target.dataset.value)
}
}
}
</script>
<style lang="scss">
.d2-contentmenu-list {
.d2-contentmenu-item {
padding: 8px 20px 8px 15px;
margin: 0;
font-size: 14px;
color: #606266;
cursor: pointer;
&:hover {
background: #ecf5ff;
color: #66b1ff;
}
.d2-contentmenu-item-title {
margin-left: 10px;
}
}
}
</style>
<template>
<div
class="d2-contextmenu"
v-show="flag"
:style="style">
<slot/>
</div>
</template>
<script>
export default {
name: 'd2-contextmenu',
props: {
visible: {
type: Boolean,
default: false
},
x: {
type: Number,
default: 0
},
y: {
type: Number,
default: 0
}
},
computed: {
flag: {
get() {
if (this.visible) {
// 注册全局监听事件 [ 目前只考虑鼠标解除触发 ]
window.addEventListener('mousedown', this.watchContextmenu)
}
return this.visible
},
set(newVal) {
this.$emit('update:visible', newVal)
}
},
style() {
return {
left: this.x + 'px',
top: this.y + 'px',
display: this.visible ? 'block' : 'none '
}
}
},
methods: {
watchContextmenu(event) {
if (!this.$el.contains(event.target) || event.button !== 0) this.flag = false
window.removeEventListener('mousedown', this.watchContextmenu)
}
},
mounted() {
// 将菜单放置到body下
document.querySelector('body').appendChild(this.$el)
}
}
</script>
<style>
.d2-contextmenu {
position: absolute;
padding: 5px 0;
z-index: 2019;
background: #FFF;
border: 1px solid #cfd7e5;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
}
</style>
<template>
<div
class="d2-contextmenu"
v-show="flag"
:style="style"
>
<slot />
</div>
</template>
<script>
export default {
name: 'D2Contextmenu',
props: {
visible: {
type: Boolean,
default: false
},
x: {
type: Number,
default: 0
},
y: {
type: Number,
default: 0
}
},
computed: {
flag: {
get() {
if (this.visible) {
// 注册全局监听事件 [ 目前只考虑鼠标解除触发 ]
window.addEventListener('mousedown', this.watchContextmenu)
}
return this.visible
},
set(newVal) {
this.$emit('update:visible', newVal)
}
},
style() {
return {
left: this.x + 'px',
top: this.y + 'px',
display: this.visible ? 'block' : 'none '
}
}
},
methods: {
watchContextmenu(event) {
if (!this.$el.contains(event.target) || event.button !== 0) this.flag = false
window.removeEventListener('mousedown', this.watchContextmenu)
}
},
mounted() {
// 将菜单放置到body下
document.querySelector('body').appendChild(this.$el)
}
}
</script>
<style>
.d2-contextmenu {
position: absolute;
padding: 5px 0;
z-index: 2019;
background: #FFF;
border: 1px solid #cfd7e5;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
}
</style>
<template>
<!-- <svg t="1492500959545" @click="click" class="hamburger" :class="{'is-active':isActive}" viewBox="0 0 1024 1024"
version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1691" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64">
<path d="M966.8023 568.849776 57.196677 568.849776c-31.397081 0-56.850799-25.452695-56.850799-56.850799l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 543.397081 998.200404 568.849776 966.8023 568.849776z"
p-id="1692"></path>
<path d="M966.8023 881.527125 57.196677 881.527125c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 856.07443 998.200404 881.527125 966.8023 881.527125z"
p-id="1693"></path>
<path d="M966.8023 256.17345 57.196677 256.17345c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.850799 56.850799-56.850799l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.850799l0 0C1023.653099 230.720755 998.200404 256.17345 966.8023 256.17345z"
p-id="1694"></path>
</svg> -->
<div @click="click" class="hamburger" :class="{'is-active':isActive}">
<d2-el-icon name="s-fold" />
</div>
</template>
<script>
export default {
name: 'hamburger',
props: {
isActive: {
type: Boolean,
default: false
},
onClick: {
type: Function,
default: null
}
},
methods: {
click() {
this.onClick && this.onClick()
}
}
}
</script>
<style scoped lang="scss">
.hamburger {
height: 50px;
cursor: pointer;
transition: .38s;
transform-origin: 50% 50%;
i{
line-height: 50px;
font-size: 14px;
}
}
.hamburger.is-active {
transform: rotate(180deg);
}
</style>
<template>
<!-- <svg t="1492500959545" @click="click" class="hamburger" :class="{'is-active':isActive}" viewBox="0 0 1024 1024"
version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1691" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64">
<path d="M966.8023 568.849776 57.196677 568.849776c-31.397081 0-56.850799-25.452695-56.850799-56.850799l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 543.397081 998.200404 568.849776 966.8023 568.849776z"
p-id="1692"></path>
<path d="M966.8023 881.527125 57.196677 881.527125c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 856.07443 998.200404 881.527125 966.8023 881.527125z"
p-id="1693"></path>
<path d="M966.8023 256.17345 57.196677 256.17345c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.850799 56.850799-56.850799l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.850799l0 0C1023.653099 230.720755 998.200404 256.17345 966.8023 256.17345z"
p-id="1694"></path>
</svg> -->
<div
@click="click"
class="hamburger"
:class="{'is-active':isActive}"
>
<d2-el-icon name="s-fold" />
</div>
</template>
<script>
export default {
name: 'Hamburger',
props: {
isActive: {
type: Boolean,
default: false
},
onClick: {
type: Function,
default: null
}
},
methods: {
click() {
this.onClick && this.onClick()
}
}
}
</script>
<style scoped lang="scss">
.hamburger {
height: 50px;
cursor: pointer;
transition: .38s;
transform-origin: 50% 50%;
i{
line-height: 50px;
font-size: 14px;
}
}
.hamburger.is-active {
transform: rotate(180deg);
}
</style>
<template>
<el-color-picker
class="btn-text can-hover"
:value="value"
:predefine="predefine"
size="mini"
@change="set"/>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
name: 'd2-header-color',
data() {
return {
predefine: [
'#FF0000', '#008000', '#0000FF'
]
}
},
computed: {
...mapState('d2admin', {
value: state => state.color.value,
listTheme: state => state.theme.list
})
},
watch: {
value(value) {
this.set(value)
}
},
mounted() {
this.predefine = [...this.predefine, ...this.listTheme.map(theme => theme.color)]
},
methods: {
...mapActions('d2admin/color', [
'set'
])
}
}
</script>
<template>
<el-color-picker
class="btn-text can-hover"
:value="value"
:predefine="predefine"
size="mini"
@change="set"
/>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
name: 'D2HeaderColor',
data() {
return {
predefine: [
'#FF0000', '#008000', '#0000FF'
]
}
},
computed: {
...mapState('d2admin', {
value: state => state.color.value,
listTheme: state => state.theme.list
})
},
watch: {
value(value) {
this.set(value)
}
},
mounted() {
this.predefine = [...this.predefine, ...this.listTheme.map(theme => theme.color)]
},
methods: {
...mapActions('d2admin/color', [
'set'
])
}
}
</script>
<template>
<div class="header-datetime"></div>
<div class="header-datetime" />
</template>
<script>
......@@ -7,7 +7,7 @@ import dayjs from 'dayjs'
const sFormat = 'YYYY年MM月DD日'
const WEEK = ['天', '一', '二', '三', '四', '五', '六']
export default {
name: 'd2-header-datetime',
name: 'D2HeaderDatetime',
data() {
return {
timeInterval: null,
......
<template>
<el-tooltip
effect="dark"
:content="active ? '退出全屏' : '全屏'"
placement="bottom">
<el-button class="d2-mr btn-text can-hover" type="text" @click="toggle">
<d2-el-icon v-if="active" name="aim"/>
<d2-el-icon v-else name="full-screen" style="font-size: 16px"/>
</el-button>
</el-tooltip>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
computed: {
...mapState('d2admin/fullscreen', [
'active'
])
},
methods: {
...mapActions('d2admin/fullscreen', [
'toggle'
])
}
}
</script>
<template>
<el-tooltip
effect="dark"
:content="active ? '退出全屏' : '全屏'"
placement="bottom"
>
<el-button
class="d2-mr btn-text can-hover"
type="text"
@click="toggle"
>
<d2-el-icon
v-if="active"
name="aim"
/>
<d2-el-icon
v-else
name="full-screen"
style="font-size: 16px"
/>
</el-button>
</el-tooltip>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
computed: {
...mapState('d2admin/fullscreen', [
'active'
])
},
methods: {
...mapActions('d2admin/fullscreen', [
'toggle'
])
}
}
</script>
......@@ -2,17 +2,27 @@
<el-dropdown
placement="bottom"
size="small"
@command="onChangeLocale">
<el-button class="d2-mr btn-text can-hover" type="text">
<d2-icon name="language" style="font-size: 16px;"/>
@command="onChangeLocale"
>
<el-button
class="d2-mr btn-text can-hover"
type="text"
>
<d2-icon
name="language"
style="font-size: 16px;"
/>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="(language, index) in $languages"
:key="index"
:command="language.value">
<d2-icon :name="$i18n.locale === language.value ? 'dot-circle-o' : 'circle-o'" class="d2-mr-5"/>
:command="language.value"
>
<d2-icon
:name="$i18n.locale === language.value ? 'dot-circle-o' : 'circle-o'"
class="d2-mr-5"
/>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
......
<template>
<el-tooltip
effect="dark"
:content="tooltipContent"
placement="bottom">
<el-button
class="d2-ml-0 d2-mr btn-text can-hover"
type="text"
@click="handleClick">
<el-badge
v-if="logLength > 0"
:max="99"
:value="logLengthError"
:is-dot="logLengthError === 0">
<d2-icon
:name="logLengthError === 0 ? 'dot-circle-o' : 'bug'"
style="font-size: 20px"/>
</el-badge>
<d2-icon
v-else
name="dot-circle-o"
style="font-size: 20px"/>
</el-button>
</el-tooltip>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
export default {
computed: {
...mapGetters('d2admin', {
logLength: 'log/length',
logLengthError: 'log/lengthError'
}),
tooltipContent() {
return this.logLength === 0
? '没有日志或异常'
: `${this.logLength} 条日志${this.logLengthError > 0
? ` | 包含 ${this.logLengthError} 个异常`
: ''}`
}
},
methods: {
...mapMutations('d2admin/log', [
'clean'
]),
handleClick() {
this.$router.push({
name: 'log'
})
}
}
}
</script>
<template>
<el-tooltip
effect="dark"
:content="tooltipContent"
placement="bottom"
>
<el-button
class="d2-ml-0 d2-mr btn-text can-hover"
type="text"
@click="handleClick"
>
<el-badge
v-if="logLength > 0"
:max="99"
:value="logLengthError"
:is-dot="logLengthError === 0"
>
<d2-icon
:name="logLengthError === 0 ? 'dot-circle-o' : 'bug'"
style="font-size: 20px"
/>
</el-badge>
<d2-icon
v-else
name="dot-circle-o"
style="font-size: 20px"
/>
</el-button>
</el-tooltip>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
export default {
computed: {
...mapGetters('d2admin', {
logLength: 'log/length',
logLengthError: 'log/lengthError'
}),
tooltipContent() {
return this.logLength === 0
? '没有日志或异常'
: `${this.logLength} 条日志${this.logLengthError > 0
? ` | 包含 ${this.logLengthError} 个异常`
: ''}`
}
},
methods: {
...mapMutations('d2admin/log', [
'clean'
]),
handleClick() {
this.$router.push({
name: 'log'
})
}
}
}
</script>
<template>
<el-button class="d2-mr btn-text can-hover" type="text" @click="handleClick">
<d2-el-icon name="search" style="font-size: 18px;"/>
</el-button>
</template>
<script>
export default {
methods: {
handleClick() {
this.$emit('click')
}
}
}
</script>
<template>
<el-button
class="d2-mr btn-text can-hover"
type="text"
@click="handleClick"
>
<d2-el-icon
name="search"
style="font-size: 18px;"
/>
</el-button>
</template>
<script>
export default {
methods: {
handleClick() {
this.$emit('click')
}
}
}
</script>
<template>
<el-dropdown placement="bottom" size="small" @command="handleChange">
<el-button class="d2-mr btn-text can-hover" type="text">
<d2-icon name="font" style="font-size: 16px;"/>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="item in options" :key="item.value" :command="item.value">
<d2-icon :name="iconName(item.value)" class="d2-mr-5"/>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
<script>
import { mapState, mapMutations, mapActions } from 'vuex'
export default {
name: 'd2-header-size',
data() {
return {
options: [
{ label: '大', value: 'default' },
{ label: '中', value: 'medium' },
{ label: '小', value: 'small' },
{ label: '最小', value: 'mini' }
]
}
},
computed: {
...mapState('d2admin/size', [
'value'
])
},
methods: {
...mapMutations({
pageKeepAliveClean: 'd2admin/page/keepAliveClean'
}),
...mapActions({
sizeSet: 'd2admin/size/set'
}),
handleChange(value) {
this.sizeSet(value)
// this.$notify({
// title: '提示',
// dangerouslyUseHTMLString: true,
// message: '已更新页面内 <b>组件</b> 的 <b>默认尺寸</b><br/>例如按钮大小,<b>非字号</b>',
// type: 'success'
// })
},
iconName(name) {
return name === this.value ? 'dot-circle-o' : 'circle-o'
}
}
}
</script>
<template>
<el-dropdown
placement="bottom"
size="small"
@command="handleChange"
>
<el-button
class="d2-mr btn-text can-hover"
type="text"
>
<d2-icon
name="font"
style="font-size: 16px;"
/>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="item in options"
:key="item.value"
:command="item.value"
>
<d2-icon
:name="iconName(item.value)"
class="d2-mr-5"
/>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
<script>
import { mapState, mapMutations, mapActions } from 'vuex'
export default {
name: 'D2HeaderSize',
data() {
return {
options: [
{ label: '大', value: 'default' },
{ label: '中', value: 'medium' },
{ label: '小', value: 'small' },
{ label: '最小', value: 'mini' }
]
}
},
computed: {
...mapState('d2admin/size', [
'value'
])
},
methods: {
...mapMutations({
pageKeepAliveClean: 'd2admin/page/keepAliveClean'
}),
...mapActions({
sizeSet: 'd2admin/size/set'
}),
handleChange(value) {
this.sizeSet(value)
// this.$notify({
// title: '提示',
// dangerouslyUseHTMLString: true,
// message: '已更新页面内 <b>组件</b> 的 <b>默认尺寸</b><br/>例如按钮大小,<b>非字号</b>',
// type: 'success'
// })
},
iconName(name) {
return name === this.value ? 'dot-circle-o' : 'circle-o'
}
}
}
</script>
<template>
<el-table
:data="list"
v-bind="table">
<el-table-column
prop="title"
<template>
<el-table
:data="list"
v-bind="table"
>
<el-table-column
prop="title"
align="center"
width="160"
/>
<el-table-column
label="预览"
width="120"
>
<div
slot-scope="scope"
class="theme-preview"
:style="{
backgroundImage: `url(${$baseUrl}${scope.row.preview})`
}"
/>
</el-table-column>
<el-table-column
prop="address"
align="center"
width="160"/>
<el-table-column
label="预览"
width="120">
<div
slot-scope="scope"
class="theme-preview"
:style="{
backgroundImage: `url(${$baseUrl}${scope.row.preview})`
}">
</div>
</el-table-column>
<el-table-column
prop="address"
align="center">
<template slot-scope="scope">
<el-button
v-if="activeName === scope.row.name"
type="primary"
icon="el-icon-check"
class="btn-active-success"
round>
已激活
</el-button>
<el-button
v-else
>
<template slot-scope="scope">
<el-button
v-if="activeName === scope.row.name"
type="primary"
icon="el-icon-check"
class="btn-active-success"
round
@click="handleSelectTheme(scope.row)">
使用
</el-button>
</template>
</el-table-column>
</el-table>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
name: 'd2-theme-list',
data() {
return {
table: {
showHeader: false,
border: true
}
}
},
computed: {
...mapState('d2admin/theme', [
'list',
'activeName'
])
},
methods: {
...mapActions('d2admin/theme', [
'set'
]),
...mapActions('d2admin/color', { setColor: 'set' }),
handleSelectTheme(row) {
const { name, color } = row
this.set(name)
this.setColor(color)
}
}
}
</script>
<style lang="scss" scoped>
.theme-preview {
height: 50px;
width: 100px;
border-radius: 4px;
background-size: cover;
border: 1px solid $color-border-1;
}
</style>
<style lang="scss">
.btn-active-success{
&:hover{
background-color: "#67C23A" !important;
}
}
</style>
>
已激活
</el-button>
<el-button
v-else
round
@click="handleSelectTheme(scope.row)"
>
使用
</el-button>
</template>
</el-table-column>
</el-table>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
name: 'D2ThemeList',
data() {
return {
table: {
showHeader: false,
border: true
}
}
},
computed: {
...mapState('d2admin/theme', [
'list',
'activeName'
])
},
methods: {
...mapActions('d2admin/theme', [
'set'
]),
...mapActions('d2admin/color', { setColor: 'set' }),
handleSelectTheme(row) {
const { name, color } = row
this.set(name)
this.setColor(color)
}
}
}
</script>
<style lang="scss" scoped>
.theme-preview {
height: 50px;
width: 100px;
border-radius: 4px;
background-size: cover;
border: 1px solid $color-border-1;
}
</style>
<style lang="scss">
.btn-active-success{
&:hover{
background-color: "#67C23A" !important;
}
}
</style>
<template>
<div>
<el-tooltip
effect="dark"
content="主题"
placement="bottom">
<el-button
class="d2-ml-0 d2-mr btn-text can-hover"
type="text"
@click="dialogVisible = true">
<d2-el-icon
name="magic-stick"
style="font-size: 18px"/>
</el-button>
</el-tooltip>
<el-dialog
title="主题"
width="600px"
:visible.sync="dialogVisible"
:append-to-body="true">
<d2-theme-list style="margin-top: -25px;"/>
</el-dialog>
</div>
</template>
<script>
import themeList from './components/d2-theme-list'
export default {
components: {
'd2-theme-list': themeList
},
data() {
return {
dialogVisible: false
}
}
}
</script>
<template>
<div>
<el-tooltip
effect="dark"
content="主题"
placement="bottom"
>
<el-button
class="d2-ml-0 d2-mr btn-text can-hover"
type="text"
@click="dialogVisible = true"
>
<d2-el-icon
name="magic-stick"
style="font-size: 18px"
/>
</el-button>
</el-tooltip>
<el-dialog
title="主题"
width="600px"
:visible.sync="dialogVisible"
:append-to-body="true"
>
<d2-theme-list style="margin-top: -25px;" />
</el-dialog>
</div>
</template>
<script>
import themeList from './components/d2-theme-list'
export default {
components: {
'd2-theme-list': themeList
},
data() {
return {
dialogVisible: false
}
}
}
</script>
<template>
<div>
<div class="d2-mr personal-wrap">
<el-popover ref="popover1"
placement="top-start"
width="400"
@show="redPotShow = false"
popper-class="popper"
v-model="visible"
trigger="hover">
<p class="title">导出和导出任务</p>
<p class="tips"> 导出和导出任务加载完成后将自动进行下载,加载过程中不要离开系统,否则将导致任务自动清空</p>
<div v-for="(item,index) in dowloadList"
:key="index"
class="downloadSty">
<span class="one-line-ellipsis downName">{{item.name}}</span>
<span class="downLabel"> {{item.labelText}}</span>
<el-popover
ref="popover1"
placement="top-start"
width="400"
@show="redPotShow = false"
popper-class="popper"
v-model="visible"
trigger="hover"
>
<p class="title">
导出和导出任务
</p>
<p class="tips">
导出和导出任务加载完成后将自动进行下载,加载过程中不要离开系统,否则将导致任务自动清空
</p>
<div
v-for="(item,index) in dowloadList"
:key="index"
class="downloadSty"
>
<span class="one-line-ellipsis downName">{{ item.name }}</span>
<span class="downLabel"> {{ item.labelText }}</span>
</div>
<div v-for="(item,index) in updateList"
:key="index+'a'"
class="updateListClass">
<div
v-for="(item,index) in updateList"
:key="index+'a'"
class="updateListClass"
>
<div v-if="item.progress!= 100">
<p>{{item.name}}</p>
<el-progress :percentage="item.progress?item.progress:2"></el-progress>
<p>{{ item.name }}</p>
<el-progress :percentage="item.progress?item.progress:2" />
</div>
<div v-else>
<p>{{item.name||''}}</p>
<p>成功{{item.succNum}}条<span v-if="item.failNum">,失败{{item.failNum}}条</span></p>
<p>{{ item.name||'' }}</p>
<p>成功{{ item.succNum }}条<span v-if="item.failNum">,失败{{ item.failNum }}条</span></p>
</div>
</div>
<!-- @click="test" -->
<span slot="reference">
<i class="el-icon-bell tipsIcon "
:class="{'redPot':redPotShow }"></i>
<i
class="el-icon-bell tipsIcon "
:class="{'redPot':redPotShow }"
/>
</span>
</el-popover>
<span v-if="show"
class="btn-text">{{info && info.detail ? (info.detail.userType == 2 ? `${info.detail.userName}` : '管理员') : '未登录'}}</span>
<span class="btn-text out-txt"
@click="clear">退出</span>
<span
v-if="show"
class="btn-text"
>{{ info && info.detail ? (info.detail.userType == 2 ? `${info.detail.userName}` : '管理员') : '未登录' }}</span>
<span
class="btn-text out-txt"
@click="clear"
>退出</span>
</div>
</div>
</template>
......@@ -78,8 +93,8 @@ export default {
},
computed: {
...mapState({
'dowloadList': (state) => state.d2admin.user.dowloadList,
'updateList': (state) => state.d2admin.user.updateList
dowloadList: (state) => state.d2admin.user.dowloadList,
updateList: (state) => state.d2admin.user.updateList
})
},
watch: {
......
// 创建 el-menu-item
export function elMenuItem(createElement, menu) {
return createElement('el-menu-item', { props: { index: menu.path } }, [
...menu.icon ? [
createElement('i', { attrs: { class: `el-icon-${menu.icon}` } })
] : [],
...menu.icon
? [
createElement('i', { attrs: { class: `el-icon-${menu.icon}` } })
]
: [],
...menu.icon === undefined & !menu.iconSvg ? [
// createElement('img', { attrs: { src: './menuIcon/' + menu.path.slice(1) + '.png' } })
// public 文件需要使用绝对路径引入
createElement('img', { attrs: { src: `${process.env.VUE_APP_PUBLIC_PATH}/menuIcon/` + menu.path.slice(1) + '.png' } })
] : [],
...menu.iconSvg ? [
createElement('d2-icon-svg', { props: { name: menu.iconSvg } })
] : [],
...menu.iconSvg
? [
createElement('d2-icon-svg', { props: { name: menu.iconSvg } })
]
: [],
createElement('span', { slot: 'title' }, menu.title || '未命名菜单')
])
}
......@@ -19,17 +23,21 @@ export function elMenuItem(createElement, menu) {
// 创建 el-submenu
export function elSubmenu(createElement, menu) {
return createElement('el-submenu', { props: { index: menu.path } }, [
...menu.icon ? [
createElement('i', { slot: 'title', attrs: { class: `el-icon-${menu.icon}` } })
] : [],
...menu.icon
? [
createElement('i', { slot: 'title', attrs: { class: `el-icon-${menu.icon}` } })
]
: [],
...menu.icon === undefined & !menu.iconSvg ? [
// createElement('img', { slot: 'title', attrs: { src: './menuIcon/' + menu.path.slice(1) + '.png' } })
// public 文件需要使用绝对路径引入
createElement('img', { slot: 'title', attrs: { src: `${process.env.VUE_APP_PUBLIC_PATH}/menuIcon/` + menu.path.slice(1) + '.png' } })
] : [],
...menu.iconSvg ? [
createElement('d2-icon-svg', { slot: 'title', props: { name: menu.iconSvg } })
] : [],
...menu.iconSvg
? [
createElement('d2-icon-svg', { slot: 'title', props: { name: menu.iconSvg } })
]
: [],
createElement('span', { slot: 'title' }, menu.title || '未命名菜单'),
...menu.children.map((child, childIndex) => child.sideHidden ? '' : (child.children === undefined ? elMenuItem : elSubmenu).call(this, createElement, child))
])
......
import { mapState } from 'vuex'
import menuMixin from '../mixin/menu'
import { elMenuItem, elSubmenu } from '../libs/util.menu'
export default {
name: 'd2-layout-header-aside-menu-header',
mixins: [
menuMixin
],
render(createElement) {
return createElement('div', {
attrs: { flex: 'cross:center' },
class: { 'd2-theme-header-menu': true, 'is-scrollable': this.isScroll },
ref: 'page'
}, [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__content', flex: '', 'flex-box': '1' },
ref: 'content'
}, [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__scroll', 'flex-box': '0' },
style: { transform: `translateX(${this.currentTranslateX}px)` },
ref: 'scroll'
}, [
createElement('el-menu', {
props: { mode: 'horizontal', defaultActive: this.active },
on: { select: this.handleMenuSelect }
}, this.header.map(menu => (menu.children === undefined ? elMenuItem : elSubmenu).call(this, createElement, menu)))
])
]),
...this.isScroll ? [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__prev', flex: 'main:center cross:center', 'flex-box': '0' },
on: { click: () => this.scroll('left') }
}, [
createElement('i', { attrs: { class: 'el-icon-arrow-left' } })
]),
createElement('div', {
attrs: { class: 'd2-theme-header-menu__next', flex: 'main:center cross:center', 'flex-box': '0' },
on: { click: () => this.scroll('right') }
}, [
createElement('i', { attrs: { class: 'el-icon-arrow-right' } })
])
] : []
])
},
computed: {
...mapState('d2admin/menu', [
'header'
])
},
data() {
return {
active: '',
isScroll: false,
scrollWidth: 0,
contentWidth: 0,
currentTranslateX: 0,
throttledCheckScroll: null
}
},
watch: {
'$route.matched': {
handler(val) {
this.active = val[val.length - 1].path
},
immediate: true
}
},
methods: {
scroll(direction) {
if (direction === 'left') {
// 向右滚动
this.currentTranslateX = 0
} else {
// 向左滚动
if (this.contentWidth * 2 - this.currentTranslateX <= this.scrollWidth) {
this.currentTranslateX -= this.contentWidth
} else {
this.currentTranslateX = this.contentWidth - this.scrollWidth
}
}
},
checkScroll() {
let contentWidth = this.$refs.content.clientWidth
let scrollWidth = this.$refs.scroll.clientWidth
if (this.isScroll) {
// 页面依旧允许滚动的情况,需要更新width
if (this.contentWidth - this.scrollWidth === this.currentTranslateX) {
// currentTranslateX 也需要相应变化【在右端到头的情况时】
this.currentTranslateX = contentWidth - scrollWidth
// 快速的滑动依旧存在判断和计算时对应的contentWidth变成正数,所以需要限制一下
if (this.currentTranslateX > 0) {
this.currentTranslateX = 0
}
}
// 更新元素数据
this.contentWidth = contentWidth
this.scrollWidth = scrollWidth
// 判断何时滚动消失: 当scroll > content
if (contentWidth > scrollWidth) {
this.isScroll = false
}
}
// 判断何时滚动出现: 当scroll < content
if (!this.isScroll && contentWidth < scrollWidth) {
this.isScroll = true
// 注意,当isScroll变为true,对应的元素盒子大小会发生变化
this.$nextTick(() => {
contentWidth = this.$refs.content.clientWidth
scrollWidth = this.$refs.scroll.clientWidth
this.contentWidth = contentWidth
this.scrollWidth = scrollWidth
this.currentTranslateX = 0
})
}
}
},
mounted() {
// 初始化判断
// 默认判断父元素和子元素的大小,以确定初始情况是否显示滚动
window.addEventListener('load', this.checkScroll)
// 全局窗口变化监听,判断父元素和子元素的大小,从而控制isScroll的开关
this.throttledCheckScroll = _.throttle(this.checkScroll, 300)
window.addEventListener('resize', this.throttledCheckScroll)
},
beforeDestroy() {
// 取消监听
window.removeEventListener('resize', this.throttledCheckScroll)
window.removeEventListener('load', this.checkScroll)
}
}
import { mapState } from 'vuex'
import menuMixin from '../mixin/menu'
import { elMenuItem, elSubmenu } from '../libs/util.menu'
export default {
name: 'd2-layout-header-aside-menu-header',
mixins: [
menuMixin
],
render(createElement) {
return createElement('div', {
attrs: { flex: 'cross:center' },
class: { 'd2-theme-header-menu': true, 'is-scrollable': this.isScroll },
ref: 'page'
}, [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__content', flex: '', 'flex-box': '1' },
ref: 'content'
}, [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__scroll', 'flex-box': '0' },
style: { transform: `translateX(${this.currentTranslateX}px)` },
ref: 'scroll'
}, [
createElement('el-menu', {
props: { mode: 'horizontal', defaultActive: this.active },
on: { select: this.handleMenuSelect }
}, this.header.map(menu => (menu.children === undefined ? elMenuItem : elSubmenu).call(this, createElement, menu)))
])
]),
...this.isScroll
? [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__prev', flex: 'main:center cross:center', 'flex-box': '0' },
on: { click: () => this.scroll('left') }
}, [
createElement('i', { attrs: { class: 'el-icon-arrow-left' } })
]),
createElement('div', {
attrs: { class: 'd2-theme-header-menu__next', flex: 'main:center cross:center', 'flex-box': '0' },
on: { click: () => this.scroll('right') }
}, [
createElement('i', { attrs: { class: 'el-icon-arrow-right' } })
])
]
: []
])
},
computed: {
...mapState('d2admin/menu', [
'header'
])
},
data() {
return {
active: '',
isScroll: false,
scrollWidth: 0,
contentWidth: 0,
currentTranslateX: 0,
throttledCheckScroll: null
}
},
watch: {
'$route.matched': {
handler(val) {
this.active = val[val.length - 1].path
},
immediate: true
}
},
methods: {
scroll(direction) {
if (direction === 'left') {
// 向右滚动
this.currentTranslateX = 0
} else {
// 向左滚动
if (this.contentWidth * 2 - this.currentTranslateX <= this.scrollWidth) {
this.currentTranslateX -= this.contentWidth
} else {
this.currentTranslateX = this.contentWidth - this.scrollWidth
}
}
},
checkScroll() {
let contentWidth = this.$refs.content.clientWidth
let scrollWidth = this.$refs.scroll.clientWidth
if (this.isScroll) {
// 页面依旧允许滚动的情况,需要更新width
if (this.contentWidth - this.scrollWidth === this.currentTranslateX) {
// currentTranslateX 也需要相应变化【在右端到头的情况时】
this.currentTranslateX = contentWidth - scrollWidth
// 快速的滑动依旧存在判断和计算时对应的contentWidth变成正数,所以需要限制一下
if (this.currentTranslateX > 0) {
this.currentTranslateX = 0
}
}
// 更新元素数据
this.contentWidth = contentWidth
this.scrollWidth = scrollWidth
// 判断何时滚动消失: 当scroll > content
if (contentWidth > scrollWidth) {
this.isScroll = false
}
}
// 判断何时滚动出现: 当scroll < content
if (!this.isScroll && contentWidth < scrollWidth) {
this.isScroll = true
// 注意,当isScroll变为true,对应的元素盒子大小会发生变化
this.$nextTick(() => {
contentWidth = this.$refs.content.clientWidth
scrollWidth = this.$refs.scroll.clientWidth
this.contentWidth = contentWidth
this.scrollWidth = scrollWidth
this.currentTranslateX = 0
})
}
}
},
mounted() {
// 初始化判断
// 默认判断父元素和子元素的大小,以确定初始情况是否显示滚动
window.addEventListener('load', this.checkScroll)
// 全局窗口变化监听,判断父元素和子元素的大小,从而控制isScroll的开关
this.throttledCheckScroll = _.throttle(this.checkScroll, 300)
window.addEventListener('resize', this.throttledCheckScroll)
},
beforeDestroy() {
// 取消监听
window.removeEventListener('resize', this.throttledCheckScroll)
window.removeEventListener('load', this.checkScroll)
}
}
import { mapState } from 'vuex'
import menuMixin from '../mixin/menu'
import { elMenuItem, elSubmenu } from '../libs/util.menu'
import BScroll from 'better-scroll'
export default {
name: 'd2-layout-header-aside-menu-side',
mixins: [
menuMixin
],
render(createElement) {
return createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-side' } }, [
createElement('el-menu', {
props: { collapse: this.asideCollapse, uniqueOpened: true, defaultActive: this.active },
ref: 'menu',
on: { select: this.handleMenuSelect }
}, this.aside.map(menu => ((menu.children === undefined || menu.children.every(i => i.sideHidden === true)) ? elMenuItem : elSubmenu).call(this, createElement, menu))),
...this.aside.length === 0 && !this.asideCollapse ? [
createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-empty', flex: 'dir:top main:center cross:center' } }, [
createElement('d2-icon', { props: { name: 'inbox' } }),
createElement('span', {}, '没有侧栏菜单')
])
] : []
])
},
data() {
return {
active: '',
asideHeight: 300,
BS: null
}
},
computed: {
...mapState('d2admin/menu', [
'aside',
'asideCollapse'
])
},
watch: {
// 折叠和展开菜单的时候销毁 better scroll
asideCollapse(val) {
this.scrollDestroy()
setTimeout(() => {
this.scrollInit()
}, 500)
},
// 监听路由 控制侧边栏激活状态
'$route.matched': {
handler(val) {
this.active = val[val.length - 1].meta.hasOwnProperty('activePath') ? val[val.length - 1].meta.activePath : val[val.length - 1].path
},
immediate: true
}
},
mounted() {
this.scrollInit()
},
beforeDestroy() {
this.scrollDestroy()
},
methods: {
scrollInit() {
this.BS = new BScroll(this.$el, {
mouseWheel: true,
click: true
// 如果你愿意可以打开显示滚动条
// scrollbar: {
// fade: true,
// interactive: false
// }
})
},
scrollDestroy() {
// https://github.com/d2-projects/d2-admin/issues/75
try {
this.BS.destroy()
} catch (e) {
delete this.BS
this.BS = null
}
}
}
}
import { mapState } from 'vuex'
import menuMixin from '../mixin/menu'
import { elMenuItem, elSubmenu } from '../libs/util.menu'
import BScroll from 'better-scroll'
export default {
name: 'd2-layout-header-aside-menu-side',
mixins: [
menuMixin
],
render(createElement) {
return createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-side' } }, [
createElement('el-menu', {
props: { collapse: this.asideCollapse, uniqueOpened: true, defaultActive: this.active },
ref: 'menu',
on: { select: this.handleMenuSelect }
}, this.aside.map(menu => ((menu.children === undefined || menu.children.every(i => i.sideHidden === true)) ? elMenuItem : elSubmenu).call(this, createElement, menu))),
...this.aside.length === 0 && !this.asideCollapse
? [
createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-empty', flex: 'dir:top main:center cross:center' } }, [
createElement('d2-icon', { props: { name: 'inbox' } }),
createElement('span', {}, '没有侧栏菜单')
])
]
: []
])
},
data() {
return {
active: '',
asideHeight: 300,
BS: null
}
},
computed: {
...mapState('d2admin/menu', [
'aside',
'asideCollapse'
])
},
watch: {
// 折叠和展开菜单的时候销毁 better scroll
asideCollapse(val) {
this.scrollDestroy()
setTimeout(() => {
this.scrollInit()
}, 500)
},
// 监听路由 控制侧边栏激活状态
'$route.matched': {
handler(val) {
this.active = val[val.length - 1].meta.hasOwnProperty('activePath') ? val[val.length - 1].meta.activePath : val[val.length - 1].path
},
immediate: true
}
},
mounted() {
this.scrollInit()
},
beforeDestroy() {
this.scrollDestroy()
},
methods: {
scrollInit() {
this.BS = new BScroll(this.$el, {
mouseWheel: true,
click: true
// 如果你愿意可以打开显示滚动条
// scrollbar: {
// fade: true,
// interactive: false
// }
})
},
scrollDestroy() {
// https://github.com/d2-projects/d2-admin/issues/75
try {
this.BS.destroy()
} catch (e) {
delete this.BS
this.BS = null
}
}
}
}
<template>
<div class="d2-panel-search-item" :class="hoverMode ? 'can-hover' : ''" flex>
<div class="d2-panel-search-item__icon" flex-box="0">
<div class="d2-panel-search-item__icon-box" flex="main:center cross:center">
<d2-el-icon v-if="item.icon" :name="item.icon"/>
<!-- <d2-icon-svg v-else-if="item.iconSvg" :name="item.iconSvg"/>
<d2-icon v-else name="file-o"/> -->
</div>
</div>
<div class="d2-panel-search-item__info" flex-box="1" flex="dir:top">
<div class="d2-panel-search-item__info-title" flex-box="1" flex="cross:center">
<span></span>
</div>
<div class="d2-panel-search-item__info-fullTitle" flex-box="0">
<span></span>
</div>
<div class="d2-panel-search-item__info-path" flex-box="0">
<span></span>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
item: {
default: () => ({})
},
hoverMode: {
default: false
}
}
}
</script>
<style lang="scss" scoped>
.d2-panel-search-item {
height: 64px;
margin: 0px -20px;
&.can-hover {
@extend %unable-select;
margin: 0px;
&:hover {
background-color: #F5F7FA;
.d2-panel-search-item__icon {
.d2-panel-search-item__icon-box {
i {
font-size: 24px;
color: $color-primary;
}
}
}
.d2-panel-search-item__info {
.d2-panel-search-item__info-title {
color: $color-text-main;
}
.d2-panel-search-item__info-fullTitle {
color: $color-text-normal;
}
.d2-panel-search-item__info-path {
color: $color-text-normal;
}
}
}
}
.d2-panel-search-item__icon {
width: 64px;
.d2-panel-search-item__icon-box {
height: 64px;
width: 64px;
border-right: 1px solid $color-border-3;
i {
font-size: 20px;
color: $color-text-sub;
}
svg {
height: 20px;
width: 20px;
}
}
}
.d2-panel-search-item__info {
margin-left: 10px;
.d2-panel-search-item__info-title {
font-size: 16px;
line-height: 16px;
font-weight: bold;
color: $color-text-normal;
}
.d2-panel-search-item__info-fullTitle {
font-size: 10px;
line-height: 14px;
color: $color-text-placehoder;
}
.d2-panel-search-item__info-path {
margin-bottom: 4px;
font-size: 10px;
line-height: 14px;
color: $color-text-placehoder;
}
}
}
</style>
<template>
<div
class="d2-panel-search-item"
:class="hoverMode ? 'can-hover' : ''"
flex
>
<div
class="d2-panel-search-item__icon"
flex-box="0"
>
<div
class="d2-panel-search-item__icon-box"
flex="main:center cross:center"
>
<d2-el-icon
v-if="item.icon"
:name="item.icon"
/>
<!-- <d2-icon-svg v-else-if="item.iconSvg" :name="item.iconSvg"/>
<d2-icon v-else name="file-o"/> -->
</div>
</div>
<div
class="d2-panel-search-item__info"
flex-box="1"
flex="dir:top"
>
<div
class="d2-panel-search-item__info-title"
flex-box="1"
flex="cross:center"
>
<span />
</div>
<div
class="d2-panel-search-item__info-fullTitle"
flex-box="0"
>
<span />
</div>
<div
class="d2-panel-search-item__info-path"
flex-box="0"
>
<span />
</div>
</div>
</div>
</template>
<script>
export default {
props: {
item: {
default: () => ({})
},
hoverMode: {
default: false
}
}
}
</script>
<style lang="scss" scoped>
.d2-panel-search-item {
height: 64px;
margin: 0px -20px;
&.can-hover {
@extend %unable-select;
margin: 0px;
&:hover {
background-color: #F5F7FA;
.d2-panel-search-item__icon {
.d2-panel-search-item__icon-box {
i {
font-size: 24px;
color: $color-primary;
}
}
}
.d2-panel-search-item__info {
.d2-panel-search-item__info-title {
color: $color-text-main;
}
.d2-panel-search-item__info-fullTitle {
color: $color-text-normal;
}
.d2-panel-search-item__info-path {
color: $color-text-normal;
}
}
}
}
.d2-panel-search-item__icon {
width: 64px;
.d2-panel-search-item__icon-box {
height: 64px;
width: 64px;
border-right: 1px solid $color-border-3;
i {
font-size: 20px;
color: $color-text-sub;
}
svg {
height: 20px;
width: 20px;
}
}
}
.d2-panel-search-item__info {
margin-left: 10px;
.d2-panel-search-item__info-title {
font-size: 16px;
line-height: 16px;
font-weight: bold;
color: $color-text-normal;
}
.d2-panel-search-item__info-fullTitle {
font-size: 10px;
line-height: 14px;
color: $color-text-placehoder;
}
.d2-panel-search-item__info-path {
margin-bottom: 4px;
font-size: 10px;
line-height: 14px;
color: $color-text-placehoder;
}
}
}
</style>
......@@ -51,19 +51,34 @@
清空本地缓存
</div>
</div>-->
<div class="panel-item" @click="handleChangeAccount">
<el-button type="text" :disabled="accountInfo.accountList.length == 1">
<i class="i el-icon-sort"></i>{{user && user.merchantAccountLevel ? (user.merchantAccountLevel == 4 ? `${user.detail.userName}` : '管理员') : '未登录'}}
<div
class="panel-item"
@click="handleChangeAccount"
>
<el-button
type="text"
:disabled="accountInfo.accountList.length == 1"
>
<i class="i el-icon-sort" />{{ user && user.merchantAccountLevel ? (user.merchantAccountLevel == 4 ? `${user.detail.userName}` : '管理员') : '未登录' }}
</el-button>
</div>
<div class="panel-item" @click="clear">
<div
class="panel-item"
@click="clear"
>
<el-button type="text">
<i class="i el-icon-switch-button"></i>退出账户
<i class="i el-icon-switch-button" />退出账户
</el-button>
</div>
</div>
<personal-dialog :visible="personalVisible" :user="info" />
<password-dialog :visible="passwordVisible" :user="info" />
<personal-dialog
:visible="personalVisible"
:user="info"
/>
<password-dialog
:visible="passwordVisible"
:user="info"
/>
</div>
</template>
......
<!-- 详情弹框 -->
<template>
<div class="password-detail">
<el-dialog
title="修改密码"
:visible.sync="visible"
:before-close="handleClose"
:append-to-body="true"
:close-on-click-modal="false"
width="600px"
>
<el-form label-width="120px" v-if="info" :model="info" :rules="rules" ref="passwordForm">
<el-form-item label="用户名:" prop="userName">
<el-input disabled="disabled" v-model="info.userName"></el-input>
</el-form-item>
<el-form-item label="原密码:" prop="oldPassword">
<el-input type="password" maxlength="12" :show-password="true" v-model="info.oldPassword" />
</el-form-item>
<el-form-item label="新密码:" prop="newPassword">
<el-input type="password" maxlength="12" :show-password="true" v-model="info.newPassword" />
</el-form-item>
<el-form-item label="确认密码:" prop="confirm">
<el-input type="password" maxlength="12" :show-password="true" v-model="info.confirm" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit">保 存</el-button>
<el-button @click="handleClose">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { ModifyPassword } from '@api/sys.account'
export default {
name: 'PasswordDialog',
components: {},
data() {
return {
rules: Object.freeze({
oldPassword: [
{ required: true, message: '请输入旧密码', trigger: ['blur'] }
],
newPassword: [
{ required: true,
validator: (rule, value, callback) => {
if (!value) {
callback(new Error('请输入新密码'))
} else {
if (this.info.confirm) {
this.$refs.passwordForm.validateField('confirm')
}
callback()
}
},
trigger: 'blur'
}
],
confirm: [
{ required: true,
validator: (rule, value, callback) => {
if (!value) {
callback(new Error('请再次输入新密码'))
} else if (value !== this.info.newPassword) {
callback(new Error('两次新密码不一致!'))
} else {
callback()
}
},
trigger: 'blur'
}
]
})
}
},
props: {
visible: {
type: Boolean,
default: false
},
user: Object
},
computed: {
info() {
return this.user
}
},
methods: {
// 修改密码
submit() {
this.$refs.passwordForm.validate(async valid => {
if (valid) {
const { userId, oldPassword, newPassword } = this.info
const result = await ModifyPassword({ userId, oldPassword, newPassword })
const { operateStatus } = result
if (operateStatus) {
this.emit(true)
return
}
this.$message.error('修改密码失败')
}
})
},
handleClose() {
this.emit(false)
},
emit(is2Login) {
this.$event.$emit('e-ps-close', is2Login)
this.$refs.passwordForm.validateField()
}
}
}
</script>
<!-- 详情弹框 -->
<template>
<div class="password-detail">
<el-dialog
title="修改密码"
:visible.sync="visible"
:before-close="handleClose"
:append-to-body="true"
:close-on-click-modal="false"
width="600px"
>
<el-form
label-width="120px"
v-if="info"
:model="info"
:rules="rules"
ref="passwordForm"
>
<el-form-item
label="用户名:"
prop="userName"
>
<el-input
disabled="disabled"
v-model="info.userName"
/>
</el-form-item>
<el-form-item
label="原密码:"
prop="oldPassword"
>
<el-input
type="password"
maxlength="12"
:show-password="true"
v-model="info.oldPassword"
/>
</el-form-item>
<el-form-item
label="新密码:"
prop="newPassword"
>
<el-input
type="password"
maxlength="12"
:show-password="true"
v-model="info.newPassword"
/>
</el-form-item>
<el-form-item
label="确认密码:"
prop="confirm"
>
<el-input
type="password"
maxlength="12"
:show-password="true"
v-model="info.confirm"
/>
</el-form-item>
</el-form>
<div
slot="footer"
class="dialog-footer"
>
<el-button
type="primary"
@click="submit"
>
保 存
</el-button>
<el-button @click="handleClose">
取 消
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { ModifyPassword } from '@api/sys.account'
export default {
name: 'PasswordDialog',
components: {},
data() {
return {
rules: Object.freeze({
oldPassword: [
{ required: true, message: '请输入旧密码', trigger: ['blur'] }
],
newPassword: [
{
required: true,
validator: (rule, value, callback) => {
if (!value) {
callback(new Error('请输入新密码'))
} else {
if (this.info.confirm) {
this.$refs.passwordForm.validateField('confirm')
}
callback()
}
},
trigger: 'blur'
}
],
confirm: [
{
required: true,
validator: (rule, value, callback) => {
if (!value) {
callback(new Error('请再次输入新密码'))
} else if (value !== this.info.newPassword) {
callback(new Error('两次新密码不一致!'))
} else {
callback()
}
},
trigger: 'blur'
}
]
})
}
},
props: {
visible: {
type: Boolean,
default: false
},
user: Object
},
computed: {
info() {
return this.user
}
},
methods: {
// 修改密码
submit() {
this.$refs.passwordForm.validate(async valid => {
if (valid) {
const { userId, oldPassword, newPassword } = this.info
const result = await ModifyPassword({ userId, oldPassword, newPassword })
const { operateStatus } = result
if (operateStatus) {
this.emit(true)
return
}
this.$message.error('修改密码失败')
}
})
},
handleClose() {
this.emit(false)
},
emit(is2Login) {
this.$event.$emit('e-ps-close', is2Login)
this.$refs.passwordForm.validateField()
}
}
}
</script>
<!-- 详情弹框 -->
<template>
<div class="personal-detail">
<el-dialog
title="个人信息"
:visible.sync="visible"
:before-close="handleClose"
:append-to-body="true"
:close-on-click-modal="false"
width="600px"
>
<el-form v-if="user" label-width="120px" :model="user">
<el-form-item label="用户名:" prop="loginName">
<el-input disabled v-model="user.loginName"></el-input>
</el-form-item>
<el-form-item label="姓名:" prop="userName">
<el-input disabled v-model="user.userName"></el-input>
</el-form-item>
<el-form-item label="联系方式:" prop="mobile">
<el-input disabled v-model="user.mobile"></el-input>
</el-form-item>
<el-form-item label="所属公司:" prop="companyName">
<el-input disabled v-model="user.companyName"></el-input>
</el-form-item>
<el-form-item label="部门:" prop="departName">
<el-input disabled v-model="user.departName"></el-input>
</el-form-item>
<el-form-item label="职务:" prop="postName">
<el-input disabled v-model="user.postName"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<!-- <el-button type="primary" @click="personDialogVisible = false">确 定</el-button> -->
<el-button @click="handleClose">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
// import { ctMethods, request } from '@/api'
export default {
name: 'personalDialog',
props: {
visible: {
type: Boolean,
default: false
},
user: Object
},
methods: {
handleClose() {
this.$event.$emit('e-pd-close')
}
}
}
</script>
<!-- 详情弹框 -->
<template>
<div class="personal-detail">
<el-dialog
title="个人信息"
:visible.sync="visible"
:before-close="handleClose"
:append-to-body="true"
:close-on-click-modal="false"
width="600px"
>
<el-form
v-if="user"
label-width="120px"
:model="user"
>
<el-form-item
label="用户名:"
prop="loginName"
>
<el-input
disabled
v-model="user.loginName"
/>
</el-form-item>
<el-form-item
label="姓名:"
prop="userName"
>
<el-input
disabled
v-model="user.userName"
/>
</el-form-item>
<el-form-item
label="联系方式:"
prop="mobile"
>
<el-input
disabled
v-model="user.mobile"
/>
</el-form-item>
<el-form-item
label="所属公司:"
prop="companyName"
>
<el-input
disabled
v-model="user.companyName"
/>
</el-form-item>
<el-form-item
label="部门:"
prop="departName"
>
<el-input
disabled
v-model="user.departName"
/>
</el-form-item>
<el-form-item
label="职务:"
prop="postName"
>
<el-input
disabled
v-model="user.postName"
/>
</el-form-item>
</el-form>
<div
slot="footer"
class="dialog-footer"
>
<!-- <el-button type="primary" @click="personDialogVisible = false">确 定</el-button> -->
<el-button @click="handleClose">
确 定
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
// import { ctMethods, request } from '@/api'
export default {
name: 'PersonalDialog',
props: {
visible: {
type: Boolean,
default: false
},
user: Object
},
methods: {
handleClose() {
this.$event.$emit('e-pd-close')
}
}
}
</script>
<template>
<div class="d2-layout-header-aside-group"
:style="styleLayoutMainGroup"
:class="{grayMode: grayActive}">
<div
class="d2-layout-header-aside-group"
:style="styleLayoutMainGroup"
:class="{grayMode: grayActive}"
>
<!-- 半透明遮罩 -->
<div class="d2-layout-header-aside-mask"></div>
<div class="d2-layout-header-aside-mask" />
<!-- 主体内容 -->
<div class="d2-layout-header-aside-content"
flex="dir:top">
<div
class="d2-layout-header-aside-content"
flex="dir:top"
>
<!-- 顶栏 -->
<div class="d2-theme-header"
:style="{
<div
class="d2-theme-header"
:style="{
opacity: this.searchActive ? 0.5 : 1
}"
flex-box="0"
flex>
<div class="logo-group d2-theme-header-logo"
:class="asideCollapse ? 'logo-only' : 'logo-all'"
flex-box="0">
<img v-if="asideCollapse"
src="../../assets/icon-only.png">
<img v-else
src="../../assets/all.png">
flex-box="0"
flex
>
<div
class="logo-group d2-theme-header-logo"
:class="asideCollapse ? 'logo-only' : 'logo-all'"
flex-box="0"
>
<img
v-if="asideCollapse"
src="../../assets/icon-only.png"
>
<img
v-else
src="../../assets/all.png"
>
<!-- <img style="width: 32px; height: 32px;" src="../../assets/icon-only.png"> -->
</div>
<p v-if="show"
class="d2-header-name">{{info ? info.detail.merchantName : ''}}</p>
<p
v-if="show"
class="d2-header-name"
>
{{ info ? info.detail.merchantName : '' }}
</p>
<!-- <hamburger :onClick="handleToggleAside" :isActive="asideCollapse" flex-box="0" class="toggle-aside-btn"></hamburger>
<span class="header-title">{{headerTitle}}</span> -->
<d2-menu-header flex-box="1" />
<!-- 顶栏右侧 -->
<div class="d2-header-right"
flex-box="0">
<div
class="d2-header-right"
flex-box="0"
>
<!-- <d2-header-datetime /> -->
<!-- 如果你只想在开发环境显示这个按钮请添加 v-if="$env === 'development'" -->
<!-- <d2-header-search @click="handleSearchClick"/> -->
......@@ -43,64 +61,87 @@
<d2-header-user />
</div>
</div>
<div class="d2-theme-header"
style="height: 40px; font-size: 14px; border-top: 1px solid #F0F2F5;"
flex-box="0"
flex>
<div class="logo-group d2-theme-header-logo"
style="height: 1px; margin-top: -1px;"
:class="asideCollapse ? 'logo-only' : 'logo-all'"
flex-box="0">
</div>
<hamburger :onClick="handleToggleAside"
:isActive="asideCollapse"
flex-box="0"
class="toggle-aside-btn"></hamburger>
<span class="header-title">{{headerTitle}}</span>
<div
class="d2-theme-header"
style="height: 40px; font-size: 14px; border-top: 1px solid #F0F2F5;"
flex-box="0"
flex
>
<div
class="logo-group d2-theme-header-logo"
style="height: 1px; margin-top: -1px;"
:class="asideCollapse ? 'logo-only' : 'logo-all'"
flex-box="0"
/>
<hamburger
:on-click="handleToggleAside"
:is-active="asideCollapse"
flex-box="0"
class="toggle-aside-btn"
/>
<span class="header-title">{{ headerTitle }}</span>
</div>
<!-- 下面 主体 -->
<div class="d2-theme-container"
flex-box="1"
flex>
<div
class="d2-theme-container"
flex-box="1"
flex
>
<!-- 主体 侧边栏 -->
<div flex-box="0"
ref="aside"
class="d2-theme-container-aside"
:style="{
<div
flex-box="0"
ref="aside"
class="d2-theme-container-aside"
:style="{
width: asideCollapse ? asideWidthCollapse : asideWidth,
opacity: this.searchActive ? 0.5 : 1
}">
}"
>
<d2-menu-side />
</div>
<!-- 主体 -->
<div class="d2-theme-container-main"
:class="this.searchActive ? 'is-search' : ''"
flex-box="1"
flex>
<div
class="d2-theme-container-main"
:class="this.searchActive ? 'is-search' : ''"
flex-box="1"
flex
>
<!-- 搜索 -->
<transition name="fade-scale">
<div v-if="searchActive"
class="d2-theme-container-main-layer"
flex>
<d2-panel-search ref="panelSearch"
@close="searchPanelClose" />
<div
v-if="searchActive"
class="d2-theme-container-main-layer"
flex
>
<d2-panel-search
ref="panelSearch"
@close="searchPanelClose"
/>
</div>
</transition>
<!-- 内容 -->
<transition name="fade-scale">
<div v-if="!searchActive"
class="d2-theme-container-main-layer"
flex="dir:top">
<div
v-if="!searchActive"
class="d2-theme-container-main-layer"
flex="dir:top"
>
<!-- tab -->
<div class="d2-theme-container-main-header"
flex-box="0">
<div
class="d2-theme-container-main-header"
flex-box="0"
>
<!-- <d2-tabs/> -->
</div>
<!-- 页面 -->
<div class="d2-theme-container-main-body"
flex-box="1">
<transition :name="transitionActive ? 'el-fade-in' : '' "
mode="out-in">
<div
class="d2-theme-container-main-body"
flex-box="1"
>
<transition
:name="transitionActive ? 'el-fade-in' : '' "
mode="out-in"
>
<keep-alive :include="keepAlive">
<router-view />
</keep-alive>
......@@ -132,7 +173,7 @@ import { mapState, mapGetters, mapActions } from 'vuex'
import mixinSearch from './mixins/search'
import { localRoutes } from '@/router/routes'
export default {
name: 'd2-layout-header-aside',
name: 'D2LayoutHeaderAside',
mixins: [
mixinSearch
],
......@@ -193,9 +234,11 @@ export default {
*/
styleLayoutMainGroup() {
return {
...this.themeActiveSetting.backgroundImage ? {
backgroundImage: `url('${this.$baseUrl}${this.themeActiveSetting.backgroundImage}')`
} : {}
...this.themeActiveSetting.backgroundImage
? {
backgroundImage: `url('${this.$baseUrl}${this.themeActiveSetting.backgroundImage}')`
}
: {}
}
}
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!