中扬CRM客户关系管理系统
LSH
2023-07-29 391c8925d9375a0d2eed2e1af12d0dc7a6c98d1e
#售前规划申请单上传文件
5个文件已修改
1个文件已添加
242 ■■■■■ 已修改文件
src/main/java/com/zy/crm/common/utils/FileSaveExampleUtil.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/controller/PlanController.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/entity/Plan.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/cstmr/cstmr.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/plan/plan.js 102 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/plan/plan.html 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/common/utils/FileSaveExampleUtil.java
New file
@@ -0,0 +1,64 @@
package com.zy.crm.common.utils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.springframework.web.multipart.MultipartFile;
public class FileSaveExampleUtil {
//    public static void main(String[] args) {
//        String filePath = "D:/work/file/file.txt"; // 指定保存文件的路径
//
//        try {
//            String content = "这是要保存的文件内容";
//            saveToFile(filePath, content);
//            System.out.println("文件保存成功!");
//        } catch (IOException e) {
//            System.out.println("文件保存失败:" + e.getMessage());
//        }
//    }
    public static void saveToFile(String filePath, String content) throws IOException {
        File file = new File(filePath);
        // 创建父目录(如果不存在)
        File parentDir = file.getParentFile();
        if (!parentDir.exists()) {
            parentDir.mkdirs();
        }
        // 将内容写入文件
        try (OutputStream outputStream = new FileOutputStream(file)) {
            byte[] bytes = content.getBytes();
            outputStream.write(bytes);
        }
    }
//    public static void main(String[] args) {
//        String savePath = "C:/path/to/save/"; // 指定保存文件的路径
//        MultipartFile file = ...; // 获取要保存的MultipartFile文件
//
//        try {
//            saveFile(file, savePath);
//            System.out.println("文件保存成功!");
//        } catch (IOException e) {
//            System.out.println("文件保存失败:" + e.getMessage());
//        }
//    }
    public static void saveFile(MultipartFile file, String savePath) throws IOException {
        // 创建保存文件的目录(如果不存在)
        File directory = new File(savePath);
        if (!directory.exists()) {
            directory.mkdirs();
        }
        // 保存文件
        String fileName = file.getOriginalFilename();
        String filePath = savePath + fileName;
        File dest = new File(filePath);
        file.transferTo(dest);
    }
}
src/main/java/com/zy/crm/manager/controller/PlanController.java
@@ -14,6 +14,7 @@
import com.core.exception.CoolException;
import com.zy.crm.common.entity.RouteCollectCountType;
import com.zy.crm.common.model.SettleDto;
import com.zy.crm.common.utils.FileSaveExampleUtil;
import com.zy.crm.common.utils.SetOfUtils;
import com.zy.crm.common.web.BaseController;
import com.zy.crm.manager.controller.result.FollowerTableVo;
@@ -37,6 +38,7 @@
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
@@ -208,6 +210,21 @@
        return R.ok();
    }
    @RequestMapping(value = "/plan/insert/file/auth")
//    @ManagerAuth
    public R insertFile(@RequestParam("planId") String planId,@RequestParam MultipartFile file){
        System.out.println("---开始---");
        String savePath = "D:/crm/plan/file/"+1+"/"; // 指定保存文件的路径
        try{
            FileSaveExampleUtil.saveFile(file, savePath);
        }catch (Exception e){
            return R.error();
        }
        return R.ok();
    }
    @PostMapping(value = "/plan/approval/auth")
    @ManagerAuth
    public R approval(@RequestParam Long planId,
src/main/java/com/zy/crm/manager/entity/Plan.java
@@ -349,13 +349,13 @@
        if (null == this.settle){ return null; }
        switch (this.settle){
            case 1:
                return "开始";
                return "等待组长审核";
            case 2:
                return "组长审核";
                return "等待售前分配规划员";
            case 3:
                return "售前审核";
                return "等待规划员提交";
            case 4:
                return "规划员审核";
                return "规划员已提交";
            case 5:
                return "审批通过";
            default:
@@ -369,6 +369,16 @@
        if (!Cools.isEmpty(user)){
            return String.valueOf(user.getNickname());
        }
        return "";
    }
    public String getNowHeadman$(){
        PlanTypeService planTypeService = SpringUtils.getBean(PlanTypeService.class);
        PlanType planType = planTypeService.selectById(this.planType);
        User user = planTypeService.findPlanLeader(planType);
        if (!Cools.isEmpty(user)){
            return String.valueOf(user.getNickname());
        }
        return null;
    }
src/main/webapp/static/js/cstmr/cstmr.js
@@ -23,7 +23,7 @@
    // 部门人员 筛选
    dropdown.render({
        elem: '#organization'
        ,content: ['<div id="organizationTree" style="height: calc(330px);border: none"></div>'].join('')
        ,content: ['<div id="organizationTree" style="height: calc(100vh - 525px);border: none"></div>'].join('')
        ,style: 'width: 370px; height: 350px; padding: 0 15px; box-shadow: 1px 1px 30px rgb(0 0 0 / 12%);'
        ,ready: function(){
            loadTree();
src/main/webapp/static/js/plan/plan.js
@@ -3,18 +3,20 @@
var treeCond;
var admin;
var planNeedXmlSelData;
var planNeedXmlFileId;
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).extend({
    steps: 'steps/steps',
    cascader: 'cascader/cascader',
}).use(['table','laydate', 'form', 'admin', 'xmSelect', 'steps', 'element', 'cascader', 'tree', 'dropdown'], function(){
}).use(['table','laydate','layer','upload', 'form', 'admin', 'xmSelect', 'steps', 'element', 'cascader', 'tree', 'dropdown'], function(){
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var layDate = layui.laydate;
    var form = layui.form;
    admin = layui.admin;
    var upload = layui.upload;
    var xmSelect = layui.xmSelect;
    var steps = layui.steps;
    var cascader = layui.cascader;
@@ -140,14 +142,16 @@
            {type: 'checkbox'}
            // ,{field: 'id', align: 'center',title: 'ID'}
            // ,{field: 'hostId$', align: 'center',title: '所属商户'}
            ,{field: 'userId$', align: 'left',title: '业务员'}
            ,{field: 'planType$', align: 'left',title: '业务类型', width: 150}
            ,{field: 'name', align: 'left',title: '售前规划申请单名称', width: 220, style: 'color: #1890ff;cursor:pointer', event: 'more'}
            ,{field: 'uuid', align: 'left',title: '规划单号', width: 100}
            ,{field: 'planNeed$', align: 'left',title: '所需', templet:function(d){return emptyShow(d.planNeed$)}}
            ,{field: 'deptId$', align: 'left',title: '所属部门'}
            ,{field: 'orderId$', align: 'left',title: '跟踪项目', width: 220, style: 'color: #1890ff;cursor:pointer', event: 'orderMore'}
            // ,{field: 'cstmrId$', align: 'left',title: '甲方单位', width: 220, style: 'color: #1890ff;cursor:pointer', event: 'cstmrMore'}
            ,{field: 'userId$', align: 'left',title: '业务员',hide: false}
            ,{field: 'planType$', align: 'left',title: '业务类型', width: 150,hide: false}
            ,{field: 'name', align: 'left',title: '售前规划申请单名称', width: 220, style: 'color: #1890ff;cursor:pointer', event: 'more',hide: false}
            ,{field: 'uuid', align: 'left',title: '规划单号', width: 100,hide: false}
            ,{field: 'planNeed$', align: 'left',title: '所需', templet:function(d){return emptyShow(d.planNeed$)},hide: false}
            ,{field: 'deptId$', align: 'left',title: '所属部门',hide: true}
            ,{field: 'planner$', align: 'left',title: '规划员',hide: false}
            // ,{field: 'nowHeadman$', align: 'left',title: '规划组长',hide: true}
            ,{field: 'orderId$', align: 'left',title: '跟踪项目', width: 220, style: 'color: #1890ff;cursor:pointer', event: 'orderMore',hide: false}
            // ,{field: 'cstmrId$', align: 'left',title: '甲方单位', width: 220, style: 'color: #1890ff;cursor:pointer', event: 'cstmrMore',hide: true}
            ,{field: 'appleTime$', align: 'left',title: '申请日期', hide: true}
            // ,{field: 'beItem$', align: 'center',title: '立项'}
            // ,{field: 'planner', align: 'left',title: '规划员', templet:function(d){return emptyShow(d.planner)}}
@@ -159,7 +163,7 @@
            // ,{field: 'planBonus', align: 'center',title: '规格奖金'}
            // ,{field: 'planLeaderBonus', align: 'center',title: '规格组长奖金'}
            // ,{field: 'files', align: 'center',title: '附件'}
            // ,{field: 'settle$', align: 'center',title: '进度'}
            ,{field: 'settle$', align: 'center',title: '进度'}
            // ,{field: 'settleMsg', align: 'center',title: '审核进度'}
            // ,{field: 'comment', align: 'center',title: '评论'}
            // ,{field: 'status$', align: 'center',title: '状态'}
@@ -191,6 +195,72 @@
            }
            pageCurr=curr;pageCount=count;
            limit();
        }
    });
    //演示多文件列表
    var uploadListIns = upload.render({
        elem: '#data-btn-file2'
        ,elemList: $('#data-btn-file3') //列表元素对象
        ,url: '/plan/insert/file/auth' //此处用的是第三方的 http 请求演示,实际使用时改成您自己的上传接口即可。
        ,accept: 'file'
        ,multiple: true
        ,number: 3
        ,auto: false
        ,bindAction: '#testListAction'
        ,choose: function(obj){
            var that = this;
            var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
            //读取本地文件
            obj.preview(function(index, file, result){
                var tr = $(['<tr id="upload-'+ index +'">'
                    ,'<td>'+ file.name +'</td>'
                    ,'<td>'+ (file.size/1014).toFixed(1) +'kb</td>'
                    ,'<td><div class="layui-progress" lay-filter="progress-demo-'+ index +'"><div class="layui-progress-bar" lay-percent=""></div></div></td>'
                    ,'<td>'
                    ,'<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
                    ,'<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
                    ,'</td>'
                    ,'</tr>'].join(''));
                //单个重传
                tr.find('.demo-reload').on('click', function(){
                    obj.upload(index, file);
                });
                //删除
                tr.find('.demo-delete').on('click', function(){
                    delete files[index]; //删除对应的文件
                    tr.remove();
                    uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值,以免删除后出现同名文件不可选
                });
                that.elemList.append(tr);
                element.render('progress'); //渲染新加的进度条组件
            });
        }
        ,done: function(res, index, upload){ //成功的回调
            var that = this;
            //if(res.code == 0){ //上传成功
            var tr = that.elemList.find('tr#upload-'+ index)
                ,tds = tr.children();
            tds.eq(3).html(''); //清空操作
            delete this.files[index]; //删除文件队列已经上传成功的文件
            return;
            //}
            this.error(index, upload);
        }
        ,allDone: function(obj){ //多文件上传完毕后的状态回调
            console.log(obj)
        }
        ,error: function(index, upload){ //错误回调
            var that = this;
            var tr = that.elemList.find('tr#upload-'+ index)
                ,tds = tr.children();
            tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
        }
        ,progress: function(n, elem, e, index){ //注意:index 参数为 layui 2.6.6 新增
            element.progress('progress-demo-'+ index, n + '%'); //执行进度条。n 即为返回的进度百分比
        }
    });
@@ -460,6 +530,16 @@
                break;
            case "del":
                del([data.id]);
                break;
            case "uploadLink":
                // 打开弹窗
                // 构建带参数的内容
                planNeedXmlFileId = data.id;
                layer.open({
                    type: 1,
                    title: '上传文件',
                    content: $('#myModal')
                });
                break;
        }
    });
@@ -798,7 +878,7 @@
});
// 关闭动作
// 点击事件
$(document).on('click','#data-detail-close', function () {
    parent.layer.closeAll();
});
src/main/webapp/views/plan/plan.html
@@ -62,7 +62,7 @@
<div class="layui-fluid">
    <div class="layui-card" style="margin-bottom: 5px">
        <div class="layui-card-body">
        <div class="layui-card-body" style="padding-top: 5px;padding-bottom: 5px ">
            <div id="search-box" class="layui-form toolbar" style="display: flex;justify-content: flex-end;position: relative">
                <div class="nav-box">
                    <div class="nav-box-item">
@@ -98,10 +98,36 @@
            <input style="display:none" id="importExcel" type="file" onchange="upload(this)" >
        </div>
    </div>
    <div class="layui-card" style="margin-bottom: 0">
        <div class="layui-card-body">
    <div class="layui-card" style="margin-bottom: 0;">
        <div class="layui-card-body" style="padding-top: 5px;padding-bottom: 5px ">
            规划单列表,
            <span class="text-danger">请勿随意删除。</span>
        </div>
    </div>
</div>
<div id="myModal"  style="display: none;">
    <div  style="padding: 10px">
        <div class="layui-upload">
            <button type="button" class="layui-btn layui-btn-normal" id="data-btn-file2">选择文件</button><input class="layui-upload-file" type="file" accept="" name="file" multiple="">
            <div class="layui-upload-list" style="max-width: 1000px;">
                <table class="layui-table">
                    <colgroup>
                        <col>
                        <col width="150">
                        <col width="260">
                        <col width="150">
                    </colgroup>
                    <thead>
                    <tr><th>文件名</th>
                        <th>大小</th>
                        <th>上传进度</th>
                        <th>操作</th>
                    </tr></thead>
                    <tbody id="data-btn-file3"></tbody>
                </table>
            </div>
            <button type="button" class="layui-btn" id="testListAction">开始上传</button>
        </div>
    </div>
</div>
@@ -110,11 +136,14 @@
    {{# if (d.settle == 1 || d.settle == 2 || d.settle == 3 || d.settle == 4) { }}
        <a class="layui-btn layui-btn-xs btn-edit" lay-event="approval">审批</a>
    {{# } }}
<!--    <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" href="javascript:void(0)" onclick="openModal()">上传文件</a>-->
    <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="uploadLink">上传文件</a>
<!--    <button type="button" onclick="openModal()">打开弹窗</button>-->
    <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs btn-edit" lay-event="del">删除</a>
</script>
<script type="text/html" id="plannerListDialog">
<scrpt type="text/html" id="plannerListDialog">
    <div class="layui-form admin-form">
        <div class="model-form" style="padding: 30px">
            <div id="plannerXmlSel"></div>
@@ -125,7 +154,7 @@
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </div>
</script>
</scrpt>
<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script>