587c5305 by renchao@pashanhoo.com

docs:注释增加

1 parent ecb27d8c
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-07-20 10:22:20
-->
<template>
<label class="el-checkbox" :class="[
border && checkboxSize ? 'el-checkbox--' + checkboxSize : '',
......@@ -26,217 +31,217 @@
</label>
</template>
<script>
import Emitter from 'element-ui/src/mixins/emitter';
import Emitter from 'element-ui/src/mixins/emitter';
export default {
name: 'ElCheckbox',
export default {
name: 'ElCheckbox',
mixins: [Emitter],
mixins: [Emitter],
inject: {
elForm: {
default: ''
inject: {
elForm: {
default: ''
},
elFormItem: {
default: ''
}
},
componentName: 'ElCheckbox',
data () {
return {
selfModel: false,
focus: false,
isLimitExceeded: false
};
},
elFormItem: {
default: ''
}
},
componentName: 'ElCheckbox',
computed: {
model: {
/**
* @description: get
* @author: renchao
*/
get () {
return this.isGroup
? this.store : this.value !== undefined
? this.value : this.selfModel;
},
/**
* @description: set
* @param {*} val
* @author: renchao
*/
set (val) {
if (this.isGroup) {
this.isLimitExceeded = false;
(this._checkboxGroup.min !== undefined &&
val.length < this._checkboxGroup.min &&
(this.isLimitExceeded = true));
data () {
return {
selfModel: false,
focus: false,
isLimitExceeded: false
};
},
(this._checkboxGroup.max !== undefined &&
val.length > this._checkboxGroup.max &&
(this.isLimitExceeded = true));
this.isLimitExceeded === false &&
this.dispatch('ElCheckboxGroup', 'input', [val]);
} else {
this.$emit('input', val);
this.selfModel = val;
}
}
},
computed: {
model: {
/**
* @description: get
* @description: isChecked
* @author: renchao
*/
get () {
return this.isGroup
? this.store : this.value !== undefined
? this.value : this.selfModel;
isChecked () {
if ({}.toString.call(this.model) === '[object Boolean]') {
return this.model;
} else if (Array.isArray(this.model)) {
return this.model.indexOf(this.label) > -1;
} else if (this.model !== null && this.model !== undefined) {
return this.model === this.trueLabel;
}
},
/**
* @description: set
* @param {*} val
* @description: isGroup
* @author: renchao
*/
set (val) {
if (this.isGroup) {
this.isLimitExceeded = false;
(this._checkboxGroup.min !== undefined &&
val.length < this._checkboxGroup.min &&
(this.isLimitExceeded = true));
(this._checkboxGroup.max !== undefined &&
val.length > this._checkboxGroup.max &&
(this.isLimitExceeded = true));
this.isLimitExceeded === false &&
this.dispatch('ElCheckboxGroup', 'input', [val]);
} else {
this.$emit('input', val);
this.selfModel = val;
isGroup () {
let parent = this.$parent;
while (parent) {
if (parent.$options.componentName !== 'ElCheckboxGroup') {
parent = parent.$parent;
} else {
this._checkboxGroup = parent;
return true;
}
}
return false;
},
/**
* @description: store
* @author: renchao
*/
store () {
return this._checkboxGroup ? this._checkboxGroup.value : this.value;
},
/**
* @description: isLimitDisabled
* @author: renchao
*/
isLimitDisabled () {
const { max, min } = this._checkboxGroup;
return !!(max || min) &&
(this.model.length >= max && !this.isChecked) ||
(this.model.length <= min && this.isChecked);
},
/**
* @description: isDisabled
* @author: renchao
*/
isDisabled () {
return this.isGroup
? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled
: this.disabled || (this.elForm || {}).disabled;
},
/**
* @description: _elFormItemSize
* @author: renchao
*/
_elFormItemSize () {
return (this.elFormItem || {}).elFormItemSize;
},
/**
* @description: checkboxSize
* @author: renchao
*/
checkboxSize () {
const temCheckboxSize = this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
return this.isGroup
? this._checkboxGroup.checkboxGroupSize || temCheckboxSize
: temCheckboxSize;
}
},
/**
* @description: isChecked
* @author: renchao
*/
isChecked () {
if ({}.toString.call(this.model) === '[object Boolean]') {
return this.model;
} else if (Array.isArray(this.model)) {
return this.model.indexOf(this.label) > -1;
} else if (this.model !== null && this.model !== undefined) {
return this.model === this.trueLabel;
}
props: {
value: {},
label: {},
indeterminate: Boolean,
disabled: Boolean,
checked: Boolean,
name: String,
trueLabel: [String, Number],
falseLabel: [String, Number],
id: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/
controls: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/
border: Boolean,
size: String
},
/**
* @description: isGroup
* @author: renchao
*/
isGroup () {
let parent = this.$parent;
while (parent) {
if (parent.$options.componentName !== 'ElCheckboxGroup') {
parent = parent.$parent;
methods: {
/**
* @description: addToStore
* @author: renchao
*/
addToStore () {
if (
Array.isArray(this.model) &&
this.model.indexOf(this.label) === -1
) {
this.model.push(this.label);
} else {
this._checkboxGroup = parent;
return true;
this.model = this.trueLabel || true;
}
},
/**
* @description: handleChange
* @author: renchao
*/
handleChange (ev) {
if (this.isLimitExceeded) return;
let value;
if (ev.target.checked) {
value = this.trueLabel === undefined ? true : this.trueLabel;
} else {
value = this.falseLabel === undefined ? false : this.falseLabel;
}
this.$emit('change', value, ev);
this.$nextTick(() => {
if (this.isGroup) {
this.dispatch('ElCheckboxGroup', 'change', [this._checkboxGroup.value]);
}
});
}
return false;
},
/**
* @description: store
* @author: renchao
*/
store () {
return this._checkboxGroup ? this._checkboxGroup.value : this.value;
},
/**
* @description: isLimitDisabled
* @author: renchao
*/
isLimitDisabled () {
const { max, min } = this._checkboxGroup;
return !!(max || min) &&
(this.model.length >= max && !this.isChecked) ||
(this.model.length <= min && this.isChecked);
},
/**
* @description: isDisabled
* @author: renchao
*/
isDisabled () {
return this.isGroup
? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled
: this.disabled || (this.elForm || {}).disabled;
},
/**
* @description: _elFormItemSize
* @description: created
* @author: renchao
*/
_elFormItemSize () {
return (this.elFormItem || {}).elFormItemSize;
created () {
this.checked && this.addToStore();
},
/**
* @description: checkboxSize
* @description: mounted
* @author: renchao
*/
checkboxSize () {
const temCheckboxSize = this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
return this.isGroup
? this._checkboxGroup.checkboxGroupSize || temCheckboxSize
: temCheckboxSize;
}
},
props: {
value: {},
label: {},
indeterminate: Boolean,
disabled: Boolean,
checked: Boolean,
name: String,
trueLabel: [String, Number],
falseLabel: [String, Number],
id: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/
controls: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/
border: Boolean,
size: String
},
methods: {
/**
* @description: addToStore
* @author: renchao
*/
addToStore () {
if (
Array.isArray(this.model) &&
this.model.indexOf(this.label) === -1
) {
this.model.push(this.label);
} else {
this.model = this.trueLabel || true;
mounted () { // 为indeterminate元素 添加aria-controls 属性
if (this.indeterminate) {
this.$el.setAttribute('aria-controls', this.controls);
}
},
/**
* @description: handleChange
* @description: watch
* @author: renchao
*/
handleChange (ev) {
if (this.isLimitExceeded) return;
let value;
if (ev.target.checked) {
value = this.trueLabel === undefined ? true : this.trueLabel;
} else {
value = this.falseLabel === undefined ? false : this.falseLabel;
watch: {
value (value) {
this.dispatch('ElFormItem', 'el.form.change', value);
}
this.$emit('change', value, ev);
this.$nextTick(() => {
if (this.isGroup) {
this.dispatch('ElCheckboxGroup', 'change', [this._checkboxGroup.value]);
}
});
}
},
/**
* @description: created
* @author: renchao
*/
created () {
this.checked && this.addToStore();
},
/**
* @description: mounted
* @author: renchao
*/
mounted () { // 为indeterminate元素 添加aria-controls 属性
if (this.indeterminate) {
this.$el.setAttribute('aria-controls', this.controls);
}
},
/**
* @description: watch
* @author: renchao
*/
watch: {
value (value) {
this.dispatch('ElFormItem', 'el.form.change', value);
}
}
};
};
</script>
......
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-07-20 13:33:07
-->
<template>
<el-dialog :visible.sync="dialogVisible" v-if="dialogVisible" :width="width" :fullscreen="fullscreen" top="0"
:append-to-body="appendToBody" :lock-scroll="true" :close-on-click-modal="false" @close="closeDialog" :key="key"
......@@ -23,117 +28,117 @@
</el-dialog>
</template>
<script>
export default {
props: {
value: { type: Boolean, default: false },
isMain: {
type: Boolean,
default: false
},
appendToBody: {
type: Boolean,
default: true
},
isButton: {
type: Boolean,
default: true,
},
width: {
type: String,
default: '70%',
},
title: {
type: String,
default: '',
},
isFullscreen: {
type: Boolean,
default: true,
},
isSave: {
type: Boolean,
default: true,
},
saveButton: {
type: String,
default: '提交',
},
isReset: {
type: Boolean,
default: true,
},
saveloding: {
type: Boolean,
default: false,
export default {
props: {
value: { type: Boolean, default: false },
isMain: {
type: Boolean,
default: false
},
appendToBody: {
type: Boolean,
default: true
},
isButton: {
type: Boolean,
default: true,
},
width: {
type: String,
default: '70%',
},
title: {
type: String,
default: '',
},
isFullscreen: {
type: Boolean,
default: true,
},
isSave: {
type: Boolean,
default: true,
},
saveButton: {
type: String,
default: '提交',
},
isReset: {
type: Boolean,
default: true,
},
saveloding: {
type: Boolean,
default: false,
},
btnDisabled: {
type: Boolean,
default: false
},
height: {
type: String,
default: ''
}
},
btnDisabled: {
type: Boolean,
default: false
data () {
return {
key: 0,
dialogVisible: false,
fullscreen: false,
scrollerHeight: ''
}
},
height: {
type: String,
default: ''
}
},
data () {
return {
key: 0,
dialogVisible: false,
fullscreen: false,
scrollerHeight: ''
}
},
watch: {
value (val) {
this.$nextTick(() => {
this.dialogVisible = val
})
this.height && (this.scrollerHeight = this.height + 'px')
}
},
methods: {
/**
* @description: handleFullscreen
* @author: renchao
*/
handleFullscreen () {
this.fullscreen = !this.fullscreen
if (!this.fullscreen) {
this.scrollerHeight = ''
} else {
this.scrollerHeight = (window.innerHeight - 120) + 'px'
watch: {
value (val) {
this.$nextTick(() => {
this.dialogVisible = val
})
this.height && (this.scrollerHeight = this.height + 'px')
}
},
/**
* @description: submitForm
* @author: renchao
*/
submitForm () {
if (this.isButton) {
this.$emit('submitForm');
methods: {
/**
* @description: handleFullscreen
* @author: renchao
*/
handleFullscreen () {
this.fullscreen = !this.fullscreen
if (!this.fullscreen) {
this.scrollerHeight = ''
} else {
this.scrollerHeight = (window.innerHeight - 120) + 'px'
}
},
/**
* @description: submitForm
* @author: renchao
*/
submitForm () {
if (this.isButton) {
this.$emit('submitForm');
}
},
/**
* @description: closeDialog
* @author: renchao
*/
closeDialog () {
this.key++
this.$emit('input', false)
this.$emit('closeDialog')
}
},
/**
* @description: closeDialog
* @author: renchao
*/
closeDialog () {
this.key++
this.$emit('input', false)
this.$emit('closeDialog')
}
},
}
}
</script>
<style rel="stylesheet/scss" lang="scss" >
@import "~@/styles/mixin.scss";
@import "~@/styles/dialogBox.scss";
@import "~@/styles/mixin.scss";
@import "~@/styles/dialogBox.scss";
</style>
<style rel="stylesheet/scss" scoped lang="scss" >
/deep/.is-fullscreen {
position: absolute;
top: 50% !important;
left: 50% !important;
transform: translate(-50%, -50%) !important;
}
/deep/.is-fullscreen {
position: absolute;
top: 50% !important;
left: 50% !important;
transform: translate(-50%, -50%) !important;
}
</style>
......
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-07-20 13:40:27
-->
<template>
<dialogBox title="配置常办项目" @submitForm="submitForm" saveButton="保存" :isFullscreen="false" width="50%"
@closeDialog="closeDialog" v-model="myValue">
......@@ -6,103 +11,103 @@
</dialogBox>
</template>
<script>
import { getMenuInfo } from "@/api/user.js";
import Tree from "@/components/Tree/src/tree.vue"
import { saveFrequentProjectsList, getHomeFrequentProjects } from "@/api/home.js";
export default {
components: {
Tree
},
props: {
value: { type: Boolean, default: false },
bindItem: { type: Array, default: [] }
},
data () {
return {
myValue: false,
defaultCheckeds: [],
projectList: [],
checkedItem: [],
defaultProps: {
children: "children",
label: "name",
disabled: function (data, node) {
if (data.children && data.children.length > 0) {
return true
} else {
return false
import { getMenuInfo } from "@/api/user.js";
import Tree from "@/components/Tree/src/tree.vue"
import { saveFrequentProjectsList, getHomeFrequentProjects } from "@/api/home.js";
export default {
components: {
Tree
},
props: {
value: { type: Boolean, default: false },
bindItem: { type: Array, default: [] }
},
data () {
return {
myValue: false,
defaultCheckeds: [],
projectList: [],
checkedItem: [],
defaultProps: {
children: "children",
label: "name",
disabled: function (data, node) {
if (data.children && data.children.length > 0) {
return true
} else {
return false
}
}
}
},
uniqueValue: ''//最后拿到的唯一选择的moduldCode值,相当于id
}
},
watch: {
value (val) {
this.myValue = val
if (val) {
this.queryClick()
},
uniqueValue: ''//最后拿到的唯一选择的moduldCode值,相当于id
}
}
},
mounted () {
this.dealCheckedItem();
},
methods: {
submitForm () {
var checkedNodes = this.$refs.tree.getCheckedNodes();
if (checkedNodes.length > 6) {
this.$message.error("最多选择6个项目!");
return
}
saveFrequentProjectsList(checkedNodes).then(res => {
if (res.code == 200) {
this.$parent.queryProjectList();
this.$message.success("保存成功");
this.$emit("input", false);
} else {
this.$message.error(res.message);
}
})
},
queryClick () {
let that = this
getMenuInfo().then(res => {
this.projectList = res.result.slice(0, -2)
})
function lookForAllId (arr = []) {
for (let item of that.bindItem) {
arr.push(item.id)
if (item.children && item.children.length) lookForAllId(item.children, arr)
watch: {
value (val) {
this.myValue = val
if (val) {
this.queryClick()
}
return arr
}
this.defaultCheckeds = lookForAllId()
},
dealCheckedItem () {
mounted () {
this.dealCheckedItem();
},
//关闭窗口
closeDialog () {
this.$emit("input", false);
},
//节点选择状态发生改变时
handleClick (data, checked, node) {
var checkedNodes = this.$refs.tree.getCheckedNodes();
if (checkedNodes.length > 6) {
this.$message({
message: '最后选择6条数据',
type: 'warning',
customClass: 'messageIndex'
methods: {
submitForm () {
var checkedNodes = this.$refs.tree.getCheckedNodes();
if (checkedNodes.length > 6) {
this.$message.error("最多选择6个项目!");
return
}
saveFrequentProjectsList(checkedNodes).then(res => {
if (res.code == 200) {
this.$parent.queryProjectList();
this.$message.success("保存成功");
this.$emit("input", false);
} else {
this.$message.error(res.message);
}
})
},
queryClick () {
let that = this
getMenuInfo().then(res => {
this.projectList = res.result.slice(0, -2)
})
this.$refs.tree.setChecked(data, false) // 取消当前节点的选中状态
function lookForAllId (arr = []) {
for (let item of that.bindItem) {
arr.push(item.id)
if (item.children && item.children.length) lookForAllId(item.children, arr)
}
return arr
}
this.defaultCheckeds = lookForAllId()
},
dealCheckedItem () {
},
//关闭窗口
closeDialog () {
this.$emit("input", false);
},
//节点选择状态发生改变时
handleClick (data, checked, node) {
var checkedNodes = this.$refs.tree.getCheckedNodes();
if (checkedNodes.length > 6) {
this.$message({
message: '最后选择6条数据',
type: 'warning',
customClass: 'messageIndex'
})
this.$refs.tree.setChecked(data, false) // 取消当前节点的选中状态
}
}
}
}
}
</script>
<style scoped lang='scss'>
/deep/.el-tree-node.is-expanded>.el-tree-node__children {
display: flex;
flex-wrap: wrap;
}
/deep/.el-tree-node.is-expanded > .el-tree-node__children {
display: flex;
flex-wrap: wrap;
}
</style>
......
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-07-20 13:40:32
-->
<template>
<div class="model">
<div class="mask">123</div>
......@@ -18,71 +23,71 @@
<style scoped lang='scss'>
//css部分
.mask {
position: fixed; //这里用固定定位,后面设置动画时才不受影响
top: 0;
height: 100%;
width: 100%;
background-color: rgba(167, 165, 165, 0.486);
opacity: 0.5;
z-index: 9;
}
.model-dialog {
position: absolute;
//让弹框居中显示
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #fff;
border-radius: 12px;
width: 600px;
height: 300px;
border: 1px solid #f5f5f5;
overflow: hidden;
z-index: 10; //这里注意层级要比mask大,覆盖它
}
.model-header {
position: relative;
height: 50px;
padding-left: 10px;
padding-top: 10px;
font-size: 20px;
line-height: 50px;
background-color: #f5f5f5;
border-bottom: 1px solid rgb(177, 176, 176);
}
.model-body {
height: 150px;
line-height: 150px;
font-size: 28px;
text-align: center;
background-color: #fff;
}
.model-footer {
background-color: #f5f5f5;
height: 100px;
text-align: center;
line-height: 100px;
}
.btn {
width: 180px;
height: 40px;
border-radius: 8px;
background-color: rgb(180, 103, 103);
color: #fff;
font-size: 18px;
border: none;
}
.icon-close {
position: absolute; //如果不加绝对布局,图表显示不出来
background-color: pink;
right: 15px;
top: 16px;
width: 30px;
height: 30px;
z-index: 10;
//background: url("../assets/icon-close.png") no-repeat;
background-size: contain;
}
//css部分
.mask {
position: fixed; //这里用固定定位,后面设置动画时才不受影响
top: 0;
height: 100%;
width: 100%;
background-color: rgba(167, 165, 165, 0.486);
opacity: 0.5;
z-index: 9;
}
.model-dialog {
position: absolute;
//让弹框居中显示
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #fff;
border-radius: 12px;
width: 600px;
height: 300px;
border: 1px solid #f5f5f5;
overflow: hidden;
z-index: 10; //这里注意层级要比mask大,覆盖它
}
.model-header {
position: relative;
height: 50px;
padding-left: 10px;
padding-top: 10px;
font-size: 20px;
line-height: 50px;
background-color: #f5f5f5;
border-bottom: 1px solid rgb(177, 176, 176);
}
.model-body {
height: 150px;
line-height: 150px;
font-size: 28px;
text-align: center;
background-color: #fff;
}
.model-footer {
background-color: #f5f5f5;
height: 100px;
text-align: center;
line-height: 100px;
}
.btn {
width: 180px;
height: 40px;
border-radius: 8px;
background-color: rgb(180, 103, 103);
color: #fff;
font-size: 18px;
border: none;
}
.icon-close {
position: absolute; //如果不加绝对布局,图表显示不出来
background-color: pink;
right: 15px;
top: 16px;
width: 30px;
height: 30px;
z-index: 10;
//background: url("../assets/icon-close.png") no-repeat;
background-size: contain;
}
</style>
\ No newline at end of file
......