Browse Source

提交商机管理的导出导出,回收站

Lijy 1 year ago
parent
commit
a2b4c2a9a0

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

@@ -1,4 +1,5 @@
 export const MOD = "/business";
+export const MODURL = "business";
 export const prefix = "/clue";
 export const GETSYSFILED = "/sys-dict/getListByCode";
 export const GETPERSONNEL = "/user/getSimpleActiveUserList";
@@ -7,6 +8,9 @@ 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 BUSIESS_DETELELIST = `/business-opportunity/deleterList`
+export const BUSIESS_ROWBACK = `/business-opportunity/rollBack`
+
 
 export const stageStatus = [
     { id: 1, name: "赢单", progress: "100%" },

+ 160 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/component/deteleTables.vue

@@ -0,0 +1,160 @@
+<template>
+    <el-dialog v-model="deteleBusinessDialogVisible" width="1000" :before-close="beForeCancel" :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">商机回收站</h4>
+                <div>
+                    <el-button type="primary" v-loading="allLoading.batchRecoveryLoading" :disabled="batchTableData.length == 0"
+                        @click="batchOperation('恢复')">批量恢复</el-button>
+                    <el-button type="primary" v-loading="allLoading.batchDeteleLoading" :disabled="batchTableData.length == 0"
+                        @click="batchOperation('删除')">批量删除</el-button>
+                    <el-button @click="cancel()">取消</el-button>
+                </div>
+            </div>
+        </template>
+        <div class="h-[60vh] flex flex-col">
+            <div class="flex-1 w-full overflow-hidden">
+                <el-table ref="busiessTableRef" :data="deteleBusinessTable" border v-loading="allLoading.tableLoading"
+                    @selection-change="changeBatch" style="width: 100%;height: 100%;">
+                    <el-table-column type="selection" width="55" />
+                    <el-table-column v-for="(item, index) in tableColumn" :prop="item.prop" :label="item.label" :key="index"
+                        :width="item.width">
+                        <template #default="scope">
+                            <span>{{ scope.row[item.prop] }}</span>
+                        </template>
+                    </el-table-column>
+                    <el-table-column label="操作" fixed="right" width="120">
+                        <template #default="scope">
+                            <el-button link type="primary" size="large"
+                                @click="businessOperationItem(scope.row.id, scope.row.name, '恢复')">恢复</el-button>
+                            <el-button link type="danger" size="large"
+                                @click="businessOperationItem(scope.row.id, scope.row.name, '删除')">删除</el-button>
+                        </template>
+                    </el-table-column>
+                </el-table>
+            </div>
+            <div class="flex justify-end pt-3">
+                <el-pagination layout="total, prev, pager, next, sizes" :page-size="tableForm.pageFrom"
+                    @size-change="handleSizeChange" @current-change="handleCurrentChange" :total="businessTotalTable"
+                    :hide-on-single-page="true" />
+            </div>
+        </div>
+    </el-dialog>
+</template>
+<script lang="ts" setup>
+import { post } from '@/utils/request';
+import { ref, reactive, onMounted, watchEffect, watch, inject } from 'vue'
+import { BUSIESS_DETELELIST, BUSIESS_ROWBACK, tableColumn } from '../api';
+import { ElTable } from 'element-plus';
+import { confirmAction } from '@/utils/tools';
+import { formatDate } from '@/utils/times';
+
+type operationType = '恢复' | '删除'
+
+const emits = defineEmits(['closeVisible']);
+const globalPopup = inject<GlobalPopup>('globalPopup')
+const deteleBusinessTable = ref([])
+const deteleBusinessDialogVisible = ref(false)
+const businessTotalTable = ref(0)
+const batchTableData = ref([])
+const allLoading = reactive({
+    batchRecoveryLoading: false,
+    batchDeteleLoading: false,
+    tableLoading: false
+})
+
+const tableForm = reactive({
+    pageIndex: 1,
+    pageFrom: 10
+})
+
+const busiessTableRef = ref<InstanceType<typeof ElTable>>() // 线索table dom
+
+const props = defineProps<{
+    visibles: boolean
+}>()
+
+watch(() => props.visibles, (newVal) => {
+    deteleBusinessDialogVisible.value = newVal
+    if (newVal) {
+        getTableList()
+    }
+})
+
+function batchOperation(type: operationType) {
+    const value = batchTableData.value.map((item: any) => item.id).join(',')
+    const label = batchTableData.value.map((item: any) => item.name).join(',')
+    businessOperationItem(value, label, type, true)
+}
+
+function businessOperationItem(value: string | number, label: string, type: operationType, batch: boolean = false) {
+    confirmAction(`确定${batch ? '批量' : ''}${type}【${label}】商机吗?`).then(() => {
+        let url = type == '恢复' ? BUSIESS_ROWBACK : ''
+        post(url, { ids: value }).then(res => {
+            if (res.code != 'ok') {
+                globalPopup?.showError(res.msg)
+                return
+            }
+            globalPopup?.showSuccess(`${type}成功`)
+            getTableList()
+            changeBatch(false)
+        }).catch((err) => {
+            globalPopup?.showError(err.message)
+        })
+    })
+}
+
+function changeBatch(flag: boolean = true) {
+    if (flag) {
+        batchTableData.value = busiessTableRef.value && busiessTableRef.value.getSelectionRows()
+    } else {
+        batchTableData.value = []
+        busiessTableRef.value && busiessTableRef.value.clearSelection()
+    }
+}
+
+function getTableList() {
+    allLoading.tableLoading = true
+    post(BUSIESS_DETELELIST, { ...tableForm }).then((res) => {
+        if (res.code == 'ok') {
+            const { data, total } = res.data
+            deteleBusinessTable.value = data.map((item: any) => {
+                return {
+                    ...item,
+                    expectedTransactionDate: formatDate(new Date(item.expectedTransactionDate))
+                }
+            })
+            businessTotalTable.value = total
+        }
+    }).finally(() => {
+        allLoading.tableLoading = false
+    })
+}
+
+function handleSizeChange(val: number) {
+    tableForm.pageIndex = 1
+    tableForm.pageFrom = val
+    getTableList()
+}
+
+function handleCurrentChange(val: number) {
+    tableForm.pageIndex = val
+    getTableList()
+}
+
+function cancel() {
+    emits('closeVisible', 'deteleBusinessVisible')
+}
+
+function beForeCancel(done: () => void) {
+    emits('closeVisible', 'deteleBusinessVisible')
+    done()
+}
+
+onMounted(() => {
+
+})
+
+</script>
+<style lang="scss" scoped></style>

+ 68 - 14
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/index.vue

@@ -52,9 +52,9 @@
             :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>
+          <el-button type="primary" @click="showVisible('deteleBusinessVisible')">回收站</el-button>
+          <el-button type="primary" @click="allVisible.importVisible = true">导入</el-button>
+          <el-button type="primary" @click="exportBusinessTableList()" :loading="allLoading.exoprtLoading">导出</el-button>
         </div>
         <div class="flex-1 w-full overflow-hidden">
           <el-table ref="businessTableRef" :data="businessTable" border v-loading="allLoading.businessTableLading"
@@ -105,11 +105,6 @@
       </div>
     </el-dialog>
 
-    <!-- 新建任务 -->
-    <TaskModal :visible="allVisible.taskModalVisible" :edit-form="taskModalForm" :save-loading="taskLoading"
-      @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 }">
@@ -131,22 +126,52 @@
         <div class="pl-3 text-[#e94a4a]">转移后,将看不到此商机</div>
       </div>
     </el-dialog>
+
+    <!-- 导入 -->
+    <el-dialog v-model="allVisible.importVisible" width="680" :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">导入产品</h4>
+          <div class="flex">
+            <el-upload class="upload-demo mr-3" :limit="1" :show-file-list="false" accept=".xlsx" :http-request="importBusiness">
+              <el-button type="primary" :loading="allLoading.importLoading">导入</el-button>
+            </el-upload>
+            <el-button @click="allVisible.importVisible = false">取消</el-button>
+          </div>
+        </div>
+      </template>
+      <div class="p-8">
+        <div class="ml-4 mr-4">
+          <div class="flex items-center">1、点击下载 <el-link type="primary" @click="downloadTemplate(MODURL, '商机导入模板.xlsx')">商机导入模板.xlsx</el-link></div>
+          <div class="mt-4">2、填写excel文件、商机名称、商机金额、商机阶段</div>
+        </div>
+      </div>
+    </el-dialog>
+
+    <!-- 新建任务 -->
+    <TaskModal :visible="allVisible.taskModalVisible" :edit-form="taskModalForm" :save-loading="taskLoading"
+      @close="closeVisible('taskModalVisible')" @submit="submitForm" :title="'新建任务'"
+      :disabled-list="['taskType', 'businessOpportunityId']" />
+
+    <!-- 回收站 -->
+    <DeteleBusiness :visibles="allVisible.deteleBusinessVisible" @closeVisible="closeVisible" />
   </div>
 </template>
 
 <script lang="ts" setup>
 import { ref, reactive, onMounted, inject } from "vue";
-import type { ElTable, FormInstance, FormRules } from 'element-plus'
+import type { ElTable, FormInstance, FormRules, UploadRequestOptions } from 'element-plus'
 import { useRouter, useRoute } from "vue-router";
-import { GETSYSFILED, MOD, GETPERSONNEL, GETGENERATEFOEM, GETBUSINESSLIST, UPDATEINSET, BUSINESSDETELE, BATCHTRANSFER, tableColumn } from './api'
+import { GETSYSFILED, MOD, GETPERSONNEL, GETGENERATEFOEM, GETBUSINESSLIST, UPDATEINSET, BUSINESSDETELE, BATCHTRANSFER, MODURL, tableColumn } from './api'
 import { GETTABLELIST } from '@/pages/product/api'
-import { post, get } from "@/utils/request";
-import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, createTaskFromType, formatDate, confirmAction } from '@/utils/tools'
+import { post, get, uploadFile } from "@/utils/request";
+import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, createTaskFromType, formatDate, confirmAction, downloadTemplate, downloadFile } from '@/utils/tools'
 import { createTask } from '@/components/TaskModal/taskFunction'
 import { formatDateTime } from '@/utils/times'
 import { GenerateForm } from '@zmjs/form-design';
 import RelatedProducts from './component/relatedProducts.vue'
 import TaskModal from '@/components/TaskModal/index.vue'
+import DeteleBusiness from './component/deteleTables.vue'
 
 const route = useRoute()
 const router = useRouter()
@@ -164,13 +189,17 @@ const allLoading = reactive({
   businessTableLading: false,
   businessSaveLading: false,
   newBusinessSaveLading: false,
-  transferLoading: false
+  transferLoading: false,
+  importLoading: false,
+  exoprtLoading: false,
 })
 const allVisible = reactive({
   newBusinessisible: false,
   recycleVisible: false,
   taskModalVisible: false,
-  batchTransferVisible: false
+  batchTransferVisible: false,
+  deteleBusinessVisible: false,
+  importVisible: false
 })
 const allText = reactive({
   newBusinessisibleText: '新建商机',
@@ -284,6 +313,31 @@ function businessDeteleItem(value: string | number, label: string, batch: boolea
   })
 }
 
+async function importBusiness(param: UploadRequestOptions) {
+  allLoading.importLoading = true
+  const formData = new FormData();
+  formData.append('multipartFile', param.file)
+  const res = await uploadFile('接口名称', formData).finally(() => {
+    allLoading.importLoading = false
+  })
+  if (res.code == 'ok') {
+    globalPopup?.showSuccess('导入成功' || '')
+    getBusinessTableList()
+    return
+  }
+  globalPopup?.showError(res.msg || '')
+}
+
+function exportBusinessTableList() {
+  allLoading.exoprtLoading = true
+  let valueForm = getFromValue(businessOpportunityForm)
+  post('接口名称', {...valueForm}).then((res) => {
+    downloadFile(res.data, '商机表导出.xlsx')
+  }).finally(() => {
+    allLoading.exoprtLoading = false
+  })
+}
+
 function changeBatch(flag: boolean = true) {
   if (flag) {
     batchTableData.value = businessTableRef.value && businessTableRef.value.getSelectionRows()

+ 3 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/product/index.vue

@@ -276,7 +276,9 @@ async function importProducts(param: UploadRequestOptions) {
   allLoading.importLoading = true
   const formData = new FormData();
   formData.append('multipartFile', param.file)
-  const res = await uploadFile(UPLOADFILE, formData)
+  const res = await uploadFile(UPLOADFILE, formData).finally(() => {
+    allLoading.importLoading = false
+  })
   allLoading.importLoading = false
   if (res.code == 'ok') {
     globalPopup?.showSuccess('导入成功' || '')

+ 3 - 2
fhKeeper/formulahousekeeper/timesheet/src/components/vueMultipleDept.vue

@@ -26,13 +26,14 @@
                         :filter-node-method="treeDatafilterNode" default-expand-all @check-change="handleCheckChange"
                         ref="treeDataComtent">
                         <span class="custom-tree-node" slot-scope="{ node, data }">
-                            <span v-if="node.data.children">
+                            <!-- <span v-if="node.data.children">
                                 <TranslationOpenDataText type='departmentName' :openid='node.label'>
                                 </TranslationOpenDataText>
                             </span>
                             <span v-else>
                                 <TranslationOpenDataText type='userName' :openid='node.label'></TranslationOpenDataText>
-                            </span>
+                            </span> -->
+                            <TranslationOpenDataText type='departmentName' :openid='node.label'></TranslationOpenDataText>
                         </span>
                     </el-tree>
                 </div>