From 3c98abe41ca031b537dbee845d7a79d4c07c2b5d Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 6 Jun 2025 22:49:12 +0800 Subject: [PATCH 1/6] =?UTF-8?q?perf:=20=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=A4=BA=E4=BE=8B=20demo01=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/infra/demo01.js | 8 ++ src/main.js | 9 +- src/utils/index.js | 53 ++++++++++-- .../infra/demo/demo01/Demo01ContactForm.vue | 7 +- src/views/infra/demo/demo01/index.vue | 84 +++++++++++++------ 5 files changed, 127 insertions(+), 34 deletions(-) diff --git a/src/api/infra/demo01.js b/src/api/infra/demo01.js index b3e5ac1..ffa72b5 100644 --- a/src/api/infra/demo01.js +++ b/src/api/infra/demo01.js @@ -26,6 +26,14 @@ export function deleteDemo01Contact(id) { }) } +/** 批量删除示例联系人 */ +export function deleteDemo01ContactList(ids) { + return request({ + url: `/infra/demo01-contact/delete-list?ids=${ids.join(',')}`, + method: 'delete' + }) +} + // 获得示例联系人 export function getDemo01Contact(id) { return request({ diff --git a/src/main.js b/src/main.js index 2061757..2e5e210 100644 --- a/src/main.js +++ b/src/main.js @@ -16,14 +16,15 @@ import './permission' // permission control import './tongji' // 百度统计 import { getDicts } from "@/api/system/dict/data"; import { getConfigKey } from "@/api/infra/config"; -import { parseTime, resetForm, handleTree, addBeginAndEndTime, divide} from "@/utils/ruoyi"; +import { parseTime, resetForm, handleTree, addBeginAndEndTime, divide } from "@/utils/ruoyi"; +import { isEmpty } from "@/utils"; import Pagination from "@/components/Pagination"; // 自定义表格工具扩展 import RightToolbar from "@/components/RightToolbar" // 代码高亮插件 // import hljs from 'highlight.js' // import 'highlight.js/styles/github-gist.css' -import {DICT_TYPE, getDictDataLabel, getDictDatas, getDictDatas2} from "@/utils/dict"; +import { DICT_TYPE, getDictDataLabel, getDictDatas, getDictDatas2 } from "@/utils/dict"; // 全局方法挂载 Vue.prototype.getDicts = getDicts @@ -37,6 +38,7 @@ Vue.prototype.DICT_TYPE = DICT_TYPE Vue.prototype.handleTree = handleTree Vue.prototype.addBeginAndEndTime = addBeginAndEndTime Vue.prototype.divide = divide +Vue.prototype.isEmpty = isEmpty // 全局组件挂载 Vue.component('DictTag', DictTag) @@ -56,6 +58,7 @@ Vue.use(VueMeta) // bpmnProcessDesigner 需要引入 import MyPD from "@/components/bpmnProcessDesigner/package/index.js"; + Vue.use(MyPD); import "@/components/bpmnProcessDesigner/package/theme/index.scss"; import "bpmn-js/dist/assets/diagram-js.css"; @@ -65,6 +68,7 @@ import "bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css"; // Form Generator 组件需要使用到 tinymce import Tinymce from '@/components/tinymce/index.vue' + Vue.component('tinymce', Tinymce) import '@/assets/icons' import request from "@/utils/request" // 实现 form generator 使用自己定义的 axios request 对象 @@ -74,6 +78,7 @@ import '@/styles/index.scss' // 默认点击背景不关闭弹窗 import ElementUI from 'element-ui' + ElementUI.Dialog.props.closeOnClickModal.default = false /** diff --git a/src/utils/index.js b/src/utils/index.js index 7a71498..03d708a 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,4 +1,4 @@ -import { parseTime } from './ruoyi' +import {parseTime} from './ruoyi' /** * 表格时间格式化 @@ -217,7 +217,7 @@ export function getTime(type) { export function debounce(func, wait, immediate) { let timeout, args, context, timestamp, result - const later = function() { + const later = function () { // 据上一次触发时间间隔 const last = +new Date() - timestamp @@ -234,7 +234,7 @@ export function debounce(func, wait, immediate) { } } - return function(...args) { + return function (...args) { context = this timestamp = +new Date() const callNow = immediate && !timeout @@ -294,9 +294,15 @@ export function deepClone(obj) { // RegExp if (_toString.call(obj) === '[object RegExp]') { const flags = [] - if (obj.global) { flags.push('g') } - if (obj.multiline) { flags.push('m') } - if (obj.ignoreCase) { flags.push('i') } + if (obj.global) { + flags.push('g') + } + if (obj.multiline) { + flags.push('m') + } + if (obj.ignoreCase) { + flags.push('i') + } return new RegExp(obj.source, flags.join('')) } @@ -438,3 +444,38 @@ export function toCamelCase(str, upperCaseFirst) { return str; } + +export const is = (val, type) => { + return toString.call(val) === `[object ${type}]` +} + +export function isString(val) { + return is(val, 'String') +} + +export function isArray(val) { + return val && Array.isArray(val) +} + +export function isObject(val) { + return val !== null && is(val, 'Object') +} + +export function isEmpty(val) { + if (val === null || val === undefined || typeof val === 'undefined') { + return true + } + if (isArray(val) || isString(val)) { + return val.length === 0 + } + + if (val instanceof Map || val instanceof Set) { + return val.size === 0 + } + + if (isObject(val)) { + return Object.keys(val).length === 0 + } + + return false +} diff --git a/src/views/infra/demo/demo01/Demo01ContactForm.vue b/src/views/infra/demo/demo01/Demo01ContactForm.vue index f3ec79f..1001534 100644 --- a/src/views/infra/demo/demo01/Demo01ContactForm.vue +++ b/src/views/infra/demo/demo01/Demo01ContactForm.vue @@ -8,8 +8,11 @@ - {{dict.label}} + + {{dict.label}} + diff --git a/src/views/infra/demo/demo01/index.vue b/src/views/infra/demo/demo01/index.vue index 0381be2..5d79856 100644 --- a/src/views/infra/demo/demo01/index.vue +++ b/src/views/infra/demo/demo01/index.vue @@ -7,16 +7,15 @@ - - - - - + 搜索 @@ -28,21 +27,44 @@ 新增 + v-hasPermi="['infra:demo01-contact:create']">新增 + + + + 导出 + - 导出 + + 批量删除 + - - - + + + + @@ -50,8 +72,8 @@ {{ parseTime(scope.row.birthday) }} - - + + @@ -100,15 +124,13 @@ export default { refreshTable: true, // 选中行 currentRow: {}, + checkedIds: [], // 查询参数 queryParams: { pageNo: 1, pageSize: 10, name: null, sex: null, - birthday: null, - description: null, - avatar: null, createTime: [], }, }; @@ -150,15 +172,29 @@ export default { await Demo01ContactApi.deleteDemo01Contact(id); await this.getList(); this.$modal.msgSuccess("删除成功"); - } catch {} + } catch { + } + }, + /** 批量删除示例联系人 */ + async handleDeleteBatch() { + await this.$modal.confirm('是否确认删除?') + try { + await Demo01ContactApi.deleteDemo01ContactList(this.checkedIds); + await this.getList(); + this.$modal.msgSuccess("删除成功"); + } catch { + } + }, + handleRowCheckboxChange(records) { + this.checkedIds = records.map((item) => item.id); }, /** 导出按钮操作 */ async handleExport() { await this.$modal.confirm('是否确认导出所有示例联系人数据项?'); try { this.exportLoading = true; - const res = await Demo01ContactApi.exportDemo01ContactExcel(this.queryParams); - this.$download.excel(res.data, '示例联系人.xls'); + const data = await Demo01ContactApi.exportDemo01ContactExcel(this.queryParams); + this.$download.excel(data, '示例联系人.xls'); } catch { } finally { this.exportLoading = false; -- Gitee From 938d0fbc4ffd1838f9d4d6dffb37218fdb615dc7 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 6 Jun 2025 22:59:22 +0800 Subject: [PATCH 2/6] =?UTF-8?q?perf:=20=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=A4=BA=E4=BE=8B=20inner=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/infra/demo03-inner.js | 26 +++--- .../demo/demo03/inner/Demo03StudentForm.vue | 17 ++-- .../inner/components/Demo03CourseForm.vue | 35 ++++---- .../inner/components/Demo03CourseList.vue | 35 ++++---- .../inner/components/Demo03GradeForm.vue | 31 +++---- .../inner/components/Demo03GradeList.vue | 37 +++++---- src/views/infra/demo/demo03/inner/index.vue | 83 ++++++++++++++----- 7 files changed, 162 insertions(+), 102 deletions(-) diff --git a/src/api/infra/demo03-inner.js b/src/api/infra/demo03-inner.js index 834522a..d30c153 100644 --- a/src/api/infra/demo03-inner.js +++ b/src/api/infra/demo03-inner.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // 创建学生 export function createDemo03Student(data) { return request({ - url: '/infra/demo03-student/create', + url: '/infra/demo03-student-inner/create', method: 'post', data: data }) @@ -12,7 +12,7 @@ export function createDemo03Student(data) { // 更新学生 export function updateDemo03Student(data) { return request({ - url: '/infra/demo03-student/update', + url: '/infra/demo03-student-inner/update', method: 'put', data: data }) @@ -21,7 +21,15 @@ export function updateDemo03Student(data) { // 删除学生 export function deleteDemo03Student(id) { return request({ - url: '/infra/demo03-student/delete?id=' + id, + url: '/infra/demo03-student-inner/delete?id=' + id, + method: 'delete' + }) +} + +/** 批量删除学生 */ +export function deleteDemo03StudentList(ids) { + return request({ + url: `/infra/demo03-student-inner/delete-list?ids=${ids.join(',')}`, method: 'delete' }) } @@ -29,7 +37,7 @@ export function deleteDemo03Student(id) { // 获得学生 export function getDemo03Student(id) { return request({ - url: '/infra/demo03-student/get?id=' + id, + url: '/infra/demo03-student-inner/get?id=' + id, method: 'get' }) } @@ -37,7 +45,7 @@ export function getDemo03Student(id) { // 获得学生分页 export function getDemo03StudentPage(params) { return request({ - url: '/infra/demo03-student/page', + url: '/infra/demo03-student-inner/page', method: 'get', params }) @@ -45,7 +53,7 @@ export function getDemo03StudentPage(params) { // 导出学生 Excel export function exportDemo03StudentExcel(params) { return request({ - url: '/infra/demo03-student/export-excel', + url: '/infra/demo03-student-inner/export-excel', method: 'get', params, responseType: 'blob' @@ -53,21 +61,19 @@ export function exportDemo03StudentExcel(params) { } // ==================== 子表(学生课程) ==================== - // 获得学生课程列表 export function getDemo03CourseListByStudentId(studentId) { return request({ - url: `/infra/demo03-student/demo03-course/list-by-student-id?studentId=` + studentId, + url: '/infra/demo03-student-inner/demo03-course/list-by-student-id?studentId=' + studentId, method: 'get' }) } // ==================== 子表(学生班级) ==================== - // 获得学生班级 export function getDemo03GradeByStudentId(studentId) { return request({ - url: `/infra/demo03-student/demo03-grade/get-by-student-id?studentId=` + studentId, + url: '/infra/demo03-student-inner/demo03-grade/get-by-student-id?studentId=' + studentId, method: 'get' }) } diff --git a/src/views/infra/demo/demo03/inner/Demo03StudentForm.vue b/src/views/infra/demo/demo03/inner/Demo03StudentForm.vue index 5d9f61a..4ead3dd 100644 --- a/src/views/infra/demo/demo03/inner/Demo03StudentForm.vue +++ b/src/views/infra/demo/demo03/inner/Demo03StudentForm.vue @@ -4,17 +4,19 @@ - + {{dict.label}} + >{{ dict.label }} + - + @@ -23,10 +25,10 @@ - + - +