Files
fe-manage/src/components/growthpath/GrowthTableModel.vue
2025-01-23 14:51:49 +08:00

562 lines
14 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="common-student">
<a-drawer
:visible="visiable"
class="drawerStyle ProjCheckship"
placement="right"
width="60%"
>
<div class="drawerMain" id="ProjCheckship" style="">
<div class="header" style="margin-bottom: 20px">
<div class="headerTitle">归属权转移</div>
<img
style="width: 29px; height: 29px; cursor: pointer"
src="../../assets/images/basicinfo/close.png"
@click="closeDrawer"
/>
</div>
<div class="TableStudent">
<a-row
type="flex"
gutter="12"
style="padding-left: 20px; margin-right: 0px"
>
<a-col>
<a-form-item title="姓名:">
<a-input
class="cus-input"
v-model:value="searchName"
placeholder="请输入姓名"
/>
</a-form-item>
</a-col>
<a-col>
<a-button
class="cus-btn"
style="background: #4ea6ff; color: #fff; width: 100px"
@click="search"
:loading="loading"
>
<template #icon
><img
style="margin-right: 10px"
src="../../assets/images/courseManage/search0.png"
/>
</template>
搜索
</a-button>
</a-col>
<a-col :span="2">
<a-button
class="cus-btn"
style="width: 100px; background: #4ea6ff; color: #fff"
@click="reset"
>
<template #icon
><img
style="margin-right: 10px"
src="../../assets/images/leveladd/reset0.png"
/>
</template>
重置
</a-button>
</a-col>
</a-row>
<a-row
type="flex"
gutter="12"
style="padding-left: 20px; margin-right: 0px"
>
<a-col v-if="type == 15">
<a-button
class="cus-btn"
style="width: 100px; background: #4ea6ff; color: #fff"
@click="setPermissions()"
>
分配查看权
</a-button>
</a-col>
<a-col v-if="type == 16">
<a-button
class="cus-btn"
style="width: 100px; background: #4ea6ff; color: #fff"
@click="setPermissions()"
>
分配管理权
</a-button>
</a-col>
</a-row>
<div style="margin-top: 20px">
<a-table
:columns="columns"
:data-source="studentList"
:pagination="stuPagination"
:loading="loading"
:row-selection="type == 17 ? null : rowSelection"
row-key="workNum"
>
<template #action="{ record }">
<a-space :size="2">
<a-button
v-if="type == 17 && record.permission != 17"
style="margin-right: 12px"
type="link"
@click="setPermissions(record)"
>转移归属权</a-button
>
<a-button
v-else-if="type !== 17 && record.permission"
@click="del(record)"
type="link"
danger
>删除</a-button
>
<div v-else>--</div>
</a-space>
</template>
</a-table>
</div>
</div>
</div>
</a-drawer>
<a-button @click="openDrawer" type="link"><slot></slot></a-button>
</div>
<!-- 删除弹窗 -->
<a-modal
v-model:visible="deleteModalVisible"
:footer="null"
wrapClassName="deleteModal1"
centered="true"
>
<div class="delete">
<div class="del_header"></div>
<div class="del_main">
<div class="header">
<div class="icon"></div>
<span>提示</span>
<div class="close_exit" @click="closeSameModal"></div>
</div>
<div class="body">
<span>确定删除?</span>
<span style="margin-top: 20px">数据删除后不可恢复</span>
</div>
<div class="del_btnbox">
<div class="del_btn btn1" @click="closeSameModal">
<div class="btnText">取消</div>
</div>
<div class="del_btn btn2" @click="sureSameModal">
<div class="btnText">确定</div>
</div>
</div>
</div>
</div>
</a-modal>
</template>
<script setup>
import { computed, defineProps, defineExpose, ref, watch } from "vue";
import {
getGrowthUserList,
assignPermissions,
delAssignPermissions,
} from "@/api/growthpath";
import { delStudentList } from "@/api/index1";
import { message } from "ant-design-vue";
import dialog from "@/utils/dialog";
const props = defineProps({
type: Number,
id: String,
});
const visiable = ref(false);
const initParams = {
userName: "",
pageNum: 1,
pageSize: 10,
growthId: props.id || "",
};
// 选中数据
const stuSelectKeys = ref([]);
// 表单选择框配置
const rowSelection = computed(() => ({
columnWidth: 20,
selectedRowKeys: stuSelectKeys.value,
onChange: onStuSelectChange,
preserveSelectedRowKeys: true,
}));
// 选择框change
const onStuSelectChange = (e) => {
stuSelectKeys.value = e;
};
const searchParams = ref(initParams);
const searchName = ref("");
// 转移归属权
const setPermissions = (data) => {
if (!data && !stuSelectKeys.value.length) {
message.warning("请选择用户");
return;
}
const title =
props.type == 15
? "是否添加查看权"
: props.type == 16
? "是否添加管理权"
: "是否转移归属权";
dialog({
content: title,
ok: () => {
let params = {
growthId: props.id,
userIds: [],
permissionType: "",
};
// 转移归属权
if (props.type == 17) {
params.userIds = [data.workNum];
params.permissionType = "17";
}
// 设置管理权
if (props.type == 16) {
params.userIds = stuSelectKeys.value;
params.permissionType = "16";
}
// 设置查看权
if (props.type == 15) {
params.userIds = stuSelectKeys.value;
params.permissionType = "15";
}
assignPermissions(params)
.then((res) => {
if (res.data.code == 200) {
message.success("操作成功");
visiable.value = false;
}
})
.catch((err) => {
message.error(err.data.msg);
});
},
});
};
const columns = ref([
{
title: "姓名",
dataIndex: "userName",
key: "userName",
width: 30,
align: "center",
ellipsis: true,
},
{
title: "工号",
dataIndex: "workNum",
key: "workNum",
width: 50,
align: "center",
ellipsis: true,
},
{
title: "部门",
dataIndex: "orgName",
key: "orgName",
width: 80,
align: "center",
ellipsis: true,
},
{
title: "权限",
dataIndex: "permission",
key: "permission",
width: 30,
align: "center",
customRender: ({ record: { permission } }) =>
permission
? {
15: "查看权",
16: "管理权",
17: "归属权",
}[permission]
: "--",
},
{
title: "操作",
dataIndex: "operation",
key: "operation",
width: 50,
align: "center",
slots: { customRender: "action" },
},
]);
const studentList = ref([]);
const total = ref(0);
const loading = ref(false);
// const { loading: stuAsyncLoading } = useAsyncStu(
// props.id,
// props.types.join(","),
// searchStu
// );
const stuPagination = computed(() => ({
total: total.value,
showSizeChanger: false,
current: searchParams.value.pageNum,
pageSize: searchParams.value.pageSize,
onChange: changePagination,
}));
const searchStu = () => {
loading.value = true;
getGrowthUserList(searchParams.value).then((res) => {
console.log(res);
studentList.value = res.data.data.records;
loading.value = false;
});
};
const openDrawer = () => {
visiable.value = true;
console.log(props.type);
};
const changePagination = (page) => {
searchParams.value.pageNum = page;
searchStu();
};
function search() {
searchParams.value.userName = searchName.value;
searchParams.value.pageNum = 1;
searchStu();
}
const deleteModalVisible = ref(false);
const deleteId = ref(null);
function del(row) {
deleteModalVisible.value = true;
deleteId.value = row.workNum;
}
//确定删除
const sureSameModal = () => {
if (deleteId.value) {
let params = {
growthId: props.id,
userIds: [deleteId.value],
};
loading.value = true;
delAssignPermissions(params).then(() => {
message.success("删除成功");
searchStu();
});
deleteModalVisible.value = false;
}
};
//取消
const closeSameModal = () => {
deleteModalVisible.value = false;
deleteId.value = null;
};
const closeDrawer = () => {
visiable.value = false;
};
function reset() {
searchParams.value = initParams;
searchName.value = "";
searchParams.value.userName = "";
searchParams.value.pageNum = 1;
searchStu();
}
watch(visiable, () => {
visiable.value && searchStu();
searchParams.value = initParams;
});
defineExpose({
searchStu,
loading,
});
</script>
<style lang="scss">
.cus-btn {
width: 100%;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16px;
border: 1px solid #4ea6ff;
border-radius: 8px;
background: #4ea6ff;
cursor: pointer;
color: #fff;
}
.cus-input {
height: 40px;
border-radius: 8px;
}
.common-student {
.ant-btn-primary {
background-color: #4ea6ff !important;
}
.tableBox .ant-table-row .ant-table-cell {
height: 48px;
font-size: 14px;
font-weight: 400;
color: #4f5156;
line-height: 29px;
padding: 0px;
}
.tableBox .ant-table-thead tr th {
font-size: 14px;
}
.ant-tabs-tabpane {
height: 100%;
}
.ant-tabs {
overflow: visible;
}
}
.deleteModal1 {
.ant-modal {
width: 424px !important;
height: 258px !important;
.ant-modal-content {
width: 424px !important;
height: 258px !important;
.ant-modal-body {
width: 424px !important;
height: 258px !important;
padding: 0 !important;
.delete {
z-index: 999;
width: 424px;
height: 258px;
background: #ffffff;
box-shadow: 0px 1px 35px 0px rgba(118, 136, 166, 0.21);
border-radius: 4px;
// position: absolute;
// left: 50%;
// top: 10%;
// transform: translate(-50%, -50%);
.del_header {
position: absolute;
width: calc(100%);
height: 68px;
background: linear-gradient(
rgba(78, 166, 255, 0.2) 0%,
rgba(78, 166, 255, 0) 100%
);
}
.del_main {
width: 100%;
position: relative;
.header {
display: flex;
align-items: center;
padding-top: 20px;
padding-left: 26px;
font-size: 16px;
.icon {
width: 16px;
height: 16px;
margin-right: 10px;
background-image: url(@/assets/images/taskpage/gan.png);
background-size: 100% 100%;
}
.close_exit {
position: absolute;
right: 42px;
cursor: pointer;
width: 20px;
height: 20px;
background-image: url(@/assets/images/coursewareManage/close.png);
background-size: 100% 100%;
}
}
.body {
width: 100%;
margin: 34px auto 56px auto;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
// background-color: red;
position: relative;
.back {
position: absolute;
top: 30px;
font-size: 12px;
font-weight: 400;
color: #666666;
}
}
.del_btnbox {
display: flex;
margin: 30px auto;
justify-content: center;
.del_btn {
width: 100px;
height: 40px;
background: rgba(64, 158, 255, 0);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
cursor: pointer;
.btnText {
font-size: 14px;
font-weight: 400;
line-height: 40px;
}
}
.btn1 {
border: 1px solid rgba(64, 158, 255, 1);
color: #4ea6ff;
margin-right: 14px;
}
.btn2 {
background-color: #4ea6ff;
color: #ffffff;
}
}
}
}
}
}
.ant-modal-close-x {
display: none;
}
}
}
</style>