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(); }