Bladeren bron

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

Min 11 maanden geleden
bovenliggende
commit
a2c50c7f4b

+ 7 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/main.ts

@@ -11,15 +11,22 @@ import App from './App.vue'
 import router from './router/index'
 import * as echarts from 'echarts';
 import zhCn from "element-plus/dist/locale/zh-cn.mjs";
+import customize from '@/utils/customInstructions'
 const app = createApp(App)
 const pinia = createPinia()
 
 pinia.use(piniaPluginPersistedstate)
 
+// element-ui
 for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
   app.component(key, component)
 }
 
+// 注册自定义指令
+for (const [key, value] of Object.entries(customize)) {
+  app.directive(value.key, value.directive)
+}
+
 app.config.globalProperties.$echarts = echarts;
 app
   .use(ElementPlus, {

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

@@ -5,16 +5,7 @@ export const GETSYSFILED = "/sys-dict/getListByCode";
 export const GETPERSONNEL = "/user/getSimpleActiveUserList";
 export const GETGENERATEFOEM = `/sys-form/getListByCode${MOD}`
 export const GETALLPRODUCT = `/sys-form/getListByCode/Order`
-export const GETTABLELIST =  `${MOD}/list`
-
-export const actionButtons: any[] = [
-    { text: '新建订单' },
-    { text: '批量转移' },
-    { text: '批量删除' },
-    { text: '回收站' },
-    { text: '导入' },
-    { text: '导出' },
-]
+export const GETTABLELIST = `${MOD}/list`
 
 export const tableColumns: TableColumn[] = [
     { prop: 'orderCode', label: '订单编号', event: 'toDetali', width: '150' },

+ 8 - 5
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/order/index.vue

@@ -36,7 +36,12 @@
       <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 v-for="(button, index) in actionButtons" :key="index" type="primary">{{ button.text }}</el-button>
+          <el-button v-permission="['aabbc']" 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">导出</el-button>
         </div>
         <div class="flex-1 w-full overflow-hidden">
           <!-- 表格 -->
@@ -71,10 +76,10 @@
 </template>
 
 <script lang="ts" setup>
-import { ref, reactive, onMounted, inject } from "vue";
+import { ref, reactive, onMounted, inject, defineExpose } from "vue";
 import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate } from '@/utils/tools'
 import { post, get } from "@/utils/request";
-import { actionButtons, tableColumns, GETSYSFILED, GETPERSONNEL, GETGENERATEFOEM, MOD, GETTABLELIST, GETALLPRODUCT } from "./api";
+import { tableColumns, GETSYSFILED, GETPERSONNEL, GETGENERATEFOEM, MOD, GETTABLELIST, GETALLPRODUCT } from "./api";
 import { useRouter, useRoute } from "vue-router";
 import { URL_FETALL } from "../customer/api";
 
@@ -103,8 +108,6 @@ const formTablePaging = reactive({ // 分页条件
   pageSize: 10,
   total: 0,
 })
-const generateFormData = ref([]) // 自定义表单数据
-
 const formTable = ref([]) // 表格数据
 const allLoading = reactive({ // 按钮加载 Loading
   formTableLading: false,

+ 3 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/type.d.ts

@@ -36,4 +36,6 @@ type TaskResponse = { saveLoading: saveLoadingType, isClose: boolean, message?:
 
 type optionType = { value: number | string, label: string | number }
 
-type sexTYpe = { value: number | string, label: string }
+type sexTYpe = { value: number | string, label: string }
+
+type buttonType = { label?: string, value?: string, type?: string, icon?: string, disabled?: boolean, loading?: boolean, text?: string, event?: void }

+ 33 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/utils/customInstructions.ts

@@ -0,0 +1,33 @@
+import { Directive } from 'vue';
+
+// 权限控制
+const PermissionDirective: Directive = {
+    mounted(el: HTMLElement, binding: { value: string[] }, vnode: any) {
+        const routePath = vnode.ctx.appContext.config.globalProperties.$route.path;
+        console.log(extractPath(routePath))
+        // const currentRoute = getCurrentInstance()?.appContext.config.globalProperties.$route;
+        // console.log('Current Route:', currentRoute);
+
+        // const permissions = binding.value;
+        // if (!Array.isArray(permissions)) {
+        //     console.error('Permissions must be provided as an array.');
+        //     return;
+        // }
+        // if (!permissions.some((permission: string) => permission === 'admin')) {
+        //     el.parentNode && el.parentNode.removeChild(el)
+        // }
+    }
+};
+
+function extractPath(str: any) {
+    const startIndex = str.indexOf('/');
+    const endIndex = str.indexOf('/', startIndex + 1);
+    return str.slice(startIndex, endIndex !== -1 ? endIndex : undefined);
+}
+
+// 导出的自定义指令
+const customize = [
+    { key: 'permission', directive: PermissionDirective, name: '角色权限' }
+]
+
+export default customize;

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

@@ -9,6 +9,7 @@ import com.management.platform.mapper.ContactsMapper;
 import com.management.platform.mapper.UserMapper;
 import com.management.platform.service.ContactsService;
 import com.management.platform.util.HttpRespMsg;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -161,5 +162,29 @@ public class ContactsController {
     }
 
 
+    //转移联系人 conctacts 里面要有要转移的负责人的 owner_id,id
+    @RequestMapping("transferContacts")
+    public HttpRespMsg transferContacts(Contacts contacts,HttpServletRequest request){
+        User user = userMapper.selectById(request.getHeader("Token"));//当前登陆的用户
+        HttpRespMsg msg = new HttpRespMsg();
+        if (contacts.getOwnerId()==null|| StringUtils.isEmpty(contacts.getOwnerId())){
+            msg.setError("请选择要转移的负责人");
+            return msg;
+        }
+        Contacts contactsGet=contactsService.getById(contacts.getId());
+        if (contacts.getOwnerId().equals(contactsGet.getOwnerId())){
+            msg.setError("该联系人已属于所选负责人");
+            return msg;
+        }
+        contactsGet.setOwnerId(contacts.getOwnerId());
+        int count= contactsService.transferContacts(contactsGet, user);
+        if (count>0){
+            msg.setMsg("操作成功");
+            return msg;
+        }else {
+            msg.setError("操作失败");
+            return msg;
+        }
+    }
 }
 

+ 3 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ContactsService.java

@@ -3,6 +3,7 @@ package com.management.platform.service;
 import com.management.platform.entity.Contacts;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.management.platform.entity.Custom;
+import com.management.platform.entity.User;
 import com.management.platform.util.HttpRespMsg;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -42,4 +43,6 @@ public interface ContactsService extends IService<Contacts> {
     HttpRespMsg exportData(String customName, String name, String email, String creatorName, String phone, String ownerName, HttpServletRequest request) throws Exception;
 
     HttpRespMsg getAllContacts(HttpServletRequest request);
+
+    int transferContacts(Contacts contactsGet, User user);
 }

+ 27 - 28
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ClueServiceImpl.java

@@ -401,7 +401,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
             //由于第一行需要指明列对应的标题
             int rowNum = sheet.getLastRowNum();
             //获取当前表单模板 校验规则
-            SysForm sysForm = sysFormMapper.selectOne(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCode, "Product").eq(SysForm::getCompanyId, companyId).eq(SysForm::getIsCurrent, 1));
+            SysForm sysForm = sysFormMapper.selectOne(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCode, "Thread").eq(SysForm::getCompanyId, companyId).eq(SysForm::getIsCurrent, 1));
             if(sysForm==null){
                 msg.setError("当前模块未配置自定义模板,需先完成配置");
                 return msg;
@@ -409,7 +409,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
             String config = sysForm.getConfig();
             JSONObject configOb = JSON.parseObject(config);
             JSONArray configObJSONArray = configOb.getJSONArray("list");
-            List<Clue> importClueList=new ArrayList<>();
+//            List<Clue> importClueList=new ArrayList<>();
             List<String> userNameList=new ArrayList<>();
             HttpRespMsg respMsg=new HttpRespMsg();
             for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
@@ -427,29 +427,32 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                     JSONObject item = configObJSONArray.getJSONObject(i);
                     String modelName = item.getString("model");
                     XSSFCell cell = row.getCell(i);
-//                    if(cell!=null){
-//                        switch (item.getString("type")){
-//                            case "time":cell.setCellType(CellType.NUMERIC);
-//                                break;
-//                            default:cell.setCellType(CellType.STRING);
-//                        }
-//                    }
-                    if(modelName.equals("inchargerId")){
-                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
-                            userNameList.add(cell.getStringCellValue());
+                    if(cell!=null){
+                        switch (item.getString("type")){
+                            case "time":cell.setCellType(CellType.NUMERIC);
+                                break;
+                            default:cell.setCellType(CellType.STRING);
                         }
                     }
+//                    if(modelName.equals("inchargerId")){
+//                        System.out.println("=====");
+//                        System.out.println(modelName);
+//                        System.out.println(cell.toString());
+//                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
+//                            userNameList.add(cell.getStringCellValue());
+//                        }
+//                    }
 
                 }
             }
-            System.out.println("参与搜索的人员列表"+userNameList + userNameList.size());
-            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
-                respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
-                if(respMsg.code.equals("0")){
-                    msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
-                    return msg;
-                }
-            }
+//            System.out.println("参与搜索的人员列表"+userNameList + userNameList.size());
+//            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
+//                respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
+//                if(respMsg.code.equals("0")){
+//                    msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
+//                    return msg;
+//                }
+//            }
             List<User> targetUserList= (List<User>) respMsg.data;
             //直接忽略空行 从row1开始
             for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
@@ -465,6 +468,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                 int cellNum = row.getLastCellNum();
                 Clue clue =new Clue();
                 clue.setCompanyId(companyId);
+                clue.setCreateTime(new Date());
                 clue.setCreateId(user.getId());
                 for (int i = 0; i < cellNum; i++) {
                     JSONObject item = configObJSONArray.getJSONObject(i);
@@ -520,7 +524,8 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
                            Optional<SysDict> first = sysDictOfClueSources.stream().filter(s -> s.getName().equals(cell.getStringCellValue())).findFirst();
                            if(first.isPresent()){
-                               clue.setClueSourceId(first.get().getId());
+                               Integer id = first.get().getId();
+                               clue.setClueSourceId(id);
                            }else {
                                throw new Exception("线索来源["+cell.getStringCellValue()+"不存在,请在系统字典中增加");
                            }
@@ -543,13 +548,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                     }
 
                 }
-                importClueList.add(clue);
-            }
-            if(importClueList.size()>0){
-                if(!saveOrUpdateBatch(importClueList)){
-                    msg.setError("验证失败");
-                    return msg;
-                }
+                clueMapper.insert(clue);
             }
         } catch (IOException | NoSuchMethodException e) {
             e.printStackTrace();

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

@@ -80,7 +80,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
 
 
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public HttpRespMsg addContacts(Contacts contacts, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         String token = String.valueOf(request.getHeader("Token"));
@@ -167,6 +167,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public HttpRespMsg updateContacts(Contacts contacts, HttpServletRequest request) {
         HttpRespMsg msg = new HttpRespMsg();
         String token = String.valueOf(request.getHeader("Token"));
@@ -189,6 +190,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public HttpRespMsg deleteContacts(List<Integer> ids, HttpServletRequest request) {
         HttpRespMsg msg = new HttpRespMsg();
         UpdateWrapper<Contacts> contactsUpdateWrapper = new UpdateWrapper<>();
@@ -245,6 +247,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public HttpRespMsg returnContacts(List<Integer> ids) {
         HttpRespMsg msg = new HttpRespMsg();
         UpdateWrapper<Contacts> contactsUpdateWrapper = new UpdateWrapper<>();
@@ -583,5 +586,27 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
         return mgs;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int transferContacts(Contacts contactsGet, User user) {
+        UpdateWrapper<Contacts> contactsUpdateWrapper = new UpdateWrapper<>();
+        contactsUpdateWrapper.eq("id", contactsGet.getId());
+        contactsUpdateWrapper.set("owner_id", contactsGet.getOwnerId());
+        int count1 = contactsMapper.update(null, contactsUpdateWrapper);
+
+        ContactsLog contactsLog = new ContactsLog();
+        contactsLog.setCompanyId(user.getCompanyId());
+        contactsLog.setContactsId(contactsGet.getId());
+        contactsLog.setOperateId(user.getId());
+        contactsLog.setOperateDate(LocalDateTime.now());
+        contactsLog.setMsg("转移联系人");
+        int count2 = contactsLogMapper.insert(contactsLog);
+        if (count1>0&&count2>0){
+            return 1;
+        }else {
+            return 0;
+        }
+    }
+
 
 }

+ 12 - 8
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -17,6 +17,10 @@ import com.management.platform.util.HttpRespMsg;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -302,9 +306,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             outputStream.close();
 
             //解析表格
-            HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(file));
+            XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(file));
             //我们只需要第一个sheet
-            HSSFSheet sheet = workbook.getSheetAt(0);
+            XSSFSheet sheet = workbook.getSheetAt(0);
             //由于第一行需要指明列对应的标题
             int rowNum = sheet.getLastRowNum();
             //获取当前表单模板 校验规则
@@ -329,7 +333,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             List<SalesOrder> orderList = salesOrderMapper.getList(user);
              List<Clue> clueList = clueMapper.selectList(new LambdaQueryWrapper<Clue>().eq(Clue::getCompanyId, user.getCompanyId()).eq(Clue::getIsDelete, 0).orderByDesc(Clue::getCreateTime));
             for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
-                HSSFRow row = sheet.getRow(rowIndex);
+                XSSFRow row = sheet.getRow(rowIndex);
                 if (row == null) {
                     continue;
                 }
@@ -343,8 +347,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 for (int i = 0; i < cellNum; i++) {
                     JSONObject item = configObJSONArray.getJSONObject(i);
                     String modelName = item.getString("model");
-                    HSSFCell cell = row.getCell(i);
-                    if(cell!=null&&StringUtils.isNotEmpty(cell.getStringCellValue())){
+                    XSSFCell cell = row.getCell(i);
+/*                    if(cell!=null&&StringUtils.isNotEmpty(cell.getStringCellValue())){
                         switch (item.getString("type")){
                             case "time":cell.setCellType(CellType.NUMERIC);
                                 System.out.println(cell.getNumericCellValue());
@@ -353,7 +357,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                                 break;
                             default:cell.setCellType(CellType.STRING);
                         }
-                    }
+                    }*/
                     if(modelName.equals("executorId")){
                         if(!StringUtils.isEmpty(cell.getStringCellValue())){
                             List<String> executorNames = new ArrayList<>();
@@ -382,7 +386,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             List<User> targetUserList= (List<User>) respMsg.data;
 
             for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
-                HSSFRow row = sheet.getRow(rowIndex);
+                XSSFRow row = sheet.getRow(rowIndex);
                 if (row == null) {
                     continue;
                 }
@@ -403,7 +407,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                     String className = modelName.substring(0, 1).toUpperCase() + modelName.substring(1);
                     String getter="get"+className;
                     String setter="set"+className;
-                    HSSFCell cell = row.getCell(i);
+                    XSSFCell cell = row.getCell(i);
                     if(cell!=null&&StringUtils.isNotEmpty(cell.getStringCellValue())){
                         switch (item.getString("type")){
                             case "time":cell.setCellType(CellType.NUMERIC);