反馈功能实现

反馈功能主要是流程跟进时对主表数据的补充

控制器代码

/**
     * 跟进反馈
     * @auth true
     * @menu true
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function follow_feedback()
    {
        if($this->request->isGet()){
            $log_id = $this->request->param('log_id');
            $data = Db::table('rht_shop_log')->field('id,pid,comment')->where('id',$log_id)->find();
            $shop_data = Db::table('rht_shop')->field('authorize_certificate,application')->where('id',$data['pid'])->find();
            $this->assign('shop_data',$shop_data);
            $this->assign('data',$data);
            $this->fetch('self_shop/follow_feedback');
        }elseif ($this->request->isPost()){
            $post_data =  $this->request->param();
            $res = $this->logic->follow_feedback_do($post_data);
            return $res;
        }
    }

逻辑层

//处理反馈
    public function follow_feedback_do($post_data)
    {
        //判断传递过来的图片路径是否为空,为空的情况就不对该字段进行更新
        $newData = ['authorize_certificate'=>$post_data['authorize_certificate'],'application'=>$post_data['application']];

        if(empty($newData['authorize_certificate'])){
            unset($newData['authorize_certificate']);
        }
        if(empty($newData['application'])){
            unset($newData['application']);
        }
        Db::startTrans();
        try{
            if(empty($post_data['authorize_certificate']) && empty($post_data['application'])){
                //未上传文件则不作修改
            }else{
                Db::table('rht_shop')->where('id',$post_data['shop_id'])->update($newData);
            }
            Db::table('rht_shop_log')->where('id',$post_data['log_id'])->update(['comment'=>$post_data['comment']]);
            Db::commit();
            return ['code'=>1,'info'=>'数据更近成功!'];
        }catch (\Exception $e) {
            Db::rollback();
            return ['code'=>0,'info'=>'数据错误,请重试','error'=>$e->getMessage()];
        }
    }

前端html

<style type="text/css">
    .form_left{text-align: left;}
</style>
<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off" id="file">
    <div class="think-box-shadow">
        <div class="layui-row margin-bottom-15">
            <label class="layui-col-xs12" style="text-align: right">
                {notempty name='$id'}<input type='hidden' value='{$id}' name='contract_id'>{/notempty}
                <button class="layui-btn layui-btn-warm layui-icon layui-icon-console" type='button' id="submit">确认更新</button>
                <button type="button" class="layui-btn layui-btn-primary" id="back">取消</button>
            </label>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-col-xs3 label-required" style="width: 102px;">集团意见</label>
            <label class="layui-col-xs10 text-center">
                <textarea name="comment" placeholder="请输入内容" required class="layui-textarea">{$data.comment}</textarea>
            </label>
        </div>
        <div class="layui-form-item">
            <input type="hidden" name="log_id" value="{$data.id}">
            <input type="hidden" name="shop_id" value="{$data.pid}">
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>上传授权证书</legend>
            </fieldset>
            <!--<label class="layui-form-label">上传授权证书<br><span class="nowrap color-desc">效果图</span></label>-->
            <div class="layui-input-block">
                <input name="authorize_certificate" type="hidden" value="{$shop_data.authorize_certificate}">
                <script>$('[name="authorize_certificate"]').uploadMultipleImage()</script>
                <p class="help-block"><span style="color: #d43f3a">*</span>&nbsp;上传图片的最佳尺寸:200像素*640像素,格式png,jpeg,jpg,gif;大小不超过 <5Mb</p>
            </div>
        </div>
        <div class="layui-form-item">
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>上传授权申请表</legend>
            </fieldset>
            <div class="layui-input-block">
                <input name="application" type="hidden" value="{$shop_data.application}">
                <script>$('[name="application"]').uploadMultipleImage()</script>
                <p class="help-block"><span style="color: #d43f3a">*</span>&nbsp;上传图片的最佳尺寸:200像素*640像素,格式png,jpeg,jpg,gif;大小不超过 <5Mb</p>
            </div>
        </div>
    </div>
</form>
<script>
    window.form.render();

    //返回事件
    $("#back").on('click',function(){
        layer.closeAll();
    });

    //获取点击事件
    $('#submit').on('click',function(){
        var comment = $('textarea[name="comment"]').val();
        if($.trim(comment)==''){
            layer.msg('请填写集团意见');
            return false;
        }
        $.post("{:url('self_shop/follow_feedback')}",$('#file').serialize(),function(data){
            return false;
            if(data.code==0){
                layer.msg(data.info);
                return false;
            }
            setTimeout(function(){
                layer.msg(data.info);
                $('.layui-layer-close ').click();
            },1000);//1秒后可点击
            //刷新当前页
            window.location.reload();
        })
    });
</script>

展示页面
在这里插入图片描述

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值