Skip to content

Commit

Permalink
feat: 表格列设置工具栏
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Dec 16, 2021
1 parent e5ba20a commit 061c6ed
Show file tree
Hide file tree
Showing 15 changed files with 366 additions and 191 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"typescript.tsdk": "./node_modules/typescript/lib",
"volar.tsPlugin": true,
"volar.tsPluginStatus": false,
"npm.packageManager": "pnpm",
"npm.packageManager": "yarn",
"editor.tabSize": 2,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.eol": "\n",
Expand Down Expand Up @@ -107,4 +107,4 @@
"vue",
"react"
]
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@vueuse/core": "^7.3.0",
"ant-design-vue": "3.0.0-alpha.15",
"axios": "^0.24.0",
"core-js": "^3.19.3",
"core-js": "^3.20.0",
"dayjs": "^1.10.7",
"lodash": "^4.17.21",
"mitt": "^3.0.0",
Expand All @@ -35,7 +35,7 @@
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"@types/lodash": "^4.14.178",
"@types/node": "^16.11.13",
"@types/node": "^17.0.0",
"@types/webpack-env": "^1.16.3",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
Expand All @@ -50,7 +50,7 @@
"babel-plugin-import": "^1.13.3",
"babel-plugin-lodash": "^3.3.4",
"commitizen": "^4.2.4",
"compression-webpack-plugin": "^9.1.2",
"compression-webpack-plugin": "^9.2.0",
"eslint": "^8.4.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
Expand Down
63 changes: 20 additions & 43 deletions src/api/system/user/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { request } from '@/utils/request';
import Api from '@/core/permission/modules/sys/user';
import { generatePermCode } from '@/core/permission/modules';

export function getUserListPage(data: API.PageParams<{ departmentIds: number[] }>) {
return request<API.TableListResult<API.UserListPageResult>>(
{
url: Api.page,
method: 'post',
data,
},
{
permCode: generatePermCode(Api.page),
},
);
return request<API.TableListResult<API.UserListPageResult>>({
url: Api.page,
method: 'post',
data,
});
}

export function createUser(data: API.CreateUserParams) {
Expand All @@ -23,23 +17,17 @@ export function createUser(data: API.CreateUserParams) {
data,
},
{
permCode: generatePermCode(Api.add),
successMsg: '创建用户成功',
},
);
}

export function getUserInfo(query: { userId: number }) {
return request<API.AdminUserInfo>(
{
url: Api.info,
method: 'get',
params: query,
},
{
permCode: generatePermCode(Api.info),
},
);
return request<API.AdminUserInfo>({
url: Api.info,
method: 'get',
params: query,
});
}

export function updateUser(data: API.UpdateAdminInfoParams) {
Expand All @@ -50,34 +38,23 @@ export function updateUser(data: API.UpdateAdminInfoParams) {
data,
},
{
permCode: generatePermCode(Api.update),
successMsg: '修改用户成功',
},
);
}

export function updateUserPassword(data: API.UpdateAdminUserPassword) {
return request(
{
url: Api.password,
method: 'post',
data,
},
{
permCode: generatePermCode(Api.password),
},
);
return request({
url: Api.password,
method: 'post',
data,
});
}

export function deleteUsers(data: { userIds: number[] }) {
return request(
{
url: Api.delete,
method: 'post',
data,
},
{
permCode: generatePermCode(Api.delete),
},
);
return request({
url: Api.delete,
method: 'post',
data,
});
}
6 changes: 6 additions & 0 deletions src/components/basic/BasicHelp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,9 @@
},
});
</script>

<style lang="less">
.basic-help__wrap p {
margin-bottom: 0;
}
</style>
56 changes: 56 additions & 0 deletions src/components/check-box/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<Checkbox v-bind="getProps" v-model:checked="checkedModel" @change="handleChange">
<slot></slot>
</Checkbox>
</template>

<script lang="ts">
export default {
inheritAttrs: false,
};
</script>

<script lang="ts" setup>
import { computed } from 'vue';
import { Checkbox } from 'ant-design-vue';
import { checkboxProps } from 'ant-design-vue/lib/checkbox';
import { omit } from 'lodash';
const props = defineProps({
...checkboxProps(),
trueValue: {
type: [Number, Boolean, String],
default: true,
},
falseValue: {
type: [Number, Boolean, String],
default: false,
},
});
const emit = defineEmits(['update:checked', 'change']);
const getProps = computed(() => {
return omit(props, ['onUpdate:checked', 'onChange']);
});
const checkedModel = computed<boolean>({
get() {
return props.checked === props.trueValue;
},
set(val) {
emit('update:checked', val ? props.trueValue : props.falseValue);
},
});
const handleChange = (e) => {
const evt = {
...e,
target: {
...e.target,
checked: e.target.checked ? props.trueValue : props.falseValue,
},
};
emit('change', evt);
};
</script>
Loading

0 comments on commit 061c6ed

Please sign in to comment.