chore: remove large file and update .gitignore
This commit is contained in:
190
src/views/safety/violationLevel/component/add.vue
Normal file
190
src/views/safety/violationLevel/component/add.vue
Normal file
@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<div class="system-busViolationLevel-add">
|
||||
<el-dialog v-model="isShowDialog" width="550px" :close-on-click-modal="false" :destroy-on-close="true">
|
||||
<template #header>
|
||||
<div v-drag="['.system-busViolationLevel-add .el-dialog', '.system-busViolationLevel-add .el-dialog__header']">添加违章等级</div>
|
||||
</template>
|
||||
<el-form ref="formRef" size="large" :model="formData" :rules="rules" label-width="90px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="违章等级" prop="violationLevel">
|
||||
<el-input v-model="formData.violationLevel" placeholder="请输入违章等级" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="颜色" prop="color">
|
||||
<el-color-picker v-model="formData.color" show-alpha />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="风险等级" prop="riskType">
|
||||
<el-select v-model="formData.riskType" placeholder="请选择风险等级">
|
||||
<el-option v-for="dict in risxList" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="岗位" prop="postIdList">
|
||||
<el-select v-model="formData.postIdList" placeholder="请选择岗位" multiple>
|
||||
<el-option v-for="dict in postListAll" :key="dict.postId" :label="dict.postName" :value="dict.postId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="违章类型" prop="violationType">
|
||||
<el-select v-model="formData.violationType" placeholder="请选择违章类型" multiple>
|
||||
<el-option v-for="dict in tourTypeOptions" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="onSubmit">确 定</el-button>
|
||||
<el-button @click="onCancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, getCurrentInstance } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { addViolationLevel } from '@/api/safety/violationLevel';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
|
||||
// Props
|
||||
defineProps<{
|
||||
tourTypeOptions: any[];
|
||||
risxList: any[];
|
||||
postListAll: any[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits(['busViolationLevelList']);
|
||||
const { proxy } = getCurrentInstance()!;
|
||||
|
||||
const formRef = ref<any>(null);
|
||||
const menuRef = ref();
|
||||
|
||||
const isShowDialog = ref(false);
|
||||
const loading = ref(false);
|
||||
|
||||
const formData = reactive({
|
||||
id: undefined,
|
||||
violationLevel: undefined,
|
||||
color: undefined,
|
||||
violationType: undefined as any,
|
||||
wxOrPc: undefined,
|
||||
createBy: undefined,
|
||||
updateBy: undefined,
|
||||
createdAt: undefined,
|
||||
updatedAt: undefined,
|
||||
deletedAt: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
riskType: '',
|
||||
postIdList: [] as any[]
|
||||
});
|
||||
|
||||
const rules = {
|
||||
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
||||
violationLevel: [
|
||||
{
|
||||
required: true,
|
||||
validator: (_rule: any, value: string) => /^[A-Z]*$/g.test(value),
|
||||
message: '请输入A-Z的字母',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
postIdList: [{ required: true, message: '岗位不能为空', trigger: 'blur' }]
|
||||
};
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = () => {
|
||||
resetForm();
|
||||
isShowDialog.value = true;
|
||||
};
|
||||
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
isShowDialog.value = false;
|
||||
};
|
||||
|
||||
// 取消操作
|
||||
const onCancel = () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
// 表单重置
|
||||
const resetForm = () => {
|
||||
Object.assign(formData, {
|
||||
id: undefined,
|
||||
violationLevel: undefined,
|
||||
color: undefined,
|
||||
violationType: undefined,
|
||||
wxOrPc: undefined,
|
||||
createBy: undefined,
|
||||
updateBy: undefined,
|
||||
createdAt: undefined,
|
||||
updatedAt: undefined,
|
||||
deletedAt: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
riskType: '',
|
||||
postIdList: []
|
||||
});
|
||||
};
|
||||
|
||||
// 提交操作
|
||||
const onSubmit = () => {
|
||||
if (!formRef.value) return;
|
||||
|
||||
formRef.value.validate((valid: boolean) => {
|
||||
if (valid) {
|
||||
loading.value = true;
|
||||
|
||||
const param = JSON.parse(JSON.stringify(formData));
|
||||
if (param.violationType?.length) {
|
||||
param.violationType = param.violationType.join(',');
|
||||
}
|
||||
|
||||
addViolationLevel(param)
|
||||
.then(() => {
|
||||
ElMessage.success('添加成功');
|
||||
closeDialog();
|
||||
emit('busViolationLevelList');
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
openDialog,
|
||||
closeDialog
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.system-busViolationLevel-add {
|
||||
.el-col {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.el-select .el-input__wrapper {
|
||||
width: 400px;
|
||||
}
|
||||
.el-select__tags {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
flex-wrap: nowrap;
|
||||
overflow: hidden;
|
||||
margin-left: 1px;
|
||||
}
|
||||
}
|
||||
</style>
|
204
src/views/safety/violationLevel/component/edit.vue
Normal file
204
src/views/safety/violationLevel/component/edit.vue
Normal file
@ -0,0 +1,204 @@
|
||||
<template>
|
||||
<div class="system-busViolationLevel-edit">
|
||||
<el-dialog v-model="isShowDialog" width="550px" :close-on-click-modal="false" :destroy-on-close="true" custom-class="busViolationLevel_edit">
|
||||
<template #header>
|
||||
<div v-drag="['.system-busViolationLevel-edit .el-dialog', '.system-busViolationLevel-edit .el-dialog__header']">
|
||||
{{ (!formData.id || formData.id == 0 ? '添加' : '修改') + '违章等级' }}
|
||||
</div>
|
||||
</template>
|
||||
<el-form ref="formRef" size="large" :model="formData" :rules="rules" label-width="90px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="违章等级" prop="violationLevel">
|
||||
<el-input v-model="formData.violationLevel" placeholder="请输入违章等级" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="颜色" prop="color">
|
||||
<el-color-picker v-model="formData.color" show-alpha />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="风险等级" prop="riskType">
|
||||
<el-select v-model="formData.riskType" placeholder="请选择风险等级">
|
||||
<el-option v-for="dict in risxList" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="岗位" prop="postIdList">
|
||||
<el-select v-model="formData.postIdList" placeholder="请选择岗位" multiple>
|
||||
<el-option v-for="dict in postListAll" :key="dict.postId" :label="dict.postName" :value="dict.postId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="违章类型" prop="violationType">
|
||||
<el-select v-model="formData.violationType" placeholder="请选择违章类型" multiple>
|
||||
<el-option v-for="dict in tourTypeOptions" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="onSubmit">确 定</el-button>
|
||||
<el-button @click="onCancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, getCurrentInstance, unref, nextTick } from 'vue';
|
||||
import { ElMessage, ElLoading } from 'element-plus';
|
||||
import { getViolationLevel, addViolationLevel, updateViolationLevel } from '@/api/safety/violationLevel';
|
||||
import { ViolationLevelForm, ViolationLevelVO } from '@/api/safety/violationLevel/types';
|
||||
|
||||
defineProps<{
|
||||
tourTypeOptions: any[];
|
||||
risxList: any[];
|
||||
postListAll: any[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits(['busViolationLevelList']);
|
||||
|
||||
const { proxy } = getCurrentInstance()!;
|
||||
const formRef = ref<any>(null);
|
||||
const isShowDialog = ref(false);
|
||||
const loading = ref(false);
|
||||
|
||||
const formData = reactive<
|
||||
Partial<ViolationLevelForm> & {
|
||||
risx?: string[] | string;
|
||||
tourType?: string[] | string;
|
||||
postIdList: number[];
|
||||
}
|
||||
>({
|
||||
id: undefined,
|
||||
violationLevel: undefined,
|
||||
color: undefined,
|
||||
riskType: undefined,
|
||||
createBy: undefined,
|
||||
updateBy: undefined,
|
||||
risx: '',
|
||||
postIdList: []
|
||||
});
|
||||
|
||||
const rules = {
|
||||
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
||||
violationLevel: [
|
||||
{
|
||||
required: true,
|
||||
validator: (_rule: any, value: string) => /^[A-Z]*$/g.test(value),
|
||||
message: '请输入A-Z的字母',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
posts: [{ required: true, message: '岗位不能为空', trigger: 'blur' }]
|
||||
};
|
||||
|
||||
const openDialog = (row?: ViolationLevelVO) => {
|
||||
resetForm();
|
||||
if (row && row.id) {
|
||||
nextTick(() => {
|
||||
const loadingInstance = ElLoading.service({
|
||||
lock: true,
|
||||
text: '正在加载中……',
|
||||
background: 'rgba(0, 0, 0, 0.7)',
|
||||
target: '.busViolationLevel_edit'
|
||||
});
|
||||
getViolationLevel(row.id as string).then((res) => {
|
||||
loadingInstance.close();
|
||||
const data = res.data;
|
||||
data.postIdList = (data.postList || []).map((item: any) => item.postId);
|
||||
data.violationType = data.violationType ? (data.violationType as string).split(',') : [];
|
||||
Object.assign(formData, data);
|
||||
});
|
||||
});
|
||||
}
|
||||
isShowDialog.value = true;
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
isShowDialog.value = false;
|
||||
};
|
||||
|
||||
const onCancel = () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
const onSubmit = () => {
|
||||
const form = unref(formRef);
|
||||
if (!form) return;
|
||||
|
||||
form.validate((valid: boolean) => {
|
||||
if (!valid) return;
|
||||
|
||||
loading.value = true;
|
||||
|
||||
const param = JSON.parse(JSON.stringify(formData));
|
||||
if (Array.isArray(param.violationType)) {
|
||||
param.violationType = param.violationType.join(',');
|
||||
}
|
||||
if (Array.isArray(param.riskType)) {
|
||||
param.riskType = param.riskType.join(',');
|
||||
}
|
||||
|
||||
const action = !param.id || param.id === 0 ? addViolationLevel : updateViolationLevel;
|
||||
const successMsg = !param.id || param.id === 0 ? '添加成功' : '修改成功';
|
||||
|
||||
action(param)
|
||||
.then(() => {
|
||||
ElMessage.success(successMsg);
|
||||
closeDialog();
|
||||
emit('busViolationLevelList');
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
Object.assign(formData, {
|
||||
id: undefined,
|
||||
grade: undefined,
|
||||
color: undefined,
|
||||
tourType: undefined,
|
||||
wxOrPc: undefined,
|
||||
createBy: undefined,
|
||||
updateBy: undefined,
|
||||
createdAt: undefined,
|
||||
updatedAt: undefined,
|
||||
deletedAt: undefined,
|
||||
risx: '',
|
||||
posts: []
|
||||
});
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
openDialog,
|
||||
closeDialog
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.system-busViolationLevel-edit {
|
||||
.el-col {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.el-select .el-input__wrapper {
|
||||
width: 400px;
|
||||
}
|
||||
.el-select__tags {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
flex-wrap: nowrap;
|
||||
overflow: hidden;
|
||||
margin-left: 1px;
|
||||
}
|
||||
}
|
||||
</style>
|
290
src/views/safety/violationLevel/index.vue
Normal file
290
src/views/safety/violationLevel/index.vue
Normal file
@ -0,0 +1,290 @@
|
||||
<template>
|
||||
<div class="system-busViolationLevel-container">
|
||||
<el-card shadow="hover">
|
||||
<div class="system-busViolationLevel-search mb15">
|
||||
<el-form :model="state.tableData.param" ref="queryRef" :inline="true" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="8" class="colBlock">
|
||||
<el-form-item label="违章类型" prop="tourType">
|
||||
<el-select v-model="state.tableData.param.violationType" placeholder="请选择违章类型" clearable>
|
||||
<el-option v-for="dict in violation_level_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8" class="colBlock">
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="busViolationLevelList">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
<el-button @click="resetQuery(queryRef)">
|
||||
<el-icon><Refresh /></el-icon>重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" @click="handleAdd" v-auth="'api/v1/system/busViolationLevel/add'">
|
||||
<el-icon><Plus /></el-icon>新增
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" :disabled="single" @click="handleUpdate(null)" v-auth="'api/v1/system/busViolationLevel/edit'">
|
||||
<el-icon><Edit /></el-icon>修改
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" :disabled="multiple" @click="handleDelete(null)" v-auth="'api/v1/system/busViolationLevel/delete'">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="state.tableData.data" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="center" type="index" :index="indexMethod" width="60" />
|
||||
<el-table-column label="违章等级" align="center" prop="violationLevel" width="100px" />
|
||||
<el-table-column label="颜色" align="center" prop="color" width="100px">
|
||||
<template #default="scope">
|
||||
<div :style="`background: ${scope.row.color};width:15px;height:15px;margin:auto;`"></div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="风险等级" align="center" prop="riskType" width="150px">
|
||||
<template #default="scope">
|
||||
<span>{{ filterRiskLevelType(scope.row.riskType) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="违章类型" show-overflow-tooltip align="center" prop="violationType" :formatter="tourTypeFormat" min-width="100px" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="150px">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding" width="160px" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button type="success" link @click="handleUpdate(scope.row)" v-auth="'api/v1/system/busViolationLevel/edit'">
|
||||
<el-icon><EditPen /></el-icon>修改
|
||||
</el-button>
|
||||
<el-button type="danger" link @click="handleDelete(scope.row)" v-auth="'api/v1/system/busViolationLevel/delete'">
|
||||
<el-icon><DeleteFilled /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="state.tableData.total > 0"
|
||||
:total="state.tableData.total"
|
||||
v-model:page="state.tableData.param.pageNum"
|
||||
v-model:limit="state.tableData.param.pageSize"
|
||||
@pagination="busViolationLevelList"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<apiV1SystemBusViolationLevelAdd
|
||||
ref="addRef"
|
||||
:tourTypeOptions="violation_level_type"
|
||||
:risxList="risk_level_type"
|
||||
@busViolationLevelList="busViolationLevelList"
|
||||
:postListAll="state.postListAll"
|
||||
/>
|
||||
<apiV1SystemBusViolationLevelEdit
|
||||
ref="editRef"
|
||||
:tourTypeOptions="violation_level_type"
|
||||
:risxList="risk_level_type"
|
||||
:postListAll="state.postListAll"
|
||||
@busViolationLevelList="busViolationLevelList"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted, getCurrentInstance, toRaw } from 'vue';
|
||||
import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
|
||||
import { listViolationLevel, delViolationLevel } from '@/api/safety/violationLevel';
|
||||
import { ViolationLevelForm, ViolationLevelVO } from '@/api/safety/violationLevel/types';
|
||||
import apiV1SystemBusViolationLevelAdd from '@/views/safety/violationLevel/component/add.vue';
|
||||
import apiV1SystemBusViolationLevelEdit from '@/views/safety/violationLevel/component/edit.vue';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import { listPost, optionselect } from '@/api/system/post';
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const { proxy } = getCurrentInstance()!;
|
||||
|
||||
const loading = ref(false);
|
||||
const queryRef = ref<FormInstance>();
|
||||
const addRef = ref<InstanceType<typeof apiV1SystemBusViolationLevelAdd>>();
|
||||
const editRef = ref<InstanceType<typeof apiV1SystemBusViolationLevelEdit>>();
|
||||
const detailRef = ref<any>();
|
||||
|
||||
const showAll = ref(false);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
|
||||
const word = computed(() => (showAll.value === false ? '展开搜索' : '收起搜索'));
|
||||
const { violation_level_type, risk_level_type } = toRefs<any>(proxy?.useDict('violation_level_type', 'risk_level_type'));
|
||||
|
||||
const state = reactive<any>({
|
||||
ids: [],
|
||||
tableData: {
|
||||
data: [],
|
||||
total: 0,
|
||||
loading: false,
|
||||
param: {
|
||||
projectId: currentProject.value?.id,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
tourType: undefined,
|
||||
createdAt: undefined,
|
||||
dateRange: []
|
||||
}
|
||||
},
|
||||
postListAll: []
|
||||
});
|
||||
|
||||
const postList = () => {
|
||||
listPost({ pageNum: 1, pageSize: 100 }).then((res) => {
|
||||
state.postListAll = res.rows ?? [];
|
||||
});
|
||||
};
|
||||
|
||||
const initTableData = () => {
|
||||
busViolationLevelList();
|
||||
};
|
||||
|
||||
const resetQuery = (formEl?: FormInstance) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
console.log(useUserStoreHook().selectedProject, currentProject.value?.id);
|
||||
|
||||
busViolationLevelList();
|
||||
};
|
||||
|
||||
const busViolationLevelList = () => {
|
||||
loading.value = true;
|
||||
listViolationLevel(state.tableData.param).then((res: any) => {
|
||||
const list = res.rows ?? [];
|
||||
state.tableData.data = list;
|
||||
state.tableData.total = res.total;
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const toggleSearch = () => {
|
||||
showAll.value = !showAll.value;
|
||||
};
|
||||
|
||||
const tourTypeFormat = (row: ViolationLevelVO) => {
|
||||
const type: string[] = [];
|
||||
if (row.violationType.includes(',')) {
|
||||
(row.violationType as string).split(',').forEach((item) => {
|
||||
type.push(proxy.selectDictLabel(violation_level_type.value, item));
|
||||
});
|
||||
} else {
|
||||
type.push(proxy.selectDictLabel(violation_level_type.value, row.violationType as string));
|
||||
}
|
||||
return type.join(',');
|
||||
};
|
||||
|
||||
const handleSelectionChange = (selection: ViolationLevelForm[]) => {
|
||||
state.ids = selection.map((item) => item.id);
|
||||
single.value = selection.length !== 1;
|
||||
multiple.value = selection.length === 0;
|
||||
};
|
||||
|
||||
const handleAdd = () => {
|
||||
addRef.value?.openDialog();
|
||||
};
|
||||
|
||||
const handleUpdate = (row: ViolationLevelVO | null) => {
|
||||
if (!row) {
|
||||
row = state.tableData.data.find((item) => item.id === state.ids[0]) ?? null;
|
||||
}
|
||||
if (row) {
|
||||
editRef.value?.openDialog(toRaw(row));
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = (row: ViolationLevelVO | null) => {
|
||||
let msg = '你确定要删除所选数据?';
|
||||
let id: (string | number)[] = [];
|
||||
if (row) {
|
||||
msg = `此操作将永久删除数据,是否继续?`;
|
||||
id = [row.id as string];
|
||||
} else {
|
||||
id = state.ids;
|
||||
}
|
||||
if (id.length === 0) {
|
||||
ElMessage.error('请选择要删除的数据。');
|
||||
return;
|
||||
}
|
||||
ElMessageBox.confirm(msg, '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
delViolationLevel(id).then(() => {
|
||||
ElMessage.success('删除成功');
|
||||
busViolationLevelList();
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const handleView = (row: ViolationLevelVO) => {
|
||||
detailRef.value?.openDialog(toRaw(row));
|
||||
};
|
||||
|
||||
const indexMethod = (index: number) => {
|
||||
const pageNum = state.tableData.param.pageNum - 1;
|
||||
if (pageNum !== -1 && pageNum !== 0) {
|
||||
return index + 1 + pageNum * state.tableData.param.pageSize;
|
||||
} else {
|
||||
return index + 1;
|
||||
}
|
||||
};
|
||||
|
||||
const filterRiskLevelType = (val: any) => {
|
||||
let label = '';
|
||||
if (val) {
|
||||
if (risk_level_type.value.length) {
|
||||
risk_level_type.value.forEach((item: any) => {
|
||||
if (item.value == val) {
|
||||
label = item.label;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return label;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
postList();
|
||||
initTableData();
|
||||
});
|
||||
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value.id,
|
||||
(nid, oid) => {
|
||||
state.tableData.param.projectId = nid;
|
||||
initTableData();
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.colBlock {
|
||||
display: block;
|
||||
}
|
||||
.colNone {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user