moonsflyer 8 miesięcy temu
rodzic
commit
abf6a0842e

+ 4 - 0
addons/qingdong/model/Contract.php

@@ -4,6 +4,7 @@ namespace addons\qingdong\model;
 
 use think\Exception;
 use think\Model;
+use addons\qingdong\model\Customer;
 use traits\model\SoftDelete;
 
 /**
@@ -318,6 +319,9 @@ class Contract Extends Model {
 	public function customer() {
 		return $this->hasOne(Customer::class, 'id', 'customer_id')->field('id,name,follow');
 	}
+    public function CustomerInfo(){
+        return $this->hasOne(Customer::class,'id','customer_id')->field('id,name');
+    }
     //商机
     public function business() {
         return $this->hasOne(Business::class, 'id', 'business_id')->field('id,name');

+ 31 - 7
application/admin/controller/qingdong/customer/Contract.php

@@ -801,6 +801,7 @@ class Contract extends Base {
         if (isset($ids)) {
             $wheres['id'] = array('in', $ids);
         }
+
         //导出全部
         if (isset($isall)) {
             if ($isall == 3) {
@@ -810,6 +811,7 @@ class Contract extends Base {
         //0:全部 1:我负责的 2:下属负责的 3:今日待跟进 4:今日已跟进 5:从未跟进的
         $type = input('type',0);
         list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
         switch($type){
             case 1:
                 $staff = Staff::info();
@@ -861,22 +863,29 @@ class Contract extends Base {
                 $wheres['owner_staff_id'] =  $staff->id;
                 break;
             default:
-                $wheres['owner_staff_id'] =  array('in',Staff::getMyStaffIds());
+                if(empty($wheres)){
+                    $wheres['owner_staff_id'] =  array('in',Staff::getMyStaffIds());
+                }
+
                 break;
 
         }
-
+        unset($wheres['owner_staff_id']);
         $list = $this->model->with([
-            'customer',
+            'CustomerInfo',
             'orderStaff',
             'contacts',
             'ownerStaff','contractOther',
         ])->where($where)->where($wheres)->order($sort, $order)->select();
+
+
         $list = collection($list)->toArray();
+//        dump($list);die;
 
         if (!$list) {
             $this->error('无导出数据');
         }
+
         $title = [
             '序号',
             '客户名称',
@@ -892,20 +901,35 @@ class Contract extends Base {
         foreach ($dataValue as $val) {
             $title[] = $val['config']['label'];
         }
+
         foreach ($list as $k => $v) {
             if($v['contract_other']){//其他客户
                 $other=$v['contract_other']['otherdata'];
                 $other=json_decode($other,true);
                 $v = array_merge($v, $other);
             }
+            $customer_name =  Db::name('qingdong_customer')->where('id', $v['customer_id'])->value('name');
+            $contacts_name =  Db::name('qingdong_contacts')->where('id', $v['contacts_id'])->value('name');
+            $contacts_name =  Db::name('qingdong_contacts')->where('id', $v['contacts_id'])->value('name');
+            $owner_staffs_list =  Db::name('qingdong_staff')->where( 'id in ('.$v['owner_staff_id'].")")->field('name')->select();
+            $owner_staffs_arr = array_column($owner_staffs_list,'name');
+            $owner_staffs_str = implode('/',$owner_staffs_arr);
             $field = array(
                 $v['id'],
-                $v['customer']['name'],
-                $v['contacts']['name']??'',
+                $customer_name,
+                $contacts_name,
                 $v['order_staff']['name']??'',
-                $v['owner_staff']['name']??'',
-                $v['createtime'],
+                $owner_staffs_str,
+                date('Y-m-d H:i:s',$v['createtime']),
             );
+//            $field = array(
+//                $v['id'],
+//                $v['customer']['name'],
+//                $v['contacts']['name']??'',
+//                $v['order_staff']['name']??'',
+//                $v['owner_staff']['name']??'',
+//                date('Y-m-d H:i:s',$v['createtime']),
+//            );
             foreach ($dataValue as $val) {
                 if ($val['component'] == 'uploadImage' || $val['component'] == 'uploadFile') {
                     $field[] = $v[$val['id'] . '_str'] ?? '';

+ 1 - 0
public/assets/js/backend/qingdong/customer/contract.js

@@ -279,6 +279,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             fixedRightNumber  : 1,
             columns      : [
                 [
+                    {checkbox : true},
                     {
                         field : 'num', title : '合同编号', fixedColumns : true, formatter : function (value, row, index) {
                             if(value ==''){