feat: 参数应用申请操作和查看功能

This commit is contained in:
TsMask
2024-07-17 17:04:13 +08:00
parent c87458bc23
commit 4d755cea5d

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { reactive, onMounted, toRaw } from 'vue'; import { reactive, onMounted, toRaw, computed } from 'vue';
import { PageContainer } from 'antdv-pro-layout'; import { PageContainer } from 'antdv-pro-layout';
import { Form, message, Modal } from 'ant-design-vue/lib'; import { Form, message, Modal } from 'ant-design-vue/lib';
import { SizeType } from 'ant-design-vue/lib/config-provider'; import { SizeType } from 'ant-design-vue/lib/config-provider';
@@ -12,9 +12,11 @@ import useNeInfoStore from '@/store/modules/neinfo';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import useI18n from '@/hooks/useI18n'; import useI18n from '@/hooks/useI18n';
import { import {
getPtNeConfigApply, getPtNeConfigApplyList,
stuPtNeConfigApply,
updatePtNeConfigApply, updatePtNeConfigApply,
} from '@/api/pt/neConfigApply'; } from '@/api/pt/neConfigApply';
import { hasRoles } from '@/plugins/auth-user';
const { t } = useI18n(); const { t } = useI18n();
const { getDict } = useDictStore(); const { getDict } = useDictStore();
const neInfoStore = useNeInfoStore(); const neInfoStore = useNeInfoStore();
@@ -173,43 +175,14 @@ function fnTableSize({ key }: MenuInfo) {
} }
/**表格多选 */ /**表格多选 */
function fnTableSelectedRowKeys(keys: (string | number)[]) { function fnTableSelectedRowKeys(keys: (string | number)[], infos: any) {
tableState.selectedRowKeys = keys; const arr = [];
} for (const item of infos) {
if (item.status === '0') {
/**申请撤回*/ arr.push(item.id);
function fnRecordCancel(row: Record<string, any>) {} }
}
/**申请退回*/ tableState.selectedRowKeys = arr;
function fnRecordBack(row: Record<string, any>) {}
/**申请下发应用*/
function fnRecordApply(row: Record<string, any>) {
const ids = tableState.selectedRowKeys.join(',');
Modal.confirm({
title: t('common.tipTitle'),
content: t('views.monitor.jobLog.delTip', { num: ids }),
onOk() {
const key = 'delJobLog';
message.loading({ content: t('common.loading'), key });
delJobLog(ids).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: t('views.monitor.jobLog.delOk'),
key,
duration: 2,
});
fnGetList();
} else {
message.error({
content: `${res.msg}`,
key,
duration: 2,
});
}
});
},
});
} }
/**查询列表, pageNum初始页数 */ /**查询列表, pageNum初始页数 */
@@ -219,7 +192,7 @@ function fnGetList(pageNum?: number) {
if (pageNum) { if (pageNum) {
queryParams.pageNum = pageNum; queryParams.pageNum = pageNum;
} }
getPtNeConfigApply(toRaw(queryParams)).then(res => { getPtNeConfigApplyList(toRaw(queryParams)).then(res => {
if (res.code === RESULT_CODE_SUCCESS) { if (res.code === RESULT_CODE_SUCCESS) {
// 取消勾选 // 取消勾选
if (tableState.selectedRowKeys.length > 0) { if (tableState.selectedRowKeys.length > 0) {
@@ -268,7 +241,7 @@ let modalState: ModalStateType = reactive({
updateBy: '', updateBy: '',
updateTime: 0, updateTime: 0,
neType: 'MME', neType: 'MME',
status: undefined, status: '0',
backInfo: '', backInfo: '',
}, },
confirmLoading: false, confirmLoading: false,
@@ -303,9 +276,8 @@ function fnModalVisibleByVive(row: Record<string, any>) {
* @param jobId 任务id * @param jobId 任务id
*/ */
function fnModalVisibleByEdit(row: Record<string, any>) { function fnModalVisibleByEdit(row: Record<string, any>) {
modalState.from = Object.assign(modalState.from, row, { Object.assign(modalState.from, row);
status: '3', modalState.from.status = '3';
});
modalState.title = '编辑状态'; modalState.title = '编辑状态';
modalState.visibleByEdit = true; modalState.visibleByEdit = true;
} }
@@ -333,16 +305,9 @@ function fnModalOk() {
duration: 3, duration: 3,
}); });
// 更新当前列表数据
const item = tableState.data.find(
(item: any) => item.id === from.id
);
if (item) {
Object.assign(item, from);
}
modalState.visibleByEdit = false; modalState.visibleByEdit = false;
modalStateFrom.resetFields(); modalStateFrom.resetFields();
fnGetList();
} else { } else {
message.error({ message.error({
content: `${res.msg}`, content: `${res.msg}`,
@@ -369,6 +334,53 @@ function fnModalCancel() {
modalState.from = {}; modalState.from = {};
} }
/**批量退回 */
function fnRecordBack(row?: Record<string, any>) {
Modal.confirm({
title: t('common.tipTitle'),
content: row
? '确认要撤回配置应用申请吗?'
: '确认要批量退回学生的配置应用申请吗?',
onOk() {
let result: any;
if (row) {
result = stuPtNeConfigApply({ neType: row.neType, status: '1' });
} else {
result = updatePtNeConfigApply({
status: "3",
backId: tableState.selectedRowKeys.join(","),
backInfo: "请重新检查配置",
});
}
result.then((res: any) => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: t('common.operateOk'),
duration: 3,
});
} else {
message.error({
content: `${res.msg}`,
duration: 3,
});
}
});
},
});
}
/**应用状态 */
const applyStatus = computed(() => {
if (hasRoles(['student'])) {
return dict.ptConfigApplyStatus.filter(s => ['0', '1'].includes(s.value));
}
let data = dict.ptConfigApplyStatus;
if (modalState.visibleByEdit && modalState.from.id) {
data = dict.ptConfigApplyStatus.filter(s => ['2', '3'].includes(s.value));
}
return data;
});
onMounted(() => { onMounted(() => {
// 初始字典数据 // 初始字典数据
Promise.allSettled([getDict('pt_config_apply_status')]).then(resArr => { Promise.allSettled([getDict('pt_config_apply_status')]).then(resArr => {
@@ -413,7 +425,7 @@ onMounted(() => {
v-model:value="queryParams.status" v-model:value="queryParams.status"
allow-clear allow-clear
:placeholder="t('common.selectPlease')" :placeholder="t('common.selectPlease')"
:options="dict.ptConfigApplyStatus" :options="applyStatus"
> >
</a-select> </a-select>
</a-form-item> </a-form-item>
@@ -444,7 +456,8 @@ onMounted(() => {
type="default" type="default"
danger danger
:disabled="tableState.selectedRowKeys.length <= 0" :disabled="tableState.selectedRowKeys.length <= 0"
@click.prevent="fnRecordCancel({ id: '#' })" @click.prevent="fnRecordBack()"
v-roles:has="['admin', 'teacher']"
> >
<template #icon><DeleteOutlined /></template> <template #icon><DeleteOutlined /></template>
批量退回 批量退回
@@ -531,7 +544,15 @@ onMounted(() => {
<template #icon><ProfileOutlined /></template> <template #icon><ProfileOutlined /></template>
</a-button> </a-button>
</a-tooltip> </a-tooltip>
<a-tooltip v-if="record.status === '0'"> <a-tooltip v-if="record.status === '0' && hasRoles(['student'])">
<template #title>撤回</template>
<a-button type="link" @click.prevent="fnRecordBack(record)">
<template #icon><RollbackOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip
v-if="record.status === '0' && hasRoles(['admin', 'teacher'])"
>
<template #title>{{ t('common.editText') }}</template> <template #title>{{ t('common.editText') }}</template>
<a-button <a-button
type="link" type="link"
@@ -620,10 +641,16 @@ onMounted(() => {
:visible="modalState.visibleByEdit" :visible="modalState.visibleByEdit"
:title="modalState.title" :title="modalState.title"
:confirm-loading="modalState.confirmLoading" :confirm-loading="modalState.confirmLoading"
:destroyOnClose="true"
@ok="fnModalOk" @ok="fnModalOk"
@cancel="fnModalCancel" @cancel="fnModalCancel"
> >
<a-form layout="horizontal" :label-col="{ span: 6 }" :label-wrap="true"> <a-form
name="modalStateFrom"
layout="horizontal"
:label-col="{ span: 6 }"
:label-wrap="true"
>
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24"> <a-col :lg="12" :md="12" :xs="24">
<a-form-item :label="t('views.ne.common.neType')" name="neType"> <a-form-item :label="t('views.ne.common.neType')" name="neType">
@@ -654,11 +681,8 @@ onMounted(() => {
> >
<a-select <a-select
v-model:value="modalState.from.status" v-model:value="modalState.from.status"
default-value="3"
:placeholder="t('common.selectPlease')" :placeholder="t('common.selectPlease')"
:options=" :options="applyStatus"
dict.ptConfigApplyStatus.filter(s => ['2', '3'].includes(s.value))
"
> >
</a-select> </a-select>
</a-form-item> </a-form-item>