fix(加班申请): 使用后端专门返回状态的接口,代替使用字典。
fix(status-tag.ts):把产品需求、项目需求的状态颜色定义收敛到此处。
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, watch } from 'vue';
|
||||
import { RDMS_OVERTIME_APPLICATION_STATUS_DICT_CODE } from '@/constants/dict';
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { fetchGetOvertimeApplicationStatusDict } from '@/service/api';
|
||||
import TableSearchFields, { type SearchField } from '@/components/custom/table-search-fields.vue';
|
||||
|
||||
defineOptions({ name: 'OvertimeApplicationSearch' });
|
||||
@@ -21,6 +21,8 @@ const searchModel = reactive<Record<string, any>>({
|
||||
approverName: ''
|
||||
});
|
||||
|
||||
const statusOptions = ref<Array<{ label: string; value: string }>>([]);
|
||||
|
||||
let syncingFromSource = false;
|
||||
|
||||
watch(
|
||||
@@ -53,6 +55,24 @@ watch(
|
||||
{ flush: 'sync' }
|
||||
);
|
||||
|
||||
async function loadStatusOptions() {
|
||||
const { error, data } = await fetchGetOvertimeApplicationStatusDict();
|
||||
|
||||
if (error || !data) {
|
||||
statusOptions.value = [];
|
||||
return;
|
||||
}
|
||||
|
||||
statusOptions.value = data.map(item => ({
|
||||
label: item.statusName,
|
||||
value: item.statusCode
|
||||
}));
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadStatusOptions();
|
||||
});
|
||||
|
||||
const fields = computed<SearchField[]>(() => [
|
||||
{
|
||||
key: 'applicantName',
|
||||
@@ -69,8 +89,8 @@ const fields = computed<SearchField[]>(() => [
|
||||
{
|
||||
key: 'statusCode',
|
||||
label: '状态',
|
||||
type: 'dict',
|
||||
dictCode: RDMS_OVERTIME_APPLICATION_STATUS_DICT_CODE,
|
||||
type: 'select',
|
||||
options: statusOptions.value,
|
||||
placeholder: '请选择状态'
|
||||
},
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
RDMS_REQ_PRIORITY_DICT_CODE,
|
||||
RDMS_REQ_SOURCE_TYPE_DICT_CODE
|
||||
} from '@/constants/dict';
|
||||
import { getStatusTagType } from '@/constants/status-tag';
|
||||
import {
|
||||
fetchChangeRequirementStatus,
|
||||
fetchDeleteRequirement,
|
||||
@@ -31,7 +32,6 @@ import {
|
||||
ACTION_TYPE_MAP,
|
||||
type RequirementStatusActionCode,
|
||||
getRequirementActionDisplayName,
|
||||
getRequirementStatusTagType,
|
||||
isRequirementActionNeedProject,
|
||||
isRequirementActionNeedReviewChoice,
|
||||
isRequirementActionTerminal
|
||||
@@ -375,7 +375,7 @@ const columns = computed(() => [
|
||||
width: 100,
|
||||
align: 'center',
|
||||
formatter: (row: Api.Product.Requirement) => (
|
||||
<ElTag type={getRequirementStatusTagType(row.statusCode)}>{getStatusLabel(row.statusCode)}</ElTag>
|
||||
<ElTag type={getStatusTagType('productRequirement', row.statusCode)}>{getStatusLabel(row.statusCode)}</ElTag>
|
||||
)
|
||||
},
|
||||
{
|
||||
|
||||
@@ -90,22 +90,7 @@ export const ACTION_TYPE_MAP: Record<string, 'primary' | 'success' | 'danger'> =
|
||||
close: 'danger',
|
||||
delete: 'danger'
|
||||
};
|
||||
export function getRequirementStatusTagType(status: Api.Product.RequirementStatusCode): UI.ThemeColor {
|
||||
const statusTagTypeMap: Record<Api.Product.RequirementStatusCode, UI.ThemeColor> = {
|
||||
pending_claim: 'info',
|
||||
pending_review: 'info',
|
||||
pending_dispatch: 'primary',
|
||||
reviewed: 'success',
|
||||
review_rejected: 'danger',
|
||||
implementing: 'primary',
|
||||
accepted: 'success',
|
||||
closed: 'danger',
|
||||
rejected: 'danger',
|
||||
cancelled: 'danger'
|
||||
};
|
||||
|
||||
return statusTagTypeMap[status];
|
||||
}
|
||||
export function isRequirementActionTerminal(actionCode: RequirementStatusActionCode) {
|
||||
const terminalActions: RequirementStatusActionCode[] = ['reject', 'cancel', 'close'];
|
||||
return terminalActions.includes(actionCode);
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
RDMS_REQ_PRIORITY_DICT_CODE,
|
||||
RDMS_REQ_SOURCE_TYPE_DICT_CODE
|
||||
} from '@/constants/dict';
|
||||
import { getStatusTagType } from '@/constants/status-tag';
|
||||
import {
|
||||
fetchChangeProjectRequirementStatus,
|
||||
fetchDeleteProjectRequirement,
|
||||
@@ -28,7 +29,6 @@ import {
|
||||
getProjectRequirementActionButtonType,
|
||||
getProjectRequirementActionDisplayName,
|
||||
getProjectRequirementActionIcon,
|
||||
getProjectRequirementStatusTagType,
|
||||
isProjectRequirementActionTerminal
|
||||
} from './shared/requirement-master-data';
|
||||
import RequirementActionDialog from './modules/requirement-action-dialog.vue';
|
||||
@@ -377,7 +377,7 @@ const columns = computed(() => [
|
||||
width: 110,
|
||||
align: 'center',
|
||||
formatter: (row: Api.Project.ProjectRequirement) => (
|
||||
<ElTag type={getProjectRequirementStatusTagType(row.statusCode)}>{getStatusLabel(row.statusCode)}</ElTag>
|
||||
<ElTag type={getStatusTagType('projectRequirement', row.statusCode)}>{getStatusLabel(row.statusCode)}</ElTag>
|
||||
)
|
||||
},
|
||||
{
|
||||
|
||||
@@ -77,24 +77,6 @@ function resolveActionKeyword(actionCode: string) {
|
||||
return Object.keys(ACTION_ICON_MAP).find(keyword => actionCode.includes(keyword));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目需求状态的标签颜色
|
||||
*/
|
||||
export function getProjectRequirementStatusTagType(status: Api.Project.ProjectRequirementStatusCode): UI.ThemeColor {
|
||||
const statusTagTypeMap: Record<Api.Project.ProjectRequirementStatusCode, UI.ThemeColor> = {
|
||||
pending_claim: 'info',
|
||||
pending_review: 'info',
|
||||
reviewed: 'success',
|
||||
review_rejected: 'danger',
|
||||
implementing: 'primary',
|
||||
accepted: 'success',
|
||||
closed: 'danger',
|
||||
rejected: 'danger',
|
||||
cancelled: 'danger'
|
||||
};
|
||||
|
||||
return statusTagTypeMap[status];
|
||||
}
|
||||
/**
|
||||
* 判断动作是否为终态动作
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user