From f703863e4e9d3e8784983ed46c0c7f8e9681407d Mon Sep 17 00:00:00 2001 From: denghy Date: Wed, 20 Feb 2019 15:49:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E9=87=8F=E6=B1=A0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Core/AbstractImport.php | 16 + .../Repositories/AccountRepository.php | 1 + .../Http/Controllers/ConfigController.php | 2 +- app/Domains/Export/Services/ExportService.php | 2 +- app/Domains/File/Services/FileService.php | 8 +- .../Real/Commands/Sync/FlowPoolSync.php | 4 +- .../Http/Controllers/FlowPoolController.php | 62 +- .../Virtual/Imports/FlowCardImport.php | 9 + .../Repositories/FlowPoolCardRepository.php | 28 +- .../FlowPoolPackageRepository.php | 72 - app/Domains/Virtual/Routes/api.php | 2 + .../Virtual/Services/FlowPoolService.php | 285 +++- app/Models/Virtual/FlowPool.php | 5 + app/Models/Virtual/FlowPoolCard.php | 20 + app/Models/Virtual/FlowPoolPackage.php | 25 - app/Models/Virtual/FlowPoolSetting.php | 7 + app/Providers/AppServiceProvider.php | 4 +- app/helpers.php | 66 + ...9_01_24_175246_create_flow_pool_tables.php | 28 +- frontend/src/api/virtual/flow_pools.js | 9 + frontend/src/assets/css/base.less | 2 +- frontend/src/assets/css/common.less | 1487 +++++++++-------- frontend/src/mixins/complete.js | 3 - frontend/src/mixins/index.js | 4 + frontend/src/views/artisan/real-sync/edit.vue | 2 +- .../src/views/artisan/real-sync/js/edit.js | 4 +- .../views/stats/company-report/js/index.js | 2 +- frontend/src/views/stats/order/js/index.js | 2 +- .../src/views/system/permissions/index.vue | 2 +- frontend/src/views/user/accounts/js/index.js | 2 +- frontend/src/views/user/roles/js/index.js | 2 +- .../src/views/virtual/companies/js/index.js | 2 +- .../virtual/company_accounts/js/index.js | 2 +- .../src/views/virtual/flow_pools/edit.vue | 39 +- .../src/views/virtual/flow_pools/index.vue | 46 +- .../src/views/virtual/flow_pools/js/edit.js | 61 +- .../src/views/virtual/flow_pools/js/index.js | 99 +- .../views/virtual/flow_pools/js/setting.js | 170 ++ .../src/views/virtual/flow_pools/setting.vue | 137 ++ .../src/views/virtual/packages/js/index.js | 2 +- .../src/views/virtual/products/js/index.js | 2 +- migreate_from_old.pgsql | 10 +- storage/app/public/templates/add-cards.xls | Bin 0 -> 17920 bytes tests/ArtisanTest.php | 2 +- tests/ExampleTest.php | 13 +- tests/MysqlTest.php | 79 + 46 files changed, 1880 insertions(+), 951 deletions(-) create mode 100644 app/Core/AbstractImport.php create mode 100644 app/Domains/Virtual/Imports/FlowCardImport.php delete mode 100644 app/Domains/Virtual/Repositories/FlowPoolPackageRepository.php delete mode 100644 app/Models/Virtual/FlowPoolPackage.php create mode 100644 frontend/src/views/virtual/flow_pools/js/setting.js create mode 100644 frontend/src/views/virtual/flow_pools/setting.vue create mode 100644 storage/app/public/templates/add-cards.xls create mode 100644 tests/MysqlTest.php diff --git a/app/Core/AbstractImport.php b/app/Core/AbstractImport.php new file mode 100644 index 00000000..c4a3f3be --- /dev/null +++ b/app/Core/AbstractImport.php @@ -0,0 +1,16 @@ +request->get('key'); $config = $this->configService->get($key); - + return res($config, '获取配置', 201); } diff --git a/app/Domains/Export/Services/ExportService.php b/app/Domains/Export/Services/ExportService.php index 8ea68984..0e907dfa 100644 --- a/app/Domains/Export/Services/ExportService.php +++ b/app/Domains/Export/Services/ExportService.php @@ -93,7 +93,7 @@ class ExportService extends Service $url = Storage::disk($disk)->url($export->filename); return $url; } - + Excel::queue($export, $export->filename, $disk); } } diff --git a/app/Domains/File/Services/FileService.php b/app/Domains/File/Services/FileService.php index 4e6de48e..8670b07a 100644 --- a/app/Domains/File/Services/FileService.php +++ b/app/Domains/File/Services/FileService.php @@ -22,7 +22,7 @@ class FileService extends Service protected $user; protected $fileRepository; - + protected $fileWithRepository; public static $types = ['account/avatar']; @@ -132,7 +132,7 @@ class FileService extends Service } } - + return $fileModel; } @@ -188,7 +188,7 @@ class FileService extends Service if (empty($news)) { return false; } - + if ($cover) { $this->detach($type, $typeid); } @@ -264,7 +264,7 @@ class FileService extends Service } list($width, $height) = ($imageInfo = @getimagesize($file->getRealPath())) === false ? [null, null] : $imageInfo; - + if (($filename = $file->storeAs($path, '', $disk)) === false) { throw new UploadFailedException('上传失败'); } diff --git a/app/Domains/Real/Commands/Sync/FlowPoolSync.php b/app/Domains/Real/Commands/Sync/FlowPoolSync.php index 9e3cd007..ce40df1f 100644 --- a/app/Domains/Real/Commands/Sync/FlowPoolSync.php +++ b/app/Domains/Real/Commands/Sync/FlowPoolSync.php @@ -23,7 +23,7 @@ class FlowPoolSync extends Command $companies = app(CompanyRepository::class)->withTrashed()->get()->keyBy('sn'); $packages = app(PackageRepository::class)->withTrashed()->get()->keyBy('sn'); - $select = ['id', 'shared_type as shared', "level_type as level", 'custom_no', 'cell_number as sn', 'name', 'flows', 'status', 'del', 'create_time']; + $select = ['id', 'type_id', 'shared_type as shared', "level_type as level", 'custom_no', 'cell_number as sn', 'name', 'flows', 'status', 'del', 'create_time']; $types = DB::connection('real')->table('jxc_flow_cell_type')->select(['id', 'carrieroperator'])->get()->pluck('carrieroperator', 'id')->toArray(); @@ -59,7 +59,7 @@ class FlowPoolSync extends Command $data = []; foreach ($flowPools as $value) { - $carrier_operator = $types[$value['typeid']] ?? 3; + $carrier_operator = $types[$value['type_id']] ?? 3; $package_ids = $flowPackages[$value['id']] ?? []; $data[] = [ diff --git a/app/Domains/Virtual/Http/Controllers/FlowPoolController.php b/app/Domains/Virtual/Http/Controllers/FlowPoolController.php index fec9da59..992e06f3 100644 --- a/app/Domains/Virtual/Http/Controllers/FlowPoolController.php +++ b/app/Domains/Virtual/Http/Controllers/FlowPoolController.php @@ -3,8 +3,11 @@ namespace App\Domains\Virtual\Http\Controllers; use App\Core\Controller; use Illuminate\Http\Request; +use Dipper\Excel\Facades\Excel; +use Illuminate\Support\Facades\Validator; +use App\Exceptions\InvalidArgumentException; +use App\Domains\Virtual\Imports\FlowCardImport; use App\Domains\Virtual\Services\FlowPoolService; -use App\Domains\Real\Repositories\FlowPoolRepository as RealFlowPoolRepository; class FlowPoolController extends Controller { @@ -27,7 +30,7 @@ class FlowPoolController extends Controller */ public function real() { - $list = app(RealFlowPoolRepository::class)->get(); + $list = $this->flowPoolService->real(); return res($list, 'RD流量池列表', 201); } @@ -88,4 +91,59 @@ class FlowPoolController extends Controller return res(true, '删除成功'); } + + /** + * 添加卡. + * + * @return \Illuminate\Http\Response + */ + public function addCards() + { + if (!$this->request->file('file')) { + throw new InvalidArgumentException('上传的文件错误'); + } + + $cards = (new FlowCardImport)->toArray($this->request->file('file')); + + if (empty($cards)) { + throw new InvalidArgumentException('上传的文件错误'); + } + + $sheet = $cards[0]; + + $simArray = []; + + foreach ($sheet as $row) { + if (is_numeric($row[0])) { + $simArray[] = $row[0]; + } + } + + $simArray = array_unique($simArray); + + if (empty($simArray)) { + throw new InvalidArgumentException('流量卡张数为空'); + } + + $pool_id = $this->request->get('pool_id', 0); + + $this->flowPoolService->addCards($pool_id, $simArray); + + return res(true, '添加成功'); + } + + /** + * 编辑. + * + * @return \Illuminate\Http\Response + */ + public function setting() + { + $attributes = $this->request->all(); + + $setting = $this->flowPoolService->setting($attributes); + + return res($setting, $attributes['id'] ? '修改成功' : '添加成功'); + } + } diff --git a/app/Domains/Virtual/Imports/FlowCardImport.php b/app/Domains/Virtual/Imports/FlowCardImport.php new file mode 100644 index 00000000..7b92f84d --- /dev/null +++ b/app/Domains/Virtual/Imports/FlowCardImport.php @@ -0,0 +1,9 @@ + '=', - 'created_at' => 'like', - ]; + protected $fieldSearchable = []; - public function model() { + public function model() + { return Model::class; } @@ -52,11 +50,21 @@ class FlowPoolCardRepository extends Repository */ public function withConditions(array $conditions = []) { - if (isset($conditions['id'])) { - $conditions['id'] = array_wrap($conditions['id']); - $this->model = $this->model->whereIn('id', $conditions['id']); + if (isset($conditions['pool_id'])) { + $conditions['pool_id'] = array_wrap($conditions['pool_id']); + $this->model = $this->model->whereIn('pool_id', $conditions['pool_id']); + } + + if (isset($conditions['sim'])) { + $conditions['sim'] = array_wrap($conditions['sim']); + $this->model = $this->model->whereIn('sim', $conditions['sim']); + } + + if (isset($conditions['package_id'])) { + $conditions['package_id'] = array_wrap($conditions['package_id']); + $this->model = $this->model->whereIn('package_id', $conditions['package_id']); } return $this; } -} \ No newline at end of file +} diff --git a/app/Domains/Virtual/Repositories/FlowPoolPackageRepository.php b/app/Domains/Virtual/Repositories/FlowPoolPackageRepository.php deleted file mode 100644 index c5baedf5..00000000 --- a/app/Domains/Virtual/Repositories/FlowPoolPackageRepository.php +++ /dev/null @@ -1,72 +0,0 @@ - '=', - 'created_at' => 'like', - ]; - - public function model() { - return Model::class; - } - - /** - * 数据格式化 - * - * @param mixed $result - * - * @return mixed - */ - public function transform($model) - { - return $model->toArray(); - } - - /** - * 查询条件 - * - * @return void - */ - public function withConditions(array $conditions = []) - { - if (isset($conditions['id'])) { - $conditions['id'] = array_wrap($conditions['id']); - $this->model = $this->model->whereIn('id', $conditions['id']); - } - - if (isset($conditions['pool_id'])) { - $conditions['pool_id'] = array_wrap($conditions['pool_id']); - $this->model = $this->model->whereIn('pool_id', $conditions['pool_id']); - } - - if (isset($conditions['package_id'])) { - $conditions['package_id'] = array_wrap($conditions['package_id']); - $this->model = $this->model->whereIn('package_id', $conditions['package_id']); - } - - return $this; - } -} diff --git a/app/Domains/Virtual/Routes/api.php b/app/Domains/Virtual/Routes/api.php index a7dc8970..30486457 100644 --- a/app/Domains/Virtual/Routes/api.php +++ b/app/Domains/Virtual/Routes/api.php @@ -59,4 +59,6 @@ $router->group(['prefix' => 'virtual', 'as' => 'virtual', 'middleware' => ['admi $router->post('/flow-pools/create', ['as' => 'flow-pools.create', 'uses' => 'FlowPoolController@create']); $router->post('/flow-pools/update/{id}', ['as' => 'flow-pools.update', 'uses' => 'FlowPoolController@update']); $router->post('/flow-pools/destroy', ['as' => 'flow-pools.destroy', 'uses' => 'FlowPoolController@destroy']); + $router->post('/flow-pools/add-cards', ['as' => 'flow-pools.add-cards', 'uses' => 'FlowPoolController@addCards']); + $router->post('/flow-pools/setting', ['as' => 'flow-pools.setting', 'uses' => 'FlowPoolController@setting']); }); diff --git a/app/Domains/Virtual/Services/FlowPoolService.php b/app/Domains/Virtual/Services/FlowPoolService.php index 80bf7ec8..0aa8395e 100644 --- a/app/Domains/Virtual/Services/FlowPoolService.php +++ b/app/Domains/Virtual/Services/FlowPoolService.php @@ -2,23 +2,30 @@ namespace App\Domains\Virtual\Services; use App\Dicts; +use Carbon\Carbon; use App\Core\Service; use Illuminate\Validation\Rule; use App\Models\Virtual\FlowPool; +use App\Models\Virtual\OrderCard; use Illuminate\Support\Facades\DB; use App\Exceptions\NotExistException; use App\Exceptions\NotAllowedException; +use App\Models\Virtual\FlowPoolSetting; use Illuminate\Support\Facades\Validator; use App\Domains\Virtual\Services\CompanyService; use App\Domains\Virtual\Services\PackageService; use App\Domains\Virtual\Repositories\FlowPoolRepository; +use App\Domains\Virtual\Repositories\OrderCardRepository; use App\Domains\Virtual\Repositories\FlowPoolCardRepository; use App\Domains\Virtual\Repositories\FlowPoolMonthRepository; -use App\Domains\Virtual\Repositories\FlowPoolPackageRepository; use App\Domains\Virtual\Repositories\FlowPoolSettingRepository; +use App\Domains\Real\Repositories\FlowPoolRepository as RealFlowPoolRepository; +use App\Exceptions\InvalidArgumentException; +use function App\range_compare; class FlowPoolService extends Service { + protected $realFlowPoolRepository; protected $flowPoolRepository; protected $flowPoolPackageRepository; protected $flowPoolSettingRepository; @@ -33,19 +40,47 @@ class FlowPoolService extends Service * @return void */ public function __construct( + RealFlowPoolRepository $realFlowPoolRepository, FlowPoolRepository $flowPoolRepository, - FlowPoolPackageRepository $flowPoolPackageRepository, FlowPoolSettingRepository $flowPoolSettingRepository, FlowPoolCardRepository $flowPoolCardRepository, FlowPoolMonthRepository $flowPoolMonthRepository ) { + $this->realFlowPoolRepository = $realFlowPoolRepository; $this->flowPoolRepository = $flowPoolRepository; - $this->flowPoolPackageRepository = $flowPoolPackageRepository; $this->flowPoolSettingRepository = $flowPoolSettingRepository; $this->flowPoolCardRepository = $flowPoolCardRepository; $this->flowPoolMonthRepository = $flowPoolMonthRepository; } + /** + * RD流量池列表 + * + * @return void + */ + public function real() + { + $used = $this->flowPoolRepository->select(['id', 'real_pool_ids'])->get(); + + $array = []; + + foreach ($used as $item) { + $item['real_pool_ids'] = $item['real_pool_ids'] ?? []; + + foreach ($item['real_pool_ids'] as $key => $value) { + $array[$value] = $item['id']; + } + } + + $list = $this->realFlowPoolRepository->get(); + + $list->map(function ($item) use ($array) { + $item->virtual_pool_id = $array[$item['id']] ?? 0; + }); + + return $list; + } + /** * 流量池列表 * @@ -59,19 +94,51 @@ class FlowPoolService extends Service $flowPools = $this->flowPoolRepository->withConditions($conditions) ->applyConditions()->paginate($limit); - $packages = $this->flowPoolPackageRepository->withConditions([ - 'pool_id' => $flowPools->pluck('id')->toArray(), - ])->get()->groupBy('pool_id'); + $packages = $this->flowPoolCardRepository->select([ + 'pool_id', + 'package_id', + ])->withConditions(['pool_id' => $flowPools->pluck('id')->toArray()])->groupBy(['pool_id', 'package_id'])->get(); + + $packages->map(function ($item) { + $item->package_name = app(PackageService::class)->load($item->package_id)['name']; + }); + + $packages = $packages->groupBy('pool_id'); + + $settings = $this->flowPoolSettingRepository->withConditions(['pool_id' => $flowPools->pluck('id')->toArray()])->orderBy('start_at', 'desc')->get(); + + $settings->map(function ($item) use ($packages) { + $itemPackages = $packages[$item->pool_id] ?? []; + + $minimum_settings = $item->minimum_settings ?? []; + + foreach ($itemPackages as $package) { + if (!in_array($package['package_id'], array_pluck($minimum_settings, 'package_id'))) { + $minimum_settings[] = [ + 'package_id' => $package['package_id'], + 'package_name' => $package['package_name'], + 'flows' => 0, + 'price' => 0 + ]; + } + } + + $item->minimum_settings = $minimum_settings; + }); + + $settings = $settings->groupBy('pool_id'); $carrierOperators = app(Dicts::class)->get('carrier_operator'); $shares = app(Dicts::class)->get('shares'); - $flowPools->map(function ($item) use ($carrierOperators, $shares, $packages) { + $flowPools->map(function ($item) use ($carrierOperators, $shares, $packages, $settings) { $item->company_name = app(CompanyService::class)->load($item['company_id'])['name']; $item->carrier_operator_name = $carrierOperators[$item['carrier_operator']]; $item->shared_name = $shares[$item['shared']]; - $item->package_ids = $packages[$item->id] ? array_pluck($packages[$item->id], 'package_id') : []; $item->real_pool_ids = empty($item->real_pool_ids) ? [] : $item->real_pool_ids; + $item->status = $item->end_at ? 1 : 0; + $item->packages = $packages[$item->id] ?? []; + $item->settings = $settings[$item->id] ?? []; }); return $flowPools; @@ -85,6 +152,11 @@ class FlowPoolService extends Service */ public function store(array $attributes = []) { + $attributes['start_at'] = $attributes['start_at'] ? Carbon::parse($attributes['start_at'])->startOfMonth()->format('Y-m-d H:i:s') : Carbon::now()->startOfMonth()->format('Y-m-d H:i:s'); + $attributes['end_at'] = $attributes['status'] ? Carbon::now()->endOfMonth()->format('Y-m-d H:i:s') : null; + + $attributes = array_only($attributes, ['id', 'company_id', 'name', 'flows', 'carrier_operator', 'shared', 'real_pool_ids', 'remark', 'start_at', 'end_at']); + $rule = [ 'name' => ['required', 'between:2,32', Rule::unique($this->flowPoolRepository->getTable(), 'name')->ignore($attributes['id'])->whereNUll('deleted_at')], 'carrier_operator' => ['required', 'in:0,1,2,3'], @@ -103,25 +175,12 @@ class FlowPoolService extends Service Validator::validate($attributes, $rule, $message); - if (empty($attributes['package_ids'])) { - throw new NotAllowedException('请至少加入一个套餐'); - } - if (!$attributes['id']) { $maxId = FlowPool::withTrashed()->max('id'); $attributes['id'] = $maxId ? $maxId + 1 : 1; $attributes['sn'] = self::sn($attributes['id']); - DB::transaction(function () use ($attributes) { - $node = $this->flowPoolRepository->create(array_except($attributes, ['package_ids'])); - - foreach ($attributes['package_ids'] as $package_id) { - $this->flowPoolPackageRepository->create([ - 'pool_id' => $node->id, - 'package_id' => $package_id, - ]); - } - }); + $node = $this->flowPoolRepository->create($attributes); } if ($attributes['id']) { @@ -131,25 +190,7 @@ class FlowPoolService extends Service throw new NotExistException('流量池不存在或已删除'); } - DB::transaction(function () use ($attributes, $node) { - $exists = $this->flowPoolPackageRepository->withConditions([ - 'pool_id' => $node->id, - ])->get()->pluck('package_id')->toArray(); - - $this->flowPoolRepository->setModel($node)->update(array_except($attributes, ['package_ids'])); - - foreach ($exists as $package_id) { - if (!in_array($package_id, $attributes['package_ids'])) { - $this->flowPoolPackageRepository->withConditions(['package_id' => $package_id])->delete(); - } - } - - foreach ($attributes['package_ids'] as $package_id) { - if (!in_array($package_id, $exists)) { - $this->flowPoolPackageRepository->create(['pool_id' => $node->id, 'package_id' => $package_id]); - } - } - }); + $this->flowPoolRepository->setModel($node)->update($attributes); } return $node; @@ -169,6 +210,168 @@ class FlowPoolService extends Service return true; } + /** + * 添加卡 + * + * @return void + */ + public function addCards($poolId, array $simArray) + { + if (!$this->flowPoolRepository->find($poolId)) { + throw new NotExistException('流量池不存在或已删除'); + } + + DB::transaction(function () use ($poolId, $simArray) { + foreach (array_chunk($simArray, 20000) as $chunk) { + $array = app(OrderCardRepository::class)->select(['sim', 'package_id'])->withConditions(['sim' => $chunk]) + ->get()->pluck('package_id', 'sim')->toArray(); + + $data = []; + + foreach ($chunk as $key => $value) { + if (!isset($array[$value])) { + throw new NotAllowedException("卡 {$value} 不存在销售记录"); + } + + $data[] = [ + 'pool_id' => $poolId, + 'sim' => $value, + 'package_id' => $array[$value], + ]; + } + + $this->flowPoolCardRepository->upsert($data, 'sim'); + } + }); + + + $this->flowPoolCardRepository->forgetCached(); + + return true; + } + + /** + * 定价管理 + * + * @param array $attributes + * @return FlowPool + */ + public function setting(array $attributes = []) + { + $attributes['start_at'] = Carbon::parse($attributes['start_at'])->startOfMonth()->format('Y-m-d H:i:s'); + $attributes['end_at'] = Carbon::parse($attributes['end_at'])->endOfMonth()->format('Y-m-d H:i:s'); + + if ($attributes['start_at'] > $attributes['end_at']) { + throw new InvalidArgumentException('开始时间必须小于结束时间'); + } + + $rule = [ + 'pool_id' => ['required', Rule::exists($this->flowPoolRepository->getTable(), 'id')], + 'first_month_price' => ['required', 'integer'], + 'other_month_price' => ['required', 'integer'], + 'gradient' => ['required', 'integer'], + 'gradient_unit' => ['required', 'in:0,1'], + ]; + + $message = [ + 'pool_id.required' => '请输入流量池ID', + 'first_month_price.required' => '请输入首月单价', + 'other_month_price.required' => '请输入次月单价', + 'gradient.required' => '请输入梯度', + 'gradient_unit.required' => '请选择梯度单位', + ]; + + Validator::validate($attributes, $rule, $message); + + if (!$attributes['id']) { + DB::transaction(function () use ($attributes) { + $settings = $this->flowPoolSettingRepository->withConditions(['pool_id' => $attributes['pool_id']])->get(); + + if (empty($settings)) { + $attributes['start_at'] = '2000-01-01 00:00:00'; + $attributes['end_at'] !== '3000-01-01 23:59:59'; + } + + $creates = []; + + if (!empty($settings)) { + foreach ($settings as $item) { + $result = range_compare([$attributes['start_at'], $attributes['end_at']], [$item['start_at'], $item['end_at']]); + switch ($result) { + case 0: + $this->flowPoolSettingRepository->where(['id' => $item['id']])->update($attributes); + $creates = []; + break 2; + case 1: + $this->flowPoolSettingRepository->destroy($item['id']); + $creates[0] = $attributes; + break; + case 2: + $this->flowPoolSettingRepository->destroy($item['id']); + $creates[0] = $attributes; + unset($item['id']); + $creates[1] = $item->toArray(); + $creates[1]['end_at'] = Carbon::parse($attributes['start_at'])->subMonth()->endOfMonth()->format('Y-m-d H:i:s'); + $creates[2] = $item->toArray(); + $creates[2]['start_at'] = Carbon::parse($attributes['end_at'])->addMonth()->startOfMonth()->format('Y-m-d H:i:s'); + break 2; + case 3: + case 4: + $creates[0] = $attributes; + break; + case 5: + $creates[0] = $attributes; + $item['start_at'] = Carbon::parse($attributes['end_at'])->addMonth()->startOfMonth()->format('Y-m-d H:i:s'); + $this->flowPoolSettingRepository->where(['id' => $item['id']])->update($item); + break; + case 6: + $creates[0] = $attributes; + $item['end_at'] = Carbon::parse($attributes['start_at'])->subMonth()->startOfMonth()->format('Y-m-d H:i:s'); + $this->flowPoolSettingRepository->where(['id' => $item['id']])->update($item); + break; + + default: + $creates[0] = $attributes; + break; + } + } + } else { + $creates[0] = $attributes; + $creates[0]['start_at'] = '2000-01-01 00:00:00'; + $creates[0]['end_at'] !== '3000-01-01 23:59:59'; + } + + $maxId = FlowPoolSetting::withTrashed()->max('id') ?? 0; + + foreach ($creates as $key => $create) { + $create['id'] = ++$maxId; + if ($key) { + $this->flowPoolSettingRepository->create($create); + } else { + $node =$this->flowPoolSettingRepository->create($create); + } + } + }); + } + + if ($attributes['id']) { + $node = $this->flowPoolSettingRepository->find($attributes['id']); + + if (!$node) { + throw new NotExistException('规则不存在或已删除'); + } + + if ($node->start_at !== $attributes['start_at'] || $node->end_at !== $attributes['end_at']) { + throw new InvalidArgumentException('起止时间不能修改'); + } + + $this->flowPoolSettingRepository->setModel($node)->update($attributes); + } + + return $node; + } + + public static function sn($id) { return sprintf('FP%011d', $id); diff --git a/app/Models/Virtual/FlowPool.php b/app/Models/Virtual/FlowPool.php index f61d846c..b7f574a6 100644 --- a/app/Models/Virtual/FlowPool.php +++ b/app/Models/Virtual/FlowPool.php @@ -27,4 +27,9 @@ class FlowPool extends Model { return $this->belongsToMany(Package::class, 'virtual_flow_pool_packages', 'pool_id', 'package_id'); } + + public function settings() + { + return $this->hasMany(FlowPoolSetting::class, 'pool_id', 'id'); + } } diff --git a/app/Models/Virtual/FlowPoolCard.php b/app/Models/Virtual/FlowPoolCard.php index 5b06567b..73cc5be7 100644 --- a/app/Models/Virtual/FlowPoolCard.php +++ b/app/Models/Virtual/FlowPoolCard.php @@ -3,8 +3,28 @@ namespace App\Models\Virtual; use App\Core\Model; +use Illuminate\Database\Eloquent\Builder; class FlowPoolCard extends Model { protected $table = 'virtual_flow_pool_cards'; + + protected $primaryKey = ['pool_id', 'sim']; + + public $incrementing = false; + + /** + * Set the keys for a save update query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @return \Illuminate\Database\Eloquent\Builder + */ + protected function setKeysForSaveQuery(Builder $query) + { + foreach ($this->getKeyName() as $key) { + $query->where($key, '=', $this->original[$key] ?? $this->getAttribute($key)); + } + + return $query; + } } diff --git a/app/Models/Virtual/FlowPoolPackage.php b/app/Models/Virtual/FlowPoolPackage.php deleted file mode 100644 index a4d922a0..00000000 --- a/app/Models/Virtual/FlowPoolPackage.php +++ /dev/null @@ -1,25 +0,0 @@ -belongsTo(Package::class, 'package_id'); - } - - public function pool() - { - return $this->belongsTo(FlowPool::class, 'pool_id'); - } -} diff --git a/app/Models/Virtual/FlowPoolSetting.php b/app/Models/Virtual/FlowPoolSetting.php index 15936f6f..f35d1361 100644 --- a/app/Models/Virtual/FlowPoolSetting.php +++ b/app/Models/Virtual/FlowPoolSetting.php @@ -3,8 +3,15 @@ namespace App\Models\Virtual; use App\Core\Model; +use Illuminate\Database\Eloquent\SoftDeletes; class FlowPoolSetting extends Model { + use SoftDeletes; + protected $table = 'virtual_flow_pool_settings'; + + protected $casts = [ + 'minimum_settings' => 'array', + ]; } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index c84d8ab9..f21bc749 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -67,9 +67,7 @@ class AppServiceProvider extends ServiceProvider }); // excel - $this->app->singleton('excel', function ($app) { - return $app->loadComponent('excel', \Dipper\Excel\ExcelServiceProvider::class); - }); + $this->app->register(\Dipper\Excel\ExcelServiceProvider::class); // 全局代理 $this->app->singleton('dipper', function ($app) { diff --git a/app/helpers.php b/app/helpers.php index 6dbdbfad..7e6e3f09 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -1,9 +1,11 @@ = $array2[1]) { + return 1; + } + + if ($array1[0] >= $array2[0] && $array1[1] <= $array2[1]) { + return 2; + } + + + if ($array1[1] < $array2[0]) { + return 3; + } + + if ($array2[1] < $array1[0]) { + return 4; + } + + if ($array1[0] < $array2[0]) { + return 5; + } + + if ($array2[0] < $array1[0]) { + return 6; + } + + return -1; + } +} diff --git a/database/migrations/2019_01_24_175246_create_flow_pool_tables.php b/database/migrations/2019_01_24_175246_create_flow_pool_tables.php index 8372afb9..8ef3430e 100644 --- a/database/migrations/2019_01_24_175246_create_flow_pool_tables.php +++ b/database/migrations/2019_01_24_175246_create_flow_pool_tables.php @@ -41,10 +41,10 @@ class CreateFlowPoolTables extends Migration $table->integer('flows')->default(255)->comment('流量值 -1不限流量 单位MB'); $table->tinyInteger('carrier_operator')->unsigned()->default(255)->comment('运营商(0:联通 1:移动 2:电信)'); $table->tinyInteger('shared')->unsigned()->default(0)->comment('共享类型 0:未知 1纵向共享 2横向共享'); - $table->text('package_ids')->nullable()->comment('RD套餐ID'); $table->text('real_pool_ids')->nullable()->comment('RD流量池ID'); $table->text('remark')->nullable()->comment('流量池备注'); - $table->tinyInteger('status')->unsigned()->default(0)->comment('状态 0:正常 1:禁用'); + $table->timestamp('start_at')->nullable()->comment('开始时间'); + $table->timestamp('end_at')->nullable()->comment('结束时间'); $table->timestamps(); $table->softDeletes(); @@ -54,20 +54,6 @@ class CreateFlowPoolTables extends Migration }); } - if (!Schema::hasTable('virtual_flow_pool_packages')) { - Schema::create('virtual_flow_pools', function (Blueprint $table) { - $table->increments('id')->comment('自增ID'); - $table->integer('pool_id')->comment('流量池ID'); - $table->integer('package_id')->comment('套餐ID'); - $table->timestamps(); - $table->softDeletes(); - - $table->unique(['pool_id', 'package_id', 'deleted_at']); - - $table->comment('VD流量池'); - }); - } - if (!Schema::hasTable('virtual_flow_pool_settings')) { Schema::create('virtual_flow_pool_settings', function (Blueprint $table) { $table->increments('id')->comment('自增ID'); @@ -75,8 +61,11 @@ class CreateFlowPoolTables extends Migration $table->text('minimum_settings')->nullable()->comment('套餐保底配置'); $table->integer('first_month_price')->unsigned()->default(0)->comment('首月单价'); $table->integer('other_month_price')->unsigned()->default(0)->comment('次月单价'); - $table->timestamp('start_at'); - $table->timestamp('end_at'); + $table->integer('gradient')->unsigned()->default(0)->comment('梯度'); + $table->tinyInteger('gradient_unit')->unsigned()->default(0)->comment('梯度单位 0:M 1:G'); + $table->timestamp('start_at')->nullable()->comment('开始时间'); + $table->timestamp('end_at')->nullable()->comment('结束时间'); + $table->timestamps(); $table->softDeletes(); $table->index('pool_id'); @@ -88,10 +77,13 @@ class CreateFlowPoolTables extends Migration if (!Schema::hasTable('virtual_flow_pool_cards')) { Schema::create('virtual_flow_pool_cards', function (Blueprint $table) { $table->integer('pool_id')->unsigned()->default(0)->comment('流量池ID'); + $table->integer('package_id')->unsigned()->default(0)->comment('套餐ID'); $table->bigInteger('sim')->unsigned()->default(0)->comment('SIM号'); $table->comment('VD流量池卡关联表'); $table->primary(['pool_id', 'sim']); + + $table->unique('sim'); }); } diff --git a/frontend/src/api/virtual/flow_pools.js b/frontend/src/api/virtual/flow_pools.js index 49ba2e5e..24aeb483 100644 --- a/frontend/src/api/virtual/flow_pools.js +++ b/frontend/src/api/virtual/flow_pools.js @@ -58,3 +58,12 @@ export function update(data, id) { export function destroy(data) { return service.post('api/virtual/flow-pools/destroy', data); } + +/** + * [setting 流量池计费规则] + * @param {[type]} data [description] + * @return {[type]} [description] + */ +export function setting(data) { + return service.post('api/virtual/flow-pools/setting', data); +} diff --git a/frontend/src/assets/css/base.less b/frontend/src/assets/css/base.less index b9079032..ddaa9df3 100644 --- a/frontend/src/assets/css/base.less +++ b/frontend/src/assets/css/base.less @@ -6,7 +6,7 @@ // Color @primary-color : #2d8cf0; -@info-color : #b3b3b3; +@info-color : #2db7f5; @success-color : #19be6b; @processing-color : @primary-color; @warning-color : #ff9900; diff --git a/frontend/src/assets/css/common.less b/frontend/src/assets/css/common.less index a2a5a32f..001f08c9 100644 --- a/frontend/src/assets/css/common.less +++ b/frontend/src/assets/css/common.less @@ -2,912 +2,1031 @@ @import '~css/base.less'; -*{ - list-style-type: none; - margin: 0; - padding: 0; - font-family: @font-family; - /*font-size: 14px;*/ +* { + list-style-type: none; + margin: 0; + padding: 0; + font-family: @font-family; + /*font-size: 14px;*/ } -table{ - border-collapse: collapse; +table { + border-collapse: collapse; } /*font-size*/ -.fz-12{ - font-size: 12px !important; -} -.fz-13{ - font-size: 13px !important; -} -.fz-14{ - font-size: 14px !important; -} -.fz-15{ - font-size: 15px !important; -} -.fz-16{ - font-size: 16px !important; -} -.fz-17{ - font-size: 17px !important; -} -.fz-18{ - font-size: 18px !important; -} -.fz-19{ - font-size: 19px !important; -} -.fz-20{ - font-size: 20px !important; -} -.fz-21{ - font-size: 21px !important; -} -.fz-22{ - font-size: 22px !important; -} -.fz-23{ - font-size: 23px !important; -} -.fz-24{ - font-size: 24px !important; -} -.fz-25{ - font-size: 25px !important; +.fz-12 { + font-size: 12px !important; } -.primary-color{ - color: @primary-color; +.fz-13 { + font-size: 13px !important; +} + +.fz-14 { + font-size: 14px !important; +} + +.fz-15 { + font-size: 15px !important; +} + +.fz-16 { + font-size: 16px !important; +} + +.fz-17 { + font-size: 17px !important; +} + +.fz-18 { + font-size: 18px !important; +} + +.fz-19 { + font-size: 19px !important; +} + + +.fz-20 { + font-size: 20px !important; +} + +.fz-21 { + font-size: 21px !important; +} + +.fz-22 { + font-size: 22px !important; +} + +.fz-23 { + font-size: 23px !important; +} + +.fz-24 { + font-size: 24px !important; +} + +.fz-25 { + font-size: 25px !important; +} + +.primary-color { + color: @primary-color; +} + +.info-color { + color: @info-color; +} + +.success-color { + color: @success-color; +} + +.warning-color { + color: @warning-color; +} + +.error-color { + color: @error-color; } /*height*/ -.h-32{ - height: 32px; +.h-32 { + height: 32px; } /*line-height*/ -.lh-22{ - line-height: 22px !important; +.lh-22 { + line-height: 22px !important; } -.lh-32{ - line-height: 32px; + +.lh-32 { + line-height: 32px; } -.lh-us{ - line-height: unset; + +.lh-us { + line-height: unset; } /*margin*/ -.umar-l2{ - margin-left: 2px !important; -} -.umar-l5{ - margin-left: 5px !important; -} -.umar-l10{ - margin-left: 10px !important; -} -.umar-l15{ - margin-left: 15px !important; -} -.umar-l20{ - margin-left: 20px !important; -} -.umar-l30{ - margin-left: 30px !important; +.umar-l2 { + margin-left: 2px !important; } -.umar-b0{ - margin-bottom: 0 !important; -} -.umar-b5{ - margin-bottom: 5px !important; -} -.umar-b10{ - margin-bottom: 10px !important; -} -.umar-b15{ - margin-bottom: 15px !important; -} -.umar-b20{ - margin-bottom: 20px !important; -} -.umar-b25{ - margin-bottom: 25px !important; -} -.umar-b30{ - margin-bottom: 30px !important; +.umar-l5 { + margin-left: 5px !important; } -.umar-a10{ - margin: 10px !important; -} -.umar-a15{ - margin: 15px !important; -} -.umar-a20{ - margin: 20px !important; +.umar-l10 { + margin-left: 10px !important; } -.umar-r0{ - margin-right: 0px !important; -} -.umar-r5{ - margin-right: 5px !important; -} -.umar-r10{ - margin-right: 10px !important; -} -.umar-r15{ - margin-right: 15px !important; -} -.umar-r20{ - margin-right: 20px !important; -} -.umar-r30{ - margin-right: 30px !important; +.umar-l15 { + margin-left: 15px !important; } -.umar-t5{ - margin-top: 5px !important; -} -.umar-t7{ - margin-top: 7px !important; -} -.umar-t10{ - margin-top: 10px !important; -} -.umar-t15{ - margin-top: 15px !important; -} -.umar-t20{ - margin-top: 20px !important; -} -.umar-t30{ - margin-top: 30px !important; -} -.umar-t40{ - margin-top: 40px !important; +.umar-l20 { + margin-left: 20px !important; } -.umar-lr5{ - margin-left: 5px !important; - margin-right: 5px !important; -} -.umar-lr10{ - margin-left: 10px !important; - margin-right: 10px !important; -} -.umar-lr15{ - margin-left: 15px !important; - margin-right: 15px !important; +.umar-l30 { + margin-left: 30px !important; } -.umar-tb5{ - margin-top: 5px !important; - margin-bottom: 5px !important; +.umar-b0 { + margin-bottom: 0 !important; } -.umar-tb10{ - margin-top: 10px !important; - margin-bottom: 10px !important; + +.umar-b5 { + margin-bottom: 5px !important; } -.umar-tb30{ - margin-top: 30px !important; - margin-bottom: 30px !important; + +.umar-b10 { + margin-bottom: 10px !important; +} + +.umar-b15 { + margin-bottom: 15px !important; +} + +.umar-b20 { + margin-bottom: 20px !important; +} + +.umar-b25 { + margin-bottom: 25px !important; +} + +.umar-b30 { + margin-bottom: 30px !important; +} + +.umar-a10 { + margin: 10px !important; +} + +.umar-a15 { + margin: 15px !important; +} + +.umar-a20 { + margin: 20px !important; +} + +.umar-r0 { + margin-right: 0px !important; +} + +.umar-r5 { + margin-right: 5px !important; +} + +.umar-r10 { + margin-right: 10px !important; +} + +.umar-r15 { + margin-right: 15px !important; +} + +.umar-r20 { + margin-right: 20px !important; +} + +.umar-r30 { + margin-right: 30px !important; +} + +.umar-t5 { + margin-top: 5px !important; +} + +.umar-t7 { + margin-top: 7px !important; +} + +.umar-t10 { + margin-top: 10px !important; +} + +.umar-t15 { + margin-top: 15px !important; +} + +.umar-t20 { + margin-top: 20px !important; +} + +.umar-t30 { + margin-top: 30px !important; +} + +.umar-t40 { + margin-top: 40px !important; +} + +.umar-lr5 { + margin-left: 5px !important; + margin-right: 5px !important; +} + +.umar-lr10 { + margin-left: 10px !important; + margin-right: 10px !important; +} + +.umar-lr15 { + margin-left: 15px !important; + margin-right: 15px !important; +} + +.umar-tb5 { + margin-top: 5px !important; + margin-bottom: 5px !important; +} + +.umar-tb10 { + margin-top: 10px !important; + margin-bottom: 10px !important; +} + +.umar-tb30 { + margin-top: 30px !important; + margin-bottom: 30px !important; } /*padding*/ -.uinn-a5{ - padding: 5px !important; -} -.uinn-a7{ - padding: 7px !important; -} -.uinn-a10{ - padding: 10px !important; -} -.uinn-a15{ - padding: 15px !important; -} -.uinn-a20{ - padding: 20px !important; -} -.uinn-a30{ - padding: 30px !important; +.uinn-a5 { + padding: 5px !important; } -.uinn-l7{ - padding-left: 7px !important; -} -.uinn-l10{ - padding-left: 10px !important; +.uinn-a7 { + padding: 7px !important; } -.uinn-r5{ - padding-right: 5px !important; -} -.uinn-r7{ - padding-right: 7px !important; -} -.uinn-r10{ - padding-right: 10px !important; -} -.uinn-r20{ - padding-right: 20px !important; -} -.uinn-r30{ - padding-right: 30px !important; +.uinn-a10 { + padding: 10px !important; } -.uinn-b5{ - padding-bottom: 5px !important; -} -.uinn-b10{ - padding-bottom: 10px !important; -} -.uinn-b15{ - padding-bottom: 15px !important; -} -.uinn-b20{ - padding-bottom: 20px !important; +.uinn-a15 { + padding: 15px !important; } -.uinn-t5{ - padding-top: 5px !important; -} -.uinn-t10{ - padding-top: 10px !important; -} -.uinn-t15{ - padding-top: 15px !important; -} -.uinn-t20{ - padding-top: 20px !important; +.uinn-a20 { + padding: 20px !important; } -.uinn-tb5{ - padding-top: 5px !important; - padding-bottom: 5px !important; -} -.uinn-tb10{ - padding-top: 10px !important; - padding-bottom: 10px !important; -} -.uinn-tb15{ - padding-top: 15px !important; - padding-bottom: 15px !important; -} -.uinn-tb20{ - padding-top: 20px !important; - padding-bottom: 20px !important; +.uinn-a30 { + padding: 30px !important; } -.uinn-lr4{ - padding-left: 4px !important; - padding-right: 4px !important; -} -.uinn-lr5{ - padding-left: 5px !important; - padding-right: 5px !important; -} -.uinn-lr10{ - padding-left: 10px !important; - padding-right: 10px !important; -} -.uinn-lr15{ - padding-left: 15px !important; - padding-right: 15px !important; -} -.uinn-lr20{ - padding-left: 20px !important; - padding-right: 20px !important; -} -.uinn-lr30{ - padding-left: 30px !important; - padding-right: 30px !important; +.uinn-l7 { + padding-left: 7px !important; } -.white-color{ - color: #fff; +.uinn-l10 { + padding-left: 10px !important; +} + +.uinn-r5 { + padding-right: 5px !important; +} + +.uinn-r7 { + padding-right: 7px !important; +} + +.uinn-r10 { + padding-right: 10px !important; +} + +.uinn-r20 { + padding-right: 20px !important; +} + +.uinn-r30 { + padding-right: 30px !important; +} + +.uinn-b5 { + padding-bottom: 5px !important; +} + +.uinn-b10 { + padding-bottom: 10px !important; +} + +.uinn-b15 { + padding-bottom: 15px !important; +} + +.uinn-b20 { + padding-bottom: 20px !important; +} + +.uinn-t5 { + padding-top: 5px !important; +} + +.uinn-t10 { + padding-top: 10px !important; +} + +.uinn-t15 { + padding-top: 15px !important; +} + +.uinn-t20 { + padding-top: 20px !important; +} + +.uinn-tb5 { + padding-top: 5px !important; + padding-bottom: 5px !important; +} + +.uinn-tb10 { + padding-top: 10px !important; + padding-bottom: 10px !important; +} + +.uinn-tb15 { + padding-top: 15px !important; + padding-bottom: 15px !important; +} + +.uinn-tb20 { + padding-top: 20px !important; + padding-bottom: 20px !important; +} + +.uinn-lr4 { + padding-left: 4px !important; + padding-right: 4px !important; +} + +.uinn-lr5 { + padding-left: 5px !important; + padding-right: 5px !important; +} + +.uinn-lr10 { + padding-left: 10px !important; + padding-right: 10px !important; +} + +.uinn-lr15 { + padding-left: 15px !important; + padding-right: 15px !important; +} + +.uinn-lr20 { + padding-left: 20px !important; + padding-right: 20px !important; +} + +.uinn-lr30 { + padding-left: 30px !important; + padding-right: 30px !important; +} + +.white-color { + color: #fff; } /*border*/ -.bd-0{ - border: 0 !important; +.bd-0 { + border: 0 !important; } -.bd-a{ - border: 1px solid @border-color-base !important; + +.bd-a { + border: 1px solid @border-color-base !important; } -.bd-r{ - border-right: 1px solid @border-color-base !important; + +.bd-r { + border-right: 1px solid @border-color-base !important; } -.bd-l{ - border-left: 1px solid @border-color-base !important; + +.bd-l { + border-left: 1px solid @border-color-base !important; } -.bd-t{ - border-top: 1px solid @border-color-base !important; + +.bd-t { + border-top: 1px solid @border-color-base !important; } -.bd-b{ - border-bottom: 1px solid @border-color-base !important; + +.bd-b { + border-bottom: 1px solid @border-color-base !important; } -.bd-a-p{ - border: 1px solid @primary-color !important; + +.bd-a-p { + border: 1px solid @primary-color !important; } -.bd-r-p{ - border-right: 1px solid @primary-color !important; + +.bd-r-p { + border-right: 1px solid @primary-color !important; } -.bd-l-p{ - border-left: 1px solid @primary-color !important; + +.bd-l-p { + border-left: 1px solid @primary-color !important; } -.bd-t-p{ - border-top: 1px solid @primary-color !important; + +.bd-t-p { + border-top: 1px solid @primary-color !important; } -.bd-b-p{ - border-bottom: 1px solid @primary-color !important; + +.bd-b-p { + border-bottom: 1px solid @primary-color !important; } /*display*/ -.ds-tc{ - display: table-cell !important; +.ds-tc { + display: table-cell !important; } -.ds-ib{ - display: inline-block !important; - *display: inline; - *zoom: 1; + +.ds-ib { + display: inline-block !important; + *display: inline; + *zoom: 1; } -.ds-n{ - display: none !important; + +.ds-n { + display: none !important; } -.ds-b{ - display: block !important; + +.ds-b { + display: block !important; } /*text-align*/ -.ta-l{ - text-align: left !important; +.ta-l { + text-align: left !important; } -.ta-c{ - text-align: center !important; + +.ta-c { + text-align: center !important; } -.ta-r{ - text-align: right !important; + +.ta-r { + text-align: right !important; } /*vertical-align*/ -.va-t{ - vertical-align: top !important; +.va-t { + vertical-align: top !important; } -.va-m{ - vertical-align: middle !important; + +.va-m { + vertical-align: middle !important; } -.va-b{ - vertical-align: bottom !important; + +.va-b { + vertical-align: bottom !important; } /*float*/ -.f-l{ - float: left !important; +.f-l { + float: left !important; } -.f-r{ - float: right !important; + +.f-r { + float: right !important; } /*point*/ -.c-p{ - cursor: pointer !important; +.c-p { + cursor: pointer !important; } -.c-d{ - cursor: default !important; + +.c-d { + cursor: default !important; } /*position*/ -.p-r{ - position: relative !important; +.p-r { + position: relative !important; } -.p-a{ - position: absolute !important; + +.p-a { + position: absolute !important; } -.p-s{ - position: static !important; + +.p-s { + position: static !important; } /*width/height*/ -.w-p-50{ - width: 50% !important; +.w-p-50 { + width: 50% !important; } -.w-p-100{ - width: 100% !important; + +.w-p-100 { + width: 100% !important; } -.w-50{ - width: 50px !important; + +.w-50 { + width: 50px !important; } -.w-60{ - width: 60px !important; + +.w-60 { + width: 60px !important; } -.w-80{ - width: 80px !important; + +.w-80 { + width: 80px !important; } -.w-100{ - width: 100px !important; + +.w-100 { + width: 100px !important; } -.w-120{ - width: 120px !important; + +.w-120 { + width: 120px !important; } -.w-150{ - width: 150px !important; + +.w-150 { + width: 150px !important; } -.w-180{ - width: 180px !important; + +.w-180 { + width: 180px !important; } -.w-200{ - width: 200px !important; + +.w-200 { + width: 200px !important; } -.w-250{ - width: 250px !important; + +.w-250 { + width: 250px !important; } -.w-300{ - width: 300px !important; + +.w-300 { + width: 300px !important; } -.h-p-100{ - height: 100% !important; + +.h-p-100 { + height: 100% !important; } /*其他样式*/ -.op-o{ - opacity: 0 !important; - filter:alpha(opacity=0) !important; +.op-o { + opacity: 0 !important; + filter: alpha(opacity=0) !important; } -.wb-ba{ - word-break: break-all !important; +.wb-ba { + word-break: break-all !important; } -.ov-h{ - overflow: hidden !important; +.ov-h { + overflow: hidden !important; } -.fs-n{ - font-style: normal !important; +.fs-n { + font-style: normal !important; } -.fw-b{ - font-weight: bold !important; -} -.fw-n{ - font-weight: normal !important; +.fw-b { + font-weight: bold !important; } -.us-n{ - -webkit-user-select: none !important; - -moz-user-select: none !important; - -ms-user-select: none !important; - -o-user-select: none !important; - user-select: none !important; +.fw-n { + font-weight: normal !important; } -.ellipsis{ - white-space: nowrap !important; - overflow: hidden !important; - -ms-text-overflow: ellipsis !important; - text-overflow: ellipsis !important; +.us-n { + -webkit-user-select: none !important; + -moz-user-select: none !important; + -ms-user-select: none !important; + -o-user-select: none !important; + user-select: none !important; } -.clearfix:after{ - content: ''; - display: block; - visibility: hidden; - clear: both; - height: 0; +.ellipsis { + white-space: nowrap !important; + overflow: hidden !important; + -ms-text-overflow: ellipsis !important; + text-overflow: ellipsis !important; +} + +.clearfix:after { + content: ''; + display: block; + visibility: hidden; + clear: both; + height: 0; } /*flex*/ -.ds-flex{ - display: -webkit-box; - display: -ms-flexbox; - display: flex; - display: -moz-flex; +.ds-flex { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + display: -moz-flex; } -.flex-1{ - -moz-box-flex: 1; - -webkit-box-flex: 1; - box-flex: 1; - -webkit-flex: 1 0 0; - -ms-flex: 1 0 0; - flex: 1 0 0; +.flex-1 { + -moz-box-flex: 1; + -webkit-box-flex: 1; + box-flex: 1; + -webkit-flex: 1 0 0; + -ms-flex: 1 0 0; + flex: 1 0 0; } -.flex-auto{ - -webkit-flex: 0 0 auto; - flex: 0 0 auto; - -moz-box-flex: 0; - -webkit-box-flex: 0; - box-flex: 0; +.flex-auto { + -webkit-flex: 0 0 auto; + flex: 0 0 auto; + -moz-box-flex: 0; + -webkit-box-flex: 0; + box-flex: 0; } /*提示*/ -.common-tips-wraper{ - .t-title{ - color: #b3b3b3; - padding: 1px 5px; - -webkit-border-radius: 1px; - -moz-border-radius: 1px; - -ms-border-radius: 1px; - -o-border-radius: 1px; - border-radius: 1px; - background-color: #e8e8e8; - display: inline; - } +.common-tips-wraper { + .t-title { + color: #b3b3b3; + padding: 1px 5px; + -webkit-border-radius: 1px; + -moz-border-radius: 1px; + -ms-border-radius: 1px; + -o-border-radius: 1px; + border-radius: 1px; + background-color: #e8e8e8; + display: inline; + } - .t-content{ - color: @gray-color; - padding-left: 7px; - font-size: 13px; - display: inline; - } + .t-content { + color: @gray-color; + padding-left: 7px; + font-size: 13px; + display: inline; + } } /*table共用样式*/ -.resize-table{ - border: 1px solid @border-color-split;; - width: 100%; - overflow-x: hidden; - overflow: auto; +.resize-table { + border: 1px solid @border-color-split; + ; + width: 100%; + overflow-x: hidden; + overflow: auto; - .list-head{ - background-color: @head-bg; - border-bottom: 1px solid @border-color-base; - text-align: left; + .list-head { + background-color: @head-bg; + border-bottom: 1px solid @border-color-base; + text-align: left; - .col-item{ - color: @gray-color; - font-weight: normal; - } - } + .col-item { + color: @gray-color; + font-weight: normal; + } + } - .col-item{ - padding: 10px; - font-size: 13px; - border-right: 1px solid @border-color-base; - border-collapse: collapse; - vertical-align: top; - // white-space: nowrap; + .col-item { + padding: 10px; + font-size: 13px; + border-right: 1px solid @border-color-base; + border-collapse: collapse; + vertical-align: top; + // white-space: nowrap; - &:last-child{ - border-right: 0; + &:last-child { + border-right: 0; + } + + &.opt-wrap { + .opt { + color: @primary-color; + cursor: pointer; + padding-right: 5px; + + &:last-child { + padding-right: 0; + } + + &:hover { + text-decoration: underline; + } + + &.disabled { + cursor: default; + color: @text-color; + + &:hover { + text-decoration: none; + } + } } - &.opt-wrap{ - .opt{ - color: @primary-color; - cursor: pointer; - padding-right: 5px; + .btn { + color: @text-color; + border-color: @text-color; - &:last-child{ - padding-right: 0; - } + &:hover { + color: @primary-color; + border-color: @primary-color; + } - &:hover{ - text-decoration: underline; - } - - &.disabled{ - cursor: default; - color: @text-color; - - &:hover{ - text-decoration: none; - } - } - } - - .btn{ - color: @text-color; - border-color: @text-color; - - &:hover{ - color: @primary-color; - border-color: @primary-color; - } - - &:focus{ - -webkit-box-shadow: none; - box-shadow: none; - } + &:focus { + -webkit-box-shadow: none; + box-shadow: none; + } - &:not(:last-child){ - margin-right: 5px; - } - } + &:not(:last-child) { + margin-right: 5px; + } } - } + } + } - .list-item{ - border-bottom: 1px solid @border-color-base; + .list-item { + border-bottom: 1px solid @border-color-base; - &:last-child{ - border-bottom: 0; - } - } + &:last-child { + border-bottom: 0; + } + } } /*列表(左标题右内容)*/ -.ui-list{ - font-size: 14px; +.ui-list { + font-size: 14px; - &::after{ - content: ''; - display: block; - visibility: hidden; - clear: both; - height: 0; - } + &::after { + content: ''; + display: block; + visibility: hidden; + clear: both; + height: 0; + } - .ui-list-title{ - vertical-align: middle; - float: left; - width: 110px; - line-height: 32px; - text-align: right; + .ui-list-title { + vertical-align: middle; + float: left; + width: 110px; + line-height: 32px; + text-align: right; - .title-require{ - color: @error-color; - position: relative; - top: 2px; - margin-right: 5px; - } - } + .title-require { + color: @error-color; + position: relative; + top: 2px; + margin-right: 5px; + } + } - .ui-list-content{ - page-break-after: left; - margin-left: 120px; - word-break: break-all; - } + .ui-list-content { + page-break-after: left; + margin-left: 120px; + word-break: break-all; + } } -.handle-wraper{ - padding: 7px !important; +.handle-wraper { + padding: 7px !important; - .text-exp{ - display: inline-block; - *display: inline; - height: 34px; - line-height: 34px; - margin-right: 5px; - float: left; + .text-exp { + display: inline-block; + *display: inline; + height: 34px; + line-height: 34px; + margin-right: 5px; + float: left; - &.gray{ - color: @gray-color; - } - } + &.gray { + color: @gray-color; + } + } - .handle-item{ - float: left; + .handle-item { + float: left; - &:not(:last-child){ - margin-right: 10px; - } - } + &:not(:last-child) { + margin-right: 10px; + } + } - &:after{ - content: ''; - display: block; - visibility: hidden; - clear: both; - height: 0; - } + &:after { + content: ''; + display: block; + visibility: hidden; + clear: both; + height: 0; + } - &.border{ - border-bottom: 7px solid @layout-body-background; - line-height: 34px; - } + &.border { + border-bottom: 7px solid @layout-body-background; + line-height: 34px; + } } /*上传文件*/ -.common-file-line{ - .img-common{ - position: relative; - display: inline-block; - width: 100px; - height: 100px; - line-height: 100px; - margin-right: 10px; - text-align: center; - border: 1px solid @border-color-base; +.common-file-line { + .img-common { + position: relative; + display: inline-block; + width: 100px; + height: 100px; + line-height: 100px; + margin-right: 10px; + text-align: center; + border: 1px solid @border-color-base; + vertical-align: top; + margin-bottom: 10px; + + .ui-img { + width: 100%; + height: 100%; vertical-align: top; - margin-bottom: 10px; + } - .ui-img{ - width: 100%; - height: 100%; - vertical-align: top; + .ui-cover { + position: absolute; + right: 0; + top: 0; + margin-top: -10px; + margin-right: -10px; + z-index: 1; + width: 22px; + height: 22px; + cursor: pointer; + background: rgba(0, 0, 0, 0.5) url(~images/close.png) center center no-repeat; + background-size: 12px; + -webkit-border-radius: 50%; + -moz-border-radius: 50%; + -ms-border-radius: 50%; + -o-border-radius: 50%; + border-radius: 50%; + } + + .ui-loading { + width: 30px; + height: 30px; + vertical-align: middle; + } + + &.add-file { + cursor: pointer; + border: 1px dashed @gray-color; + text-align: center; + -webkit-transition: all 0.2s; + -o-transition: all 0.2s; + transition: all 0.2s; + + .ui-plus-round { + position: absolute; + top: 50%; + left: 50%; + margin-top: -13px; + margin-left: -9px; + font-size: 25px; + color: @gray-color; } - .ui-cover{ - position: absolute; - right:0; - top:0; - margin-top: -10px; - margin-right: -10px; - z-index:1; - width:22px; - height:22px; - cursor: pointer; - background: rgba(0,0,0,0.5) url(~images/close.png) center center no-repeat; - background-size: 12px; - -webkit-border-radius: 50%; - -moz-border-radius: 50%; - -ms-border-radius: 50%; - -o-border-radius: 50%; - border-radius: 50%; + &:hover { + border-color: @primary-color; + + .ui-plus-round { + color: @primary-color; + } } - - .ui-loading{ - width: 30px; - height: 30px; - vertical-align: middle; - } - - &.add-file{ - cursor: pointer; - border: 1px dashed @gray-color; - text-align: center; - -webkit-transition: all 0.2s; - -o-transition: all 0.2s; - transition: all 0.2s; - - .ui-plus-round{ - position: absolute; - top:50%; - left:50%; - margin-top: -13px; - margin-left: -9px; - font-size: 25px; - color: @gray-color; - } - - &:hover{ - border-color: @primary-color; - - .ui-plus-round{ - color: @primary-color; - } - } - } - } + } + } } /*页面的一些公共样式*/ -.search-wrap{ - // border-top: 1px solid @border-color-base; +.search-wrap { + // border-top: 1px solid @border-color-base; } /*列表*/ -.page-list-wrap{ - padding: 10px 7px; +.page-list-wrap { + padding: 10px 7px; } /*分页*/ -.page-turn-wrap{ - padding: 20px 7px; - text-align: right; +.page-turn-wrap { + padding: 20px 7px; + text-align: right; } /*编辑页面*/ -.page-edit-wrap{ - padding-top: 20px; - padding-bottom: 20px; +.page-edit-wrap { + padding-top: 20px; + padding-bottom: 20px; - .ui-list{ - margin-bottom: 25px; - } + .ui-list { + margin-bottom: 25px; + } - .ui-icon-wrap{ - height: 32px; - display: inline-block; - background: @gray-color; - margin-left: 15px; - padding: 0 15px; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - -ms-border-radius: 3px; - -o-border-radius: 3px; - border-radius: 3px; - } + .ui-icon-wrap { + height: 32px; + display: inline-block; + background: @gray-color; + margin-left: 15px; + padding: 0 15px; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + -ms-border-radius: 3px; + -o-border-radius: 3px; + border-radius: 3px; + } - .page-save-wrap{ - margin-top: 35px; + .page-save-wrap { + margin-top: 35px; - .btn{ - &:not(:last-child){ - margin-right: 15px; - } + .btn { + &:not(:last-child) { + margin-right: 15px; } - } + } + } } /*弹出详情*/ -.page-detail-wrap{ - position: relative; +.page-detail-wrap { + position: relative; - .ui-list{ - &:not(:last-child){ - margin-bottom: 25px; - } + .ui-list { + &:not(:last-child) { + margin-bottom: 25px; + } - .ui-list-title{ - line-height: unset; - } - } + .ui-list-title { + line-height: unset; + } + } } -.hover-style{ - cursor: pointer; - color: @primary-color; +.hover-style { + cursor: pointer; + color: @primary-color; - &:hover{ - text-decoration: underline; - color: @warning-color; - } + &:hover { + text-decoration: underline; + color: @warning-color; + } } -.scale-img{ - position: relative; - overflow: hidden; - height: 100px; - margin: 5px 0; +.scale-img { + position: relative; + overflow: hidden; + height: 100px; + margin: 5px 0; - img{ - position: absolute; - vertical-align: top; - height: 100%; - top:50%; - left: 50%; - -webkit-transform: translate(-50%, -50%); - -ms-transform: translate(-50%, -50%); - -o-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); - } + img { + position: absolute; + vertical-align: top; + height: 100%; + top: 50%; + left: 50%; + -webkit-transform: translate(-50%, -50%); + -ms-transform: translate(-50%, -50%); + -o-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + } } -.page-tips{ - .num{ - color: @primary-color; - padding: 0 5px; - } +.page-tips { + .num { + color: @primary-color; + padding: 0 5px; + } - .clear{ - color: @primary-color; - cursor: pointer; - } + .clear { + color: @primary-color; + cursor: pointer; + } } /*iview*/ -.ivu-table-cell{ - .btn{ - &:not(:last-child){ - margin-right: 5px; - } - } +.ivu-table-cell { + .btn { + &:not(:last-child) { + margin-right: 5px; + } + } } -.vue-treeselect__control{ - height: 32px !important; +.vue-treeselect__control { + height: 32px !important; } diff --git a/frontend/src/mixins/complete.js b/frontend/src/mixins/complete.js index 4bb9d3e4..2265703e 100644 --- a/frontend/src/mixins/complete.js +++ b/frontend/src/mixins/complete.js @@ -16,9 +16,6 @@ export default { }, methods: { handleComplete(array, value = '', key = 'name', indexKey = 'id') { - console.log(1); - console.log(value); - if (value === '') { return array; } diff --git a/frontend/src/mixins/index.js b/frontend/src/mixins/index.js index 89fc5040..770ccb07 100644 --- a/frontend/src/mixins/index.js +++ b/frontend/src/mixins/index.js @@ -3,6 +3,7 @@ import { } from 'vuex'; import { objectDot } from 'service/util'; import default_head from 'images/head.png'; +import { getToken } from 'service/auth'; export default { data() { @@ -35,6 +36,9 @@ export default { }; }, computed: { + token: () => { + return getToken(); + }, ...mapGetters(['apps_info', 'left_menu', 'top_menu', 'permissions_array', 'permissions_object', 'account', 'page_nodes', 'tagnavs', 'cache_page', 'breadcrumb']) }, methods: { diff --git a/frontend/src/views/artisan/real-sync/edit.vue b/frontend/src/views/artisan/real-sync/edit.vue index b54cb737..c21d246b 100644 --- a/frontend/src/views/artisan/real-sync/edit.vue +++ b/frontend/src/views/artisan/real-sync/edit.vue @@ -49,7 +49,7 @@ type="primary" v-if="this.status === 'wait'" :disabled="disabled" - >下一步 + >{{ current ? '下一步' : '开始同步'}} + diff --git a/frontend/src/views/user/accounts/js/index.js b/frontend/src/views/user/accounts/js/index.js index cfcfd286..59a2c77f 100644 --- a/frontend/src/views/user/accounts/js/index.js +++ b/frontend/src/views/user/accounts/js/index.js @@ -92,7 +92,7 @@ export default{ type: 'primary', size: 'small', disabled: false, - icon: 'ios-create' + icon: 'md-create' }, class: ['btn'], on: { diff --git a/frontend/src/views/user/roles/js/index.js b/frontend/src/views/user/roles/js/index.js index 872b5f17..a7ca6ff8 100644 --- a/frontend/src/views/user/roles/js/index.js +++ b/frontend/src/views/user/roles/js/index.js @@ -60,7 +60,7 @@ export default{ type: 'primary', size: 'small', disabled: false, - icon: 'ios-create' + icon: 'md-create' }, class: ['btn'], on: { diff --git a/frontend/src/views/virtual/companies/js/index.js b/frontend/src/views/virtual/companies/js/index.js index 1c6b4be2..e66ed621 100644 --- a/frontend/src/views/virtual/companies/js/index.js +++ b/frontend/src/views/virtual/companies/js/index.js @@ -104,7 +104,7 @@ export default { type: 'primary', size: 'small', disabled: false, - icon: 'ios-create' + icon: 'md-create' }, class: ['btn'], on: { diff --git a/frontend/src/views/virtual/company_accounts/js/index.js b/frontend/src/views/virtual/company_accounts/js/index.js index e0a98ae5..5ae09619 100644 --- a/frontend/src/views/virtual/company_accounts/js/index.js +++ b/frontend/src/views/virtual/company_accounts/js/index.js @@ -101,7 +101,7 @@ export default { type: 'primary', size: 'small', disabled: false, - icon: 'ios-create' + icon: 'md-create' }, class: ['btn'], on: { diff --git a/frontend/src/views/virtual/flow_pools/edit.vue b/frontend/src/views/virtual/flow_pools/edit.vue index 9ba17c41..79fc214e 100644 --- a/frontend/src/views/virtual/flow_pools/edit.vue +++ b/frontend/src/views/virtual/flow_pools/edit.vue @@ -11,6 +11,22 @@