Commit 59679b5f authored by baiyinhao's avatar baiyinhao

修改页面

parent 3cc9e1ed
This diff is collapsed.
<template>
<BasicModal width="40%" v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
<BasicModal
width="40%"
v-bind="$attrs"
@register="registerModal"
:title="getTitle"
@ok="handleSubmit"
>
<BasicForm @register="registerForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import {ref, computed, unref, reactive} from 'vue';
import { ref, computed, unref, reactive } from 'vue';
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
import { accountFormSchema } from './institution.data';
import { getDeptList } from '@/api/system/dept/dept';
import {addUserApi,UserDetailApi,UserUpdataApi} from '@/api/system/user/user'
import { encryptTwo } from '../../../../src/utils/jsencrypt.js'
import { addUserApi, UserDetailApi, UserUpdataApi } from '@/api/system/user/user';
import { encryptTwo } from '../../../../src/utils/jsencrypt.js';
import { useMessage } from '@/hooks/web/useMessage';
import {TreeData} from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
import { TreeData } from '@/views/dataSharingAndExchange/catalogingManagement/institutionData';
defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']);
......@@ -36,6 +43,7 @@ import {ref, computed, unref, reactive} from 'vue';
resetFields();
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
isMove.value = !!data?.isMove;
if (unref(isUpdate)) {
// 获取行数据的id
......@@ -46,13 +54,12 @@ import {ref, computed, unref, reactive} from 'vue';
});
}
const treeList = handleTree(TreeData, 'businessId',undefined,undefined,undefined)
const treeList = handleTree(TreeData, 'businessId', undefined, undefined, undefined);
updateSchema([
{
field: 'institutionId',
componentProps: {
treeData: treeList
treeData: treeList,
},
},
]);
......@@ -61,51 +68,65 @@ import {ref, computed, unref, reactive} from 'vue';
const getTitle = computed(() => (!unref(isUpdate) ? '新增账号' : '编辑账号'));
function handleTree(data, id, parentId, children, rootId) {
id = id || 'id'
parentId = parentId || 'parentId'
children = children || 'children'
rootId = rootId || Math.min.apply(Math, data.map(item => { return item[parentId] })) || 0
id = id || 'id';
parentId = parentId || 'parentId';
children = children || 'children';
rootId =
rootId ||
Math.min.apply(
Math,
data.map((item) => {
return item[parentId];
}),
) ||
0;
// 对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data))
const cloneData = JSON.parse(JSON.stringify(data));
// 循环所有项
const treeData = cloneData.filter(father => {
const branchArr = cloneData.filter(child => {
const treeData = cloneData.filter((father) => {
const branchArr = cloneData.filter((child) => {
// 返回每一项的子级数组
return father[id] === child[parentId]
})
branchArr.length > 0 ? father.children = branchArr : ''
return father[id] === child[parentId];
});
branchArr.length > 0 ? (father.children = branchArr) : '';
// 返回第一层
return father[parentId] === rootId
})
return treeData !== '' ? treeData : data
return father[parentId] === rootId;
});
return treeData !== '' ? treeData : data;
}
/**确定按钮*/
async function handleSubmit() {
try {
//拿到表单内容
// 拿到表单内容
const values = await validate();
//通过表单获取的institutionId去查找相同TreeData中的institutionId的institutionName
const institutionName = TreeData.find(item => item.businessId === values.institutionId).institutionName
values.institutionName = institutionName
// const institutionName = TreeData.find(
// (item) => item.businessId === values.institutionId,
// ).institutionName;
// values.institutionName = institutionName;
setModalProps({ confirmLoading: true });
// 编辑
if(unref(isUpdate)) {
values.businessId = rowId.value
if (unref(isUpdate)) {
values.businessId = rowId.value;
//修改列表值
emit('success', { isUpdate: unref(isUpdate), values: { ...values, id: rowId.value } });
createMessage.success('编辑成功');
closeModal();
}else {
} else {
//根据institutionId去查找相同TreeData中的institutionId的institutionName
const institutionName = TreeData.find(item => item.businessId === values.institutionId).institutionName
// const institutionName = TreeData.find(
// (item) => item.businessId === values.institutionId,
// ).institutionName;
const paramsAdd = {
username: values.username,
name: values.name,
institutionId: values.institutionId,
institutionName: institutionName,
createDate: formatDate(new Date())
}
project: values.project,
describe: values.describe,
// institutionName: institutionName,
createDate: formatDate(new Date()),
};
emit('success', { isUpdate: unref(isUpdate), values: { ...paramsAdd } });
createMessage.success('新增成功');
closeModal();
......@@ -115,8 +136,8 @@ import {ref, computed, unref, reactive} from 'vue';
}
}
// 格式化日期
function formatDate(date) {
// 格式化日期
function formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1
const day = String(date.getDate()).padStart(2, '0');
......@@ -125,5 +146,5 @@ function formatDate(date) {
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
}
</script>
......@@ -12,12 +12,12 @@
/>
<Icon
@click="handleGoBack"
icon="ph:building-apartment-bold"
icon="dashicons:images-alt2"
class="header_icon"
size="40px"
/>
<div>
<div class="header_title">人力资源信息</div>
<div class="header_title">轮播图详情</div>
</div>
</div>
<div class="right_section">
......@@ -60,7 +60,7 @@
:data="permissionsData"
:schema="permissionsInfo"
/>
<div class="mianBodyEditContainer">
<!-- <div class="mianBodyEditContainer">
<Tabs v-model:activeKey="page" size="large" class="mianBodyEditContainerTabs">
<a-tab-pane key="1" tab="采样数据">
<div v-if="page === '1'">
......@@ -213,7 +213,7 @@
</div>
</a-tab-pane>
</Tabs>
</div>
</div> -->
<StorageManageModal @register="registerStorageManageModal" />
<AccountModal @register="registerEditModal" @success="handleSuccess" />
</PageWrapper>
......@@ -248,7 +248,6 @@
const { createMessage } = useMessage();
const page = ref('1');
const tableData = ref([]);
const samplingTableData = ref([]);
const associationData = ref([]);
......
......@@ -24,8 +24,13 @@
</template>
<BasicTable @register="registerTable" :searchInfo="searchInfo">
<template #toolbar>
<a-button type="primary">新增轮播图</a-button>
<a-button type="primary">批量删除</a-button>
<a-button type="primary" @click="handleAdd">新增轮播图</a-button>
<a-button
type="error"
@click="handleDeleteBatch"
:disabled="getRowSelection().selectedRowKeys <= 0"
>批量删除</a-button
>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
......@@ -41,8 +46,20 @@
{
icon: 'dashicons:edit-large',
tooltip: '编辑',
onClick: handleEdit.bind(null, record),
// onClick: handleDetails.bind(null, record),
},
// 删除按钮
{
icon: 'ant-design:delete-outlined',
color: 'error',
tooltip: '删除',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</template>
......@@ -188,12 +205,14 @@
openModal(true, {
record,
isAdd: true,
isUpdate: false,
});
}
/** 编辑按钮*/
function handleEdit(record: Recordable) {
openModal(true, {
record,
isAdd: false,
isUpdate: true,
});
} /** 详情按钮*/
......@@ -216,7 +235,17 @@
createMessage.success('删除成功!');
reload();
}
function handleDeleteBatch(record: Recordable) {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '确认批量删除选中数据吗?',
onOk() {
createMessage.success('删除成功!');
reload();
},
});
}
/** 导入成功*/
function handleImportSuccess() {
reload();
......
......@@ -86,7 +86,7 @@ export const columns: BasicColumn[] = [
},
{
title: '轮播图描述',
dataIndex: 'ownerInstitution',
dataIndex: 'describe',
width: 150,
},
{
......@@ -135,7 +135,7 @@ export const searchFormSchema: FormSchema[] = [
colProps: { span: 4 },
},
{
field: 'ownerInstitution',
field: 'describe',
label: ' ',
component: 'Input',
componentProps: {
......@@ -167,67 +167,79 @@ export const accountFormSchema: any[] = [
rules: [
{
required: true,
message: '请输入姓名',
message: '请输入名称',
},
],
},
{
field: 'describe',
label: '描述',
field: 'project',
label: '轮播图文件名',
component: 'Input',
colProps: { lg: 24, md: 24 },
rules: [
{
required: true,
message: '请输入描述',
},
],
},
{
field: 'visibleRange',
label: '可见范围',
component: 'Select',
componentProps: {
options: [
{ label: '所有人', value: '所有人' },
{ label: '用户1', value: '用户1' },
{ label: '用户2', value: '用户2' },
],
},
colProps: { lg: 24, md: 24 },
rules: [
{
required: true,
message: '请输入登录名',
message: '请输入文件名',
},
],
},
{
field: 'resourceNum',
label: '可见资源数',
component: 'InputNumber',
field: 'describe',
label: '轮播图描述',
component: 'Input',
colProps: { lg: 24, md: 24 },
rules: [
{
required: true,
message: '请输入',
message: '请输入描述',
},
],
},
{
field: 'institutionId',
label: '所属编目',
component: 'TreeSelect',
colProps: { lg: 24, md: 24 },
componentProps: {
fieldNames: {
label: 'institutionName',
value: 'businessId',
},
getPopupContainer: () => document.body,
},
required: true,
},
// {
// field: 'visibleRange',
// label: '可见范围',
// component: 'Select',
// componentProps: {
// options: [
// { label: '所有人', value: '所有人' },
// { label: '用户1', value: '用户1' },
// { label: '用户2', value: '用户2' },
// ],
// },
// colProps: { lg: 24, md: 24 },
// rules: [
// {
// required: true,
// message: '请输入登录名',
// },
// ],
// },
// {
// field: 'resourceNum',
// label: '可见资源数',
// component: 'InputNumber',
// colProps: { lg: 24, md: 24 },
// rules: [
// {
// required: true,
// message: '请输入',
// },
// ],
// },
// {
// field: 'institutionId',
// label: '所属编目',
// component: 'TreeSelect',
// colProps: { lg: 24, md: 24 },
// componentProps: {
// fieldNames: {
// label: 'institutionName',
// value: 'businessId',
// },
// getPopupContainer: () => document.body,
// },
// required: true,
// },
];
export const EditFormSchema: any[] = [
{
......
......@@ -286,7 +286,7 @@ export const tableDataForIndex: any[] = [
name: '一级资源',
project: '一级编目',
releaseStatus: '已发布',
ownerInstitution: 'test1',
describe: 'test1',
resourceNum: 3,
institutionId: 101,
createDate: '2024-10-24 10:04:04',
......@@ -303,7 +303,7 @@ export const tableDataForIndex: any[] = [
releaser: 'duck',
name: '二级资源',
project: '公共安全',
ownerInstitution: 'test2',
describe: 'test2',
releaseStatus: '已发布',
resourceNum: 4,
institutionId: 102,
......@@ -322,7 +322,7 @@ export const tableDataForIndex: any[] = [
name: '三级资源',
project: '卫生健康',
releaseStatus: '已发布',
ownerInstitution: 'test1',
describe: 'test1',
resourceNum: 5,
institutionId: 103,
createDate: '2024-10-24 10:04:04',
......@@ -340,7 +340,7 @@ export const tableDataForIndex: any[] = [
name: '四级资源',
project: '文化休闲',
releaseStatus: '已发布',
ownerInstitution: 'test3',
describe: 'test3',
resourceNum: 6,
institutionId: 104,
createDate: '2024-10-24 10:04:04',
......@@ -358,7 +358,7 @@ export const tableDataForIndex: any[] = [
name: '五级资源',
project: '经济建设',
releaseStatus: '已发布',
ownerInstitution: 'test1',
describe: 'test1',
resourceNum: 7,
institutionId: 105,
createDate: '2024-10-24 10:04:04',
......@@ -376,7 +376,7 @@ export const tableDataForIndex: any[] = [
name: '特级资源',
project: '科技教育',
releaseStatus: '未发布',
ownerInstitution: 'test4',
describe: 'test4',
resourceNum: 8,
createDate: '2024-10-24 10:04:04',
releaseDate: '2024-10-25 10:04:04',
......
......@@ -312,6 +312,6 @@
}
.headerForm {
margin-top: 30px;
margin-bottom: 30px;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment