refactor(components): 统一组件API规范并完善表单重置功能

- 将多个组件的props从具体属性名改为统一的value属性
- 为所有组件添加v-model支持,替换原有的具体属性绑定
- 统一实现resetField方法,确保表单重置功能一致性
- 修正组件内部数据绑定逻辑,使用innerValue替代直接修改prop
- 更新文档示例,将API参数说明改为value | v-model格式
- 为代码编辑器、富文本编辑器等组件添加input事件发射
- 调整文件上传组件的值类型定义,从Object改为String
- 移除废弃的maxLength回调方法,优化编辑器性能
- 重构双向绑定逻辑,确保父子组件数据同步正确性
- 为树形选择器添加ref引用以便操作内部实例
- 调整组件演示页面的导入路径和标签页名称结构
This commit is contained in:
2026-02-05 14:34:32 +08:00
parent 9adedc71a5
commit 882ac772d3
31 changed files with 218 additions and 120 deletions
@@ -199,7 +199,8 @@ export default {
*/ */
resetField() { resetField() {
this.dataSource = [] this.dataSource = []
this.$emit('input', this.dataSource) this.$emit('change', [])
this.$emit('input', [])
} }
} }
} }
@@ -18,6 +18,7 @@
/> />
</div> </div>
<el-tree <el-tree
ref="deptTree"
:data="deptData" :data="deptData"
:load="getDeptData" :load="getDeptData"
:props="defaultProps" :props="defaultProps"
@@ -45,8 +46,7 @@ export default {
return { return {
deptName: '', deptName: '',
deptData: [], deptData: [],
defaultProps: { children: 'children', label: 'name', isLeaf: 'leaf' }, defaultProps: { children: 'children', label: 'name', isLeaf: 'leaf' }
currentDept: null
} }
}, },
methods: { methods: {
@@ -74,7 +74,13 @@ export default {
// 绑定node-click事件 // 绑定node-click事件
this.$emit('node-click', value) this.$emit('node-click', value)
// 绑定form value // 绑定form value
this.$emit('change', value.id)
this.$emit('input', value.id) this.$emit('input', value.id)
},
resetField() {
this.$refs.deptTree.setCurrentNode(null)
this.$emit('change', null)
this.$emit('input', null)
} }
} }
} }
@@ -31,8 +31,8 @@ export default {
name: 'CuteFileUpload', name: 'CuteFileUpload',
props: { props: {
value: { value: {
type: Object, type: String,
required: true, required: false,
default: null default: null
}, },
/** /**
@@ -73,9 +73,10 @@ export default {
// console.error('response', response) // console.error('response', response)
// console.error('file', file) // console.error('file', file)
// console.error('fileList', fileList) // console.error('fileList', fileList)
this.value.fileUrl = response
// 绑定on-success事件 // 绑定on-success事件
this.$emit('on-success', response, file, fileList) this.$emit('on-success', response, file, fileList)
this.$emit('change', response)
this.$emit('input', response)
}, },
// 监听上传失败 // 监听上传失败
handleError(e, file, fileList) { handleError(e, file, fileList) {
@@ -83,6 +84,13 @@ export default {
KitMessage.Error(msg.message) KitMessage.Error(msg.message)
// 绑定on-error事件 // 绑定on-error事件
this.$emit('on-error', e, file, fileList) this.$emit('on-error', e, file, fileList)
this.$emit('change', null)
this.$emit('input', null)
},
resetField() {
this.$refs.upload.clearFiles()
this.$emit('change', null)
this.$emit('input', null)
} }
} }
} }
@@ -29,7 +29,7 @@ export default {
name: 'CuteFileUpload', name: 'CuteFileUpload',
props: { props: {
value: { value: {
type: Object, type: String,
required: true, required: true,
default: null default: null
}, },
@@ -70,9 +70,10 @@ export default {
// console.error('response', response) // console.error('response', response)
// console.error('file', file) // console.error('file', file)
// console.error('fileList', fileList) // console.error('fileList', fileList)
this.value.fileUrl = response
// 绑定on-success事件 // 绑定on-success事件
this.$emit('on-success', response, file, fileList) this.$emit('on-success', response, file, fileList)
this.$emit('change', response)
this.$emit('input', response)
}, },
// 监听上传失败 // 监听上传失败
handleError(e, file, fileList) { handleError(e, file, fileList) {
@@ -80,6 +81,13 @@ export default {
KitMessage.Error(msg.message) KitMessage.Error(msg.message)
// 绑定on-error事件 // 绑定on-error事件
this.$emit('on-error', e, file, fileList) this.$emit('on-error', e, file, fileList)
this.$emit('change', null)
this.$emit('input', null)
},
resetField() {
this.$refs.upload.clearFiles()
this.$emit('change', null)
this.$emit('input', null)
} }
} }
} }
@@ -6,7 +6,7 @@
--> -->
<template> <template>
<el-select <el-select
v-model="productLine" v-model="innerValue"
filterable filterable
clearable clearable
placeholder="请选择产品线" placeholder="请选择产品线"
@@ -33,22 +33,24 @@ export default {
props: { props: {
value: { value: {
type: String, type: String,
required: false,
default: null default: null
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
required: false,
default: false default: false
} }
}, },
data() { data() {
return { return {
deptOptions: [], deptOptions: [],
productLine: this.value innerValue: this.value
} }
}, },
watch: { watch: {
value(newVal) { value(newVal) {
this.productLine = newVal this.innerValue = newVal
} }
}, },
created() { created() {
@@ -64,7 +66,7 @@ export default {
}) })
}, },
handleChange(value) { handleChange(value) {
this.productLine = value this.innerValue = value
for (const item of this.deptOptions) { for (const item of this.deptOptions) {
if (item.value === value) { if (item.value === value) {
this.$emit('detail', item) this.$emit('detail', item)
@@ -75,6 +77,11 @@ export default {
this.$emit('change', value) this.$emit('change', value)
// 绑定form value // 绑定form value
this.$emit('input', value) this.$emit('input', value)
},
resetField() {
this.innerValue = null
this.$emit('change', null)
this.$emit('input', null)
} }
} }
} }
@@ -6,7 +6,7 @@
--> -->
<template> <template>
<el-cascader <el-cascader
v-model="productLine" v-model="innerValue"
:disabled="disabled" :disabled="disabled"
:options="deptOptions" :options="deptOptions"
style="width: 100%" style="width: 100%"
@@ -25,22 +25,24 @@ export default {
props: { props: {
value: { value: {
type: Array, type: Array,
required: false,
default: null default: null
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
required: false,
default: false default: false
} }
}, },
data() { data() {
return { return {
deptOptions: [], deptOptions: [],
productLine: this.value innerValue: this.value
} }
}, },
watch: { watch: {
value(newVal) { value(newVal) {
this.productLine = newVal this.innerValue = newVal
} }
}, },
created() { created() {
@@ -71,12 +73,17 @@ export default {
}) })
}, },
handleChange(value) { handleChange(value) {
this.productLine = value this.innerValue = value
// console.error('value', value) // console.error('value', value)
// 绑定change事件 // 绑定change事件
this.$emit('change', value) this.$emit('change', value)
// 绑定form value // 绑定form value
this.$emit('input', value) this.$emit('input', value)
},
resetField() {
this.innerValue = null
this.$emit('change', null)
this.$emit('input', null)
} }
} }
} }
@@ -6,7 +6,7 @@
--> -->
<template> <template>
<el-select <el-select
v-model="user" v-model="innerValue"
style="width: 100%" style="width: 100%"
filterable filterable
remote remote
@@ -41,21 +41,21 @@ export default {
}, },
data() { data() {
return { return {
user: [], innerValue: [],
loading: false, loading: false,
options: [] options: []
} }
}, },
watch: { watch: {
value(newVal) { value(newVal) {
this.user = newVal this.innerValue = newVal
} }
}, },
async mounted() { async created() {
const that = this const that = this
if (that.value && that.value.length > 0) { if (that.value) {
that.options = await CuteUserSelectApi.listMetadataByUsernames(that.value) that.options = await CuteUserSelectApi.listMetadataByUsernames([that.value])
that.users = that.value that.innerValue = that.value
} }
}, },
methods: { methods: {
@@ -81,6 +81,11 @@ export default {
this.$emit('change', value) this.$emit('change', value)
// 绑定form value // 绑定form value
this.$emit('input', value) this.$emit('input', value)
},
resetField() {
this.innerValue = null
this.$emit('change', null)
this.$emit('input', null)
} }
} }
} }
@@ -6,7 +6,7 @@
--> -->
<template> <template>
<el-select <el-select
v-model="users" v-model="innerValue"
style="width: 100%" style="width: 100%"
multiple multiple
filterable filterable
@@ -36,26 +36,28 @@ export default {
value: { value: {
type: Array, type: Array,
required: false, required: false,
default: null default: function() {
return []
}
} }
}, },
data() { data() {
return { return {
users: [], innerValue: [],
loading: false, loading: false,
options: [] options: []
} }
}, },
watch: { watch: {
value(newVal) { value(newVal) {
this.users = newVal this.innerValue = newVal
} }
}, },
async mounted() { async mounted() {
const that = this const that = this
if (that.value && that.value.length > 0) { if (that.value && that.value.length > 0) {
that.options = await CuteUserSelectApi.listMetadataByUsernames(that.value) that.options = await CuteUserSelectApi.listMetadataByUsernames(that.value)
that.users = that.value that.innerValue = that.value
} }
}, },
methods: { methods: {
@@ -81,6 +83,11 @@ export default {
this.$emit('change', value) this.$emit('change', value)
// 绑定form value // 绑定form value
this.$emit('input', value) this.$emit('input', value)
},
resetField() {
this.innerValue = []
this.$emit('change', [])
this.$emit('input', [])
} }
} }
} }
@@ -35,9 +35,9 @@ const SupportModeList = ['yaml', 'java', 'go', 'swift', 'dockerfile', 'groovy',
export default { export default {
name: 'CuteCodeEditor', name: 'CuteCodeEditor',
props: { props: {
content: { value: {
type: String, type: String,
required: true, required: false,
default: '' default: ''
}, },
height: { height: {
@@ -62,7 +62,7 @@ export default {
} }
}, },
watch: { watch: {
content(newVal, oldVal) { value(newVal, oldVal) {
const editorValue = this.editor.getValue() const editorValue = this.editor.getValue()
if (newVal !== editorValue) { if (newVal !== editorValue) {
this.editor.setValue(newVal) this.editor.setValue(newVal)
@@ -92,12 +92,14 @@ export default {
theme: 'darcula' theme: 'darcula'
}) })
this.editor.setSize('auto', this.height) this.editor.setSize('auto', this.height)
if (this.content) { if (this.value) {
this.editor.setValue(this.content) this.editor.setValue(this.value)
} }
this.editor.setOption('readOnly', this.readonly) this.editor.setOption('readOnly', this.readonly)
this.editor.on('change', cm => { this.editor.on('change', cm => {
this.$emit('change', cm.getValue()) const value = cm.getValue()
this.$emit('change', value)
this.$emit('input', value)
}) })
return return
} }
@@ -118,6 +120,8 @@ export default {
}, },
resetField() { resetField() {
this.editor.setValue('') this.editor.setValue('')
this.$emit('change', '')
this.$emit('input', '')
} }
} }
} }
@@ -8,7 +8,7 @@
<template> <template>
<mavon-editor <mavon-editor
ref="md" ref="md"
v-model="content" v-model="innerValue"
:style="`height: + ${height};overflow-y: hidden`" :style="`height: + ${height};overflow-y: hidden`"
:ishljs="true" :ishljs="true"
@imgAdd="imgAdd" @imgAdd="imgAdd"
@@ -30,7 +30,7 @@ export default {
mavonEditor mavonEditor
}, },
props: { props: {
content: { value: {
type: String, type: String,
required: true, required: true,
default: '' default: ''
@@ -38,7 +38,8 @@ export default {
}, },
data() { data() {
return { return {
height: document.documentElement.clientHeight - dynamicHeight + 'px' height: document.documentElement.clientHeight - dynamicHeight + 'px',
innerValue: ''
} }
}, },
computed: { computed: {
@@ -47,6 +48,11 @@ export default {
'baseApi' 'baseApi'
]) ])
}, },
watch: {
value(newVal) {
this.innerValue = newVal
}
},
mounted() { mounted() {
const that = this const that = this
window.onresize = () => { window.onresize = () => {
@@ -64,12 +70,17 @@ export default {
}, },
onChange(value, render) { onChange(value, render) {
this.$emit('change', value, render) this.$emit('change', value, render)
this.$emit('input', value)
}, },
onSave(value, render) { onSave(value, render) {
this.$emit('save', value, render) this.$emit('save', value, render)
this.$emit('change', value)
this.$emit('input', value)
}, },
resetField() { resetField() {
this.content = '' this.innerValue = ''
this.$emit('change', '')
this.$emit('input', '')
} }
} }
} }
@@ -6,20 +6,14 @@
* @description 使用方式:<cute-one-key-copy :content.sync="data" /> * @description 使用方式:<cute-one-key-copy :content.sync="data" />
--> -->
<template> <template>
<el-button <el-button v-clipboard:copy="value" v-clipboard:success="onCopy" v-clipboard:error="onError" size="small" icon="el-icon-document-copy" />
v-clipboard:copy="content"
v-clipboard:success="onCopy"
v-clipboard:error="onError"
size="small"
icon="el-icon-document-copy"
/>
</template> </template>
<script> <script>
export default { export default {
name: 'CuteOneKeyCopy', name: 'CuteOneKeyCopy',
props: { props: {
content: { value: {
type: String, type: String,
required: true, required: true,
default: '' default: ''
@@ -13,7 +13,7 @@
:mode="editMode" :mode="editMode"
/> />
<Editor <Editor
v-model="editValue" v-model="innerValue"
:style="`height: 500px;overflow-y: hidden`" :style="`height: 500px;overflow-y: hidden`"
:default-config="editorConfig" :default-config="editorConfig"
:mode="editMode" :mode="editMode"
@@ -44,7 +44,7 @@ export default {
required: false, required: false,
default: false default: false
}, },
content: { value: {
type: String, type: String,
required: false, required: false,
default: '' default: ''
@@ -80,7 +80,7 @@ export default {
// 'default' or 'simple' // 'default' or 'simple'
editMode: 'simple', editMode: 'simple',
editor: null, editor: null,
editValue: '' innerValue: ''
} }
}, },
computed: { computed: {
@@ -89,6 +89,11 @@ export default {
'baseApi' 'baseApi'
]) ])
}, },
watch: {
value(newVal) {
this.innerValue = newVal
}
},
methods: { methods: {
/** /**
* 编辑器创建完毕时的回调函数 * 编辑器创建完毕时的回调函数
@@ -97,7 +102,7 @@ export default {
onCreated(editor) { onCreated(editor) {
// 一定要用 Object.seal(), 否则会报错 // 一定要用 Object.seal(), 否则会报错
this.editor = Object.seal(editor) this.editor = Object.seal(editor)
this.editValue = this.content this.innerValue = this.value
}, },
/** /**
* 编辑器内容、选区变化时的回调函数 * 编辑器内容、选区变化时的回调函数
@@ -112,6 +117,7 @@ export default {
// 纯文本内容 // 纯文本内容
const text = editor.getText() const text = editor.getText()
this.$emit('change', html, text) this.$emit('change', html, text)
this.$emit('input', html)
}, },
/** /**
* 编辑器销毁时的回调函数。调用 editor.destroy() 即可销毁编辑器 * 编辑器销毁时的回调函数。调用 editor.destroy() 即可销毁编辑器
@@ -123,15 +129,6 @@ export default {
} }
editor.destroy() editor.destroy()
}, },
/**
* 编辑器内容达到最大长度时的回调函数(会导致卡顿)
* @param editor
*/
onMaxLength(editor) {
if (editor == null) {
return
}
},
/** /**
* 编辑器 focus 时的回调函数 * 编辑器 focus 时的回调函数
* @param editor * @param editor
@@ -211,6 +208,9 @@ export default {
return return
} }
this.editor.dangerouslyInsertHtml(html) this.editor.dangerouslyInsertHtml(html)
const content = this.getHtml()
this.$emit('change', content)
this.$emit('input', content)
}, },
/** /**
* 获取编辑器html内容 * 获取编辑器html内容
@@ -229,6 +229,9 @@ export default {
return return
} }
this.editor.clear() this.editor.clear()
const content = this.getHtml()
this.$emit('change', content)
this.$emit('input', content)
}, },
/** /**
* 撤销 * 撤销
@@ -238,6 +241,9 @@ export default {
return return
} }
this.editor.undo() this.editor.undo()
const content = this.getHtml()
this.$emit('change', content)
this.$emit('input', content)
}, },
/** /**
* 重做 * 重做
@@ -247,6 +253,9 @@ export default {
return return
} }
this.editor.redo() this.editor.redo()
const content = this.getText()
this.$emit('change', content)
this.$emit('input', content)
}, },
/** /**
* 获取选中的文本 * 获取选中的文本
@@ -265,6 +274,9 @@ export default {
return return
} }
this.editor.deleteFragment() this.editor.deleteFragment()
const content = this.getHtml()
this.$emit('change', content)
this.$emit('input', content)
}, },
/** /**
* 获取选中的内容。JSON格式 * 获取选中的内容。JSON格式
@@ -293,12 +305,16 @@ export default {
return return
} }
this.editor.insertText(text) this.editor.insertText(text)
const content = this.getHtml()
this.$emit('change', content)
this.$emit('input', content)
}, },
/** /**
* el-form重置联动 * el-form重置联动
*/ */
resetField() { resetField() {
this.setHtml('') this.clear()
this.$emit('change', '')
this.$emit('input', '') this.$emit('input', '')
} }
} }
@@ -6,7 +6,7 @@
--> -->
<template> <template>
<el-input <el-input
v-model="content" v-model="innerValue"
type="textarea" type="textarea"
:autosize="{ minRows: 1, maxRows: 5}" :autosize="{ minRows: 1, maxRows: 5}"
placeholder="请输入内容" placeholder="请输入内容"
@@ -50,12 +50,23 @@ export default {
}, },
data() { data() {
return { return {
content: this.value innerValue: ''
}
},
watch: {
value(newVal) {
this.innerValue = newVal
} }
}, },
methods: { methods: {
handleInput(value) { handleInput(value) {
this.$emit('change', value)
this.$emit('input', value) this.$emit('input', value)
},
resetField() {
this.innerValue = ''
this.$emit('change', '')
this.$emit('input', '')
} }
} }
} }
@@ -6,7 +6,6 @@
--> -->
<template> <template>
<el-row> <el-row>
<!-- <el-button @click="onTestValue">测试值</el-button>-->
<el-col :span="11"> <el-col :span="11">
<el-input <el-input
v-model="searchValue" v-model="searchValue"
@@ -96,6 +95,7 @@ export default {
*/ */
value: { value: {
type: Array, type: Array,
require: false,
default: function() { default: function() {
return [] return []
} }
@@ -115,7 +115,7 @@ export default {
*/ */
primaryKey: { primaryKey: {
type: String, type: String,
require: false, require: true,
default: 'id' default: 'id'
}, },
/** /**
@@ -139,8 +139,9 @@ export default {
searchCacheDS: [] searchCacheDS: []
} }
}, },
mounted() { watch: {
this.rightValues = this.value value(newVal) {
this.rightValues = newVal
this.leftDataSource = this.dataSource this.leftDataSource = this.dataSource
const key = this.primaryKey const key = this.primaryKey
@@ -159,6 +160,7 @@ export default {
} else { } else {
this.leftDataSource = leftDataSource this.leftDataSource = leftDataSource
} }
}
}, },
methods: { methods: {
onSearchValueChange(value) { onSearchValueChange(value) {
@@ -234,14 +236,24 @@ export default {
this.$emit('change', this.rightValues) this.$emit('change', this.rightValues)
this.$emit('input', this.rightValues) this.$emit('input', this.rightValues)
} }
},
/**
* el-form重置联动
*/
resetField() {
const searchCacheDS = this.searchCacheDS
if (searchCacheDS && searchCacheDS.length > 0) {
this.leftDataSource = [...searchCacheDS, ...this.rightDataSource]
this.searchCacheDS = []
} else {
this.leftDataSource = [...this.leftDataSource, ...this.rightDataSource]
}
this.searchValue = ''
this.leftSelection = []
this.rightSelection = []
this.rightDataSource = []
this.rightValues = []
} }
// onTestValue() {
// console.error('==============leftDataSource', this.leftDataSource)
// console.error('==============leftSelection', this.leftSelection)
// console.error('==============rightDataSource', this.rightDataSource)
// console.error('==============rightSelection', this.rightSelection)
// console.error('==============rightValues', this.rightValues)
// }
} }
} }
</script> </script>
@@ -44,9 +44,9 @@ export default {
dept: null dept: null
}, },
apiData: [ apiData: [
{ name: 'value', remark: '绑定的值', type: 'string', defaultValue: '-', required: '否' }, { name: 'value | v-model', remark: '绑定的值', type: 'string', defaultValue: '-', required: '否' },
{ name: 'node-click', remark: '部门节点发生改变的时候触发的回调', type: '(value) => {}', defaultValue: '-', required: '否' }, { name: 'search', remark: '搜索部门回调事件', type: '(value) => {}', defaultValue: '-', required: '否' },
{ name: 'search', remark: '搜索部门回调事件', type: '(value) => {}', defaultValue: '-', required: '否' } { name: 'node-click', remark: '部门节点发生改变的时候触发的回调', type: '(value) => {}', defaultValue: '-', required: '否' }
] ]
} }
}, },
@@ -18,7 +18,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="文件上传" prop="fileUrl"> <el-form-item label="文件上传" prop="fileUrl">
<cute-file-drag-upload v-model="form" mode="local" /> <cute-file-drag-upload v-model="form.fileUrl" mode="local" />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submitForm('form')">提 交</el-button> <el-button type="primary" @click="submitForm('form')">提 交</el-button>
@@ -37,7 +37,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="文件上传" prop="fileUrl" label-width="80px"> <el-form-item label="文件上传" prop="fileUrl" label-width="80px">
<cute-file-drag-upload v-model="form" mode="local" /> <cute-file-drag-upload v-model="form.fileUrl" mode="local" />
</el-form-item> </el-form-item>
</cute-form-dialog> </cute-form-dialog>
<h4>与CuteFormDrawer集成</h4> <h4>与CuteFormDrawer集成</h4>
@@ -53,7 +53,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="文件上传" prop="fileUrl" label-width="80px"> <el-form-item label="文件上传" prop="fileUrl" label-width="80px">
<cute-file-drag-upload v-model="form" mode="local" /> <cute-file-drag-upload v-model="form.fileUrl" mode="local" />
</el-form-item> </el-form-item>
</cute-form-drawer> </cute-form-drawer>
<h4>API</h4> <h4>API</h4>
@@ -83,7 +83,7 @@ export default {
fileUrl: '' fileUrl: ''
}, },
apiData: [ apiData: [
{ name: 'value', remark: '上传的文件路径', type: 'string', defaultValue: '-', required: '是' }, { name: 'value | v-model', remark: '上传的文件路径', type: 'string', defaultValue: '-', required: '否' },
{ name: 'mode', remark: '上传方式。local本地、oss对象存储', type: 'string', defaultValue: 'local', required: '否' } { name: 'mode', remark: '上传方式。local本地、oss对象存储', type: 'string', defaultValue: 'local', required: '否' }
] ]
} }
@@ -18,7 +18,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="文件上传" prop="fileUrl"> <el-form-item label="文件上传" prop="fileUrl">
<cute-file-upload v-model="form" mode="local" /> <cute-file-upload v-model="form.fileUrl" mode="local" />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submitForm('form')">提 交</el-button> <el-button type="primary" @click="submitForm('form')">提 交</el-button>
@@ -37,7 +37,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="文件上传" prop="fileUrl" label-width="80px"> <el-form-item label="文件上传" prop="fileUrl" label-width="80px">
<cute-file-upload v-model="form" mode="local" /> <cute-file-upload v-model="form.fileUrl" mode="local" />
</el-form-item> </el-form-item>
</cute-form-dialog> </cute-form-dialog>
<h4>与CuteFormDrawer集成</h4> <h4>与CuteFormDrawer集成</h4>
@@ -53,7 +53,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="文件上传" prop="fileUrl" label-width="80px"> <el-form-item label="文件上传" prop="fileUrl" label-width="80px">
<cute-file-upload v-model="form" mode="local" /> <cute-file-upload v-model="form.fileUrl" mode="local" />
</el-form-item> </el-form-item>
</cute-form-drawer> </cute-form-drawer>
<h4>API</h4> <h4>API</h4>
@@ -40,7 +40,7 @@ export default {
productLine: null productLine: null
}, },
apiData: [ apiData: [
{ name: 'value', remark: '绑定的值', type: 'string', defaultValue: '-', required: '否' }, { name: 'value | v-model', remark: '绑定的值', type: 'string', defaultValue: '-', required: '否' },
{ name: 'disabled', remark: '是否禁用', type: 'boolean', defaultValue: 'false', required: '否' }, { name: 'disabled', remark: '是否禁用', type: 'boolean', defaultValue: 'false', required: '否' },
{ name: 'change', remark: '产品线发生改变的时候触发的回调', type: '(value) => {}', defaultValue: '-', required: '否' }, { name: 'change', remark: '产品线发生改变的时候触发的回调', type: '(value) => {}', defaultValue: '-', required: '否' },
{ name: 'detail', remark: '产品线明细发生改变的时候触发的回调', type: '(value) => {}', defaultValue: '-', required: '否' } { name: 'detail', remark: '产品线明细发生改变的时候触发的回调', type: '(value) => {}', defaultValue: '-', required: '否' }
@@ -41,7 +41,7 @@ export default {
productLine: null productLine: null
}, },
apiData: [ apiData: [
{ name: 'value', remark: '绑定的值', type: 'string', defaultValue: '-', required: '否' } { name: 'value | v-model', remark: '绑定的值', type: 'string', defaultValue: '-', required: '否' }
] ]
} }
}, },
@@ -41,7 +41,7 @@ export default {
user: '' user: ''
}, },
apiData: [ apiData: [
{ name: 'value', remark: '绑定的值', type: 'string', defaultValue: '-', required: '否' }, { name: 'value | v-model', remark: '绑定的值', type: 'string', defaultValue: '-', required: '否' },
{ name: 'change', remark: '选中用户发生改变的时候触发的回调', type: '(value) => {}', defaultValue: '-', required: '否' } { name: 'change', remark: '选中用户发生改变的时候触发的回调', type: '(value) => {}', defaultValue: '-', required: '否' }
] ]
} }
@@ -42,7 +42,7 @@ export default {
user: [] user: []
}, },
apiData: [ apiData: [
{ name: 'value', remark: '绑定的值', type: 'array', defaultValue: '[]', required: '否' }, { name: 'value | v-model', remark: '绑定的值', type: 'array', defaultValue: '[]', required: '否' },
{ name: 'change', remark: '选中用户发生改变的时候触发的回调', type: '(value) => {}', defaultValue: '-', required: '否' } { name: 'change', remark: '选中用户发生改变的时候触发的回调', type: '(value) => {}', defaultValue: '-', required: '否' }
] ]
} }
@@ -6,9 +6,9 @@
<li>在使用过程中有任何问题,咨询 @Odboy(前端)</li> <li>在使用过程中有任何问题,咨询 @Odboy(前端)</li>
</ul> </ul>
<h4>Java编辑器</h4> <h4>Java编辑器</h4>
<cute-code-editor :content="javaContent" mode="java" @change="onJavaChange" /> <cute-code-editor v-model="javaContent" mode="java" @change="onJavaChange" />
<h4>Yaml编辑器</h4> <h4>Yaml编辑器</h4>
<cute-code-editor :content="yamlContent" mode="yaml" @change="onYamlChange" /> <cute-code-editor v-model="yamlContent" mode="yaml" @change="onYamlChange" />
<h4>API</h4> <h4>API</h4>
<el-table :data="apiData"> <el-table :data="apiData">
<el-table-column prop="name" label="参数" width="220" /> <el-table-column prop="name" label="参数" width="220" />
@@ -77,7 +77,7 @@ export default {
' # IMMEDIATE(立即): 当应用程序以"IMMEDIATE"模式关闭时,它会立即终止,而不管当前是否有任何活动任务或请求。这种方式适用于那些可以立即停止而不会造成严重问题的情况。\n' + ' # IMMEDIATE(立即): 当应用程序以"IMMEDIATE"模式关闭时,它会立即终止,而不管当前是否有任何活动任务或请求。这种方式适用于那些可以立即停止而不会造成严重问题的情况。\n' +
' shutdown: graceful\n', ' shutdown: graceful\n',
apiData: [ apiData: [
{ name: 'content', remark: '内容', type: 'string', defaultValue: '-', required: '是' }, { name: 'value | v-model', remark: '内容', type: 'string', defaultValue: '-', required: '否' },
{ name: 'height', remark: '编辑框高度', type: 'string', defaultValue: '500px', required: '否' }, { name: 'height', remark: '编辑框高度', type: 'string', defaultValue: '500px', required: '否' },
{ name: 'readonly', remark: '是否只读', type: 'boolean', defaultValue: 'false', required: '否' }, { name: 'readonly', remark: '是否只读', type: 'boolean', defaultValue: 'false', required: '否' },
{ name: 'mode', remark: '语法模式。支持:yaml | java | go | swift | dockerfile | groovy | lua | perl | python | ruby | sql | xml | vue', type: 'string', defaultValue: 'yaml', required: '否' }, { name: 'mode', remark: '语法模式。支持:yaml | java | go | swift | dockerfile | groovy | lua | perl | python | ruby | sql | xml | vue', type: 'string', defaultValue: 'yaml', required: '否' },
@@ -7,7 +7,7 @@
</ul> </ul>
<h4>基础用法</h4> <h4>基础用法</h4>
<cute-markdown <cute-markdown
:content="content" v-model="content"
@change="onChange" @change="onChange"
@save="onSave" @save="onSave"
/> />
@@ -38,20 +38,20 @@ export default {
'- HTML 标签;\n' + '- HTML 标签;\n' +
'- 流程图和序列图 \n', '- 流程图和序列图 \n',
apiData: [ apiData: [
{ name: 'content', remark: 'markdown格式内容', type: 'string', defaultValue: '-', required: '是' }, { name: 'value | v-model', remark: 'markdown格式内容', type: 'string', defaultValue: '-', required: '否' },
{ name: 'change', remark: '编辑区发生变化的回调事件', type: '(text, markdown) => {}', defaultValue: '-', required: '否' }, { name: 'change', remark: '编辑区发生变化的回调事件', type: '(markdown, html) => {}', defaultValue: '-', required: '否' },
{ name: 'save', remark: 'ctrl + s 的回调事件(保存按键,同样触发该回调)', type: '(text, markdown) => {}', defaultValue: '-', required: '否' } { name: 'save', remark: 'ctrl + s 的回调事件(保存按键,同样触发该回调)', type: '(markdown, html) => {}', defaultValue: '-', required: '否' }
] ]
} }
}, },
methods: { methods: {
onChange(text, markdown) { onChange(markdown, html) {
console.log('onChange:text', text)
console.log('onChange:markdown', markdown) console.log('onChange:markdown', markdown)
console.log('onChange:html', html)
}, },
onSave(text, markdown) { onSave(markdown, html) {
console.log('onSave:text', text)
console.log('onSave:markdown', markdown) console.log('onSave:markdown', markdown)
console.log('onSave:html', html)
} }
} }
} }
@@ -8,7 +8,8 @@
<h4>基础用法:clipboard版</h4> <h4>基础用法:clipboard版</h4>
<div id="btn" @click="copy">复制</div> <div id="btn" @click="copy">复制</div>
<h4>基础用法:OneKeyCopy组件版(推荐)</h4> <h4>基础用法:OneKeyCopy组件版(推荐)</h4>
<cute-one-key-copy :content.sync="msg" /> <!-- v-model 会自动绑定元素的 value 属性,并监听 input 事件(某些元素如复选框监听 change 事件)-->
<cute-one-key-copy v-model="msg" />
<h4>API</h4> <h4>API</h4>
<el-table :data="apiData"> <el-table :data="apiData">
<el-table-column prop="name" label="参数" width="220" /> <el-table-column prop="name" label="参数" width="220" />
@@ -30,7 +31,7 @@ export default {
return { return {
msg: '来复制我吧', msg: '来复制我吧',
apiData: [ apiData: [
{ name: 'content', remark: '待复制的内容', type: 'string', defaultValue: '-', required: '是' } { name: 'value | v-model', remark: '待复制的内容', type: 'string', defaultValue: '-', required: '否' }
] ]
} }
}, },
@@ -34,7 +34,7 @@ export default {
return { return {
content: '', content: '',
apiData: [ apiData: [
{ name: 'content', remark: '内容', type: 'string', defaultValue: '-', required: '是' }, { name: 'value | v-model', remark: '内容', type: 'string', defaultValue: '-', required: '否' },
{ name: 'readonly', remark: '是否只读', type: 'boolean', defaultValue: 'false', required: '否' }, { name: 'readonly', remark: '是否只读', type: 'boolean', defaultValue: 'false', required: '否' },
{ name: 'change', remark: '内容改变回调事件', type: '(html, text) => {}', defaultValue: '-', required: '否' }, { name: 'change', remark: '内容改变回调事件', type: '(html, text) => {}', defaultValue: '-', required: '否' },
{ name: 'focus', remark: '编辑器获得焦点回调事件', type: '(editor) => {}', defaultValue: '-', required: '否' }, { name: 'focus', remark: '编辑器获得焦点回调事件', type: '(editor) => {}', defaultValue: '-', required: '否' },
@@ -56,7 +56,7 @@ export default {
{ id: 18, name: '小王', description: '小王牛P' } { id: 18, name: '小王', description: '小王牛P' }
], ],
apiData: [ apiData: [
{ name: 'value', remark: '右侧已选值', type: 'array', defaultValue: '[]', required: '否' }, { name: 'value | v-model', remark: '右侧数据对象属性值集合', type: 'array', defaultValue: '[]', required: '否' },
{ name: 'dataSource', remark: '左侧表格数据', type: 'array', defaultValue: '[]', required: '是' }, { name: 'dataSource', remark: '左侧表格数据', type: 'array', defaultValue: '[]', required: '是' },
{ name: 'primary-key', remark: '取对象的哪个值作为value', type: 'string', defaultValue: 'id', required: '否' }, { name: 'primary-key', remark: '取对象的哪个值作为value', type: 'string', defaultValue: 'id', required: '否' },
{ name: 'loading', remark: '是否加载中', type: 'boolean', defaultValue: 'false', required: '是' }, { name: 'loading', remark: '是否加载中', type: 'boolean', defaultValue: 'false', required: '是' },
@@ -50,7 +50,7 @@
</el-collapse-item> </el-collapse-item>
</el-collapse> </el-collapse>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="快捷组件" name="kit"> <el-tab-pane label="快捷组件" name="util">
<el-collapse accordion> <el-collapse accordion>
<el-collapse-item title="信息提示 KitMessage" name="KitMessage"> <el-collapse-item title="信息提示 KitMessage" name="KitMessage">
<KitMessageDemo /> <KitMessageDemo />
@@ -130,10 +130,10 @@
import CutePage from '@/views/components/dev/CutePage.vue' import CutePage from '@/views/components/dev/CutePage.vue'
import CuteButtonDemo from '@/views/componentsDemo/dev/CuteButtonDemo.vue' import CuteButtonDemo from '@/views/componentsDemo/dev/CuteButtonDemo.vue'
import KitMessageDemo from '@/views/componentsDemo/dev/KitMessageDemo.vue' import KitMessageDemo from '@/views/componentsDemo/util/KitMessageDemo.vue'
import KitNotificationDemo from '@/views/componentsDemo/dev/KitNotificationDemo.vue' import KitNotificationDemo from '@/views/componentsDemo/util/KitNotificationDemo.vue'
import KitDialogDemo from '@/views/componentsDemo/dev/KitDialogDemo.vue' import KitDialogDemo from '@/views/componentsDemo/util/KitDialogDemo.vue'
import KitWsClientDemo from '@/views/componentsDemo/dev/KitWsClientDemo.vue' import KitWsClientDemo from '@/views/componentsDemo/util/KitWsClientDemo.vue'
import CuteLinkDemo from '@/views/componentsDemo/dev/CuteLinkDemo.vue' import CuteLinkDemo from '@/views/componentsDemo/dev/CuteLinkDemo.vue'
import CutePageDemo from '@/views/componentsDemo/dev/CutePageDemo.vue' import CutePageDemo from '@/views/componentsDemo/dev/CutePageDemo.vue'
import CuteNoDataDemo from '@/views/componentsDemo/dev/CuteNoDataDemo.vue' import CuteNoDataDemo from '@/views/componentsDemo/dev/CuteNoDataDemo.vue'