table.data.js 3.48 KB
import dayjs from "dayjs";
import { keyBy } from "lodash-es";
import { getTaskCenterBizCategoryListApi } from "@/views/residentManage/taskCenter/api/index.js";
import { overdueFlagOptions, priorityOptions, statusOptions } from "@/views/residentManage/taskCenter/constant/index.js";

export async function getTableFormSchema() {
	const bizTypesList = await getTaskCenterBizCategoryListApi();
	return [

		{
			label: "任务编号",
			name: "condition.taskNo",
			type: "input",
			maxlength: 20,
		},
		{
			label: "任务标题",
			name: "condition.title",
			type: "input",
			maxlength: 100,
		},

		{
			label: "优先级",
			name: "condition.priorities",
			type: "select",
			isClear: true,
			optionList: priorityOptions,
			optionId: "value",
			optionLabel: "label",
			multiple: true,
		},

		{
			label: "完成状态",
			name: "condition.status",
			type: "select",
			isClear: true,
			optionList: statusOptions,
			optionId: "value",
			optionLabel: "label",
		},
		{
			label: "任务分类",
			name: "condition.bizTypes",
			type: "select",
			isClear: true,
			optionList: bizTypesList,
			optionId: "bizType",
			optionLabel: "categoryName",
			multiple: true,
		},
		{
			label: "执行人",
			name: "condition.assigneeName",
			type: "input",
			maxlength: 20,
		},
		{
			label: "创建人",
			name: "condition.creatorName",
			type: "input",
			maxlength: 20,
		},
		{
			label: "是否逾期",
			name: "condition.overdueFlag",
			type: "select",
			isClear: true,
			optionList: overdueFlagOptions,
			optionId: "value",
			optionLabel: "label",
		},

	];
} ;

export async function getTableColumns() {
	return [
		{
			label: "任务编号",
			prop: "taskNo",
			width: "180px",
			align: "left",
		},
		{
			label: "任务标题",
			prop: "title",
			minWidth: "200px",
			align: "left",
		},
		{
			label: "任务分类",
			prop: "bizTypeName",
			width: "180px",
			align: "left",
		},
		{
			label: "优先级",
			prop: "priority",
			width: "100px",
			useTag: true,
			align: "left",
			tagOptions: keyBy(priorityOptions, "value"),
		},
		{
			label: "执行人",
			prop: "assignees",
			width: "120px",
			align: "left",
			formatter: (row) => {
				return (row?.assignees || []).map(item => item.assigneeName).join(",") || "-";
			},
		},
		{
			label: "完成状态",
			prop: "status",
			align: "left",
			width: "120px",
			formatter: (row) => {
				return statusOptions.find(item => item.value === row.status)?.label || "-";
			},

			valueClass: (cellValue) => {
				return { UNFINISHED: "yellow-dot", FINISHED: "green-dot" }[cellValue.status];
			},
		},
		{
			label: "完成时间",
			prop: "completeTime",
			width: "180px",
			align: "left",
			formatter: (row) => {
				return row.completeTime || "-";
			},
		},
		{
			label: "截止时间",
			prop: "dueTime",
			width: "180px",
			align: "left",
			formatter: (row) => {
				return row.dueTime || "-";
			},
			valueClass: ({ dueTime, completeTime }) => {
				if (!dueTime)
					return "";
				if (!completeTime) {
					if (dayjs(dueTime).isBefore(dayjs())) {
						return "color-red";
					}
				}
				if (completeTime) {
					if (dayjs(dueTime).isBefore(dayjs(completeTime))) {
						return "color-red";
					}
				}
			},
		},
		{
			label: "创建人",
			prop: "createdBy",
			width: "140px",
			align: "left",
			formatter: (row) => {
				return row.createdBy || "-";
			},
		},
		{
			label: "创建时间",
			prop: "createdDate",
			width: "180px",
			align: "left",
			formatter: (row) => {
				return row.createdDate || "-";
			},
		},
	];
}