Просмотр исходного кода

客户管家提交任务相关模块代码

Lijy 11 месяцев назад
Родитель
Сommit
19f352fa4c

+ 19 - 2
fhKeeper/formulahousekeeper/customerBuler-crm/src/components/TaskModal/index.vue

@@ -33,7 +33,7 @@
           </template>
           <template v-for="item in TASK_TYPE_FIELD">
             <el-select v-model="form[item.field]" v-if="form.taskType == item.type" placeholder="请选择" clearable
-              filterable :disabled="disabledList && disabledList.includes(item.field)">
+              filterable :disabled="disabledList && disabledList.includes(item.field)" @change="(e: any) => {taskFormChange(e, item.field)}">
               <el-option v-for="v in taskTypeValueData" :key="v.id" :value="v[item.valueIndex]"
                 :label="v[item.labelIndex]" />
             </el-select>
@@ -41,7 +41,7 @@
         </el-form-item>
         <el-form-item label="联系人:" v-if="TASK_TYPE.find(v => v.value == (form.taskType || '1'))?.show">
           <el-select v-model="form.contactsId" placeholder="请选择" clearable filterable
-            :disabled="disabledList && disabledList.includes('contactsId')">
+            :disabled="(disabledList && disabledList.includes('contactsId'))">
             <el-option v-for="item in contactValueData" :key="item.id" :value="item.id" :label="item.name" />
           </el-select>
         </el-form-item>
@@ -135,6 +135,7 @@ import { Delete, Plus } from "@element-plus/icons-vue"
 import { FormInstance, dayjs } from 'element-plus';
 import { getFromValue } from '@/utils/tools';
 import { Props, Emits } from './type';
+import { URL_GETALL } from '@/pages/contacts/api';
 const props = defineProps<Props>()
 const emits = defineEmits<Emits>();
 watch(() => props.saveLoading, (val) => {
@@ -214,6 +215,22 @@ const form = ref<any>({});
 const formRef = ref<FormInstance>();
 const generateFormRef = ref<InstanceType<typeof GenerateForm>>();
 const generateFormData = ref<any>({ ...defaultGenerateFormData });
+function taskFormChange(e: any, field: 'customId' | 'businessOpportunityId' | 'orderId' | 'clueId') {
+  const fieldMap = {
+    'customId': 'customerId',
+    'businessOpportunityId': 'businessId',
+    'orderId': 'salesId',
+    'clueId': ''
+  };
+  let fieldStr = fieldMap[field] || '';
+  updateContactPerson(e, fieldStr)
+}
+function updateContactPerson(val: any, field: string) {
+  let formVal = field ? { [field]: val } : {}
+  get(URL_GETALL, { ...formVal }).then(({ data }) => {
+    contactValueData.value = data;//联系人
+  })
+}
 function closeVisible() {
   formRef.value?.resetFields();
   generateFormData.value = { ...defaultGenerateFormData };

+ 2 - 2
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/tasks/api.ts

@@ -30,9 +30,9 @@ export const defaultSearchForm = {
 };
 export const PRIORITY = [
   //优先级
-  { label: "", value: 2 },
+  { label: "", value: 2 },
   { label: "中", value: 1 },
-  { label: "", value: 0 },
+  { label: "", value: 0 },
 ];
 export const STATUS: StatusType[] = [
   //任务状态

+ 38 - 16
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/tasks/index.vue

@@ -15,7 +15,7 @@
             <el-form-item label="客户名称:" label-width="7em" prop="customName">
               <el-input v-model="searchForm.customName" placeholder="请输入" />
             </el-form-item>
-            <el-form-item label="联系人:" label-width="7em" prop="contactsName">
+            <el-form-item label="联系人号码:" label-width="7em" prop="contactsName">
               <el-input v-model="searchForm.contactsName" placeholder="请输入" />
             </el-form-item>
             <el-form-item label="执行人:" label-width="7em" prop="executorName">
@@ -52,13 +52,14 @@
     <div class="flex-1 p-5 overflow-auto">
       <div class="bg-white w-full h-full p-3 shadow-md rounded-md flex flex-col">
         <div class="ml-auto p-3">
-          <el-button type="primary" @click="createTasks()">创建任务</el-Button>
+          <el-button type="primary" v-permission="['tasksAdd']" @click="createTasks()">创建任务</el-Button>
           <el-button type="primary" :disabled="len == 0" :loading="btnLoading" @click="deleteTasks()">批量删除</el-Button>
-          <el-button type="primary" @click="openImportModal()">导入</el-Button>
-          <el-button type="primary" :loading="btnLoading" @click="exportTasks()">导出</el-Button>
+          <el-button type="primary" v-permission="['tasksImport']" @click="openImportModal()">导入</el-Button>
+          <!-- <el-button type="primary" :loading="btnLoading" @click="exportTasks()">导出</el-Button> -->
+          <el-button type="primary" v-permission="['tasksExport']" :loading="btnLoading" @click="newExportTasks()">导出</el-Button>
         </div>
         <div class="flex-1 overflow-y-auto">
-          <el-table :data="tableData" style="width: 100%;height: 100%;" ref="tableRef" v-loading="loading">
+          <el-table :data="tableData" :show-overflow-tooltip="tableShowOverflowTooltip" style="width: 100%;height: 100%;" ref="tableRef" v-loading="loading">
             <el-table-column type="selection" width="55" />
             <el-table-column prop="taskName" label="任务名称" header-align="center" align="center" show-overflow-tooltip
               width="200" />
@@ -75,19 +76,11 @@
                 </el-text>
               </template>
             </el-table-column>
-            <el-table-column prop="customName" label="执行人" width="120" header-align="center" align="center" />
+            <el-table-column prop="executorNames" label="执行人" width="120" header-align="center" align="center" />
             <el-table-column prop="startDate" label="开始时间" width="200" :sortable="true" header-align="center"
               align="center" value-format="YYYY-MM-DD" />
             <el-table-column prop="endDate" label="截止时间" width="200" :sortable="true" header-align="center"
               align="center" value-format="YYYY-MM-DD" />
-            <el-table-column prop="contactsName" label="联系人" header-align="center" align="center" width="120">
-              <template #default="scope">
-                <el-link :underline="false" type="primary" @click="goDetail(scope.row, 'contacts', 'contactsId')">
-                  {{ scope.row.contactsName }}
-                </el-link>
-              </template>
-            </el-table-column>
-            <el-table-column prop="contactsTel" label="联系人号码" header-align="center" align="center" width="140" />
             <el-table-column prop="customName" label="客户名称" header-align="center" align="center" width="120">
               <template #default="scope">
                 <el-link :underline="false" type="primary" @click="goDetail(scope.row, 'customer', 'customId')">
@@ -117,8 +110,16 @@
                 </el-link>
               </template>
             </el-table-column>
+            <el-table-column prop="contactsName" label="联系人名称" header-align="center" align="center" width="120">
+              <template #default="scope">
+                <el-link :underline="false" type="primary" @click="goDetail(scope.row, 'contacts', 'contactsId')">
+                  {{ scope.row.contactsName }}
+                </el-link>
+              </template>
+            </el-table-column>
+            <el-table-column prop="contactsTel" label="联系人号码" header-align="center" align="center" width="140" />
 
-            <el-table-column fixed="right" label="操作" header-align="center" align="center" width="150">
+            <el-table-column fixed="right" label="操作" header-align="center" align="center" width="160" v-permission="['tasksEdit']">
 
               <template #default="scope">
                 <el-button link type="primary" @click.prevent="editRow(scope.row)">
@@ -165,6 +166,7 @@ import ImportModal from './ImportModal.vue';
 import ExportModal from './ExportModal.vue';
 import { post, uploadFile } from '@/utils/request';
 import { getFromValue, confirmAction, downloadFile } from '@/utils/tools';
+import { tableShowOverflowTooltip } from '@/utils/globalVariables'
 import { pushMap } from './type';
 const router = useRouter()
 const { getFunctionList } = useStore()
@@ -216,6 +218,23 @@ const tableRef = ref<InstanceType<typeof ElTable>>();
 const loading = ref<boolean>(false);
 const totalCount = ref<number>(0);
 const tableData = ref<any[]>([])
+
+function newExportTasks() {
+  btnLoading.value = true
+  const { startDate, endDate } = searchForm.value;
+  let params = {
+    ...searchForm.value,
+    startDate: startDate && dayjs(startDate).format('YYYY-MM-DD 00:00:00'),
+    endDate: endDate && dayjs(endDate).format('YYYY-MM-DD 23:59:59')
+  }
+  post(EXPORT_DATA_BY_TASK_ID, {...getFromValue(params)}).then((res) => {
+    globalPopup?.showSuccess("导出成功")
+    downloadFile(res.data, "任务列表.xlsx");
+  }).finally(() => {
+    btnLoading.value = false
+  })
+}
+
 function search() {
   loading.value = true;
   const { startDate, endDate } = searchForm.value;
@@ -228,7 +247,10 @@ function search() {
     loading.value = false;
     const { total, record } = data;
     totalCount.value = total;
-    tableData.value = record;
+    tableData.value = record.map((item: any) => ({
+      ...item,
+      executorNames: item.taskExecutors?.join(',') ?? ''
+    }));
   }).catch(err => {
     globalPopup?.showError(err);
     loading.value = false;