refactor(front): 优化组件功能和消息提示

- 修改部门树组件的值类型
- 优化文件上传组件的大小计算和消息提示
- 统一使用 CsMessage 组件进行消息提示
- 调整控制台日志输出级别
This commit is contained in:
2025-07-27 11:58:44 +08:00
parent 14460b1c9a
commit b6c93031c6
17 changed files with 60 additions and 48 deletions
@@ -30,7 +30,7 @@ export default {
name: 'CuteDeptTree', name: 'CuteDeptTree',
props: { props: {
value: { value: {
type: Object, type: [Number, String],
required: false, required: false,
default: null default: null
} }
@@ -68,9 +68,11 @@ export default {
}) })
}, 100) }, 100)
}, },
handleNodeClick(data) { handleNodeClick(value) {
this.$emit('node-click', data) // 绑定node-click事件
this.$emit('input', data) this.$emit('node-click', value)
// 绑定form value
this.$emit('input', value.id)
} }
} }
} }
@@ -17,9 +17,9 @@
</template> </template>
<script> <script>
import { Message } from 'element-ui'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import CsMessage from '@/utils/elementui/CsMessage'
export default { export default {
name: 'CuteFileUpload', name: 'CuteFileUpload',
@@ -44,7 +44,7 @@ export default {
methods: { methods: {
beforeUpload(file) { beforeUpload(file) {
let isLt2M = true let isLt2M = true
isLt2M = file.size / 1024 / 1024 < 100 isLt2M = file.size / 1024 ** 2 < 100
if (!isLt2M) { if (!isLt2M) {
this.$message.error('上传文件大小不能超过 100MB') this.$message.error('上传文件大小不能超过 100MB')
return false return false
@@ -53,17 +53,21 @@ export default {
}, },
// 监听上传失成功 // 监听上传失成功
handleSuccess(response, file, fileList) { handleSuccess(response, file, fileList) {
// Message.success('上传成功') CsMessage.Success('上传成功')
// this.$refs.upload.clearFiles() // this.$refs.upload.clearFiles()
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 this.value.fileUrl = response
// 绑定on-success事件
this.$emit('on-success', response, file, fileList)
}, },
// 监听上传失败 // 监听上传失败
handleError(e, file, fileList) { handleError(e, file, fileList) {
const msg = JSON.parse(e.message) const msg = JSON.parse(e.message)
Message.error(msg.message) CsMessage.Error(msg.message)
// 绑定on-error事件
this.$emit('on-error', e, file, fileList)
} }
} }
} }
@@ -15,9 +15,9 @@
</template> </template>
<script> <script>
import { Message } from 'element-ui'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import CsMessage from '@/utils/elementui/CsMessage'
export default { export default {
name: 'CuteFileUpload', name: 'CuteFileUpload',
@@ -42,7 +42,7 @@ export default {
methods: { methods: {
beforeUpload(file) { beforeUpload(file) {
let isLt2M = true let isLt2M = true
isLt2M = file.size / 1024 / 1024 < 100 isLt2M = file.size / 1024 ** 2 < 100
if (!isLt2M) { if (!isLt2M) {
this.$message.error('上传文件大小不能超过 100MB') this.$message.error('上传文件大小不能超过 100MB')
return false return false
@@ -51,17 +51,20 @@ export default {
}, },
// 监听上传失成功 // 监听上传失成功
handleSuccess(response, file, fileList) { handleSuccess(response, file, fileList) {
// Message.success('上传成功')
// this.$refs.upload.clearFiles() // this.$refs.upload.clearFiles()
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 this.value.fileUrl = response
// 绑定on-success事件
this.$emit('on-success', response, file, fileList)
}, },
// 监听上传失败 // 监听上传失败
handleError(e, file, fileList) { handleError(e, file, fileList) {
const msg = JSON.parse(e.message) const msg = JSON.parse(e.message)
Message.error(msg.message) CsMessage.Error(msg.message)
// 绑定on-error事件
this.$emit('on-error', e, file, fileList)
} }
} }
} }
@@ -59,7 +59,10 @@ export default {
}) })
}, },
onChange(value) { onChange(value) {
// 绑定change事件
this.$emit('change', value) this.$emit('change', value)
// 绑定form value
this.$emit('input', value)
} }
} }
} }
@@ -26,7 +26,7 @@ import 'codemirror/mode/ruby/ruby'
import 'codemirror/mode/sql/sql' import 'codemirror/mode/sql/sql'
import 'codemirror/mode/vue/vue' import 'codemirror/mode/vue/vue'
import 'codemirror/mode/xml/xml' import 'codemirror/mode/xml/xml'
import { Message } from 'element-ui' import CsMessage from '@/utils/elementui/CsMessage'
const SupportModeList = ['yaml', 'java', 'go', 'swift', 'dockerfile', 'groovy', 'lua', 'perl', 'python', 'ruby', 'sql', 'xml', 'vue'] const SupportModeList = ['yaml', 'java', 'go', 'swift', 'dockerfile', 'groovy', 'lua', 'perl', 'python', 'ruby', 'sql', 'xml', 'vue']
export default { export default {
@@ -98,7 +98,7 @@ export default {
}) })
return return
} }
Message.error('不支持的mode') CsMessage.Error('不支持的mode')
}, },
methods: { methods: {
getValue() { getValue() {
@@ -309,7 +309,7 @@ export default {
CsMessage.Warning('当前流水线节点不支持查看明细') CsMessage.Warning('当前流水线节点不支持查看明细')
return return
} }
console.error('templateData', this.templateData) console.log('templateData', this.templateData)
this.$refs.detailDrawer.show() this.$refs.detailDrawer.show()
}, },
onNodeRetryClick() { onNodeRetryClick() {
@@ -327,7 +327,7 @@ export default {
this.$emit('retry', data) this.$emit('retry', data)
}, },
onNodeOperationClick(buttonInfo) { onNodeOperationClick(buttonInfo) {
console.error('buttonInfo', buttonInfo) console.log('buttonInfo', buttonInfo)
} }
} }
} }
@@ -27,9 +27,9 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import '@wangeditor/editor/dist/css/style.css' import '@wangeditor/editor/dist/css/style.css'
import { Message } from 'element-ui'
import { Editor, Toolbar } from '@wangeditor/editor-for-vue' import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
import { UploadFile } from '@/utils/CsDomUtil' import { UploadFile } from '@/utils/CsDomUtil'
import CsMessage from '@/utils/elementui/CsMessage'
export default { export default {
name: 'CuteRichTextEditor', name: 'CuteRichTextEditor',
@@ -155,19 +155,19 @@ export default {
customAlert(info, type) { customAlert(info, type) {
switch (type) { switch (type) {
case 'success': case 'success':
Message.success(info) CsMessage.Error(info)
break break
case 'info': case 'info':
Message.info(info) CsMessage.Info(info)
break break
case 'warning': case 'warning':
Message.warning(info) CsMessage.Warning(info)
break break
case 'error': case 'error':
Message.error(info) CsMessage.Error(info)
break break
default: default:
Message.info(info) CsMessage.Info(info)
break break
} }
}, },
@@ -40,7 +40,7 @@ export default {
const that = this const that = this
that.$refs[formName].validate((valid) => { that.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
console.error('submitForm:form', that.form) console.log('submitForm:form', that.form)
} else { } else {
return false return false
} }
@@ -40,7 +40,7 @@ export default {
const that = this const that = this
that.$refs[formName].validate((valid) => { that.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
console.error('submitForm:form', that.form) console.log('submitForm:form', that.form)
} else { } else {
return false return false
} }
@@ -39,7 +39,7 @@ export default {
}, },
methods: { methods: {
onChange(value) { onChange(value) {
console.error('onChange', value) console.log('onChange', value)
} }
} }
} }
@@ -26,12 +26,12 @@ export default {
}, },
methods: { methods: {
onChange(text, markdown) { onChange(text, markdown) {
console.error('onChange:text', text) console.log('onChange:text', text)
console.error('onChange:markdown', markdown) console.log('onChange:markdown', markdown)
}, },
onSave(text, markdown) { onSave(text, markdown) {
console.error('onSave:text', text) console.log('onSave:text', text)
console.error('onSave:markdown', markdown) console.log('onSave:markdown', markdown)
} }
} }
} }
@@ -9,8 +9,8 @@
</template> </template>
<script> <script>
import Clipboard from 'clipboard' import Clipboard from 'clipboard'
import { Message } from 'element-ui'
import CuteOneKeyCopy from '@/views/components/dev/CuteOneKeyCopy' import CuteOneKeyCopy from '@/views/components/dev/CuteOneKeyCopy'
import CsMessage from '@/utils/elementui/CsMessage'
export default { export default {
components: { CuteOneKeyCopy }, components: { CuteOneKeyCopy },
@@ -32,13 +32,13 @@ export default {
}) })
// 复制成功 // 复制成功
clipboard.on('success', (e) => { clipboard.on('success', (e) => {
Message.success('复制成功') CsMessage.Success('复制成功')
console.log(e, '复制成功') console.log(e, '复制成功')
clipboard.destroy() clipboard.destroy()
}) })
// //复制失败 // //复制失败
clipboard.on('error', (e) => { clipboard.on('error', (e) => {
Message.error('复制失败') CsMessage.Error('复制失败')
console.log(e, '复制失败') console.log(e, '复制失败')
clipboard.destroy() clipboard.destroy()
}) })
@@ -22,8 +22,8 @@ export default {
}, },
methods: { methods: {
onChange(html, text) { onChange(html, text) {
console.error('onChange:html', html) console.log('onChange:html', html)
console.error('onChange:text', text) console.log('onChange:text', text)
} }
} }
} }
@@ -171,13 +171,13 @@ export default {
this.$refs.dialogForm.show() this.$refs.dialogForm.show()
}, },
onDialogFormSubmit(values) { onDialogFormSubmit(values) {
console.error('onDialogFormSubmit', values) console.log('onDialogFormSubmit', values)
}, },
onDrawerClick() { onDrawerClick() {
this.$refs.drawerFrom.show() this.$refs.drawerFrom.show()
}, },
onDrawerFormSubmit(values) { onDrawerFormSubmit(values) {
console.error('onDrawerFormSubmit', values) console.log('onDrawerFormSubmit', values)
} }
} }
} }
@@ -248,7 +248,7 @@ export default {
}, },
methods: { methods: {
onChange(value) { onChange(value) {
console.error('onChange', value) console.log('onChange', value)
} }
} }
} }
@@ -166,7 +166,7 @@ export default {
}, },
beforeUpload(file) { beforeUpload(file) {
let isLt2M = true let isLt2M = true
isLt2M = file.size / 1024 / 1024 < 100 isLt2M = file.size / 1024 ** 2 < 100
if (!isLt2M) { if (!isLt2M) {
this.loading = false this.loading = false
this.$message.error('上传文件大小不能超过 100MB') this.$message.error('上传文件大小不能超过 100MB')
@@ -101,7 +101,7 @@ import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination' import pagination from '@crud/Pagination'
import DateRangePicker from '@/components/DateRangePicker' import DateRangePicker from '@/components/DateRangePicker'
import Clipboard from 'clipboard' import Clipboard from 'clipboard'
import { Message } from 'element-ui' import CsMessage from '@/utils/elementui/CsMessage'
const defaultForm = { id: null } const defaultForm = { id: null }
export default { export default {
@@ -137,7 +137,7 @@ export default {
}, },
beforeUpload(file) { beforeUpload(file) {
let isLt2M = true let isLt2M = true
isLt2M = file.size / 1024 / 1024 < 100 isLt2M = file.size / 1024 ** 2 < 100
if (!isLt2M) { if (!isLt2M) {
this.loading = false this.loading = false
this.$message.error('上传文件大小不能超过 100MB') this.$message.error('上传文件大小不能超过 100MB')
@@ -169,12 +169,12 @@ export default {
}) })
// 复制成功 // 复制成功
clipboard.on('success', (e) => { clipboard.on('success', (e) => {
Message.success('复制成功') CsMessage.Success('复制成功')
clipboard.destroy() clipboard.destroy()
}) })
// //复制失败 // //复制失败
clipboard.on('error', (e) => { clipboard.on('error', (e) => {
Message.error('复制失败') CsMessage.Error('复制失败')
clipboard.destroy() clipboard.destroy()
}) })
} }