瀏覽代碼

提交代码

Lijy 11 月之前
父節點
當前提交
eb3a6727b6

+ 133 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/components/detailcompinents/relatedTasks.vue

@@ -0,0 +1,133 @@
+<template>
+    <div class="relatedTasks pl-4 pr-4 pt-3 pb-3 h-full flex flex-col">
+        <div class="flex justify-between">
+            <div class="title">相关任务</div>
+            <div>
+                <el-button type="primary" @click="newTask()">新建任务</el-button>
+            </div>
+        </div>
+        <div class="flex-1 overflow-auto pt-3">
+            <el-table :data="relatedTaskstable" border style="width: 100%;height: 100%;">
+                <el-table-column prop="taskName" label="任务名称">
+                    <template #default="scope">
+                        <el-button link type="primary" size="large" @click="toTask()">{{
+                            scope.row.taskName
+                        }}</el-button>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="priorityStr" label="优先级" width="130" />
+                <el-table-column prop="statusStr" label="状态" width="130" />
+                <el-table-column prop="executorNamesStr" label="执行人" width="130" />
+                <el-table-column prop="startTimes" label="开始时间" width="130" />
+                <el-table-column prop="endTimes" label="截至时间" width="130" />
+            </el-table>
+        </div>
+    </div>
+
+    <!-- 新建任务 -->
+    <TaskModal :visible="allVisible.taskModalVisible" :edit-form="taskModalForm" :save-loading="taskLoading"
+        @close="closeTaskModal" @submit="submitForm" :title="'新建任务'" :disabled-list="props.disabledList" />
+</template>
+<script lang="ts" setup>
+import { PRIORITY } from '../TaskModal/api';
+import { STATUS } from '../../pages/tasks/api';
+import { formatDate } from '../../utils/times';
+import { createTaskFromType } from '../../utils/tools';
+import { ElNotification, NotificationParamsTyped } from 'element-plus'
+import { ref, reactive, onMounted, watchEffect } from 'vue'
+import { useRouter } from "vue-router";
+import TaskModal from '../TaskModal/index.vue'
+import { createTask } from '../TaskModal/taskFunction';
+import { ITEM_RENDER_EVT } from 'element-plus/es/components/virtual-list/src/defaults';
+import { Props, Emits } from './type';
+
+const props = defineProps<Props>()
+const emits = defineEmits<Emits>();
+
+type saveLoadingType = "1" | "2" | "3" | "4"; //1是没有保存, 2是正在保存, 3是保存成功, 4是保存失败
+
+const relatedTaskstable = ref([])
+const information = ref<any>({})
+const router = useRouter()
+const taskLoading = ref<saveLoadingType>('1')
+const taskModalForm = ref({}) // 任务弹窗表单
+const allVisible = reactive({
+    taskModalVisible: false
+})
+
+function submitForm(submitData: any, isClose: boolean) { // 任务提交
+    taskLoading.value = '2'
+    createTask(submitData, isClose).then((res) => {
+        const { saveLoading, isClose } = res
+        taskLoading.value = saveLoading
+        allVisible.taskModalVisible = isClose
+        globalPopup('新建成功', 'success')
+        emits('refreshData')
+    }).catch((err) => {
+        const { saveLoading, isClose, message } = err
+        taskLoading.value = saveLoading
+        allVisible.taskModalVisible = isClose
+        globalPopup(message, 'error')
+    })
+}
+
+function globalPopup(str: string, type: string) {
+    notificationTiop({
+      message: str || '成功',
+      type: type,
+      title: "提示",
+      duration: 2000
+    })
+}
+
+const notificationTiop = (options: NotificationParamsTyped) => {
+  ElNotification(options)
+}
+
+function newTask() {
+    const { id } = information.value
+    taskModalForm.value = { ...createTaskFromType(props.formTaskType), [props.filed as any]: id, }
+    allVisible.taskModalVisible = true
+}
+
+function toTask() {
+    router.push({
+        path: `/tasks`
+    })
+}
+
+function closeTaskModal() {
+    allVisible.taskModalVisible = false
+}
+
+// 接收参数赋值
+function receiveAssignment(item: any) {
+    console.log(item, '<==== 过来的值')
+    information.value = item.information
+    const dataVal = item.data
+    for (let i in dataVal) {
+        dataVal[i].executorNamesStr = (dataVal[i].executorNames || []).join(','),
+            dataVal[i].startTimes = dataVal[i].startDate ? formatDate(new Date(dataVal[i].startDate)) : '',
+            dataVal[i].endTimes = dataVal[i].endDate ? formatDate(new Date(dataVal[i].endDate)) : '',
+            dataVal[i].priorityStr = PRIORITY.find(item => item.value == dataVal[i].priority)?.label || '',
+            dataVal[i].statusStr = STATUS.find(item => item.value == dataVal[i].status)?.label || ''
+    }
+    relatedTaskstable.value = dataVal
+}
+
+watchEffect(() => {
+    receiveAssignment(props)
+});
+
+// 生命周期钩子
+onMounted(() => {
+});
+</script>
+<style scoped lang="scss">
+.relatedTasks {
+    .title {
+        font-size: 18px;
+        color: #000
+    }
+}
+</style>

+ 50 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/components/detailcompinents/type.d.ts

@@ -0,0 +1,50 @@
+type TASK_VALUE_TYPE = 0 | 1 | 2 | 3;
+type tableTypeFiled = {
+    id: number,
+    status: number,
+    priority: number,
+    executorNames: Array,
+    startDate: string,
+    endDate: string,
+}
+export interface Props {
+    /**
+     * data: 任务 Table 数据
+     */
+    data: tableTypeFiled[];
+    /**
+     * information: 详情数据
+     */
+    information: any;
+    /**
+     * disabledList:新建任务需要禁用的字段(参考 TaskModal 文件)
+     */
+    disabledList?: (
+        | "taskName"
+        | "priority"
+        | "taskType"
+        | "customId"
+        | "businessOpportunityId"
+        | "orderId"
+        | "clueId"
+        | "contactsId"
+        | "executorId"
+        | "startDate"
+        | "endDate"
+    )[];
+    /** 
+     * formTaskType: 任务类型  0是客户, 1是商机, 2是销售订单 ,3是线索
+     */
+    formTaskType: TASK_VALUE_TYPE,
+    /**
+     * 详情数据中需要关联的任务类型字段
+     */
+    filed?: 'customId' | 'businessOpportunityId' | 'orderId' | 'clueId' 
+}
+
+export interface Emits {
+    /**
+     *  新建任务后触发的更新数据事件
+     */
+    (event: "refreshData"): void;
+}

+ 5 - 3
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/detail/index.vue

@@ -40,7 +40,7 @@
 
       <div class="w-full h-auto flex justify-between mt-2">
         <div class="bg-white shadow-md rounded-md" style="width: 65%;">
-          <RelatedTasks />
+          <DetailCompinents :data="detailCompinentsData" :information="businessInfo" :formTaskType="1" :filed="'businessOpportunityId'" :disabledList="['taskType', 'businessOpportunityId']" @refreshData="getDetail" />
         </div>
         <div class="bg-white ml-2 shadow-md rounded-md flex-1">
           <OperationRecord />
@@ -66,7 +66,8 @@ import { BUSIESS_ALL, BUSIESS_GETSATE, BUSIESS_INFO } from '../api'
 
 import Information from '../component/information.vue'
 import Attachment from '../component/attachment.vue'
-import RelatedTasks from '../component/relatedTasks.vue';
+// import RelatedTasks from '../component/relatedTasks.vue';
+import DetailCompinents from '@/components/detailcompinents/relatedTasks.vue'
 import OperationRecord from '../component/operationRecord.vue';
 import Products from '../component/products.vue';
 import { post } from "@/utils/request";
@@ -78,6 +79,7 @@ type stageListType = {
 }
 
 const route = useRoute()
+const detailCompinentsData = ref([])
 const optionVal = ref<any>('')
 const stageStatusVal = ref('')
 const options = ref<optionType[]>([])
@@ -93,8 +95,8 @@ const stageList = ref<stageListType[]>([])
 function getDetail() {
   allLoading.skeletonLoading
   post(BUSIESS_INFO, { id: optionVal.value }).then(({ data }) => {
-    console.log(data, '<====== 数据')
     businessInfo.value = (data || []);
+    detailCompinentsData.value = data.taskList || []
   }).finally(() => {
     allLoading.skeletonLoading
   })

+ 2 - 2
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/thread/detail/index.vue

@@ -10,7 +10,7 @@
     </div>
     <div class="layout pl-3 pr-3 pb-3">
       <div class="bg-white w-2/3 shadow-md rounded-md">
-        <RelatedTasks :data="relatedTasks" :information="information" @refreshData="refreshData"></RelatedTasks>
+        <DetailCompinents :data="relatedTasks" :information="information" :formTaskType="3" :disabledList="['taskType', 'clueId']" :filed="'clueId'" @refreshData="refreshData"></DetailCompinents>
       </div>
       <div class="bg-white w-1/3 ml-3 shadow-md rounded-md">
         <OperationRecord :data="operationRecord" :information="information" @refreshData="refreshData"></OperationRecord>
@@ -22,7 +22,7 @@
 <script lang="ts" setup>
 import Information from './components/information.vue'
 import Attachment from './components/attachment.vue'
-import RelatedTasks from './components/relatedTasks.vue';
+import DetailCompinents from '@/components/detailcompinents/relatedTasks.vue'
 import OperationRecord from './components/operationRecord.vue';
 import { ref, reactive, onMounted, inject } from "vue";
 import { post, get } from "@/utils/request";