Skip to content

Commit

Permalink
perf: 移除MessageBox,Message引入,减小40k左右的打包大小
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Mar 12, 2021
1 parent 845defa commit f4794cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 61 deletions.
24 changes: 10 additions & 14 deletions src/component/crud-table/src/CrudTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ import {
import VueCompositionApi, {
reactive, computed, ref, defineComponent, Ref, watch,
} from '@vue/composition-api';
import { Message, MessageBox } from 'element-ui';
import GenerateFormDialog from './GenerateFormDialog.vue';
import ProTable from '../../pro-table';
import { CrudTableProps } from '../types/CrudTable.types';
Expand Down Expand Up @@ -254,7 +253,9 @@ export default defineComponent({
setup(props: CrudTableProps, {
listeners, attrs, emit, root,
}) {
const { $PROCRUD } = root;
const {
$PROCRUD, $message, $alert, $confirm,
} = root;

// 当前行
let currentRow = reactive<any>({});
Expand Down Expand Up @@ -399,9 +400,6 @@ export default defineComponent({
};
};

const ElMessage = Message;
const ElMessageBox = MessageBox;

// 增删改查按钮方法定义
const handlerButtonMethods = {
// 添加
Expand Down Expand Up @@ -493,7 +491,7 @@ export default defineComponent({
btnDeletesOnClick() {
const { length } = selectedRows.value || [];
if (length > 0) {
ElMessageBox.confirm(`已选中${length}项,确认删除?`, '提示', {
$confirm(`已选中${length}项,确认删除?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
Expand All @@ -508,22 +506,20 @@ export default defineComponent({
);
promiseForDels.then(() => {
tableReload();
ElMessage.success('批量删除成功');
$message.success('批量删除成功');
});
})
.catch(() => {
ElMessage.info('已取消删除');
$message.info('已取消删除');
});
} else {
console.log(ElMessage);

ElMessage('请先选择删除项');
$message.info('请先选择删除项');
}
},

// 操作列-删除
actionColumnDel(row) {
ElMessageBox.confirm('确认删除?', '提示', {
$confirm('确认删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
Expand All @@ -534,14 +530,14 @@ export default defineComponent({
const promiseForDel = props.promiseForDel ? props.promiseForDel(row.id) : $PROCRUD.crud(DML.DELETE, props.tableName, {}, { id: row.id });
promiseForDel.then(() => {
tableReload();
ElMessage({
$alert({
type: 'success',
message: '删除成功',
});
});
})
.catch(() => {
ElMessage.info('已取消删除');
$message.info('已取消删除');
});
},

Expand Down
47 changes: 0 additions & 47 deletions src/utils/confirm.ts

This file was deleted.

0 comments on commit f4794cd

Please sign in to comment.