mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 00:29:19 +08:00
prettier: 代码格式化
This commit is contained in:
+34
-21
@@ -1,11 +1,13 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { Form, Input, Modal, Select, message, Switch } from 'ant-design-vue';
|
||||
import type { PositionVO } from '#/api/organization/position';
|
||||
|
||||
import {
|
||||
createPositionApi,
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Form, Input, message, Modal, Select, Switch } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
createPositionApi,
|
||||
updatePositionApi,
|
||||
type PositionVO
|
||||
} from '#/api/organization/position';
|
||||
|
||||
interface Props {
|
||||
@@ -25,7 +27,7 @@ const formRef = ref();
|
||||
const loading = ref(false);
|
||||
const visible = ref(false);
|
||||
const isEdit = ref(false);
|
||||
const currentPositionData = ref<PositionVO.PositionInfoVO | null>(null);
|
||||
const currentPositionData = ref<null | PositionVO.PositionInfoVO>(null);
|
||||
|
||||
// 内部表单数据类型
|
||||
interface FormData {
|
||||
@@ -48,7 +50,7 @@ const formData = ref<FormData>({
|
||||
// 开关组件不需要选项数组
|
||||
|
||||
// 模态框标题
|
||||
const modalTitle = computed(() => isEdit.value ? '编辑岗位' : '添加岗位');
|
||||
const modalTitle = computed(() => (isEdit.value ? '编辑岗位' : '添加岗位'));
|
||||
|
||||
// 重置表单
|
||||
function resetForm() {
|
||||
@@ -72,13 +74,13 @@ async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
loading.value = true;
|
||||
|
||||
|
||||
// 转换boolean值为number值
|
||||
const submitData = {
|
||||
...formData.value,
|
||||
status: formData.value.status ? 1 : 0
|
||||
status: formData.value.status ? 1 : 0,
|
||||
};
|
||||
|
||||
|
||||
if (isEdit.value && currentPositionData.value) {
|
||||
await updatePositionApi(currentPositionData.value.id, submitData);
|
||||
message.success('更新成功');
|
||||
@@ -86,7 +88,7 @@ async function handleSubmit() {
|
||||
await createPositionApi(submitData);
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
|
||||
visible.value = false;
|
||||
emit('success');
|
||||
} catch (error) {
|
||||
@@ -98,12 +100,15 @@ async function handleSubmit() {
|
||||
}
|
||||
|
||||
// 暴露给父组件的方法
|
||||
function open(editMode: boolean = false, positionData?: PositionVO.PositionInfoVO | null) {
|
||||
function open(
|
||||
editMode: boolean = false,
|
||||
positionData?: null | PositionVO.PositionInfoVO,
|
||||
) {
|
||||
isEdit.value = editMode;
|
||||
currentPositionData.value = positionData || null;
|
||||
|
||||
|
||||
resetForm();
|
||||
|
||||
|
||||
if (editMode && positionData) {
|
||||
formData.value = {
|
||||
name: positionData.name,
|
||||
@@ -113,7 +118,7 @@ function open(editMode: boolean = false, positionData?: PositionVO.PositionInfoV
|
||||
status: positionData.status === 1, // 转换为boolean
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
visible.value = true;
|
||||
}
|
||||
|
||||
@@ -138,14 +143,18 @@ defineExpose({
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item label="岗位名称" name="name" :rules="[{ required: true, message: '请输入岗位名称' }]">
|
||||
<Form.Item
|
||||
label="岗位名称"
|
||||
name="name"
|
||||
:rules="[{ required: true, message: '请输入岗位名称' }]"
|
||||
>
|
||||
<Input v-model:value="formData.name" placeholder="请输入岗位名称" />
|
||||
</Form.Item>
|
||||
|
||||
|
||||
<Form.Item label="岗位编码" name="code">
|
||||
<Input v-model:value="formData.code" placeholder="请输入岗位编码" />
|
||||
</Form.Item>
|
||||
|
||||
|
||||
<Form.Item label="所属部门" name="departmentId">
|
||||
<Select
|
||||
v-model:value="formData.departmentId"
|
||||
@@ -154,11 +163,15 @@ defineExpose({
|
||||
allow-clear
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
|
||||
<Form.Item label="描述" name="remark">
|
||||
<Input.TextArea v-model:value="formData.remark" placeholder="请输入岗位描述" :rows="3" />
|
||||
<Input.TextArea
|
||||
v-model:value="formData.remark"
|
||||
placeholder="请输入岗位描述"
|
||||
:rows="3"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
|
||||
<Form.Item label="状态" name="status">
|
||||
<Switch
|
||||
v-model:checked="formData.status"
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { PositionDTO, PositionVO } from '#/api/organization/position';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { Button, message, Space, Tag } from 'ant-design-vue';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import {
|
||||
deletePositionApi,
|
||||
import { Button, message, Space, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deletePositionApi,
|
||||
getPositionPageApi,
|
||||
type PositionVO,
|
||||
type PositionDTO
|
||||
} from '#/api/organization/position';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import PositionModal from './components/PositionModal.vue';
|
||||
|
||||
defineOptions({ name: 'PositionManagement' });
|
||||
|
||||
// 创建图标组件
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
|
||||
defineOptions({ name: 'PositionManagement' });
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const positionModalRef = ref();
|
||||
@@ -106,7 +108,25 @@ const gridOptions: VxeGridProps<any> = {
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
layouts: ['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total'] as ('PrevJump' | 'PrevPage' | 'Number' | 'NextPage' | 'NextJump' | 'Sizes' | 'FullJump' | 'Total')[],
|
||||
layouts: [
|
||||
'PrevJump',
|
||||
'PrevPage',
|
||||
'Number',
|
||||
'NextPage',
|
||||
'NextJump',
|
||||
'Sizes',
|
||||
'FullJump',
|
||||
'Total',
|
||||
] as (
|
||||
| 'FullJump'
|
||||
| 'NextJump'
|
||||
| 'NextPage'
|
||||
| 'Number'
|
||||
| 'PrevJump'
|
||||
| 'PrevPage'
|
||||
| 'Sizes'
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
// 配置远程加载
|
||||
proxyConfig: {
|
||||
@@ -221,9 +241,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
</template>
|
||||
|
||||
<!-- VbenVxeGrid 表格 -->
|
||||
<Grid
|
||||
:loading="loading"
|
||||
>
|
||||
<Grid :loading="loading">
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
@@ -238,7 +256,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<template #department="{ row }: { row: any }">
|
||||
<span v-if="!row.departmentId">-</span>
|
||||
<span v-else>
|
||||
{{ departmentOptions.find(d => d.value === row.departmentId)?.label || '未知部门' }}
|
||||
{{
|
||||
departmentOptions.find((d) => d.value === row.departmentId)
|
||||
?.label || '未知部门'
|
||||
}}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
@@ -252,12 +273,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }: { row: any }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)">
|
||||
编辑
|
||||
</Button>
|
||||
<Button size="small" danger @click="handleDelete(row)">
|
||||
删除
|
||||
</Button>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Button size="small" danger @click="handleDelete(row)"> 删除 </Button>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user