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

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

@@ -91,7 +91,6 @@ import DetailCompinents from '@/components/detailcompinents/relatedTasks.vue'
 import OperationRecord from '../component/operationRecord.vue';
 import Products from '../component/products.vue';
 import { post } from "@/utils/request";
-import { number } from "echarts";
 
 type stageListType = {
   name: string,

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

@@ -1,6 +1,7 @@
 import { SEX } from '../api.ts'
 export const MOD = 'contacts'
 export const URL = '/contacts'
+export const IMPORTMOD = 'Contacts'
 
 export const GETSYSFILED = "/sys-dict/getListByCode";
 export const GETPERSONNEL = "/user/getSimpleActiveUserList";
@@ -11,6 +12,9 @@ export const URL_ADD = `${URL}/addContacts`
 export const URL_UPLOAD = `${URL}/updateContacts`
 export const URL_DETELERECYCLE =  `${URL}/deleteContacts`
 export const URL_BATCHDETELE = `${URL}/confirmDeleteContacts`
+export const URL_RECYCLELIST = `${URL}/getDeletedContacts`
+export const URL_DETELEITEM = `${URL}/confirmDeleteContacts`
+export const URL_RESTORE = `${URL}/returnContacts`
 
 export const actionButtons: any[] = [
     { text: '新建联系人' },

+ 160 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/contacts/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 tableColumns" :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.pageSize"
+                    @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 { URL_RECYCLELIST, URL_DETELEITEM, URL_RESTORE, tableColumns } 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,
+    pageSize: 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 == '恢复' ? URL_RESTORE : URL_DETELEITEM
+        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(URL_RECYCLELIST, { ...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.pageSize = val
+    getTableList()
+}
+
+function handleCurrentChange(val: number) {
+    tableForm.pageIndex = val
+    getTableList()
+}
+
+function cancel() {
+    emits('closeVisible', 'deteleContactsVisible')
+}
+
+function beForeCancel(done: () => void) {
+    emits('closeVisible', 'deteleContactsVisible')
+    done()
+}
+
+onMounted(() => {
+
+})
+
+</script>
+<style lang="scss" scoped></style>

+ 52 - 6
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/contacts/index.vue

@@ -28,7 +28,7 @@
           <!-- <el-button v-for="(button, index) in actionButtons" :key="index" type="primary">{{ button.text }}</el-button> -->
           <el-button type="primary" @click="editContacts(false)">新建联系人</el-button>
           <el-button type="primary" @click="batchDeteleItem" :disabled="batchTableData.length <= 0">批量删除</el-button>
-          <el-button type="primary">回收站</el-button>
+          <el-button type="primary" @click="showVisible('deteleContactsVisible')">回收站</el-button>
           <el-button type="primary">导入</el-button>
           <el-button type="primary">导出</el-button>
         </div>
@@ -87,18 +87,46 @@
         </div>
       </div>
     </el-dialog>
+
+    <!-- 回收站 -->
+    <DeteleTables :visibles="allVisible.deteleContactsVisible" @closeVisible="closeVisible" />
+
+    <!-- 导入 -->
+    <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(IMPORTMOD, allText.importText)">{{ allText.importText }}</el-link></div>
+          <div class="mt-4">2、填写excel文件、客户名称必填</div>
+        </div>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script lang="ts" setup>
 import { ref, reactive, onMounted, inject } from "vue";
-import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate, getTemplateKey, confirmAction, createTaskFromType } from '@/utils/tools'
-import { post, get } from "@/utils/request";
-import { actionButtons, tableColumns, GETSYSFILED, GETPERSONNEL, GETGENERATEFOEM, MOD, URL_PAGECONTACTS, getSex, URL_ADD, URL_UPLOAD, URL_BATCHDETELE, URL_DETELERECYCLE } from "./api";
+import { getAllListByCode, getFromValue, resetFromValue, getTemplateKey, confirmAction, downloadTemplate } from '@/utils/tools'
+import { post, get, uploadFile } from "@/utils/request";
+import { actionButtons, tableColumns, GETSYSFILED, GETPERSONNEL, GETGENERATEFOEM, MOD, URL_PAGECONTACTS, getSex, URL_ADD, URL_UPLOAD, URL_BATCHDETELE, URL_DETELERECYCLE, IMPORTMOD } from "./api";
 import { useRouter, useRoute } from "vue-router";
 import { GenerateForm } from '@zmjs/form-design';
 import { URL_FETALL } from "../customer/api";
-import { ElTable } from "element-plus";
+import { ElTable, UploadRequestOptions } from "element-plus";
+
+import DeteleTables from './component/deteleTables.vue'
 
 const router = useRouter()
 const globalPopup = inject<GlobalPopup>('globalPopup')
@@ -141,17 +169,35 @@ const batchTableData = ref([])
 const allLoading = reactive({ // 按钮加载 Loading
   formTableLading: false,
   editContactsSaveLoading: false,
-  contactsTemplateRefLoading: false
+  contactsTemplateRefLoading: false,
+  importLoading: false
 })
 const allVisible = reactive({
   editContactsVisible: false,
   taskModalVisible: false,
+  deteleContactsVisible: false,
+  importVisible: false
 })
 const allText = reactive({
   editContactsText: '新建联系人',
+  importText: '联系人导入模板.xlsx'
 })
 
 // 方法
+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('导入成功' || '')
+    getContactPerson()
+    return
+  }
+  globalPopup?.showError(res.msg || '')
+}
 
 function batchDeteleItem() {
   const value = batchTableData.value.map((item: any) => item.id).join(',')