路由修改

main
项洋 24 hours ago
parent 8c1cd44ec2
commit df52028d0b

@ -1,126 +1,151 @@
import { defineStore } from 'pinia'
import auth from "@/plugins/auth";
import router, { constantRoutes, dynamicRoutes } from "@/router";
import { getRouters } from "@/api/menu";
import Layout from "@/layout/index";
import ParentView from "@/components/ParentView";
import InnerLink from "@/layout/components/InnerLink";
import auth from '@/plugins/auth'
import router, { constantRoutes, dynamicRoutes } from '@/router'
import { getRouters } from '@/api/menu'
import Layout from '@/layout/index'
import ParentView from '@/components/ParentView'
import InnerLink from '@/layout/components/InnerLink'
// 匹配views里面所有的.vue文件
const modules = import.meta.glob("./../../views/**/*.vue");
const modules = import.meta.glob('@/views/**/*.vue')
export const usePermissionStore = defineStore("permission", {
state: () => ({
routes: [],
addRoutes: [],
defaultRoutes: [],
topbarRouters: [],
sidebarRouters: [],
}),
actions: {
setRoutes(routes) {
this.addRoutes = routes;
this.routes = constantRoutes.concat(routes);
},
setDefaultRoutes(routes) {
this.defaultRoutes = constantRoutes.concat(routes);
},
setTopbarRoutes(routes) {
this.topbarRouters = routes;
},
setSidebarRouters(routes) {
this.sidebarRouters = routes;
},
generateRoutes(roles) {
return new Promise((resolve) => {
// 向后端请求路由数据
getRouters().then((res) => {
const sdata = JSON.parse(JSON.stringify(res.data));
const rdata = JSON.parse(JSON.stringify(res.data));
const defaultData = JSON.parse(JSON.stringify(res.data));
const sidebarRoutes = filterAsyncRouter(sdata);
const rewriteRoutes = filterAsyncRouter(rdata, false, true);
const defaultRoutes = filterAsyncRouter(defaultData);
const asyncRoutes = filterDynamicRoutes(dynamicRoutes);
asyncRoutes.forEach((route) => {
router.addRoute(route);
});
this.setRoutes(rewriteRoutes);
this.setSidebarRouters(constantRoutes.concat(sidebarRoutes));
this.setDefaultRoutes(sidebarRoutes);
this.setTopbarRoutes(defaultRoutes);
resolve(rewriteRoutes);
});
});
},
},
});
// 动态路由遍历,验证是否具备权限
const filterDynamicRoutes = (routes) => {
const res = []
routes.forEach(route => {
if (route.permissions) {
if (auth.hasPermiOr(route.permissions)) {
res.push(route)
}
} else if (route.roles) {
if (auth.hasRoleOr(route.roles)) {
res.push(route)
}
}
})
return res
}
// 遍历后台传来的路由字符串,转换为组件对象
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
return asyncRouterMap.filter((route) => {
const filterAsyncRouter = (asyncRouterMap, lastRouter = false, type = false) => {
return asyncRouterMap.filter(route => {
if (type && route.children) {
route.children = filterChildren(route.children);
route.children = filterChildren(route.children)
}
if (route.component) {
// Layout ParentView 组件特殊处理
if (route.component === "Layout") {
route.component = Layout;
} else if (route.component === "ParentView") {
route.component = ParentView;
} else if (route.component === "InnerLink") {
route.component = InnerLink;
if (route.component === 'Layout') {
route.component = Layout
} else if (route.component === 'ParentView') {
route.component = ParentView
} else if (route.component === 'InnerLink') {
route.component = InnerLink
} else {
route.component = loadView(route.component);
route.component = loadView(route.component)
}
}
if (route.children != null && route.children && route.children.length) {
route.children = filterAsyncRouter(route.children, route, type);
route.children = filterAsyncRouter(route.children, route, type)
} else {
delete route["children"];
delete route["redirect"];
delete route['children']
delete route['redirect']
}
return true;
});
return true
})
}
function filterChildren(childrenMap, lastRouter = false) {
var children = [];
childrenMap.forEach((el) => {
el.path = lastRouter ? lastRouter.path + "/" + el.path : el.path;
if (el.children && el.children.length && el.component === "ParentView") {
children = children.concat(filterChildren(el.children, el));
const filterChildren = (childrenMap, lastRouter = false) => {
const children = []
childrenMap.forEach(el => {
el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path
if (el.children && el.children.length && el.component === 'ParentView') {
children.push(...filterChildren(el.children, el))
} else {
children.push(el);
children.push(el)
}
});
return children;
})
return children
}
// 动态路由遍历,验证是否具备权限
export function filterDynamicRoutes(routes) {
const res = [];
routes.forEach((route) => {
if (route.permissions) {
if (auth.hasPermiOr(route.permissions)) {
res.push(route);
}
} else if (route.roles) {
if (auth.hasRoleOr(route.roles)) {
res.push(route);
}
const loadView = (view) => {
let res
for (const path in modules) {
const dir = path.split('views/')[1].split('.vue')[0]
if (dir === view) {
res = modules[path]
}
});
return res;
}
return res
}
export const loadView = (view) => {
let res;
for (const path in modules) {
const dir = path.split("views/")[1].split(".vue")[0];
if (dir === view) {
res = () => modules[path]();
export const usePermissionStore = defineStore('permission', {
state: () => ({
routes: [],
addRoutes: [],
defaultRoutes: [],
topbarRouters: [],
sidebarRouters: []
}),
getters: {
getRoutes: (state) => state.routes,
getAddRoutes: (state) => state.addRoutes,
getDefaultRoutes: (state) => state.defaultRoutes,
getTopbarRouters: (state) => state.topbarRouters,
getSidebarRouters: (state) => state.sidebarRouters
},
actions: {
// 设置路由
setRoutes(routes) {
this.addRoutes = routes
this.routes = constantRoutes.concat(routes)
},
// 设置默认路由
setDefaultRoutes(routes) {
this.defaultRoutes = constantRoutes.concat(routes)
},
// 设置顶部导航栏路由
setTopbarRoutes(routes) {
this.topbarRouters = routes
},
// 设置侧边栏路由
setSidebarRouters(routes) {
this.sidebarRouters = routes
},
// 生成路由
async generateRoutes() {
try {
const res = await getRouters()
console.log(res)
const sdata = JSON.parse(JSON.stringify(res.data))
const rdata = JSON.parse(JSON.stringify(res.data))
const defaultData = JSON.parse(JSON.stringify(res.data))
const sidebarRoutes = filterAsyncRouter(sdata)
const rewriteRoutes = filterAsyncRouter(rdata, false, true)
const defaultRoutes = filterAsyncRouter(defaultData)
const asyncRoutes = filterDynamicRoutes(dynamicRoutes)
// 添加动态路由
asyncRoutes.forEach(route => {
router.addRoute(route)
})
console.log(rewriteRoutes)
this.setRoutes(rewriteRoutes)
this.setSidebarRouters(constantRoutes.concat(sidebarRoutes))
this.setDefaultRoutes(sidebarRoutes)
this.setTopbarRoutes(defaultRoutes)
return rewriteRoutes
} catch (error) {
console.error('生成路由出错:', error)
return []
}
}
}
return res;
};
})

@ -14,21 +14,14 @@
<el-col :span="7">
<el-form-item label="任务状态:">
<el-select v-model="formInline.taskStatus" placeholder="请选择">
<el-option label="已关闭" value="0">
</el-option>
<el-option label="进行中" value="1">
</el-option>
<el-option label="正常完成" value="2">
</el-option>
<el-option label="超期完成" value="3">
</el-option>
<el-option label="已关闭" value="0" />
<el-option label="进行中" value="1" />
<el-option label="正常完成" value="2" />
<el-option label="超期完成" value="3" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="5">
<!-- <el-form-item label="任务编号:">
<el-input v-model="formInline.id" placeholder="请输入"></el-input>
</el-form-item> -->
<el-form-item label="任务完成时间:">
<el-date-picker v-model="formInline.time" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
type="datetimerange" start-placeholder="开始时间" end-placeholder="结束时间" placeholder="请选择">
@ -39,15 +32,12 @@
<el-row>
<el-col :span="8">
<el-form-item>
<!-- <el-date-picker v-model="formInline.time" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
type="datetimerange" start-placeholder="开始时间" end-placeholder="结束时间" placeholder="请选择">
</el-date-picker> -->
</el-form-item>
</el-col>
<el-col :span="16" style="text-align: right;padding-right: 20px;">
<el-form-item>
<el-button size="mini" @click="resetQuery('queryFrom')"></el-button>
<el-button size="mini" type="primary" @click="handleQuery('queryFrom')"></el-button>
<el-button size="small" @click="resetQuery"></el-button>
<el-button size="small" type="primary" @click="handleQuery"></el-button>
</el-form-item>
</el-col>
</el-row>
@ -57,11 +47,8 @@
<div class="search-title">
<span class="search-title-span">任务列表</span>
<el-row :gutter="10" class="mb8">
<!-- <el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"></el-button>
</el-col> -->
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"></el-button>
<el-button type="primary" :icon="Plus" size="small" @click="handleAdd"></el-button>
</el-col>
</el-row>
</div>
@ -69,56 +56,36 @@
<el-table v-loading="loading" :data="tableData" :height="tabHeader" :max-height="tabHeader"
:row-class-name="tableRowClassName">
<el-table-column type="index" width="60" label="序号" align="center" />
<!-- <el-table-column label="任务编号" key="id" width="200px" prop="id" align="center" /> -->
<el-table-column label="任务名称" key="taskName" prop="taskName" align="center" />
<el-table-column label="任务下发时间" key="taskTime" prop="taskTime" align="center">
<!-- <template slot-scope="scope">
<dict-tag :options="dict.type.project_middle_type" :value="scope.row.projectMiddleType"/>
</template> -->
</el-table-column>
<el-table-column label="任务下发时间" key="taskTime" prop="taskTime" align="center" />
<el-table-column label="任务期限" key="taskDeadline" prop="taskDeadline" align="center" />
<el-table-column label="任务完成时间" key="taskFinishTime" prop="taskFinishTime" align="center" />
<el-table-column label="任务状态" key="taskStatus" width="200px" prop="taskStatus" class-name="table-status"
align="center">
<template slot-scope="scope">
<span v-if="scope.row.taskStatus == 0" style="color: #F56C6C;">
已关闭
</span>
<span v-if="scope.row.taskStatus == 1" style="color: #E6A23C;">
进行中
</span>
<span v-if="scope.row.taskStatus == 2" style="color: #67C23A;">
正常完成
</span>
<span v-if="scope.row.taskStatus == 3" style="color:#67C23A;">
超期完成
</span>
<span v-if="scope.row.taskStatus == 4" style="color: #F56C6C;">
审核不通过
</span>
<span v-if="scope.row.taskStatus == 5" style="color: #F56C6C;">
审核驳回
</span>
<template #default="{ row }">
<span v-if="row.taskStatus == 0" style="color: #F56C6C;"></span>
<span v-if="row.taskStatus == 1" style="color: #E6A23C;"></span>
<span v-if="row.taskStatus == 2" style="color: #67C23A;"></span>
<span v-if="row.taskStatus == 3" style="color:#67C23A;"></span>
<span v-if="row.taskStatus == 4" style="color: #F56C6C;"></span>
<span v-if="row.taskStatus == 5" style="color: #F56C6C;"></span>
</template>
</el-table-column>
<el-table-column label="操作" prop="userId" class-name="table-operation" align="center">
<template slot-scope="scope">
<template #default="{ row }">
<div style="display: flex;align-items: center;justify-content: center;">
<div style="display: flex;align-items: center;cursor: pointer;" @click="goInfo(scope.row)">
<img src="@/assets/images/icon-ck@2x.png" alt="" style="width: 20px;margin-right: 5px;">
<div style="display: flex;align-items: center;cursor: pointer;" @click="goInfo(row)">
<el-icon class="mr-1"><View /></el-icon>
<span class="look-info" style="color: #1485EF;">查看</span>
</div>
<!-- -->
<div style="display: flex;align-items: center;cursor: pointer;margin-left: 10px;"
@click="delInfo(scope.row)" v-if="scope.row.taskStatus == 1 && scope.row.taskStatus != 0">
<img src="@/assets/images/icon-shenhe@2x.png" alt="" style="width: 15px;margin-right: 5px;">
@click="delInfo(row)" v-if="row.taskStatus == 1 && row.taskStatus != 0">
<el-icon class="mr-1"><Edit /></el-icon>
<span class="del-info" style="color: #1485EF;">审核</span>
</div>
<div style="display: flex;align-items: center;cursor: pointer;margin-left: 10px;"
@click="guanbijiekou(scope.row)" v-if="scope.row.taskStatus == 1 && scope.row.taskStatus != 0">
<!-- -->
<!-- <img src="@/assets/images/icon-shenhe@2x.png" alt="" style="width: 15px;margin-right: 5px;"> -->
<i class="el-icon-delete"></i>
@click="guanbijiekou(row)" v-if="row.taskStatus == 1 && row.taskStatus != 0">
<el-icon class="mr-1"><Delete /></el-icon>
<span class="del-info" style="color: #1485EF;">关闭</span>
</div>
</div>
@ -132,7 +99,7 @@
<my-dialog title="新增任务" @close="importClose" ref="taskDialog" class="taskDialogBox" width="43%">
<el-row>
<el-col :span="21">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px">
<el-form :model="ruleForm" :rules="rules" ref="ruleFormRef" label-width="120px">
<el-form-item label="任务名称" prop="taskName">
<el-input v-model="ruleForm.taskName" placeholder="请输入任务名称"></el-input>
</el-form-item>
@ -151,21 +118,20 @@
</el-select>
</el-col>
<el-col class="btn-box">
<el-button type="primary" @click="addliebiao"><i class="el-icon-s-unfold"></i></el-button>
<el-button type="primary" @click="addliebiao"><el-icon><Expand /></el-icon></el-button>
</el-col>
</el-form-item>
<el-form-item label="任务期限" prop="taskDeadline">
<el-date-picker type="datetime" placeholder="选择日期" v-model="ruleForm.taskDeadline" style="width: 100%;"
value-format="yyyy-MM-dd HH:mm:ss" default-time="23:59:59"
:picker-options="pickerOptions"></el-date-picker>
:disabled-date="disabledDate"></el-date-picker>
</el-form-item>
<el-form-item class="newTask-form-item">
<el-button @click="resetForm('ruleForm')"></el-button>
<el-button type="primary" @click="submitForm('ruleForm')" :loading="btnloading">发布</el-button>
<el-button @click="resetForm"></el-button>
<el-button type="primary" @click="submitForm" :loading="btnloading">发布</el-button>
</el-form-item>
</el-form>
</el-col>
<el-col :span="6"></el-col>
</el-row>
</my-dialog>
@ -174,390 +140,326 @@
<danweiList ref="danweiList" @adddanweilist="adddanweilist" @liebiaoClose="liebiaoClose"></danweiList>
</my-dialog>
</div>
</div>
</template>
<script>
<script setup>
import { ref, reactive, onMounted, onUnmounted, nextTick } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, View, Edit, Delete, Expand } from '@element-plus/icons-vue'
import myPagination from "@/views/components/Pagination/index.vue"
import myDialog from "@/views/components/myDialog/index.vue"
import danweiList from "@/views/system/user/danweiList.vue"
import { addassetTaskadd, getassetTask, getassetTaskid, assetTaskclose } from "@/api/renwuApi/index.js"
export default {
// dicts: ['jjh_project_type', 'bms_approval_status', "project_middle_type", "project_small_type", "project_categories"],
components: { myPagination, myDialog, danweiList },
data() {
return {
pickerOptions: {
disabledDate(time) {
const date = new Date();
const oneday = date.getTime();
return time.getTime() < new Date().getTime() - 86400000;
},
selectableRange: (() => {
let data = new Date();
let hour = data.getHours();
let minute = data.getMinutes();
let second = data.getSeconds();
return [`${hour}:${minute}:${second} - 23:59:59`]
})(),
},
btnloading: false,
formInline: {
name: "",
type: "",
time: [],
number: "",
status: "",
},
total: 0,
pagination: {
current: 1,
size: 10,
},
tableData: [
],
loading: false,
tabHeader: undefined,
ruleForm: {
taskName: "",
dwmc: [],
taskDeadline: "",
type: []
},
rules: {
taskName: [
{ required: true, message: '请输入', trigger: 'change' },
],
dwmc: [
{ required: true, message: '请选择', trigger: 'change' }
],
taskDeadline: [
{ required: true, message: '请选择日期', trigger: 'change' }
],
type: [
{ required: true, message: '请选择', trigger: 'change' }
]
},
tabclicklist: [],
chanckList: [
{
lable: "0",
conent: "web资产"
},
{
lable: "1",
conent: "小程序资产"
},
{
lable: "2",
conent: "公众号资产"
},
{
lable: "3",
conent: "电子邮件资产"
},
{
lable: "4",
conent: "移动应用程序资产"
},
]
}
},
mounted() {
if (localStorage.getItem('ismypagination')) {
if (JSON.parse(localStorage.getItem('ismypagination')).isfanhui) {
this.formInline = JSON.parse(localStorage.getItem('ismypagination'))
this.handleQuery()
} else {
localStorage.removeItem("ismypagination")
}
}
localStorage.removeItem("ismypaginationTow")
localStorage.removeItem("activeName")
this.getInfo();
this.cancalDebounce();
window.addEventListener('resize', this.cancalDebounce);
},
destroyed() {
window.removeEventListener('resize', this.cancalDebounce);
},
methods: {
isclear(value,index){
this.tabclicklist = this.tabclicklist.filter(user => user.nickName != value)
},
disabledDate(time) {
//
console.log(time);
return time.getTime() < Date.now() - 8.64e7; //
},
checkboxChange() {
console.log(111);
this.ruleForm.dwmc = []
this.tabclicklist = []
setTimeout(() => {
this.$refs.ruleForm.clearValidate()
}, 0);
},
//
resetForm() {
this.ruleForm = {
dwmc: [],
taskName: "",
taskDeadline: "",
type: []
const router = useRouter()
const taskDialog = ref(null)
const liebiaoDialog = ref(null)
const danweiList = ref(null)
const ruleFormRef = ref(null)
const loading = ref(false)
const btnloading = ref(false)
const total = ref(0)
const tabHeader = ref(undefined)
const tabclicklist = ref([])
const formInline = reactive({
name: "",
type: "",
time: [],
number: "",
status: "",
})
const pagination = reactive({
current: 1,
size: 10,
})
const tableData = ref([])
const ruleForm = reactive({
taskName: "",
dwmc: [],
taskDeadline: "",
type: []
})
const rules = {
taskName: [{ required: true, message: '请输入', trigger: 'change' }],
dwmc: [{ required: true, message: '请选择', trigger: 'change' }],
taskDeadline: [{ required: true, message: '请选择日期', trigger: 'change' }],
type: [{ required: true, message: '请选择', trigger: 'change' }]
}
}
this.$refs.taskDialog.close()
this.tabclicklist = []
this.btnloading = false
},
fonsisis(data) {
//
const specificTimeStr = data;
// Date
const specificTime = new Date(specificTimeStr);
//
const currentTime = new Date();
//
if (currentTime > specificTime) {
return false
} else {
return true
}
const chanckList = [
{ lable: "0", conent: "web资产" },
{ lable: "1", conent: "小程序资产" },
{ lable: "2", conent: "公众号资产" },
{ lable: "3", conent: "电子邮件资产" },
{ lable: "4", conent: "移动应用程序资产" },
]
// Methods
const isclear = (value) => {
tabclicklist.value = tabclicklist.value.filter(user => user.nickName != value)
}
},
submitForm(formName) {
console.log(this.ruleForm.taskDeadline);
this.fonsisis(this.ruleForm.taskDeadline)
if (!this.fonsisis(this.ruleForm.taskDeadline)) {
this.$message.error('选择时间不能小于当前时间');
return false
}
this.$refs[formName].validate((valid) => {
if (valid) {
this.btnloading = true
this.ruleForm.dwmc = this.ruleForm.dwmc.join(",")
this.ruleForm.type = this.ruleForm.type.join(",")
addassetTaskadd(this.ruleForm).then(res => {
this.resetForm()
this.getInfo();
this.$modal.msgSuccess("新增成功");
this.btnloading = false
})
setTimeout(() => {
this.ruleForm.dwmc = this.ruleForm.dwmc.split(",")
this.ruleForm.type = this.ruleForm.type.split(",")
}, 0);
} else {
console.log('error submit!!');
return false;
}
});
},
adddanweilist(val) {
if (val) {
let list = val
this.ruleForm.dwmc = []
list.forEach(element => {
this.ruleForm.dwmc.push(element.nickName)
});
} else {
this.ruleForm.dwmc = []
}
this.tabclicklist = val
},
//
getInfo() {
this.loading = true;
getassetTask(this.pagination).then(res => {
this.loading = false;
this.total = res.data.total;
this.tableData = res.data.records;
})
},
//
resetQuery() {
this.formInline = {
name: "",
type: "",
time: [],
number: "",
status: "",
}
this.pagination = {
current: 1,
size: 10,
}
localStorage.removeItem("ismypagination")
this.getInfo();
},
//
addliebiao() {
console.log(this.ruleForm.type);
if (this.ruleForm.type.length > 0) {
this.$refs.liebiaoDialog.open()
setTimeout(() => {
this.$refs.danweiList.getType(this.ruleForm.type)
const disabledDate = (time) => {
return time.getTime() < Date.now() - 8.64e7
}
const checkboxChange = () => {
ruleForm.dwmc = []
tabclicklist.value = []
nextTick(() => {
ruleFormRef.value?.clearValidate()
})
}
const resetForm = () => {
Object.assign(ruleForm, {
dwmc: [],
taskName: "",
taskDeadline: "",
type: []
})
taskDialog.value?.close()
tabclicklist.value = []
btnloading.value = false
}
// this.$refs.danweiList.getList()
const fonsisis = (data) => {
const specificTime = new Date(data)
const currentTime = new Date()
return currentTime <= specificTime
}
}, 10);
if (this.tabclicklist) {
setTimeout(() => {
this.$refs.danweiList.dakai(this.tabclicklist)
}, 100);
const submitForm = async () => {
if (!fonsisis(ruleForm.taskDeadline)) {
ElMessage.error('选择时间不能小于当前时间')
return
}
if (!ruleFormRef.value) return
await ruleFormRef.value.validate(async (valid) => {
if (valid) {
btnloading.value = true
try {
const submitData = {
...ruleForm,
dwmc: ruleForm.dwmc.join(","),
type: ruleForm.type.join(",")
}
} else {
this.$message('请先选择核查资产类型');
await addassetTaskadd(submitData)
resetForm()
await getInfo()
ElMessage.success("新增成功")
} catch (error) {
console.error(error)
} finally {
btnloading.value = false
}
}
})
}
const adddanweilist = (val) => {
if (val) {
ruleForm.dwmc = val.map(element => element.nickName)
} else {
ruleForm.dwmc = []
}
tabclicklist.value = val
}
},
liebiaoClose() {
this.$refs.danweiList.queryParams = {
current: 1,
size: 10,
userName: undefined,
nickName: undefined,
dwlx: undefined,
},
this.$refs.liebiaoDialog.close()
},
//
handleQuery() {
this.pagination = {
current: 1,
size: 10
}
if (this.formInline.time.length > 0) {
this.formInline.begainTime = this.formInline.time[0]
this.formInline.endTime = this.formInline.time[1]
const getInfo = async () => {
loading.value = true
try {
const res = await getassetTask(pagination)
total.value = res.data.total
tableData.value = res.data.records
} catch (error) {
console.error(error)
} finally {
loading.value = false
}
}
const resetQuery = () => {
Object.assign(formInline, {
name: "",
type: "",
time: [],
number: "",
status: "",
})
Object.assign(pagination, {
current: 1,
size: 10,
})
localStorage.removeItem("ismypagination")
getInfo()
}
const addliebiao = () => {
if (ruleForm.type.length > 0) {
liebiaoDialog.value?.open()
nextTick(() => {
danweiList.value?.getType(ruleForm.type)
if (tabclicklist.value) {
setTimeout(() => {
danweiList.value?.dakai(tabclicklist.value)
}, 100)
}
this.pagination = { ...this.pagination, ...this.formInline };
this.formInline.isfanhui = false
localStorage.setItem("ismypagination", JSON.stringify(this.formInline))
this.getInfo();
},
//
getPagination(pages) {
this.pagination.current = pages.page;
this.pagination.size = pages.limit;
this.getInfo();
},
//
handleImport() { },
//
handleExport() { },
//
handleAdd() {
this.$refs.taskDialog.open()
setTimeout(() => {
this.$refs.ruleForm.clearValidate()
}, 100);
},
//
importClose() {
this.resetForm()
},
//
goInfo(row) {
getassetTaskid(row.id)
this.$router.push({
name: 'TaskInfo', query: {
pageType: "look",
id: row.id
}
})
},
delInfo(row) {
//taskAudit
this.$router.push({
name: 'TaskInfo', query: {
pageType: "info",
id: row.id
}
})
},
//
guanbijiekou(row) {
console.log(row);
this.$confirm('此操作将关闭任务, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
assetTaskclose({ taskId: row.id, taskName: row.taskName }).then(res => {
if (res.code == 200) {
this.$message({
type: 'success',
message: '关闭成功!'
});
this.getInfo();
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消关闭'
});
});
},
//
edit() {
},
//
// table
tableRowClassName({ row, rowIndex }) {
if (rowIndex % 2 !== 0) {
return 'evenNumber-row';
})
} else {
ElMessage.warning('请先选择核查资产类型')
}
}
const liebiaoClose = () => {
if (danweiList.value) {
danweiList.value.queryParams = {
current: 1,
size: 10,
userName: undefined,
nickName: undefined,
dwlx: undefined,
}
}
liebiaoDialog.value?.close()
}
const handleQuery = () => {
Object.assign(pagination, {
current: 1,
size: 10
})
if (formInline.time.length > 0) {
formInline.begainTime = formInline.time[0]
formInline.endTime = formInline.time[1]
}
Object.assign(pagination, formInline)
formInline.isfanhui = false
localStorage.setItem("ismypagination", JSON.stringify(formInline))
getInfo()
}
const getPagination = (pages) => {
pagination.current = pages.page
pagination.size = pages.limit
getInfo()
}
const handleAdd = () => {
taskDialog.value?.open()
nextTick(() => {
ruleFormRef.value?.clearValidate()
})
}
const importClose = () => {
resetForm()
}
const goInfo = (row) => {
getassetTaskid(row.id)
router.push({
name: 'TaskInfo',
query: {
pageType: "look",
id: row.id
}
})
}
const delInfo = (row) => {
router.push({
name: 'TaskInfo',
query: {
pageType: "info",
id: row.id
}
})
}
const guanbijiekou = (row) => {
ElMessageBox.confirm('此操作将关闭任务, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
try {
const res = await assetTaskclose({ taskId: row.id, taskName: row.taskName })
if (res.code == 200) {
ElMessage.success('关闭成功!')
await getInfo()
}
return '';
},
//
cancalDebounce() {
const element = document.getElementById('L-size-main'); // ID
const header = document.getElementById('L-header'); // ID
const pagination = document.getElementById('L-pagination'); // ID
const elementHeight = element.offsetHeight;
const headerHeight = header.offsetHeight;
const paginationtHeight = pagination.offsetHeight;
this.tabHeader = elementHeight - headerHeight - paginationtHeight - 110;
} catch (error) {
console.error(error)
}
},
}).catch(() => {
ElMessage.info('已取消关闭')
})
}
const tableRowClassName = ({ rowIndex }) => {
return rowIndex % 2 !== 0 ? 'evenNumber-row' : ''
}
const cancalDebounce = () => {
const element = document.getElementById('L-size-main')
const header = document.getElementById('L-header')
const pagination = document.getElementById('L-pagination')
if (element && header && pagination) {
const elementHeight = element.offsetHeight
const headerHeight = header.offsetHeight
const paginationtHeight = pagination.offsetHeight
tabHeader.value = elementHeight - headerHeight - paginationtHeight - 110
}
}
// Lifecycle hooks
onMounted(() => {
if (localStorage.getItem('ismypagination')) {
const storedPagination = JSON.parse(localStorage.getItem('ismypagination'))
if (storedPagination.isfanhui) {
Object.assign(formInline, storedPagination)
handleQuery()
} else {
localStorage.removeItem("ismypagination")
}
}
localStorage.removeItem("ismypaginationTow")
localStorage.removeItem("activeName")
getInfo()
cancalDebounce()
window.addEventListener('resize', cancalDebounce)
})
onUnmounted(() => {
window.removeEventListener('resize', cancalDebounce)
})
</script>
<style lang="scss" scoped>
.mr-1 {
margin-right: 4px;
}
.el-icon-s-unfold {
font-size: 16px;
}
// ::v-deep .el-dialog__body{
// padding-left: 80px;
// }
.el-icon-delete {
color: #409EFF;
font-size: 16px;

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save