瀏覽代碼

Merge remote-tracking branch 'origin/master'

yusm 11 月之前
父節點
當前提交
3b7614bfba

+ 2 - 2
fhKeeper/formulahousekeeper/customerBuler-crm/src/components/TaskModal/api.ts

@@ -56,8 +56,8 @@ export const TASK_TYPE_FIELD: {
   {
     type: "2",
     field: "orderId",
-    valueIndex: "value",
-    labelIndex: "label",
+    valueIndex: "id",
+    labelIndex: "orderName",
   },
   {
     type: "3",

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

@@ -178,7 +178,7 @@ watch(() => props.editForm, (val) => {
   post(ALL_ORDERS, { pageIndex: -1, pageSize: -1 }).then(({ data }) => {
     orderData.value = data.record;//销售订单
     if (taskType == 2) {
-      taskTypeValueData.value = data;
+      taskTypeValueData.value = data.record;
     }
   })
   get(ALL_CLUE, {}).then(({ data }) => {

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

@@ -20,6 +20,7 @@ export const REFIENAMEFILE = `/business-opportunity/reFileName`
 export const UPLOADFILEFILE = `/business-opportunity/uploadFile`
 export const URL_IMPOERBUSINESS = `/business-opportunity/importData`
 export const URL_DETELESTAGE = `/business-opportunity/deleteStage`
+export const URL_SAVECONTACT = `/business-opportunity/saveContactsId`
 
 
 export const stageStatus = [

+ 61 - 8
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/component/information.vue

@@ -3,9 +3,10 @@
         <div class="flex justify-between">
             <div class="title">基本信息</div>
             <div>
-                <el-button type="primary">关联联系人</el-button>
+                <el-button type="primary" @click="associateContact()" v-if="!information.cuntactsId">关联联系人</el-button>
                 <el-button type="primary" @click="claimBusiness()" v-if="!information.customerId">认领</el-button>
-                <el-button type="primary" @click="showVisible('transferBusinessVisible')" v-else>转移</el-button>
+                <el-button type="primary" @click="showVisible('transferBusinessVisible')"
+                    v-if="information.customerId">转移</el-button>
                 <el-button type="primary" @click="showVisible('editBusinessVisible')">编辑</el-button>
             </div>
         </div>
@@ -69,7 +70,8 @@
                 <div class="flex justify-between items-center border-b pb-3 dialog-header">
                     <h4 :id="titleId">{{ '转移商机' }}</h4>
                     <div>
-                        <el-button type="primary" :loading="allLoading.transferBusinessLoading" @click="transferBusiness()">转移</el-button>
+                        <el-button type="primary" :loading="allLoading.transferBusinessLoading"
+                            @click="transferBusiness()">转移</el-button>
                         <el-button @click="allVisible.transferBusinessVisible = false">取消</el-button>
                     </div>
                 </div>
@@ -84,16 +86,39 @@
                 <div class="pl-3 text-[#e94a4a]">转移后,将看不到此商机</div>
             </div>
         </el-dialog>
+
+        <!-- 关联 -->
+        <el-dialog v-model="allVisible.saveContactVisible" 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">{{ '关联联系人' }}</h4>
+                    <div>
+                        <el-button type="primary" :loading="allLoading.saveContactLoading"
+                            @click="saveAssociateContact()">关联</el-button>
+                        <el-button @click="allVisible.saveContactVisible = 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="contactsId" placeholder="请选择" class="flex1">
+                        <el-option v-for="item in contactsList" :key="item.value" :label="item.label" :value="item.value" />
+                    </el-select>
+                </div>
+            </div>
+        </el-dialog>
     </div>
 </template>
 <script lang="ts" setup>
 import { ref, reactive, onMounted, onUnmounted, defineExpose, inject, watchEffect } from 'vue'
 import { GenerateForm } from '@zmjs/form-design';
 import { get, post } from '@/utils/request';
-import { BATCHTRANSFER, GETGENERATEFOEM, GETPERSONNEL, UPDATEINSET } from '../api';
+import { BATCHTRANSFER, GETGENERATEFOEM, GETPERSONNEL, UPDATEINSET, URL_SAVECONTACT } from '../api';
 import { formatDateTime } from '@/utils/times';
 import { confirmAction } from '@/utils/tools';
 import { useStore } from '@/store/index'
+import { URL_GETALL } from '@/pages/contacts/api';
 
 const { userInfo } = useStore()
 const globalPopup = inject<GlobalPopup>('globalPopup')
@@ -107,20 +132,49 @@ const transferValue = ref('')
 const transferOptions = ref<personnelInterface[]>([])
 const generateFormValue = ref({})
 const generateForm = ref<typeof GenerateForm>() // 自定义表单dom
+const contactsId = ref('')
+const contactsList = ref<optionType[]>([])
 const allVisible = reactive({
     editBusinessVisible: false,
-    transferBusinessVisible: false
+    transferBusinessVisible: false,
+    saveContactVisible: false
 })
 const allLoading = reactive({
     editBusinessLoading: false,
     businessSaveLading: false,
-    transferBusinessLoading: false
+    transferBusinessLoading: false,
+    saveContactLoading: false
 })
 const generateFormData = ref({
     config: {},
     list: []
 }) // 自定义表单数据
 
+function associateContact() {
+    contactsId.value = ''
+    getContactList()
+    showVisible('saveContactVisible')
+}
+
+function getContactList() {
+    post(URL_GETALL, { customerId: information.value.customerId }).then(({ data }) => {
+        contactsList.value = data.map((item: any) => {
+            return { value: item.id, label: item.name }
+        })
+    })
+}
+
+function saveAssociateContact() {
+    allLoading.saveContactLoading = false
+    post(URL_SAVECONTACT, { id: information.value.id, contactsId: contactsId.value }).then(() => {
+        globalPopup?.showSuccess('关联成功')
+        closeVisible('saveContactVisible')
+        emits('refreshData')
+    }).finally(() => {
+        allLoading.saveContactLoading = false
+    })
+}
+
 function transferBusiness() {
     const ids = information.value?.id
     const inchargerId = information.value?.inchargerName ? transferValue.value : userInfo.id
@@ -222,5 +276,4 @@ onMounted(() => {
             line-height: 1.5;
         }
     }
-}
-</style>
+}</style>

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

@@ -60,16 +60,17 @@
           <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 v-for="(item, index) in tableColumn" :prop="item.prop" :label="item.label" :key="index" :width="item.width">
+            <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>
+                <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 label="操作" fixed="right" width="200">
               <template #default="scope">
-                <el-button link type="primary" size="large"
-                  @click="editNewBusiness(scope.row)">编辑</el-button>
+                <el-button link type="primary" size="large" @click="editNewBusiness(scope.row)">编辑</el-button>
                 <el-button link type="primary" size="large" @click="newTask(scope.row)">新建任务</el-button>
                 <el-button link type="danger" size="large"
                   @click="businessDeteleItem(scope.row.id, scope.row.name)">删除</el-button>
@@ -99,9 +100,11 @@
         </div>
       </template>
       <div class="h-[60vh] overflow-y-auto scroll-bar pt-3" v-loading="allLoading.generateFormLading">
-        <GenerateForm ref="businessTemplateRef" :data="businessTemplate" :value="businessTemplateValue" :key="businessTemplateKey" />
+        <GenerateForm ref="businessTemplateRef" :data="businessTemplate" :value="businessTemplateValue"
+          :key="businessTemplateKey" />
         <div>相关产品</div>
-        <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList" />
+        <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList"
+          :productTableListValue="productTableListValue" />
       </div>
     </el-dialog>
 
@@ -133,7 +136,8 @@
         <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-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>
@@ -142,7 +146,8 @@
       </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="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>
@@ -236,6 +241,7 @@ const fixedData = reactive({
   Personnel: [] as personnelInterface[]
 })
 const productTableList = ref([])
+const productTableListValue = ref([])
 
 
 function editBusiness(visibles: boolean) {
@@ -265,11 +271,13 @@ function editNewBusiness(item: any) {
   showVisible('newBusinessisible')
   allLoading.generateFormLading = true
   if (item) {
+    editProduct(item)
     businessTemplateValue.value = item
     allText.newBusinessisibleText = '编辑商机'
   }
   if (!item) {
     businessTemplateValue.value = {}
+    productTableListValue.value = []
     allText.newBusinessisibleText = '新建商机'
   }
   setTimeout(() => {
@@ -353,7 +361,7 @@ async function importBusiness(param: UploadRequestOptions) {
 function exportBusinessTableList() {
   allLoading.exoprtLoading = true
   let valueForm = getFromValue(businessOpportunityForm)
-  post('接口名称', {...valueForm}).then((res) => {
+  post('接口名称', { ...valueForm }).then((res) => {
     downloadFile(res.data, '商机表导出.xlsx')
   }).finally(() => {
     allLoading.exoprtLoading = false
@@ -369,6 +377,17 @@ function changeBatch(flag: boolean = true) {
   }
 }
 
+function editProduct(row: any) {
+  const list = row.businessItemProductList.map((item: any) => {
+    const { id, productName, productCode, unit, unitName, typeName, type, price, inventory, orderProductDetail, num, discount, sealPrice, totalPrice } = item
+    return {
+      id, productId: id, productName, productCode, unit, unitName, typeName, type, price, inventory,
+      num, discount, sealPrice, totalPrice 
+    }
+  })
+  productTableListValue.value = list
+}
+
 function showVisible(type: keyof typeof allVisible) { // 显示弹窗
   allVisible[type] = true
 }
@@ -425,7 +444,7 @@ async function getSystemField() {
   fixedData.BusinessStage = (row.data || []).map((item: any) => {
     const { name, id, seq } = item
     return { name, id, seq }
-  }).sort(function (a: any, b: any) {return a.seq - b.seq;});
+  }).sort(function (a: any, b: any) { return a.seq - b.seq; });
 
   const { data } = await post(GETPERSONNEL, {})
   fixedData.Personnel = data.map((item: any) => {
@@ -447,7 +466,7 @@ function toBusinessTableDetail(row: any) {
 }
 
 function dealWithTableColumn(row: any, eventName: string) {
-  if(eventName == 'toClueTableDetail') {
+  if (eventName == 'toClueTableDetail') {
     toBusinessTableDetail(row)
   }
 }
@@ -491,5 +510,4 @@ onMounted(() => {
     font-size: 18px;
     line-height: 24px;
   }
-}
-</style>
+}</style>

+ 6 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/order/api.ts

@@ -1,5 +1,5 @@
 export const MOD = '/order'
-export const IMPOERMOD = 'Order'
+export const IMPORTMOD = 'Order'
 
 export const GETSYSFILED = "/sys-dict/getListByCode";
 export const GETPERSONNEL = "/user/getSimpleActiveUserList";
@@ -9,6 +9,11 @@ export const GETTABLELISTPRODUCT = `/product/list`
 export const GETTABLELIST = `${MOD}/list`
 export const URL_OEDERUPDATE = `${MOD}/addOrUpdate`
 export const URL_PRODUTWITHORDER = `${MOD}/productWithOrder`
+export const URL_DETELEITEM = `${MOD}/delete`
+export const EXPORTTIME = `${MOD}/exportData`
+export const IMPORITEM = `${MOD}/importData`
+export const URL_BATCHDELETE = `${MOD}/batchDeleteOrder`
+export const URL_RECOVER = `${MOD}/recover`
 
 export const tableColumns: TableColumn[] = [
     { prop: 'orderCode', label: '订单编号', event: 'toDetali', width: '150' },

+ 156 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/order/component/deteleTables.vue

@@ -0,0 +1,156 @@
+<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 { GETTABLELIST, tableColumns, URL_BATCHDELETE, URL_RECOVER } 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_RECOVER : URL_BATCHDELETE
+        // let url = ''
+        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(GETTABLELIST, { ...tableForm, isDelete: 1 }).then((res) => {
+        if (res.code == 'ok') {
+            const { record, total } = res.data
+            deteleBusinessTable.value = record
+            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', 'deteleOrderVisible')
+}
+
+function beForeCancel(done: () => void) {
+    emits('closeVisible', 'deteleOrderVisible')
+    done()
+}
+
+onMounted(() => {
+
+})
+
+</script>
+<style lang="scss" scoped></style>

+ 173 - 26
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/order/index.vue

@@ -37,16 +37,17 @@
         <div class="flex justify-end pb-3">
           <!-- 操作按钮 -->
           <el-button type="primary" @click="editOrder(false)">新建订单</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">导出</el-button>
+          <el-button type="primary" :disabled="batchTableData.length <= 0">批量转移</el-button>
+          <el-button type="primary" @click="batchDeteleItem()" :disabled="batchTableData.length <= 0">批量删除</el-button>
+          <el-button type="primary" @click="showVisible('deteleOrderVisible')">回收站</el-button>
+          <el-button type="primary" @click="showVisible('importVisible')">导入</el-button>
+          <el-button type="primary" @click="exportOrderTableList()" :loading="allLoading.exoprtLoading">导出</el-button>
         </div>
         <div class="flex-1 w-full overflow-hidden">
           <!-- 表格 -->
           <el-table ref="otherTableRef" :data="formTable" border v-loading="allLoading.formTableLading"
-            style="width: 100%;height: 100%;">
+            style="width: 100%;height: 100%;" @selection-change="changeBatch">
+            <el-table-column type="selection" width="55" />
             <el-table-column v-for="(column, index) in tableColumns" :key="index" :prop="column.prop"
               :label="column.label" :width="column.width">
               <template #default="scope">
@@ -59,8 +60,9 @@
             <el-table-column :label="'操作'" :width="'200px'" fixed="right">
               <template #default="scope">
                 <el-button link type="primary" size="large" @click="editOrder(scope.row)">编辑</el-button>
-                <el-button link type="primary" size="large">新建任务</el-button>
-                <el-button link type="danger" size="large">删除</el-button>
+                <el-button link type="primary" size="large" @click="newTask(scope.row)">新建任务</el-button>
+                <el-button link type="danger" size="large"
+                  @click="orderDeteleItem(scope.row.id, scope.row.orderName)">删除</el-button>
               </template>
             </el-table-column>
           </el-table>
@@ -68,7 +70,7 @@
         <div class="flex justify-end pt-3">
           <!-- 分页 -->
           <el-pagination layout="total, prev, pager, next, sizes" :total="formTablePaging.total"
-            :hide-on-single-page="true" />
+            :hide-on-single-page="true" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
         </div>
       </div>
     </div>
@@ -88,7 +90,39 @@
       <div class="h-[60vh] overflow-y-auto scroll-bar pt-3" v-loading="allLoading.orderTemplateLoadinng">
         <GenerateForm ref="orderTemplateRef" :data="orderTemplate" :value="orderTemplateValue" />
         <div>相关产品</div>
-        <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList" :productTableListValue="productTableListValue" />
+        <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList"
+          :productTableListValue="productTableListValue" />
+      </div>
+    </el-dialog>
+
+    <!-- 新建任务 -->
+    <TaskModal :visible="allVisible.taskModalVisible" :edit-form="taskModalForm" :save-loading="taskLoading"
+      @close="allVisible.taskModalVisible = false" @submit="submitForm" :title="'新建任务'"
+      :disabled-list="['taskType', 'orderId']" />
+
+    <!-- 回收站 -->
+    <DeteleTables :visibles="allVisible.deteleOrderVisible" @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>
@@ -96,16 +130,20 @@
 
 <script lang="ts" setup>
 import { ref, reactive, onMounted, inject, defineExpose } from "vue";
-import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate, getTemplateKey } from '@/utils/tools'
-import { post, get } from "@/utils/request";
-import { tableColumns, GETSYSFILED, GETPERSONNEL, GETGENERATEFOEM, MOD, GETTABLELIST, GETALLPRODUCT, GETTABLELISTPRODUCT, URL_OEDERUPDATE, URL_PRODUTWITHORDER } from "./api";
+import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate, getTemplateKey, createTaskFromType, confirmAction, downloadFile, downloadTemplate } from '@/utils/tools'
+import { post, get, uploadFile } from "@/utils/request";
+import { tableColumns, GETSYSFILED, GETPERSONNEL, GETGENERATEFOEM, MOD, GETTABLELIST, GETALLPRODUCT, GETTABLELISTPRODUCT, URL_OEDERUPDATE, URL_PRODUTWITHORDER, URL_DETELEITEM, EXPORTTIME, IMPORTMOD, IMPORITEM } from "./api";
 import { useRouter, useRoute } from "vue-router";
 import { GenerateForm } from '@zmjs/form-design';
+import { formatDateTime } from "@/utils/times";
+import { ElTable, UploadRequestOptions } from "element-plus";
+import { createTask } from "@/components/TaskModal/taskFunction";
 import { URL_FETALL } from "../customer/api";
 
 import RelatedProducts from '@/components/relatedProducts/relatedProducts.vue'
+import DeteleTables from './component/deteleTables.vue'
 import TaskModal from '@/components/TaskModal/index.vue'
-import { formatDateTime } from "@/utils/times";
+
 
 const router = useRouter()
 const globalPopup = inject<GlobalPopup>('globalPopup')
@@ -127,41 +165,129 @@ const selectData = reactive({ // 下拉数据
   AllProduct: [] as any[] // 所有产品
 })
 const formTablePaging = reactive({ // 分页条件
-  currentPage: 1,
+  pageIndex: 1,
   pageSize: 10,
   total: 0,
 })
 const allLoading = reactive({ // 按钮加载 Loading
   formTableLading: false,
   editSaveLading: false,
-  orderTemplateLoadinng: false
+  orderTemplateLoadinng: false,
+  exoprtLoading: false,
+  importLoading: false
 })
 const allVisible = reactive({
-  editOrderVisible: false
+  editOrderVisible: false,
+  taskModalVisible: false,
+  deteleOrderVisible: false,
+  importVisible: false
 })
 const allText = reactive({
-  orderEditText: '新建订单'
+  orderEditText: '新建订单',
+  importText: '销售订单表导出.xlsx'
 })
 const orderTemplate = ref({
   list: [],
   config: {}
 })
+const filterItems = ref<FilterItem[]>([
+  { label: '订单编号', key: 'orderCode', type: 'input' },
+  { label: '订单名称', key: 'orderName', type: 'input' },
+  { label: '客户名称', key: 'customId', type: 'select', options: selectData.Customer },
+  { label: '商机名称', key: 'businessOpportunityId', type: 'input' },
+  { label: '订单类型', key: 'ordertype', type: 'select', options: selectData.OrderType },
+  { label: '回款状态', key: 'receivedStatus', type: 'select', options: selectData.RemittanceStatus },
+  { label: '负责人', key: 'inchargerId', type: 'select', options: selectData.Personnel },
+  { label: '下单时间', key: '', type: 'date' },
+]) // 渲染筛选条件
 const orderTemplateValue = ref({})
 const orderTemplateKey = ref(1)
 const orderTemplateRef = ref<typeof GenerateForm>()
 const relatedProductsRef = ref<typeof RelatedProducts>()
-const filterItems = ref<FilterItem[]>([]) // 渲染筛选条件
+const otherTableRef = ref<InstanceType<typeof ElTable>>()
+const taskLoading = ref<saveLoadingType>('1')
+const batchTableData = ref([])
 const formTable = ref([]) // 表格数据
 const productTableList = ref([])
 const productTableListValue = ref([])
+const taskModalForm = ref({})
+
+async function importBusiness(param: UploadRequestOptions) {
+  allLoading.importLoading = true
+  const formData = new FormData();
+  formData.append('multipartFile', param.file)
+  const res = await uploadFile(IMPORITEM, formData).finally(() => {
+    allLoading.importLoading = false
+  })
+  if (res.code == 'ok') {
+    globalPopup?.showSuccess('导入成功' || '')
+    getTableList()
+    return
+  }
+  globalPopup?.showError(res.msg || '')
+}
+
+function exportOrderTableList() {
+  allLoading.exoprtLoading = true
+  let valueForm = getFromValue(filterForm)
+  post(EXPORTTIME, {...valueForm}).then((res) => {
+    downloadFile(res.data, allText.importText)
+  }).finally(() => {
+    allLoading.exoprtLoading = false
+  })
+}
+
+function batchDeteleItem() {
+  const value = batchTableData.value.map((item: any) => item.id).join(',')
+  const label = batchTableData.value.map((item: any) => item.orderName).join(',')
+  orderDeteleItem(value, label, true)
+}
+
+function orderDeteleItem(value: string | number, label: string, batch: boolean = false) {
+  confirmAction(`确定${batch ? '批量' : ''}删除【${label}】客户吗?`).then(() => {
+    post(URL_DETELEITEM, { ids: value }).then(res => {
+      if (res.code != 'ok') {
+        globalPopup?.showError(res.msg)
+        return
+      }
+      globalPopup?.showSuccess('删除成功')
+      changeBatch(false)
+      getTableList()
+    }).catch((err) => {
+      globalPopup?.showError(err.message)
+    })
+  })
+}
+
+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?.showSuccess('新增成功')
+  }).catch((err) => {
+    const { saveLoading, isClose, message } = err
+    taskLoading.value = saveLoading
+    allVisible.taskModalVisible = isClose
+    globalPopup?.showError(message)
+  })
+}
+
+function newTask(item: any) {
+  const { id } = item
+  taskModalForm.value = { ...createTaskFromType(2), orderId: id, }
+  console.log(taskModalForm.value)
+  allVisible.taskModalVisible = true
+}
 
 function saveOrder(flag: boolean) {
   orderTemplateRef.value?.getData().then((res: any) => {
     let productTableListData = relatedProductsRef?.value?.returnData()
-    for(var i in productTableListData) {
+    for (var i in productTableListData) {
       productTableListData[i].sealPrice = productTableListData[i].sellingPrice,
-      productTableListData[i].discount = productTableListData[i].discount,
-      productTableListData[i].num = productTableListData[i].quantity
+        productTableListData[i].discount = productTableListData[i].discount,
+        productTableListData[i].num = productTableListData[i].quantity
     }
     const produt = productTableListData ? JSON.stringify(productTableListData) : []
     allLoading.editSaveLading = true
@@ -221,7 +347,7 @@ function toDetali(row: any) {
 
 function getTableList() {
   const formValue = getFromValue(filterForm)
-  const formPaging = { pageIndex: formTablePaging.currentPage, pageSize: formTablePaging.pageSize }
+  const formPaging = { pageIndex: formTablePaging.pageIndex, pageSize: formTablePaging.pageSize }
   allLoading.formTableLading = true
   post(GETTABLELIST, { ...formValue, ...formPaging }).then(res => {
     const { total, record } = res.data
@@ -273,6 +399,15 @@ async function getSystemField() {
   setFilterItems()
 }
 
+function changeBatch(flag: boolean = true) {
+  if (flag) {
+    batchTableData.value = otherTableRef.value && otherTableRef.value.getSelectionRows()
+  } else {
+    batchTableData.value = []
+    otherTableRef.value && otherTableRef.value.clearSelection()
+  }
+}
+
 function showVisible(type: keyof typeof allVisible) { // 显示弹窗
   allVisible[type] = true
 }
@@ -298,9 +433,10 @@ function editProduct(row: any) {
   post(URL_PRODUTWITHORDER, { id: row.id }).then(({ data }) => {
     const list = data.map((item: any) => {
       const { id, productName, productCode, unit, unitName, typeName, type, price, inventory, orderProductDetail } = item
-      return { id, productId: id, productName, productCode, unit, unitName, typeName, type, price, inventory, 
-        quantity: +orderProductDetail?.num, 
-        discount: +orderProductDetail?.discount, 
+      return {
+        id, productId: id, productName, productCode, unit, unitName, typeName, type, price, inventory,
+        quantity: +orderProductDetail?.num,
+        discount: +orderProductDetail?.discount,
         sellingPrice: +orderProductDetail?.sealPrice,
         totalPrice: +orderProductDetail?.totalPrice
       }
@@ -336,6 +472,17 @@ function getProductTableList() {
   })
 }
 
+function handleSizeChange(val: number) {
+  formTablePaging.pageIndex = 1
+  formTablePaging.pageSize = val
+  getTableList()
+}
+
+function handleCurrentChange(val: number) {
+  formTablePaging.pageIndex = val
+  getTableList()
+}
+
 onMounted(() => {
   getSystemField()
   getAllProduct()

+ 5 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ProductController.java

@@ -144,7 +144,11 @@ public class ProductController {
             List<Integer> idList = splitList.stream().map(i -> Integer.valueOf(i)).collect(Collectors.toList());
             int count = taskService.count(new LambdaQueryWrapper<Task>().in(Task::getProductId, idList));
             if(count>0){
-                msg.setError("当前产品已绑定到相关任务,删除失败");
+                msg.setError("存在已绑定到相关任务的产品,删除失败");
+                return msg;
+            }
+            if(orderProductDetailService.count(new LambdaQueryWrapper<OrderProductDetail>().in(OrderProductDetail::getOrderId,idList))>0){
+                msg.setError("存在关联订单的产品,删除失败");
                 return msg;
             }
             if(idList.size()>0){

+ 25 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/SalesOrderController.java

@@ -12,6 +12,7 @@ import com.management.platform.util.HttpRespMsg;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -160,6 +161,10 @@ public class SalesOrderController {
             List<String> splitList = Arrays.asList(idSplit);
             List<Integer> idList = splitList.stream().map(s -> Integer.valueOf(s)).collect(Collectors.toList());
             List<SalesOrder> orderList = salesOrderService.list(new LambdaQueryWrapper<SalesOrder>().in(SalesOrder::getId, idList));
+            if(orderProductDetailService.count(new LambdaQueryWrapper<OrderProductDetail>().in(OrderProductDetail::getOrderId,idList))>0){
+                msg.setError("存在关联产品的订单,删除失败");
+                return msg;
+            }
             orderList.forEach(o->{
                 o.setIsDelete(1);
             });
@@ -187,6 +192,26 @@ public class SalesOrderController {
         return msg;
     }
 
+    /**
+     * @Description:批量删除产品数据
+     * @Param: [ids]
+     * @return: com.management.platform.util.HttpRespMsg
+     * @Author: yurk
+     * @Date: 2024/5/21
+     */
+    @RequestMapping("/batchDeleteOrder")
+    public HttpRespMsg batchDeleteProduct(String ids){
+        HttpRespMsg msg=new HttpRespMsg();
+        if(!StringUtils.isEmpty(ids)){
+            String[] idsSplit = ids.split(",");
+            List<String> splitList = Arrays.asList(idsSplit);
+            List<Integer> idList = splitList.stream().map(i -> Integer.valueOf(i)).collect(Collectors.toList());
+            idList.add(-1);
+            salesOrderService.removeByIds(idList);
+        }
+        return msg;
+    }
+
 
     /**
      * 恢复订单(假删除 isDelete标记 1-->0)

+ 9 - 4
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/BusinessItemProduct.java

@@ -28,21 +28,26 @@ public class BusinessItemProduct extends Model<BusinessItemProduct> {
      *  
      */
     @TableId("id")
-    private Integer id;
+    private Long id;
 
     /**
      * 产品id
      */
     @TableField("product_id")
     private Integer productId;
+    /**
+     * 产品id
+     */
+    @TableField("inventory")
+    private Integer inventory;
     @TableField(exist = false)
     private String productName;
     @TableField(exist = false)
     private String unit;
-    @TableField(exist = false)
+    @TableField("price")
     private BigDecimal price;
-    @TableField(exist = false)
-    private String inventory;
+//    @TableField(exist = false)
+//    private String inventory;
     @TableField(exist = false)
     private String productType;
 

+ 1 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/BusinessOpportunityServiceImpl.java

@@ -144,6 +144,7 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
         List<BusinessItemProduct> businessItemProducts = JSONArray.parseArray(bo.getBusinessItemProductList(), BusinessItemProduct.class);
         for (BusinessItemProduct businessItemProduct : businessItemProducts) {
             businessItemProduct.setBusinessId(bo.getId());
+//            businessItemProduct.setId(null);
             bipMapper.insert(businessItemProduct);
         }
         ActionLog actionLog = new ActionLog();

+ 1 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/BusinessItemProductMapper.xml

@@ -4,7 +4,7 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.management.platform.entity.BusinessItemProduct">
-        <id column="id" property="id" />
+        <id column="id" property="id" javaType="java.lang.Long" />
         <result column="product_id" property="productId" />
         <result column="quantity" property="quantity" />
         <result column="discount" property="discount" />