daofu-gov-pc/src/views/work-manage/index.vue

267 lines
7.0 KiB
Vue
Raw Normal View History

2024-01-26 09:02:58 +08:00
<template>
<div class="percentage-content">
<el-radio-group class="rg" v-model="tabIndex" @change="clickRadio">
<template v-for="item in tabs" :key="item.sortId">
<el-radio-button :label="item.sortId">{{ item.typeName }}</el-radio-button>
2024-01-26 09:02:58 +08:00
</template>
</el-radio-group>
<div class="content">
<!-- <transition name="main" mode="out-in" appear>
2024-01-26 09:02:58 +08:00
<component :is="tabs[tabIndex].compon" />
</transition> -->
2024-01-29 09:44:22 +08:00
<!-- <CG :tabIndex="tabIndex" :typeId="typeId"></CG> -->
<div class="h-layout space-between h-center">
<div>
<div class="h-layout">
<div
class="tool-item"
@click="(dialogVisible = true), (form = {}), (readonly = false)"
>
<svg-icon name="add" class="icon" />
<span>新增</span>
</div>
<div class="tool-item" @click="getList">
<svg-icon name="refurbish" class="icon" />
<span>刷新</span>
</div>
</div>
</div>
</div>
<el-table
ref="loading"
class="table"
v-loading="tableDataloading"
:data="tableData"
header-row-class-name="el-one-header"
border
>
<el-table-column type="index" align="center" label="序号" width="80"/>
<el-table-column prop="title" align="center" label="工作内容" />
2024-06-06 09:39:20 +08:00
<el-table-column prop="startTime" align="center" label="开始时间" width="150">
<template #default="scope">
{{scope.row.startTime}}
</template>
</el-table-column>
<el-table-column prop="endTime" align="center" label="结束时间" width="150">
<template #default="scope">
{{scope.row.endTime?scope.row.endTime:'--'}}
</template>
</el-table-column>
2024-01-29 09:44:22 +08:00
<el-table-column prop="chinaName" align="center" label="发布人" width="120"/>
<el-table-column prop="postName" align="center" label="发布人岗位" width="150"/>
<el-table-column
:resizable="true"
align="center"
width="260"
label="操作"
>
<template #default="scope">
2024-06-06 09:39:20 +08:00
<span
v-if="tabIndex != 3"
2024-01-29 09:44:22 +08:00
class="operate"
2024-06-06 09:39:20 +08:00
@click="
(dialogVisible = true), (form = scope.row), (readonly = true)
2024-01-29 09:44:22 +08:00
"
>
2024-06-06 09:39:20 +08:00
<svg-icon name="detail" class="icon"></svg-icon>
<span class="detail">详情</span>
</span>
2024-01-29 09:44:22 +08:00
<span
2024-06-06 09:39:20 +08:00
v-else
2024-01-29 09:44:22 +08:00
class="operate"
2024-06-06 09:39:20 +08:00
@click="toDetail(scope.row.workId)"
2024-01-29 09:44:22 +08:00
>
<svg-icon name="detail" class="icon"></svg-icon>
<span class="detail">详情</span>
</span>
<span class="operate" @click="deletelist(scope.row)">
<svg-icon name="delete" class="icon"></svg-icon>
<span class="func">删除</span>
</span>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<el-pagination
class="pagination"
2024-06-17 09:22:03 +08:00
@size-change="getSendWorkPage"
@current-change="getSendWorkPage"
2024-01-29 09:44:22 +08:00
v-model:current-page.sync="currentPage"
:page-sizes="[10, 15, 20, 30]"
v-model:page-size.sync="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
background
>
</el-pagination>
<!-- 新增 -->
<Add
:visible="dialogVisible"
:form="form"
:readonly="readonly"
@close="onclone"
:typeId="typeId"
:tabsTitle="tabsTitle"
/>
2024-01-26 09:02:58 +08:00
</div>
</div>
</template>
<script lang='ts' setup>
import { onMounted, ref } from "vue";
2024-01-29 09:44:22 +08:00
import Add from "./components/add.vue";
2024-03-14 17:31:52 +08:00
import { wkTypes, sendWorkPage, deleteWork } from "@/api/Work";
import { ElMessageBox, ElMessage } from "element-plus";
2024-01-29 09:44:22 +08:00
import useUserStore from "@/store/modules/user";
2024-06-06 09:39:20 +08:00
import { useRouter } from "vue-router";
const router = useRouter();
2024-01-29 09:44:22 +08:00
const userStore = useUserStore();
const user = ref(JSON.parse(userStore.userInfo));
const userId = ref(user.value.userId);
2024-01-26 09:02:58 +08:00
const tabIndex = ref(0);
const tabs = ref([
{ typeName: "常规工作", sortId: 1, },
2024-01-26 09:02:58 +08:00
]);
const typeId = ref('');
2024-01-29 09:44:22 +08:00
//弹窗标题
const tabsTitle = ref('');
//头部点击取id
const clickRadio = ()=>{
tabs.value.forEach(item => {
if (item.sortId == tabIndex.value) {
typeId.value = item.typeId
2024-01-29 09:44:22 +08:00
tabsTitle.value = item.typeName;
}
});
2024-01-29 09:44:22 +08:00
getList()
}
//工作类型
const getWkTypes = ()=>{
let params = {
classify:1
}
wkTypes(params).then((res: any) => {
tabs.value = res.data;
typeId.value = res.data[0].typeId;
2024-01-29 09:44:22 +08:00
tabsTitle.value = res.data[0].typeName;
tabIndex.value = 1;
2024-01-29 09:44:22 +08:00
getSendWorkPage();
});
}
const search = ref([]);
const currentPage = ref(1);
const pageSize = ref(10);
const total = ref(0);
//获取列表
const tableDataloading = ref(false);
const tableData = ref([]);
const getSendWorkPage = () => {
tableDataloading.value = true;
let params = {
userId:userId.value,
limit: pageSize.value,
page: currentPage.value,
typeId:typeId.value,
};
sendWorkPage(params).then((res: any) => {
tableData.value = res.data.list;
total.value = res.data.total;
tableDataloading.value = false;
});
2024-01-29 09:44:22 +08:00
};
//新增弹窗
const dialogVisible = ref(false);
const form = ref({});
const readonly = ref(false);
//关闭新增弹窗
const onclone = () => {
dialogVisible.value = false;
form.value = {};
getList();
};
//删除
const deletelist = (data)=>{
2024-03-14 17:31:52 +08:00
ElMessageBox.confirm("是否确认删除?", "提示", {
confirmButtonText: "是",
cancelButtonText: "否",
type: "warning",
}).then(() => {
let params = {
workId: data.workId,
classify: 1,
};
deleteWork(params).then((res: any) => {
if (res.code == 1) {
ElMessage.success({
message: "删除成功",
type: "success",
});
} else {
ElMessage.error({
message: res.message,
type: "error",
});
}
getList();
});
});
2024-01-29 09:44:22 +08:00
2024-06-06 09:39:20 +08:00
};
//应急事件详情
const toDetail = (id) => {
router.push({
name: "work-detail",
query: { id: id },
});
};
2024-01-29 09:44:22 +08:00
const getList = ()=>{
currentPage.value = 1;
getSendWorkPage();
}
onMounted(() => {
getWkTypes();
});
2024-01-26 09:02:58 +08:00
</script>
<style lang="scss" scoped>
.percentage-content {
height: auto;
2024-01-26 09:02:58 +08:00
display: flex;
flex-direction: column;
.rg {
padding: 16px;
background: #fff;
box-shadow: 0 0 6px rgb(0 120 255 / 10%);
border-radius: 6px;
display: flex;
flex-direction: row;
margin-bottom: 10px;
:deep(.el-radio-button__inner) {
min-width: 150px;
}
2024-01-26 09:02:58 +08:00
}
.content {
width: 100%;
background: #fff;
border-radius: 0.26042vw;
box-shadow: 0 0 0.41667vw 0 rgb(8 33 85 / 10%);
padding: 0.83333vw;
overflow-y: auto;
overflow-x: hidden !important;
box-sizing: border-box;
.table {
margin-top: 16px;
}
2024-01-26 09:02:58 +08:00
}
}
</style>