From 064dbf1e1be3ea7c80b90b53acb885078484944f Mon Sep 17 00:00:00 2001 From: Anyon Date: Thu, 17 Sep 2020 18:40:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8C=BA=E5=9F=9F=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/service/TruckService.php | 2 +- .../view/shop_truck_template/form_region.html | 41 ++++++++++++++----- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/app/data/service/TruckService.php b/app/data/service/TruckService.php index 6fd21eb12..6cc9c138c 100644 --- a/app/data/service/TruckService.php +++ b/app/data/service/TruckService.php @@ -34,7 +34,7 @@ class TruckService extends Service public function region($level = 3) { - $items = $this->app->db->name('ShopTruckRegion')->where('level', '<=', $level)->column('id,pid,name', 'id'); + $items = $this->app->db->name('ShopTruckRegion')->where('level', '<=', $level)->column('id,pid,name,status', 'id'); return DataExtend::arr2tree($items, 'id', 'pid', 'subs'); } diff --git a/app/data/view/shop_truck_template/form_region.html b/app/data/view/shop_truck_template/form_region.html index 5b136d17a..39016c9ad 100644 --- a/app/data/view/shop_truck_template/form_region.html +++ b/app/data/view/shop_truck_template/form_region.html @@ -5,26 +5,29 @@
配送区域
-
- +
+
+ + +
{{province.name}} 可选区域
- +
+ + +
{{city.name}} 可选区域
- +
+ + +
@@ -41,13 +44,29 @@ require(['angular'], function () { var app = angular.module("TruckForm", []).run(callback); var _data = document.getElementById('RegionData').value || '[]'; - console.log(_data) angular.bootstrap(document.getElementById(app.name), [app.name]); function callback($rootScope) { $rootScope.items = angular.fromJson(_data); + $rootScope.items.forEach(function (province) { + province.status = !!province.status; + if (province.subs) province.subs.forEach(function (city) { + city.status = !!city.status; + if (city.subs) city.subs.forEach(function (area) { + area.status = !!area.status; + }); + }); + }); $rootScope.province = $rootScope.items[0]; $rootScope.city = $rootScope.province.subs[0]; + $rootScope.SetChangeCity = function (item, status) { + if (item.subs) item.subs.forEach(function (item) { + item.status = status; + if (item.subs) item.subs.forEach(function (item) { + item.status = status; + }) + }); + }; $rootScope.SetActiveProvince = function (province) { $rootScope.city = province.subs[0]; $rootScope.province = province;