Parcourir la source

客户合同列表

moonsflyer il y a 9 mois
Parent
commit
c290df385c

+ 69 - 0
application/admin/controller/qingdong/customer/Cuscontract.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace app\admin\controller\qingdong\customer;
+
+use app\admin\controller\qingdong\Base;
+use think\Db;
+use think\Exception;
+
+
+/**
+ * 合同管理
+ * 操作文档:https://doc.fastadmin.net/qingdong
+ * 软件介绍:https://www.fastadmin.net/store/qingdong.html
+ * 售后微信:qingdong_crm
+ */
+class Cuscontract extends Base {
+	protected $relationSearch = true;
+	/**
+	 * @var \addons\qingdong\model\Contract
+	 */
+	protected $model = null;
+
+
+	public function _initialize() {
+		parent::_initialize();
+		$this->model = new \addons\qingdong\model\Contract;
+	}
+
+
+	/**
+	 * 查看
+	 */
+	public function index() {
+		//设置过滤方法
+		if ($this->request->isAjax()) {
+
+            $params = $this->request->get();
+
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+            $wheres = [];
+            $wheres['customer_id'] = $params['ids'];
+			$list = $this->model->where($where)->where($wheres)
+                ->with([
+				'customer',
+				'orderStaff',
+				'contacts',
+                'contractOther'
+			])->order($sort, $order)->paginate($limit);
+            $data = $list->items();
+            foreach($data as &$v){
+                $contract_remark='';
+                $contract_other = $v['contract_other'];
+                $otherdata = json_decode($contract_other['otherdata'],true);
+                if(is_array($otherdata)){
+                    if(isset($otherdata['other_zdywys'])){
+                        $contract_remark = $otherdata['other_zdywys'];
+                    }
+                }
+                $v['contract_remark'] = $contract_remark;
+//                outFileLog($contract_remark,'cus_contract','$v');
+            }
+
+			$result = array("total" => $list->total(), "rows" => $list->items());
+			return json($result);
+		}
+		return $this->view->fetch();
+	}
+
+}

+ 27 - 0
application/admin/view/qingdong/customer/contract/contract_list.html

@@ -0,0 +1,27 @@
+<link href="__CDN__/assets/addons/qingdong/css/index.css?v={$Think.config.site.version}" rel="stylesheet">
+
+<style>
+
+</style>
+<div class="panel panel-default panel-intro">
+    <div class="panel-heading">
+        <ul class="nav nav-tabs">
+            <li class="active"><a href="#first" data-toggle="tab">全部</a></li>
+        </ul>
+    </div>
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="first">
+                <div class="widget-body no-padding">
+
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 7 - 0
application/common.php

@@ -478,6 +478,13 @@ if (!function_exists('check_url_allowed')) {
     }
 }
 
+/*
+ * 导出数据到日志文件
+ * */
+function outFileLog($data,$filename='log',$title='data'){
+    file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/log/'.$filename.'.txt', PHP_EOL .date('Y-m-d h:i:s', time()).'~'.$title.':' . json_encode($data,JSON_UNESCAPED_UNICODE), FILE_APPEND);
+}
+
 if (!function_exists('build_suffix_image')) {
     /**
      * 生成文件后缀图片

+ 128 - 0
public/assets/js/backend/qingdong/customer/cuscontract.js

@@ -0,0 +1,128 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index  : function () {
+        // 初始化表格参数配置
+            Table.api.init();
+            //绑定事件
+            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
+                var panel = $($(this).attr("href"));
+                if (panel.length > 0) {
+                    Controller.table[panel.attr("id")].call(this);
+                    $(this).on('click', function (e) {
+                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
+                    });
+                }
+                //移除绑定的事件
+                $(this).unbind('shown.bs.tab');
+            });
+
+            //必须默认触发shown.bs.tab事件
+            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
+        },
+        tableinfo:{
+            url          : '',
+            toolbar: '#toolbar',
+            pk           : 'id',
+            sortName     : 'id',
+            fixedColumns : true,
+            fixedNumber  : 1,
+            fixedRightNumber  : 1,
+            columns      : [
+                [
+                    {
+                        field : 'num', title : '合同编号', fixedColumns : true, formatter : function (value, row, index) {
+                            if(value ==''){
+                                value = '无';
+                            }
+                            return "<a href='javascript:void(0);' data-id='" + row.id + "' class='show-detail'>" + value + "</a>";
+                        },operate:'like'
+                    },
+                    {
+                        field : 'name', title : '合同名称', fixedColumns : true, formatter : function (value, row, index) {
+                            if(value ==''){
+                                value = '无';
+                            }
+                            return value;
+                        },operate:false
+                    },
+                    {field : 'customer', title : '客户名称', formatter : function (value, row, index) {
+                            if(row.customer){
+                                return "<a href='javascript:void(0);' data-id='" + row.customer_id + "' class='show-customer'>" + row.customer.name + "</a>";
+                            }
+                            return '';
+                        },operate:false},
+                    {field : 'contract_remark', title : '备注',operate:false},
+                    // {field : 'customer_id', title : '客户名称', visible: false, addClass: "selectpage", extend: "data-source='qingdong/customer/customer/index' data-field='name'"},
+                    {field : 'remark', title : '备注',operate:false},
+                    {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
+
+                ]
+            ],
+
+            pagination        : true,
+            search            : false,
+            commonSearch      : true,
+            searchFormVisible : true,
+            //显示导出按钮
+            showExport: false,
+            onLoadSuccess:function(row){
+                var role = row.role;
+
+                // 根据 role 值动态修改 columns 配置
+                var table = $("#table");
+
+                // 这里就是数据渲染结束后的回调函数
+                $(".btn-add").data("area",["80%","80%"]);
+                $(".btn-edit").data("area",["80%","80%"]);
+            }
+        },
+        table: {
+            first: function () {
+                // 初始化表格参数配置
+                Table.api.init({
+                    // extend : {
+                    //     add_url    : 'qingdong/customer/contract/add',
+                    //     detail_url : 'qingdong/customer/contract/detail',
+                    //     table      : 'contract',
+                    // }
+                });
+                if(Config.fields !='[]'){
+                    if (Config.fields && Object.keys(Config.fields).length > 0) {
+                        var fields = JSON.parse(Config.fields);
+                        var start = Controller.tableinfo.columns[0].length-2;
+                        for (var i = 0; i < fields.length; i++) {
+                            if (fields[i].hasOwnProperty('formatter'))
+                                fields[i].formatter = eval(fields[i].formatter);
+                            if (fields[i].hasOwnProperty('events'))
+                                fields[i].events = eval(fields[i].events);
+                            if (fields[i].hasOwnProperty('searchList'))
+                                fields[i].searchList = JSON.parse(fields[i].searchList);
+                            Controller.tableinfo.columns[0].splice(start + i, 0, fields[i]);
+                        }
+                    }
+
+                }
+                const q = {};
+                location.search.replace(/([^?&=]+)=([^&]+)/g,function(_,k,v){q[k]=v});
+
+                var table = $("#table");
+                Controller.tableinfo.url=location.href+'&type=0';
+                Controller.tableinfo.toolbar='#toolbar';
+                Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
+
+                if (q.isselect == 1) {
+                    Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length - 1].visible = false;
+                } else {
+                    Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length - 2].visible = false;
+                }
+
+                // 初始化表格
+                table.bootstrapTable(Controller.tableinfo);
+                // 为表格绑定事件
+                Table.api.bindevent(table);
+            },
+        },
+    };
+    return Controller;
+});

+ 12 - 0
public/assets/js/backend/qingdong/customer/customer.js

@@ -364,6 +364,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     return true;
                                 }
                             },
+							{
+								name: 'contract',
+								text: __('合同列表'),
+								title: __('合同列表'),
+								extend:'data-area=["80%","80%"]',
+								classname: ' records btn-dialog',
+								url: 'qingdong/customer/cuscontract?ref=addtabs',
+								visible: function (row) {
+
+									return true;
+								}
+							},
                             // {
                             //     name: 'seas',
                             //     text: __('公海'),