Lijy пре 1 година
родитељ
комит
a92d2948c1

+ 14 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/api.ts

@@ -5,9 +5,23 @@ export const GETPERSONNEL = "/user/getSimpleActiveUserList";
 export const GETGENERATEFOEM = `/sys-form/getListByCode${MOD}`
 export const GETBUSINESSLIST = `/business-opportunity/list`
 export const UPDATEINSET = `/business-opportunity/insertAndUpdate`
+export const BUSINESSDETELE = `/business-opportunity/delete`
+export const BATCHTRANSFER = `/business-opportunity/claim`
 
 export const stageStatus = [
     { id: 1, name: "赢单", progress: "100%" },
     { id: 2, name: "输单", progress: "0%" },
     { id: 3, name: "无效", progress: "0%" }
+]
+
+export const tableColumn: businessTableColumnInterface[] = [
+    { prop: "name", label: "商机名称", width: "180", eventName: "toClueTableDetail" },
+    { prop: "customerName", label: "客户名称", width: "180" },
+    { prop: "contactsName", label: "联系人", width: "180", eventName: "showName" },
+    { prop: "amountOfMoney", label: "商机金额", width: "180" },
+    { prop: "stageValue", label: "商机阶段", width: "180" },
+    { prop: "expectedTransactionDate", label: "预计成交", width: "180" },
+    { prop: "inchargerName", label: "负责人", width: "180" },
+    { prop: "creatorName", label: "创建人", width: "180" },
+    { prop: "createTime", label: "创建时间", width: "180" }
 ]

+ 106 - 16
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/index.vue

@@ -48,18 +48,25 @@
       <div class="bg-white w-full h-full p-3 shadow-md rounded-md flex flex-col">
         <div class="flex justify-end pb-3">
           <el-button type="primary" @click="showVisible('newBusinessisible')">新建商机</el-button>
-          <el-button type="primary">批量转移</el-button>
-          <el-button type="primary">批量删除</el-button>
+          <el-button type="primary" @click="showVisible('batchTransferVisible')"
+            :disabled="batchTableData.length <= 0">批量转移</el-button>
+          <el-button type="primary" @click="batchDeteleItem()" :disabled="batchTableData.length <= 0">批量删除</el-button>
           <el-button type="primary">阶段设置</el-button>
           <el-button type="primary">回收站</el-button>
           <el-button type="primary">导入</el-button>
           <el-button type="primary">导出</el-button>
         </div>
         <div class="flex-1 w-full overflow-hidden">
-          <el-table ref="clueTableRef" :data="businessTable" border v-loading="allLoading.businessTableLading"
-            style="width: 100%;height: 100%;">
+          <el-table ref="businessTableRef" :data="businessTable" border v-loading="allLoading.businessTableLading"
+            @selection-change="changeBatch" style="width: 100%;height: 100%;">
             <el-table-column type="selection" width="55" />
-            <el-table-column prop="name" label="商机名称" width="180">
+            <el-table-column v-for="(item, index) in tableColumn" :prop="item.prop" :label="item.label" :key="index" :width="item.width">
+              <template #default="scope">
+                <el-button link type="primary" size="large" @click="dealWithTableColumn(scope.row, item.eventName)" v-if="item.eventName">{{scope.row[item.prop]}}</el-button>
+                <template v-else>{{scope.row[item.prop]}}</template>
+              </template>
+            </el-table-column>
+            <!-- <el-table-column prop="name" label="商机名称" width="180">
               <template #default="scope">
                 <el-button link type="primary" size="large" @click="toBusinessTableDetail(scope.row)">{{
                   scope.row.name
@@ -79,12 +86,14 @@
             <el-table-column prop="expectedTransactionDate" label="预计成交" width="180"></el-table-column>
             <el-table-column prop="inchargerName" label="负责人" width="180"></el-table-column>
             <el-table-column prop="creatorName" label="创建人" width="180"></el-table-column>
-            <el-table-column prop="createTime" label="创建时间" width="180"></el-table-column>
+            <el-table-column prop="createTime" label="创建时间" width="180"></el-table-column> -->
             <el-table-column label="操作" fixed="right" width="200">
               <template #default="scope">
-                <el-button link type="primary" size="large" @click="editShowVisible('newBusinessisible', scope.row)">编辑</el-button>
+                <el-button link type="primary" size="large"
+                  @click="editShowVisible('newBusinessisible', scope.row)">编辑</el-button>
                 <el-button link type="primary" size="large" @click="newTask(scope.row)">新建任务</el-button>
-                <el-button link type="danger" size="large">删除</el-button>
+                <el-button link type="danger" size="large"
+                  @click="businessDeteleItem(scope.row.id, scope.row.name)">删除</el-button>
               </template>
             </el-table-column>
           </el-table>
@@ -119,18 +128,41 @@
 
     <!-- 新建任务 -->
     <TaskModal :visible="allVisible.taskModalVisible" :edit-form="taskModalForm" :save-loading="taskLoading"
-      @close="closeVisible('taskModalVisible')" @submit="submitForm" :title="'新建任务'" :disabled-list="['taskType', 'businessOpportunityId']" />
+      @close="closeVisible('taskModalVisible')" @submit="submitForm" :title="'新建任务'"
+      :disabled-list="['taskType', 'businessOpportunityId']" />
+
+    <!-- 批量转移 -->
+    <el-dialog v-model="allVisible.batchTransferVisible" width="600" :show-close="false" top="10vh">
+      <template #header="{ close, titleId, titleClass }">
+        <div class="flex justify-between items-center border-b pb-3 dialog-header">
+          <h4 :id="titleId">{{ allText.transferText }}</h4>
+          <div>
+            <el-button type="primary" v-loading="allLoading.transferLoading" @click="transferBusiness()">转移</el-button>
+            <el-button @click="allVisible.batchTransferVisible = false">取消</el-button>
+          </div>
+        </div>
+      </template>
+      <div class="scroll-bar m-6">
+        <div class="flex mb-4">
+          <div class="w-20 flex items-center justify-end pr-4">转移至:</div>
+          <el-select v-model="transferPersonnel" placeholder="请选择" class="flex1">
+            <el-option v-for="item in fixedData.Personnel" :key="item.id" :label="item.name" :value="item.id" />
+          </el-select>
+        </div>
+        <div class="pl-3 text-[#e94a4a]">转移后,将看不到此商机</div>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script lang="ts" setup>
 import { ref, reactive, onMounted, inject } from "vue";
-import type { FormInstance, FormRules } from 'element-plus'
+import type { ElTable, FormInstance, FormRules } from 'element-plus'
 import { useRouter, useRoute } from "vue-router";
-import { GETSYSFILED, MOD, GETPERSONNEL, GETGENERATEFOEM, GETBUSINESSLIST, UPDATEINSET } from './api'
+import { GETSYSFILED, MOD, GETPERSONNEL, GETGENERATEFOEM, GETBUSINESSLIST, UPDATEINSET, BUSINESSDETELE, BATCHTRANSFER, tableColumn } from './api'
 import { GETTABLELIST } from '@/pages/product/api'
 import { post, get } from "@/utils/request";
-import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, createTaskFromType, formatDate } from '@/utils/tools'
+import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, createTaskFromType, formatDate, confirmAction } from '@/utils/tools'
 import { createTask } from '@/components/TaskModal/taskFunction'
 import { formatDateTime } from '@/utils/times'
 import { GenerateForm } from '@zmjs/form-design';
@@ -140,6 +172,7 @@ import TaskModal from '@/components/TaskModal/index.vue'
 const route = useRoute()
 const router = useRouter()
 const globalPopup = inject<GlobalPopup>('globalPopup')
+const businessTableRef = ref<InstanceType<typeof ElTable>>() // 商机table dom
 const businessTotalTable = ref(0)
 const generateForm = ref<typeof GenerateForm>() // 自定义表单dom
 const relatedProductsRef = ref<typeof RelatedProducts>()
@@ -152,18 +185,23 @@ const allLoading = reactive({
   businessTableLading: false,
   businessSaveLading: false,
   newBusinessSaveLading: false,
+  transferLoading: false
 })
 const allVisible = reactive({
   newBusinessisible: false,
   recycleVisible: false,
-  taskModalVisible: false
+  taskModalVisible: false,
+  batchTransferVisible: false
 })
 const allText = reactive({
-  newBusinessisibleText: '新建商机'
+  newBusinessisibleText: '新建商机',
+  transferText: '转移商机'
 }) // 所有文本
 
 const taskModalForm = ref({}) // 任务弹窗表单
 const taskLoading = ref<saveLoadingType>("1");
+const batchTableData = ref([]) // 批量数据
+const transferPersonnel = ref('') // 转移人
 
 const businessOpportunityForm = reactive<businessOpportunityFormType>({
   name: '',
@@ -228,10 +266,54 @@ function submitForm(submitData: any, isClose: boolean) { // 任务提交
     const { saveLoading, isClose, message } = err
     taskLoading.value = saveLoading
     allVisible.taskModalVisible = isClose
-    globalPopup?.showSuccess(message)
+    globalPopup?.showError(message)
+  })
+}
+
+function transferBusiness() {
+  const ids = batchTableData.value.map((item: any) => item.id).join(',')
+  allLoading.transferLoading = true
+  post(BATCHTRANSFER, { ids, inchargerId: transferPersonnel.value }).then(() => {
+    transferPersonnel.value = ''
+    globalPopup?.showSuccess('转移成功')
+    closeVisible('batchTransferVisible')
+    getBusinessTableList()
+  }).finally(() => {
+    allLoading.transferLoading = false
   })
 }
 
+function batchDeteleItem() {
+  const value = batchTableData.value.map((item: any) => item.id).join(',')
+  const label = batchTableData.value.map((item: any) => item.name).join(',')
+  businessDeteleItem(value, label, true)
+}
+
+function businessDeteleItem(value: string | number, label: string, batch: boolean = false) {
+  confirmAction(`确定${batch ? '批量' : ''}删除【${label}】商机吗?`).then(() => {
+    post(BUSINESSDETELE, { ids: value }).then(res => {
+      if (res.code != 'ok') {
+        globalPopup?.showError(res.msg)
+        return
+      }
+      globalPopup?.showSuccess('删除成功')
+      changeBatch(false)
+      getBusinessTableList()
+    }).catch((err) => {
+      globalPopup?.showError(err.message)
+    })
+  })
+}
+
+function changeBatch(flag: boolean = true) {
+  if (flag) {
+    batchTableData.value = businessTableRef.value && businessTableRef.value.getSelectionRows()
+  } else {
+    batchTableData.value = []
+    businessTableRef.value && businessTableRef.value.clearSelection()
+  }
+}
+
 function showVisible(type: keyof typeof allVisible) { // 显示弹窗
   allVisible[type] = true
 }
@@ -246,6 +328,7 @@ function handleClose(done: () => void) {
 
 function getBusinessTableList() {
   const formValue = getFromValue(businessOpportunityForm)
+  allLoading.businessTableLading = true
   post(GETBUSINESSLIST, { ...formValue }).then((res) => {
     const { data, total } = res.data
     businessTable.value = data.map((item: any) => {
@@ -255,6 +338,8 @@ function getBusinessTableList() {
       }
     })
     businessTotalTable.value = total
+  }).finally(() => {
+    allLoading.businessTableLading = false
   })
 }
 
@@ -294,13 +379,18 @@ async function getSystemField() {
 }
 
 function toBusinessTableDetail(row: any) {
-  console.log('点击跳转详情')
   router.push({
     path: `${MOD}/detail`,
     query: { id: row.id }
   })
 }
 
+function dealWithTableColumn(row: any, eventName: string) {
+  if(eventName == 'toClueTableDetail') {
+    toBusinessTableDetail(row)
+  }
+}
+
 function getProductTableList() {
   post(GETTABLELIST, { pageIndex: -1, pageSize: -1 }).then((res) => {
     if (res.code == 'ok') {

+ 8 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/type.d.ts

@@ -26,3 +26,11 @@ interface personnelInterface {
   phone: string;
   jobNumber: string;
 }
+
+interface businessTableColumnInterface {
+  prop: string;
+  label: string;
+  width: string;
+  eventName?: string;
+  event?: () => void;
+}

+ 0 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/thread/index.vue

@@ -359,7 +359,6 @@ function batchDeletes() {
 }
 
 function toClueTableDetail(row: any) {
-  console.log('点击跳转详情')
   router.push({
     path: `${MOD}/detail`,
     query: { id: row.id }