Commit b0a1f5d9 by Jaxon

feat(任务中心): 业务开发 - 人员管理 - 任务中心

1 parent eae05685
...@@ -14,3 +14,14 @@ export function getTaskCenterBizCategoryListApi(data = {}) { ...@@ -14,3 +14,14 @@ export function getTaskCenterBizCategoryListApi(data = {}) {
data.method = "dj.api.taskcenter.bizcategory.list"; data.method = "dj.api.taskcenter.bizcategory.list";
return request(data, RequestMethods.POST); return request(data, RequestMethods.POST);
} }
// 获取任务详情
export function getTaskCenterDetailApi(data = {}) {
data.method = "dj.api.taskcenter.task.detail";
return request(data, RequestMethods.POST);
}
export function getTaskCenterCountApi(data = {}) {
data.method = "dj.api.taskcenter.task.count";
return request(data, RequestMethods.POST);
}
...@@ -24,10 +24,12 @@ export const statusOptions = [ ...@@ -24,10 +24,12 @@ export const statusOptions = [
{ {
value: "UNFINISHED", value: "UNFINISHED",
label: "未完成", label: "未完成",
className: "yellow-dot",
}, },
{ {
value: "FINISHED", value: "FINISHED",
label: "已完成", label: "已完成",
className: "green-dot",
}, },
]; ];
......
import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat";
import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
import DescriptionImageList from "@/components/descriptions/components/imageList.vue";
import { statusOptions } from "@/views/residentManage/taskCenter/constant";
import "dayjs/locale/zh-cn";
dayjs.extend(isSameOrBefore);
dayjs.extend(isSameOrAfter);
dayjs.extend(customParseFormat);
function parseDatetime(value) {
if (!value)
return "-";
const formats = [
"YYYY-MM-DDTHH:mm:ss",
"YYYY-MM-DD HH:mm:ss",
"YYYY-MM-DDTHH:mm",
"YYYY-MM-DD",
];
for (const format of formats) {
const parsed = dayjs(value, format, true);
if (parsed.isValid()) {
return parsed.format("YYYY-MM-DD HH:mm:ss");
}
}
return "-";
}
function renderText(h, { data, schemaItem, schema }) {
return h("span", schemaItem.meta.fieldValue || "-");
}
function renderDatetime(h, { data, schemaItem, schema }) {
const formatted = parseDatetime(schemaItem.meta.fieldValue);
return h("span", formatted);
}
function renderLink(h, { data, schemaItem, schema }) {
const { fieldValue, linkAlias } = schemaItem.meta;
if (!fieldValue)
return h("span", "-");
const linkProps = {
attrs: {
href: fieldValue,
target: "_blank",
type: "primary",
},
on: {
click: (e) => {
e.preventDefault();
window.open(fieldValue, "_blank");
},
},
};
return h("el-link", linkProps, linkAlias || fieldValue);
}
function renderImage(h, { data, schemaItem, schema }) {
const { fieldValue } = schemaItem.meta;
if (!fieldValue || !Array.isArray(fieldValue) || fieldValue.length === 0) {
return h("span", "-");
}
return h(DescriptionImageList, { props: { list: fieldValue, size: 80 } });
}
function isImageUrl(url) {
if (!url)
return false;
const imageExtensions = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".svg"];
const lowerUrl = url.toLowerCase();
return imageExtensions.some(ext => lowerUrl.includes(ext));
}
function renderAttachment(h, { data, schemaItem, schema }) {
const { fieldValue } = schemaItem.meta;
if (!fieldValue || !Array.isArray(fieldValue) || fieldValue.length === 0) {
return h("span", "-");
}
const containerChildren = fieldValue.map((item, index) => {
const fileName = item.name || item.fileName || item.url || `附件${index + 1}`;
const fileUrl = item.value || item.url || "";
const rowChildren = [
h("span", { attrs: { class: "file-name" } }, fileName),
];
if (isImageUrl(fileUrl)) {
rowChildren.push(
h("span", {
attrs: { class: "download-link" },
style: { marginLeft: "8px", color: "#409eff", cursor: "pointer" },
on: { click: () => handleDownload(fileUrl, fileName) },
}, "下载"),
);
} else {
rowChildren.push(
h("el-link", {
props: { type: "text", href: fileUrl, target: "_blank" },
style: { marginLeft: "8px", lineHeight: 1 },
}, "下载"),
);
}
return h("div", { attrs: { class: "attachment-item", style: "display: flex; align-items: center; margin-bottom: 8px;" } }, rowChildren);
});
return h("div", { attrs: { class: "attachment-list" } }, containerChildren);
}
async function handleDownload(url, fileName) {
console.log("下载");
try {
const response = await fetch(url, {
credentials: "include",
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const blob = await response.blob();
const blobUrl = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = blobUrl;
link.download = fileName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
setTimeout(() => URL.revokeObjectURL(blobUrl), 1000);
} catch (error) {
console.error("下载失败:", error);
try {
const fallbackLink = document.createElement("a");
fallbackLink.href = url;
fallbackLink.download = fileName;
document.body.appendChild(fallbackLink);
fallbackLink.click();
document.body.removeChild(fallbackLink);
} catch (fallbackError) {
console.error("降级下载失败:", fallbackError);
}
}
}
export default {
TEXT: renderText,
NUMBER: renderText,
ENUM: renderText,
DATETIME: renderDatetime,
LINK: renderLink,
IMAGE: renderImage,
ATTACHMENT: renderAttachment,
};
import { overdueFlagOptions, priorityOptions, statusOptions } from "@/views/residentManage/taskCenter/constant/index.js";
export async function getTaskCenterTaskDescriptionSchema() {
return [
{
name: "description",
label: "任务描述",
col: 24,
labelWidth: "120px",
// slot : 整体的插槽名,优先级高于name
// itemStyle: 每一项的样式
// tooltip: boolean 是否用tooltip 展示data数据
// tooltipProps: el-tooltip 的传参
// render ?:(h,{ data,schemaItem,schema } )=>{} 自定义渲染
// isHide 是否隐藏 (data)=>boolean || boolean
},
{
name: "bizTypeName",
label: "任务分类",
col: 24,
labelWidth: "120px",
},
{
name: "status",
label: "完成状态",
col: 24,
labelWidth: "120px",
render: (h, { data }) => {
const item = statusOptions.find(item => item.value === data.status);
// const names = data.assignees.map(item => item.assigneeName).join(",") || "-";
return h("span", { class: item?.className || "yellow-dot" }, item?.label || "-");
},
},
{
name: "priority",
label: "优先级",
col: 24,
labelWidth: "120px",
render: (h, { data }) => {
const item = priorityOptions.find(item => item.value === data.priority);
return h(
"el-tag",
{
props: {
type: item?.type,
},
},
item?.label || "-",
);
},
},
{
name: "assignees",
label: "执行人",
col: 24,
labelWidth: "120px",
render: (h, { data }) => {
console.log("data");
const names = data.assignees.map(item => item.assigneeName).join(",") || "-";
return h("span", {}, names);
},
},
{
divider: true,
},
{
divider: true,
},
{
name: "taskNo",
label: "任务编号",
col: 24,
labelWidth: "120px",
},
{
name: "createdBy",
label: "创建人",
col: 24,
labelWidth: "120px",
},
{
name: "createdDate",
label: "创建时间",
col: 24,
labelWidth: "120px",
},
{
name: "dueTime",
label: "截止时间",
col: 24,
labelWidth: "120px",
},
];
}
<template> <template>
<!-- 预估利润率 --> <!-- 预估利润率 -->
<div v-loading="pageLoading" class="detail-wrapper"> <div v-loading="pageLoading" class="detail-wrapper">
<div class="container-wrapper">
<div class="title-wrapper"> <div class="title-wrapper">
<span class="title"> <VenusBackButton />
利润率测算 <span class="title" style="margin-left:12px;">
{{ detail.title }}
</span> </span>
</div> </div>
<div class="description-wrapper">
<VenusDialog v-model="dialog.profitRateCalFinish.show" <Descriptions :data="detail"
title="提示" :schema="descriptionSchema">
:height="100" </Descriptions>
width="400px" </div>
:show-close="false" </div>
:close-on-click-modal="false"
:show-footer="false"
:confirm-loading="false">
<!-- 正在测算中, 请稍后 -->
</VenusDialog>
</div> </div>
</template> </template>
<script> <script>
import VenusDialog from "@/components/venusDialog/index.vue"; import { toUpper } from "lodash-es";
import Descriptions from "@/components/descriptions/index.vue";
import VenusBackButton from "@/components/venusBackButton/index.vue";
import { getTaskCenterDetailApi } from "@/views/residentManage/taskCenter/api";
import cover2Descriptions from "./cover2Descriptions.js";
import { getTaskCenterTaskDescriptionSchema } from "./detail.data.js";
export default { export default {
name: "", name: "TaskCenterDetail",
components: { components: {
VenusDialog, VenusBackButton,
Descriptions,
}, },
props: { props: {
}, },
...@@ -35,7 +37,9 @@ export default { ...@@ -35,7 +37,9 @@ export default {
return { return {
pageLoading: false, pageLoading: false,
// 轮训用的 , null || Fn, 为Fn时, 执行即取消轮训 // 轮训用的 , null || Fn, 为Fn时, 执行即取消轮训
taskId: "",
detail: {},
descriptionSchema: [],
dialog: { dialog: {
profitRateCalFinish: { profitRateCalFinish: {
show: false, show: false,
...@@ -48,24 +52,156 @@ export default { ...@@ -48,24 +52,156 @@ export default {
}, },
async mounted() { async mounted() {
const { query } = this.$route;
}, this.taskId = query.taskId;
beforeDestroy() { await this.getData(query.taskId);
const schema = await getTaskCenterTaskDescriptionSchema();
schema.splice(6, 0, ...this.detail.bizDisplayInfo.map(item => ({
name: item.fieldId,
label: item.fieldName,
col: 24,
labelWidth: "120px",
meta: item,
render: cover2Descriptions[toUpper(item.fieldType)],
})));
this.descriptionSchema = schema;
}, },
methods: { methods: {
async getTableData() { async getData(taskId) {
if (!taskId) {
return;
}
const res = await getTaskCenterDetailApi({ taskId });
if (!res) {
return;
}
try {
res.bizContext = JSON.parse(res.bizContext);
} catch (e) {
res.bizContext = [];
}
try {
res.bizDisplayInfo = JSON.parse(res.bizDisplayInfo);
} catch (e) {
res.bizDisplayInfo = [];
}
}, // const bizDisplayInfo = [
// {
// fieldId: "1",
// fieldName: "文本",
// fieldType: "text",
// fieldValue: "张三",
// linkAlias: null,
// },
// {
// fieldId: "2",
// fieldName: "数值",
// fieldType: "NUMBER",
// fieldValue: "15.369",
// linkAlias: null,
// },
// {
// fieldId: "3",
// fieldName: "枚举",
// fieldType: "ENUM",
// fieldValue: "男",
// linkAlias: null,
// },
// {
// fieldId: "4",
// fieldName: "日期",
// fieldType: "DATETIME",
// fieldValue: "2026-05-21 17:02:00",
// linkAlias: null,
// },
// {
// fieldId: "5",
// fieldName: "链接",
// fieldType: "LINK",
// fieldValue: "https://www.sojson.com/",
// linkAlias: "sojson",
// },
// {
// fieldId: "6",
// fieldName: "图片",
// fieldType: "IMAGE",
// fieldValue: [
// {
// name: "美图秀秀",
// value: "https://picsum.photos/200",
// },
// {
// name: "美图秀秀1",
// value: "https://picsum.photos/200",
// },
// ],
// linkAlias: "",
// },
// {
// fieldId: "7",
// fieldName: "最强附件",
// fieldType: "ATTACHMENT",
// fieldValue: [
// {
// name: "跨域 图片附件",
// value: "https://img.alicdn.com/bao/uploaded/i2/2206584264218/O1CN01bPOXSC1h1tkK7TTN9_!!2206584264218-0-C2M.jpg_460x460q90.jpg_.webp",
// },
// {
// name: "跨域 视频 附件",
// value: "https://media.w3.org/2010/05/sintel/trailer.mp4",
// },
// {
// name: "跨域 pdf 附件",
// value: "https://dnf999.neocities.org/%E6%B5%8B%E8%AF%95.pdf",
// },
// {
// name: "跨域 zip 附件",
// value: "https://files.vsports.fr/games/civ6_online.zip",
// },
getData() { // {
return {}; // name: "跨域 xlsx 附件",
}, // value: "https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/%E5%95%86%E5%93%81%E4%B8%8A%E6%9E%B6%E8%A1%A820260519004303.xlsx",
// },
// ],
// linkAlias: null,
// },
// ];
this.$set(this, "detail", res);
},
}, },
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.detail-wrapper { .detail-wrapper {
.container-wrapper {
min-height: 600px;
box-shadow: 0 6px 32px 0 rgba(0, 0, 0, 0.12);
margin: 0 20px 0;
background-color: white;
padding: 20px;
border-radius: 8px;
.title-wrapper {
color: #333;
font-size: 20px;
font-weight: 600;
margin-bottom: 20px;
display: flex;
align-items: center;
}
.description-wrapper {
::v-deep .el-divider {
margin: 0 0 12px;
background-color: #ebeef5;
}
::v-deep .form-item {
margin-bottom: 12px;
}
}
}
} }
</style> </style>
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
:search-form="table.searchForm"> :search-form="table.searchForm">
</d2-search> </d2-search>
<div class="up-btns"> <div class="up-btns">
<el-button :id="table.tableParams.btnId" <el-button size="small"
size="small" type="primary"
type="primary"> @click="handleSearch()">
查询 查询
</el-button> </el-button>
<el-button size="small" @click="handleReset"> <el-button size="small" @click="handleReset">
...@@ -21,13 +21,47 @@ ...@@ -21,13 +21,47 @@
</div> </div>
</template> </template>
<div class="d2-container-content"> <div class="d2-container-content">
<d2-table-header> <d2-table-header :left-span="24">
<!-- 新增商品上架 handleModify --> <template #left>
<span style=" display: inline-block; margin-right: 10px"> <div class="table-title-wrapper">
<auth-button category="Button" <div class="title">
:data="{ operate: 'create' }" 任务列表
:show-btn-ids="['9031801']" /> </div>
<div class="table-sum-wrapper">
<el-tag type="info">
总任务数: {{ table.headerSummary.totalCount }}
</el-tag>
<el-tag type="info">
未完成: {{ table.headerSummary.unfinishedCount }}
</el-tag>
<el-tag type="info">
已完成: {{ table.headerSummary.finishedCount }}
</el-tag>
<el-tag type="info">
已逾期: {{ table. headerSummary.overdueCount }}
</el-tag>
</div>
<div class="sort-wrapper">
<el-dropdown @command="handleChangeSort">
<span class="el-dropdown-link" style="cursor:pointer">
{{ table.searchForm.orderBy === "createdDate desc" ? "按创建时间" : "按截止时间" }}
<i class="el-icon-sort" />
</span> </span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="createdDate desc" :class="table.searchForm.orderBy === 'createdDate desc' ? 'is-active' : '' ">
按创建时间
</el-dropdown-item>
<el-dropdown-item command="dueTime asc" :class="table.searchForm.orderBy === 'dueTime asc' ? 'is-active' : '' ">
按截止时间
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
</template>
</d2-table-header> </d2-table-header>
<d2-table ref="tableRef" v-bind="table"> <d2-table ref="tableRef" v-bind="table">
<template #auth-button="{ scope }"> <template #auth-button="{ scope }">
...@@ -46,23 +80,44 @@ ...@@ -46,23 +80,44 @@
</template> </template>
<script> <script>
import { cloneDeep } from "lodash-es"; import { get, isEmpty } from "lodash-es";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { mapActions } from "vuex"; import { mapActions } from "vuex";
import { setAllOptions } from "@/libs/select.js"; import { setAllOptions } from "@/libs/select.js";
import { getTaskCenterListApi } from "@/views/residentManage/taskCenter/api/index.js"; import reportTrackFunMixin from "@/mixins/reportTrackFunMixin";
import { getTaskCenterCountApi, getTaskCenterListApi } from "@/views/residentManage/taskCenter/api/index.js";
import { getTableColumns, getTableFormSchema } from "@/views/residentManage/taskCenter/view/table/table.data"; import { getTableColumns, getTableFormSchema } from "@/views/residentManage/taskCenter/view/table/table.data";
export default { export default {
name: "ShelfProduct", name: "ShelfProduct",
components: { components: {
}, },
mixins: [reportTrackFunMixin],
data() { data() {
return { return {
table: { table: {
formSchema: [], formSchema: [],
getListApi: getTaskCenterListApi, headerSummary: {
searchForm: { }, finishedCount: 0,
overdueCount: 0,
totalCount: 0,
unfinishedCount: 0,
},
getListApi: async (query) => {
const res = await getTaskCenterListApi(query);
const headerSummary = await getTaskCenterCountApi(query);
Object.assign(this.table.headerSummary, headerSummary);
return res;
},
searchForm: {
orderBy: "createdDate desc",
// 排序字段:创建时间升序:createdDate asc
// 降序:createdDate desc
// 更新时间升序:updatedDate asc
// 降序:updatedDate desc
// 截止时间升序:dueTime asc
// 降序:dueTime desc
},
// 表格参数 // 表格参数
tableParams: { tableParams: {
btnId: nanoid(), btnId: nanoid(),
...@@ -81,7 +136,9 @@ export default { ...@@ -81,7 +136,9 @@ export default {
}; };
}, },
async mounted() { async mounted() {
this.trackMenu();
await this.getBaseData(); await this.getBaseData();
await this.getHeaderSummary();
this.table.formSchema = await getTableFormSchema(); this.table.formSchema = await getTableFormSchema();
this.table.tableParams.tableColumns = await getTableColumns(); this.table.tableParams.tableColumns = await getTableColumns();
}, },
...@@ -89,9 +146,43 @@ export default { ...@@ -89,9 +146,43 @@ export default {
...mapActions({ ...mapActions({
close: "d2admin/page/close", close: "d2admin/page/close",
}), }),
checkQuery() {
const { searchForm, formSchema } = this.table;
const hasFormValue = formSchema.some(({ name }) => {
const value = get(searchForm, name);
if (Array.isArray(value)) {
return value.length > 0;
}
if (typeof value === "string") {
return value.trim() !== "";
}
return !isEmpty(value);
});
if (hasFormValue) {
return true;
}
return searchForm.orderBy !== "createdDate desc";
},
trackMenu() {
this.setReportTrackData(0, "task_web_menu_entry", {});
},
handleSearch(clearQuery = true, resetPage = true) {
const query = this.table.searchForm;
if (this.checkQuery()) {
console.log("埋点");
this.setReportTrackData(0, "task_web_search_request", query);
}
this.$refs.tableRef.refreshTable(clearQuery, resetPage);
},
async getBaseData() { async getBaseData() {
setAllOptions(this.table.formSchema); setAllOptions(this.table.formSchema);
}, },
async getHeaderSummary() {
const headerSummary = await getTaskCenterCountApi();
Object.assign(this.table.headerSummary, headerSummary);
},
handleReset() { handleReset() {
this.table.searchForm = this.$options.data().table.searchForm; this.table.searchForm = this.$options.data().table.searchForm;
this.$refs.tableRef.refreshTable(false, true); this.$refs.tableRef.refreshTable(false, true);
...@@ -129,7 +220,8 @@ export default { ...@@ -129,7 +220,8 @@ export default {
// this.dialog.reject.show = true; // this.dialog.reject.show = true;
}, },
// 查看 // 查看
handleDetail({ taskId }) { async handleDetail({ taskId, bizTypeName, bizType }) {
this.setReportTrackData(0, "task_web_view_detail", { taskId, bizTypeName, bizType });
this.$router.push({ this.$router.push({
path: "/resident-manage/task-center/detail", path: "/resident-manage/task-center/detail",
query: { query: {
...@@ -137,6 +229,13 @@ export default { ...@@ -137,6 +229,13 @@ export default {
}, },
}); });
}, },
handleChangeSort(command) {
if (this.table.searchForm.orderBy === command) {
return;
}
this.table.searchForm.orderBy = command;
this.handleSearch(false, true);
},
// 新增 或 修改 // 新增 或 修改
handleModify({ operate, record }) { handleModify({ operate, record }) {
// console.log("record", record); // console.log("record", record);
...@@ -162,11 +261,47 @@ export default { ...@@ -162,11 +261,47 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
::v-deep .is-active {
background-color: #eaeef7;
color: #5579bd;
}
.d2-container-content { .d2-container-content {
.table-title-wrapper {
display: flex;
align-items: center;
margin-bottom: 8px;
> .title {
font-size: 16px;
font-weight: bold;
color: rgba(0, 0, 0, 0.88);
flex-shrink: 0;
}
> .table-sum-wrapper {
flex-shrink: 0;
flex: 1;
margin-left: 20px;
.el-tag {
margin-left: 16px;
&:first-child {
margin-left: 0;
}
color: #000;
font-size: 13px;
font-weight: bold;
border: 0;
background-color: #f5f5f5;
}
}
> .sort-wrapper {
}
}
::v-deep .d2-table { ::v-deep .d2-table {
.el-table__body-wrapper { .el-table__body-wrapper {
.cell { .cell {
padding: 0 6px; padding: 0 6px;
.el-tag {
width: auto !important;
}
} }
} }
} }
......
import dayjs from "dayjs";
import { keyBy } from "lodash-es"; import { keyBy } from "lodash-es";
import { getTaskCenterBizCategoryListApi } from "@/views/residentManage/taskCenter/api/index.js"; import { getTaskCenterBizCategoryListApi } from "@/views/residentManage/taskCenter/api/index.js";
import { overdueFlagOptions, priorityOptions, statusOptions } from "@/views/residentManage/taskCenter/constant/index.js"; import { overdueFlagOptions, priorityOptions, statusOptions } from "@/views/residentManage/taskCenter/constant/index.js";
...@@ -21,12 +22,13 @@ export async function getTableFormSchema() { ...@@ -21,12 +22,13 @@ export async function getTableFormSchema() {
{ {
label: "优先级", label: "优先级",
name: "condition.priority", name: "condition.priorities",
type: "select", type: "select",
isClear: true, isClear: true,
optionList: priorityOptions, optionList: priorityOptions,
optionId: "value", optionId: "value",
optionLabel: "label", optionLabel: "label",
multiple: true,
}, },
{ {
...@@ -114,11 +116,8 @@ export async function getTableColumns() { ...@@ -114,11 +116,8 @@ export async function getTableColumns() {
return statusOptions.find(item => item.value === row.status)?.label || "-"; return statusOptions.find(item => item.value === row.status)?.label || "-";
}, },
className: (cellValue) => { valueClass: (cellValue) => {
return { return { UNFINISHED: "yellow-dot", FINISHED: "green-dot" }[cellValue.status];
UNFINISHED: "yellowSpot",
FINISHED: "greenSpot",
}[cellValue.status];
}, },
}, },
{ {
...@@ -130,6 +129,23 @@ export async function getTableColumns() { ...@@ -130,6 +129,23 @@ export async function getTableColumns() {
label: "截止时间", label: "截止时间",
prop: "dueTime", prop: "dueTime",
width: "180px", width: "180px",
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: "创建人", label: "创建人",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!