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