diff --git a/app/admin/controller/SysAccountController.php b/app/admin/controller/SysAccountController.php index dc90fd9..64398bb 100644 --- a/app/admin/controller/SysAccountController.php +++ b/app/admin/controller/SysAccountController.php @@ -2,8 +2,10 @@ namespace app\admin\controller; use app\common\controller\BaseController; +use app\common\model\SysCurrency; use app\common\traits\crud\CrudControllerTrait; use app\admin\service\SysAccountService; +use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard\Currency; class SysAccountController extends BaseController { @@ -28,6 +30,7 @@ class SysAccountController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name'); return $data; } @@ -43,6 +46,7 @@ class SysAccountController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name'); return $data; } } \ No newline at end of file diff --git a/app/admin/controller/SysPortController.php b/app/admin/controller/SysPortController.php new file mode 100644 index 0000000..d98577e --- /dev/null +++ b/app/admin/controller/SysPortController.php @@ -0,0 +1,53 @@ +service = new SysPortService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + if (isset($data['country_id'])) + if (isset($data['country_id'])) + $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr'); + return $data; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr'); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/logic/SysPortLogic.php b/app/admin/logic/SysPortLogic.php new file mode 100644 index 0000000..434c24a --- /dev/null +++ b/app/admin/logic/SysPortLogic.php @@ -0,0 +1,17 @@ +validator; + } + + /** + * 构建查询条件 + */ + + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['port_code','port_name'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + //$config['where']['status'] = 1; + break; + case 'show': + $config['where']['id'] = $p['id']; + //$config['where']['status'] = 1; + break; + case 'store': + break; + case 'update': + $config['where']['id'] = $p['id']; + break; + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } + + /** + * 添加前置处理 + */ + public function beforeServiceStore($data, Request $request) + { + if(empty($data['lat'])) + unset($data['lat']); + if(empty($data['lng'])) + unset($data['lng']); + return $data; + } + + /** + * 添加前置处理 + */ + public function beforeServiceUpdate($data, Request $request) + { + if(empty($data['lat'])) + unset($data['lat']); + if(empty($data['lng'])) + unset($data['lng']); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/validate/SysPortValidate.php b/app/admin/validate/SysPortValidate.php new file mode 100644 index 0000000..26cb9cd --- /dev/null +++ b/app/admin/validate/SysPortValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/model/SysPort.php b/app/common/model/SysPort.php new file mode 100644 index 0000000..2249b98 --- /dev/null +++ b/app/common/model/SysPort.php @@ -0,0 +1,49 @@ +