|
@@ -31,8 +31,9 @@
|
|
|
/**
|
|
|
* @description 接收人组件
|
|
|
*/
|
|
|
-import { ref, onMounted } from "vue";
|
|
|
+import { ref, onMounted, watch } from "vue";
|
|
|
import { http } from "../http";
|
|
|
+import PubsubService from "@/utils/PubsubService";
|
|
|
interface IProp {
|
|
|
type: "weekly" | "daily";
|
|
|
onChange: (data: any) => any;
|
|
@@ -42,6 +43,29 @@ interface IProp {
|
|
|
const { type, onChange } = defineProps<IProp>();
|
|
|
|
|
|
const dataSource = ref<any[]>([]);
|
|
|
+const filteredDataSource = ref<any[]>([]);
|
|
|
+const searchQuery = ref<string>("");
|
|
|
+const active = ref(0);
|
|
|
+const activeProject = ref(null);
|
|
|
+
|
|
|
+// 回填工作量
|
|
|
+const callFullSelect = (defaultData: any[]) => {
|
|
|
+ if (defaultData && defaultData.length) {
|
|
|
+ dataSource.value = dataSource.value
|
|
|
+ .map((item) => {
|
|
|
+ const defaultItem = defaultData.find(
|
|
|
+ (dItem) => dItem.projectId === item.projectId
|
|
|
+ );
|
|
|
+ if (defaultItem) {
|
|
|
+ item.workTime = defaultItem.workTime;
|
|
|
+ item.workTimeName = `${defaultItem.workTime}小时`;
|
|
|
+ }
|
|
|
+ return item;
|
|
|
+ })
|
|
|
+ .sort((a, b) => b.workTime - a.workTime);
|
|
|
+ filteredDataSource.value = dataSource.value;
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
onMounted(async () => {
|
|
|
// 获取项目列表
|
|
@@ -56,8 +80,14 @@ onMounted(async () => {
|
|
|
};
|
|
|
}) ?? [];
|
|
|
filteredDataSource.value = dataSource.value;
|
|
|
+ // 接收回填事件
|
|
|
+ PubsubService.subscribe("callback-full-project-select", (params) => {
|
|
|
+ callFullSelect(params);
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
+// watch(() => defaultData, callFullSelect, { immediate: true, deep: true });
|
|
|
+
|
|
|
// 生成工作时长数据
|
|
|
const workTimeList = (type: string) => {
|
|
|
const arrays =
|
|
@@ -71,8 +101,6 @@ const workTimeList = (type: string) => {
|
|
|
};
|
|
|
|
|
|
// 过滤
|
|
|
-const searchQuery = ref<string>("");
|
|
|
-const filteredDataSource = ref<any[]>([]);
|
|
|
const setFilteredDataSource = () => {
|
|
|
filteredDataSource.value = dataSource.value;
|
|
|
if (!searchQuery.value) {
|
|
@@ -88,8 +116,6 @@ const setFilteredDataSource = () => {
|
|
|
watch(searchQuery, setFilteredDataSource);
|
|
|
|
|
|
// 设置工作量
|
|
|
-const active = ref(0);
|
|
|
-const activeProject = ref(null);
|
|
|
const projectTitme = (project: any) => {
|
|
|
if (!project.workTimeName || project.workTime == "") {
|
|
|
return project.projectName;
|