From 8d8d7c4f85f8be55457b5d15fe26b29341422e14 Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Mon, 17 Mar 2025 12:09:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(zhjw):=20=E4=BC=98=E5=8C=96=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E6=A0=87=E7=AD=BE=E5=92=8C=E5=9C=B0=E5=9D=80=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -将 customer_tags 从字符串改为数组类型 - 添加 full_address_id 字段用于存储地址 ID 数组- 在后端控制器中处理 customer_tags 的字符串与数组转换 - 更新 SalesService 中的信息获取逻辑,处理客户标签和地址 ID --- .../src/addon/zhjw/views/sales/sales_edit.vue | 3 +- .../app/adminapi/controller/sales/Sales.php | 14 ++++++-- .../app/service/admin/sales/SalesService.php | 33 ++++++++++++++----- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/admin/src/addon/zhjw/views/sales/sales_edit.vue b/admin/src/addon/zhjw/views/sales/sales_edit.vue index 31a01b85..55dedc7a 100644 --- a/admin/src/addon/zhjw/views/sales/sales_edit.vue +++ b/admin/src/addon/zhjw/views/sales/sales_edit.vue @@ -185,7 +185,7 @@ const initialFormData = { city_id: '', district_id: '', community_name: '', - customer_tags: '', + customer_tags: [], full_address: '', full_address_id: [],//选中后的值 格式=[130000,130300,130304] @@ -240,6 +240,7 @@ const setFormData = async (id: number = 0) => { Object.keys(formData).forEach((key: string) => { if (data[key] != undefined) formData[key] = data[key] }) + formData.full_address_id = [Number(formData.province_id), Number(formData.city_id), Number(formData.district_id)] } if (id) setFormData(id); diff --git a/niucloud/addon/zhjw/app/adminapi/controller/sales/Sales.php b/niucloud/addon/zhjw/app/adminapi/controller/sales/Sales.php index 174d4987..17a62ef1 100644 --- a/niucloud/addon/zhjw/app/adminapi/controller/sales/Sales.php +++ b/niucloud/addon/zhjw/app/adminapi/controller/sales/Sales.php @@ -81,9 +81,14 @@ class Sales extends BaseAdminController ["city_id",0], ["district_id",0], ["community_name",""], - ["customer_tags",""], + ["customer_tags",[]], ]); + + if(!empty($data['customer_tags'])){ + $data['customer_tags'] = implode(',',$data['customer_tags']); + } + $this->validate($data, 'addon\zhjw\app\validate\sales\Sales.add'); $id = (new SalesService())->add($data); return success('ADD_SUCCESS', ['id' => $id]); @@ -112,9 +117,14 @@ class Sales extends BaseAdminController ["city_id",0], ["district_id",0], ["community_name",""], - ["customer_tags",""], + ["customer_tags",[]], ]); + + if(!empty($data['customer_tags'])){ + $data['customer_tags'] = implode(',',$data['customer_tags']); + } + $this->validate($data, 'addon\zhjw\app\validate\sales\Sales.edit'); (new SalesService())->edit($id, $data); return success('EDIT_SUCCESS'); diff --git a/niucloud/addon/zhjw/app/service/admin/sales/SalesService.php b/niucloud/addon/zhjw/app/service/admin/sales/SalesService.php index cbfe7331..44e522c8 100644 --- a/niucloud/addon/zhjw/app/service/admin/sales/SalesService.php +++ b/niucloud/addon/zhjw/app/service/admin/sales/SalesService.php @@ -41,7 +41,7 @@ class SalesService extends BaseAdminService $field = 'id,student_phone,student_name,sex,age,school_name,grade,class_name,source_channel,customer_source,add_staff_id,get_staff_id,contact_name,province_id,city_id,district_id,full_address,community_name,customer_tags,create_time,update_time,is_deleted,created_by,created_role,updated_by,updated_role'; $order = 'id desc'; - $search_model = $this->model->withSearch(["student_phone","student_name","sex","age","school_name","grade","class_name","source_channel","customer_source","add_staff_id","get_staff_id","contact_name","province_id","city_id","district_id","community_name","customer_tags","create_time"], $where)->with(['staff','staff','sysArea','sysArea','sysArea'])->field($field)->order($order); + $search_model = $this->model->withSearch(["student_phone", "student_name", "sex", "age", "school_name", "grade", "class_name", "source_channel", "customer_source", "add_staff_id", "get_staff_id", "contact_name", "province_id", "city_id", "district_id", "community_name", "customer_tags", "create_time"], $where)->with(['staff', 'staff', 'sysArea', 'sysArea', 'sysArea'])->field($field)->order($order); $list = $this->pageQuery($search_model); return $list; } @@ -55,7 +55,20 @@ class SalesService extends BaseAdminService { $field = 'id,student_phone,student_name,sex,age,school_name,grade,class_name,source_channel,customer_source,add_staff_id,get_staff_id,contact_name,province_id,city_id,district_id,full_address,community_name,customer_tags,create_time,update_time,is_deleted,created_by,created_role,updated_by,updated_role'; - $info = $this->model->field($field)->where([['id', "=", $id]])->with(['staff','staff','sysArea','sysArea','sysArea'])->findOrEmpty()->toArray(); + $info = $this->model->field($field)->where([['id', "=", $id]])->with(['staff', 'staff', 'sysArea', 'sysArea', 'sysArea'])->findOrEmpty()->toArray(); + + if(empty($info['customer_tags'])){ + $info['customer_tags'] = []; + }else{ + $info['customer_tags'] = explode(',',$info['customer_tags']); + } + + if(!empty($info['province_id']) && !empty($info['city_id']) && !empty($info['district_id'])){ + $info['full_address_id'] = [$info['province_id'],$info['city_id'],$info['district_id']]; + }else{ + $info['full_address_id'] = []; + } + return $info; } @@ -96,16 +109,18 @@ class SalesService extends BaseAdminService return $res; } - - public function getStaffAll(){ - $staffModel = new Staff(); - return $staffModel->select()->toArray(); + + public function getStaffAll() + { + $staffModel = new Staff(); + return $staffModel->select()->toArray(); } - public function getSysAreaAll(){ - $sysAreaModel = new SysArea(); - return $sysAreaModel->select()->toArray(); + public function getSysAreaAll() + { + $sysAreaModel = new SysArea(); + return $sysAreaModel->select()->toArray(); }