common.blade.php 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
  4. @endsection
  5. @section('content')
  6. <div class="page-content container">
  7. <div class="panel">
  8. <div class="panel-heading">
  9. <h1 class="panel-title"><i class="icon wb-settings" aria-hidden="true"></i>通用配置</h1>
  10. </div>
  11. <div class="panel-body container-fluid">
  12. <div class="nav-tabs-vertical" data-plugin="tabs">
  13. <ul class="nav nav-tabs mr-25" role="tablist">
  14. <li class="nav-item" role="presentation">
  15. <a class="nav-link active" data-toggle="tab" href="#method" aria-controls="method" role="tab">加密</a>
  16. </li>
  17. <li class="nav-item" role="presentation">
  18. <a class="nav-link" data-toggle="tab" href="#protocol" aria-controls="protocol" role="tab">协议</a>
  19. </li>
  20. <li class="nav-item" role="presentation">
  21. <a class="nav-link" data-toggle="tab" href="#obfs" aria-controls="obfs" role="tab">混淆</a>
  22. </li>
  23. <li class="nav-item" role="presentation">
  24. <a class="nav-link" data-toggle="tab" href="#level" aria-controls="level" role="tab">等级</a>
  25. </li>
  26. <li class="nav-item" role="presentation">
  27. <a class="nav-link" data-toggle="tab" href="#country" aria-controls="country" role="tab">国家地区</a>
  28. </li>
  29. <li class="nav-item" role="presentation">
  30. <a class="nav-link" data-toggle="tab" href="#label" aria-controls="label" role="tab">标签</a>
  31. </li>
  32. <li class="nav-item" role="presentation">
  33. <a class="nav-link" data-toggle="tab" href="#category" aria-controls="category" role="tab">商品分类</a>
  34. </li>
  35. </ul>
  36. <div class="tab-content py-15">
  37. <div class="tab-pane active" id="method" role="tabpanel">
  38. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_config_modal">
  39. 新增<i class="icon wb-plus"></i>
  40. </button>
  41. <table class="text-md-center" data-toggle="table" data-height="700" data-virtual-scroll="true" data-mobile-responsive="true">
  42. <thead class="thead-default">
  43. <tr>
  44. <th> 名称</th>
  45. <th> {{trans('common.action')}}</th>
  46. </tr>
  47. </thead>
  48. <tbody>
  49. @foreach($methods as $method)
  50. <tr>
  51. <td> {{$method->name}}</td>
  52. <td>
  53. @if($method->is_default)
  54. <span class='badge badge-lg badge-default'>默认</span>
  55. @else
  56. <div class="btn-group">
  57. <button class="btn btn-primary" onclick="setDefault('{{$method->id}}')">
  58. 默认
  59. </button>
  60. <button class="btn btn-danger" onclick="delConfig('{{$method->id}}','{{$method->name}}')">
  61. <i class="icon wb-trash"></i>
  62. </button>
  63. </div>
  64. @endif
  65. </td>
  66. </tr>
  67. @endforeach
  68. </tbody>
  69. </table>
  70. </div>
  71. <div class="tab-pane" id="protocol" role="tabpanel">
  72. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_config_modal">
  73. 新增<i class="icon wb-plus"></i>
  74. </button>
  75. <table class="text-md-center" data-toggle="table" data-height="700" data-virtual-scroll="true" data-mobile-responsive="true">
  76. <thead class="thead-default">
  77. <tr>
  78. <th> 名称</th>
  79. <th> {{trans('common.action')}}</th>
  80. </tr>
  81. </thead>
  82. <tbody>
  83. @foreach($protocols as $protocol)
  84. <tr>
  85. <td> {{$protocol->name}}</td>
  86. <td>
  87. @if($protocol->is_default)
  88. <span class="badge badge-lg badge-default">默认</span>
  89. @else
  90. <div class="btn-group">
  91. <button class="btn btn-primary" onclick="setDefault('{{$protocol->id}}')">
  92. 默认
  93. </button>
  94. <button class="btn btn-danger" onclick="delConfig('{{$protocol->id}}','{{$protocol->name}}')">
  95. <i class="icon wb-trash"></i>
  96. </button>
  97. </div>
  98. @endif
  99. </td>
  100. </tr>
  101. @endforeach
  102. </tbody>
  103. </table>
  104. </div>
  105. <div class="tab-pane" id="obfs" role="tabpanel">
  106. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_config_modal">
  107. 新增<i class="icon wb-plus"></i>
  108. </button>
  109. <table class="text-md-center" data-toggle="table" data-height="700" data-virtual-scroll="true" data-mobile-responsive="true">
  110. <thead class="thead-default">
  111. <tr>
  112. <th> 名称</th>
  113. <th> {{trans('common.action')}}</th>
  114. </tr>
  115. </thead>
  116. <tbody>
  117. @foreach($obfsList as $obfs)
  118. <tr>
  119. <td> {{$obfs->name}}</td>
  120. <td>
  121. @if($obfs->is_default)
  122. <span class="badge badge-lg badge-default">默认</span>
  123. @else
  124. <div class="btn-group">
  125. <button class="btn btn-primary" onclick="setDefault('{{$obfs->id}}')">
  126. 默认
  127. </button>
  128. <button class="btn btn-danger" onclick="delConfig('{{$obfs->id}}','{{$obfs->name}}')">
  129. <i class="icon wb-trash"></i>
  130. </button>
  131. </div>
  132. @endif
  133. </td>
  134. </tr>
  135. @endforeach
  136. </tbody>
  137. </table>
  138. </div>
  139. <div class="tab-pane" id="level" role="tabpanel">
  140. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_level_modal">
  141. 新增<i class="icon wb-plus"></i>
  142. </button>
  143. <table class="text-md-center" data-toggle="table" data-height="700" data-virtual-scroll="true" data-mobile-responsive="true">
  144. <thead class="thead-default">
  145. <tr>
  146. <th> 等级</th>
  147. <th> 名称</th>
  148. <th> {{trans('common.action')}}</th>
  149. </tr>
  150. </thead>
  151. <tbody>
  152. @foreach($levels as $level)
  153. <tr>
  154. <td>
  155. <input type="text" class="form-control" name="level" id="level_{{$level->id}}" value="{{$level->level}}"/>
  156. </td>
  157. <td>
  158. <input type="text" class="form-control" name="level_name" id="level_name_{{$level->id}}" value="{{$level->name}}"/>
  159. </td>
  160. <td>
  161. <div class="btn-group">
  162. <button type="button" class="btn btn-primary" onclick="updateLevel('{{$level->id}}')">
  163. <i class="icon wb-edit" aria-hidden="true"></i></button>
  164. <button type="button" class="btn btn-danger" onclick="delLevel('{{$level->id}}','{{$level->name}}')">
  165. <i class="icon wb-trash"></i></button>
  166. </div>
  167. </td>
  168. </tr>
  169. @endforeach
  170. </tbody>
  171. </table>
  172. </div>
  173. <div class="tab-pane" id="category" role="tabpanel">
  174. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_category_modal">
  175. 新增<i class="icon wb-plus"></i>
  176. </button>
  177. <table class="text-md-center" data-toggle="table" data-height="700" data-virtual-scroll="true" data-mobile-responsive="true">
  178. <thead class="thead-default">
  179. <tr>
  180. <th> 名称</th>
  181. <th> 排序</th>
  182. <th> {{trans('common.action')}}</th>
  183. </tr>
  184. </thead>
  185. <tbody>
  186. @foreach($categories as $category)
  187. <tr>
  188. <td>
  189. <input type="text" class="form-control" name="name" id="category_name_{{$category->id}}" value="{{$category->name}}"/>
  190. </td>
  191. <td>
  192. <input type="text" class="form-control" name="sort" id="category_sort_{{$category->id}}" value="{{$category->sort}}"/>
  193. </td>
  194. <td>
  195. <div class="btn-group">
  196. <button type="button" class="btn btn-primary" onclick="updateCategory('{{$category->id}}')">
  197. <i class="icon wb-edit" aria-hidden="true"></i></button>
  198. <button type="button" class="btn btn-danger" onclick="delCategory('{{$category->id}}','{{$category->name}}')">
  199. <i class="icon wb-trash"></i></button>
  200. </div>
  201. </td>
  202. </tr>
  203. @endforeach
  204. </tbody>
  205. </table>
  206. </div>
  207. <div class="tab-pane" id="country" role="tabpanel">
  208. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_country_modal">
  209. 新增<i class="icon wb-plus"></i>
  210. </button>
  211. <table class="text-md-center" data-toggle="table" data-height="700" data-virtual-scroll="true" data-mobile-responsive="true">
  212. <thead class="thead-default">
  213. <tr>
  214. <th> 图标</th>
  215. <th> 代码</th>
  216. <th> 国家/地区名称</th>
  217. <th> {{trans('common.action')}}</th>
  218. </tr>
  219. </thead>
  220. <tbody>
  221. @foreach($countries as $country)
  222. <tr>
  223. <td>
  224. <i class="fi fis fi-{{$country->code}} h-40 w-40" aria-hidden="true"></i>
  225. </td>
  226. <td>
  227. {{$country->code}}
  228. </td>
  229. <td>
  230. <input type="text" class="form-control" name="country_name" id="country_{{$country->code}}" value="{{$country->name}}"/>
  231. </td>
  232. <td>
  233. <div class="btn-group">
  234. <button type="button" class="btn btn-primary" onclick="updateCountry('{{$country->code}}')">
  235. <i class="icon wb-edit" aria-hidden="true"></i></button>
  236. <button type="button" class="btn btn-danger" onclick="delCountry('{{$country->code}}','{{$country->name}}')">
  237. <i class="icon wb-trash"></i></button>
  238. </div>
  239. </td>
  240. </tr>
  241. @endforeach
  242. </tbody>
  243. </table>
  244. </div>
  245. <div class="tab-pane" id="label" role="tabpanel">
  246. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_label_modal">
  247. 新增<i class="icon wb-plus"></i>
  248. </button>
  249. <table class="text-md-center" data-toggle="table" data-height="700" data-virtual-scroll="true" data-mobile-responsive="true">
  250. <thead class="thead-default">
  251. <tr>
  252. <th> 名称</th>
  253. <th> 关联节点数</th>
  254. <th> 排序</th>
  255. <th> {{trans('common.action')}}</th>
  256. </tr>
  257. </thead>
  258. <tbody>
  259. @foreach($labels as $label)
  260. <tr>
  261. <td>
  262. <input type="text" class="form-control" name="label_name" id="label_name_{{$label->id}}" value="{{$label->name}}"/>
  263. </td>
  264. <td> {{$label->nodes->count()}} </td>
  265. <td>
  266. <input type="number" class="form-control" name="label_sort" id="label_sort_{{$label->id}}" value="{{$label->sort}}"/>
  267. </td>
  268. <td>
  269. <div class="btn-group">
  270. <button type="button" class="btn btn-primary" onclick="updateLabel('{{$label->id}}')">
  271. <i class="icon wb-edit" aria-hidden="true"></i></button>
  272. <button type="button" class="btn btn-danger" onclick="delLabel('{{$label->id}}','{{$label->name}}')">
  273. <i class="icon wb-trash"></i></button>
  274. </div>
  275. </td>
  276. </tr>
  277. @endforeach
  278. </tbody>
  279. </table>
  280. </div>
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285. </div>
  286. <div class="modal fade" id="add_config_modal" aria-hidden="true" role="dialog" tabindex="-1">
  287. <div class="modal-dialog modal-simple modal-center">
  288. <div class="modal-content">
  289. <div class="modal-header">
  290. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  291. <span aria-hidden="true">×</span>
  292. </button>
  293. <h4 class="modal-title">新增配置</h4>
  294. </div>
  295. <form action="#" method="post" class="modal-body">
  296. <div class="alert alert-danger" style="display: none;" id="msg"></div>
  297. <div class="row">
  298. <div class="col-md-6 form-group">
  299. <select class="form-control" name="type" id="type" placeholder="类型">
  300. <option value="1" selected>加密方式</option>
  301. <option value="2">协议</option>
  302. <option value="3">混淆</option>
  303. </select>
  304. </div>
  305. <div class="col-md-6 form-group">
  306. <input type="text" class="form-control" name="name" id="name" placeholder="名称">
  307. </div>
  308. </div>
  309. </form>
  310. <div class="modal-footer">
  311. <button class="btn btn-danger mr-auto" data-dismiss="modal">关 闭</button>
  312. <button class="btn btn-primary" onclick="addConfig()">提 交</button>
  313. </div>
  314. </div>
  315. </div>
  316. </div>
  317. <div class="modal fade" id="add_level_modal" aria-hidden="true" role="dialog" tabindex="-1">
  318. <div class="modal-dialog modal-simple modal-center">
  319. <div class="modal-content">
  320. <div class="modal-header">
  321. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  322. <span aria-hidden="true">×</span>
  323. </button>
  324. <h4 class="modal-title">新增等级</h4>
  325. </div>
  326. <form action="#" method="post" class="modal-body">
  327. <div class="alert alert-danger" style="display: none;" id="level_msg"></div>
  328. <div class="row">
  329. <div class="col-md-6 form-group">
  330. <input type="text" class="form-control" name="level" id="add_level" placeholder="等级">
  331. </div>
  332. <div class="col-md-6 form-group">
  333. <input type="text" class="form-control" name="level_name" id="add_level_name" placeholder="等级名称">
  334. </div>
  335. </div>
  336. </form>
  337. <div class="modal-footer">
  338. <button data-dismiss="modal" class="btn btn-danger mr-auto">关 闭</button>
  339. <button class="btn btn-primary" onclick="addLevel()">提 交</button>
  340. </div>
  341. </div>
  342. </div>
  343. </div>
  344. <div class="modal fade" id="add_category_modal" aria-hidden="true" role="dialog" tabindex="-1">
  345. <div class="modal-dialog modal-simple modal-center">
  346. <div class="modal-content">
  347. <div class="modal-header">
  348. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  349. <span aria-hidden="true">×</span>
  350. </button>
  351. <h4 class="modal-title">新增分类</h4>
  352. </div>
  353. <form action="#" method="post" class="modal-body">
  354. <div class="alert alert-danger" style="display: none;" id="category_msg"></div>
  355. <div class="row">
  356. <div class="col-md-6 form-group">
  357. <input type="text" class="form-control" name="name" id="add_category_name" placeholder="分类名称">
  358. </div>
  359. <div class="col-md-6 form-group">
  360. <input type="text" class="form-control" name="sort" id="add_category_sort" placeholder="分类排序">
  361. </div>
  362. </div>
  363. </form>
  364. <div class="modal-footer">
  365. <button data-dismiss="modal" class="btn btn-danger mr-auto">关 闭</button>
  366. <button class="btn btn-primary" onclick="addCategory()">提 交</button>
  367. </div>
  368. </div>
  369. </div>
  370. </div>
  371. <div class="modal fade" id="add_country_modal" aria-hidden="true" role="dialog" tabindex="-1">
  372. <div class="modal-dialog modal-simple modal-center">
  373. <div class="modal-content">
  374. <div class="modal-header">
  375. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  376. <span aria-hidden="true">×</span>
  377. </button>
  378. <h4 class="modal-title">新增国家/地区</h4>
  379. </div>
  380. <form action="#" method="post" class="modal-body">
  381. <div class="alert alert-danger" style="display: none;" id="country_msg"></div>
  382. <div class="row">
  383. <div class="col-md-6 form-group">
  384. <input type="text" class="form-control" name="country_code" id="add_country_code" placeholder="ISO国家代码">
  385. </div>
  386. <div class="col-md-6 form-group">
  387. <input type="text" class="form-control" name="country_name" id="add_country_name" placeholder=" 国家/地区名称">
  388. </div>
  389. </div>
  390. </form>
  391. <div class="modal-footer">
  392. <button data-dismiss="modal" class="btn btn-danger mr-auto">关 闭</button>
  393. <button class="btn btn-primary" onclick="addCountry()">提 交</button>
  394. </div>
  395. </div>
  396. </div>
  397. </div>
  398. <div class="modal fade" id="add_label_modal" aria-hidden="true" role="dialog" tabindex="-1">
  399. <div class="modal-dialog modal-simple modal-center">
  400. <div class="modal-content">
  401. <div class="modal-header">
  402. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  403. <span aria-hidden="true">×</span>
  404. </button>
  405. <h4 class="modal-title">新增标签</h4>
  406. </div>
  407. <form action="#" method="post" class="modal-body">
  408. <div class="alert alert-danger" style="display: none;" id="lable_msg"></div>
  409. <div class="row">
  410. <div class="col-md-6 form-group">
  411. <input type="text" class="form-control" name="label" id="add_label" placeholder="标签">
  412. </div>
  413. <div class="col-md-6 form-group">
  414. <input type="text" class="form-control" name="label_sort" id="add_label_sort" placeholder="排序">
  415. </div>
  416. </div>
  417. </form>
  418. <div class="modal-footer">
  419. <button data-dismiss="modal" class="btn btn-danger mr-auto">关 闭</button>
  420. <button class="btn btn-primary" onclick="addLabel()">提 交</button>
  421. </div>
  422. </div>
  423. </div>
  424. </div>
  425. @endsection
  426. @section('javascript')
  427. <script src="/assets/custom/jump-tab.js"></script>
  428. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js"></script>
  429. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
  430. <script>
  431. function addLevel() { // 添加等级
  432. @can('admin.config.level.store')
  433. const level = $('#add_level').val();
  434. const level_name = $('#add_level_name').val();
  435. if (level.trim() === '') {
  436. $('#level_msg').show().html('等级不能为空');
  437. $('#level').focus();
  438. return false;
  439. }
  440. if (level_name.trim() === '') {
  441. $('#level_msg').show().html('等级名称不能为空');
  442. $('#level_name').focus();
  443. return false;
  444. }
  445. $.ajax({
  446. url: '{{route('admin.config.level.store')}}',
  447. method: 'POST',
  448. data: {_token: '{{csrf_token()}}', level: level, name: level_name},
  449. beforeSend: function() {
  450. $('#level_msg').show().html('正在添加');
  451. },
  452. success: function(ret) {
  453. if (ret.status === 'fail') {
  454. $('#level_msg').show().html(ret.message);
  455. return false;
  456. }
  457. $('#add_level_modal').modal('hide');
  458. window.location.reload();
  459. },
  460. error: function() {
  461. $('#level_msg').show().html('请求错误,请重试');
  462. },
  463. complete: function() {
  464. swal.fire({title: '添加成功', icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  465. },
  466. });
  467. @endcan
  468. @cannot('admin.config.level.store')
  469. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  470. @endcannot
  471. }
  472. function updateLevel(id) { // 更新等级
  473. @can('admin.config.level.update')
  474. $.ajax({
  475. method: 'PUT',
  476. url: '{{route('admin.config.level.update', '')}}/' + id,
  477. data: {
  478. _token: '{{csrf_token()}}',
  479. level: $('#level_' + id).val(),
  480. name: $('#level_name_' + id).val(),
  481. },
  482. dataType: 'json',
  483. success: function(ret) {
  484. if (ret.status === 'success') {
  485. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  486. } else {
  487. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  488. }
  489. },
  490. });
  491. @endcan
  492. @cannot('admin.config.level.update')
  493. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  494. @endcannot
  495. }
  496. function delLevel(id, name) { // 删除等级
  497. @can('admin.config.level.destroy')
  498. swal.fire({
  499. title: '确定删除等级 【' + name + '】 ?',
  500. icon: 'question',
  501. allowEnterKey: false,
  502. showCancelButton: true,
  503. cancelButtonText: '{{trans('common.close')}}',
  504. confirmButtonText: '{{trans('common.confirm')}}',
  505. }).then((result) => {
  506. if (result.value) {
  507. $.ajax({
  508. method: 'DELETE',
  509. url: '{{route('admin.config.level.destroy', '')}}/' + id,
  510. data: {_token: '{{csrf_token()}}'},
  511. dataType: 'json',
  512. success: function(ret) {
  513. if (ret.status === 'success') {
  514. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  515. } else {
  516. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  517. }
  518. },
  519. });
  520. }
  521. });
  522. @endcan
  523. @cannot('admin.config.level.destroy')
  524. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  525. @endcannot
  526. }
  527. function addCategory() { // 添加分类
  528. @can('admin.config.category.store')
  529. const name = $('#add_category_name').val();
  530. const sort = $('#add_category_sort').val();
  531. if (name.trim() === '') {
  532. $('#category_msg').show().html('分类名称不能为空');
  533. $('#category_name').focus();
  534. return false;
  535. }
  536. if (sort.trim() === '') {
  537. $('#category_msg').show().html('分类排序不能为空');
  538. $('#category_sort').focus();
  539. return false;
  540. }
  541. $.ajax({
  542. url: '{{route('admin.config.category.store')}}',
  543. method: 'POST',
  544. data: {_token: '{{csrf_token()}}', name: name, sort: sort},
  545. beforeSend: function() {
  546. $('#category_msg').show().html('正在添加');
  547. },
  548. success: function(ret) {
  549. if (ret.status === 'fail') {
  550. $('#category_msg').show().html(ret.message);
  551. return false;
  552. }
  553. $('#add_category_modal').modal('hide');
  554. window.location.reload();
  555. },
  556. error: function() {
  557. $('#category_msg').show().html('请求错误,请重试');
  558. },
  559. complete: function() {
  560. swal.fire({title: '添加成功', icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  561. },
  562. });
  563. @endcan
  564. @cannot('admin.config.category.store')
  565. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  566. @endcannot
  567. }
  568. function updateCategory(id) { // 更新分类
  569. @can('admin.config.category.update')
  570. $.ajax({
  571. method: 'PUT',
  572. url: '{{route('admin.config.category.update', '')}}/' + id,
  573. data: {
  574. _token: '{{csrf_token()}}',
  575. name: $('#category_name_' + id).val(),
  576. sort: $('#category_sort_' + id).val(),
  577. },
  578. dataType: 'json',
  579. success: function(ret) {
  580. if (ret.status === 'success') {
  581. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  582. } else {
  583. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  584. }
  585. },
  586. });
  587. @endcan
  588. @cannot('admin.config.category.update')
  589. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  590. @endcannot
  591. }
  592. function delCategory(id, name) { // 删除分类
  593. @can('admin.config.category.destroy')
  594. swal.fire({
  595. title: '确定删除分类 【' + name + '】 ?',
  596. icon: 'question',
  597. allowEnterKey: false,
  598. showCancelButton: true,
  599. cancelButtonText: '{{trans('common.close')}}',
  600. confirmButtonText: '{{trans('common.confirm')}}',
  601. }).then((result) => {
  602. if (result.value) {
  603. $.ajax({
  604. method: 'DELETE',
  605. url: '{{route('admin.config.category.destroy', '')}}/' + id,
  606. data: {_token: '{{csrf_token()}}'},
  607. dataType: 'json',
  608. success: function(ret) {
  609. if (ret.status === 'success') {
  610. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  611. } else {
  612. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  613. }
  614. },
  615. });
  616. }
  617. });
  618. @endcan
  619. @cannot('admin.config.category.destroy')
  620. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  621. @endcannot
  622. }
  623. function addCountry() { // 添加国家/地区
  624. @can('admin.config.country.store')
  625. const country_name = $('#add_country_name').val();
  626. const country_code = $('#add_country_code').val();
  627. if (country_code.trim() === '') {
  628. $('#country_msg').show().html('国家/地区代码不能为空');
  629. $('#add_country_code').focus();
  630. return false;
  631. }
  632. if (country_name.trim() === '') {
  633. $('#country_msg').show().html('国家/地区名称不能为空');
  634. $('#add_country_name').focus();
  635. return false;
  636. }
  637. $.ajax({
  638. url: '{{route('admin.config.country.store')}}',
  639. method: 'POST',
  640. data: {_token: '{{csrf_token()}}', code: country_code, name: country_name},
  641. beforeSend: function() {
  642. $('#country_msg').show().html('正在添加');
  643. },
  644. success: function(ret) {
  645. if (ret.status === 'fail') {
  646. $('#country_msg').show().html(ret.message);
  647. return false;
  648. }
  649. $('#add_country_modal').modal('hide');
  650. window.location.reload();
  651. },
  652. error: function() {
  653. $('#country_msg').show().html('请求错误,请重试');
  654. },
  655. complete: function() {
  656. swal.fire({
  657. title: '添加成功',
  658. icon: 'success',
  659. timer: 1000,
  660. showConfirmButton: false,
  661. }).then(() => window.location.reload());
  662. },
  663. });
  664. @endcan
  665. @cannot('admin.config.country.store')
  666. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  667. @endcannot
  668. }
  669. function updateCountry(code) { // 更新国家/地区
  670. @can('admin.config.country.update')
  671. $.ajax({
  672. method: 'PUT',
  673. url: '{{route('admin.config.country.update', '')}}/' + code,
  674. data: {_token: '{{csrf_token()}}', name: $('#country_' + code).val()},
  675. dataType: 'json',
  676. success: function(ret) {
  677. if (ret.status === 'success') {
  678. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  679. } else {
  680. swal.fire({title: ret.message, icon: 'error'});
  681. }
  682. },
  683. });
  684. @endcan
  685. @cannot('admin.config.country.update')
  686. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  687. @endcannot
  688. }
  689. function delCountry(code, name) { // 删除国家/地区
  690. @can('admin.config.country.destroy')
  691. swal.fire({
  692. title: '确定删除 【' + name + '】 信息?',
  693. icon: 'question',
  694. allowEnterKey: false,
  695. showCancelButton: true,
  696. cancelButtonText: '{{trans('common.close')}}',
  697. confirmButtonText: '{{trans('common.confirm')}}',
  698. }).then((result) => {
  699. if (result.value) {
  700. $.ajax({
  701. method: 'DELETE',
  702. url: '{{route('admin.config.country.destroy', '')}}/' + code,
  703. data: {_token: '{{csrf_token()}}'},
  704. dataType: 'json',
  705. success: function(ret) {
  706. if (ret.status === 'success') {
  707. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  708. } else {
  709. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  710. }
  711. },
  712. });
  713. }
  714. });
  715. @endcan
  716. @cannot('admin.config.country.destroy')
  717. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  718. @endcannot
  719. }
  720. function addConfig() { // 添加配置
  721. @can('admin.config.ss.store')
  722. const name = $('#name').val();
  723. const type = $('#type').val();
  724. if (name.trim() === '') {
  725. $('#msg').show().html('名称不能为空');
  726. $('#name').focus();
  727. return false;
  728. }
  729. $.ajax({
  730. url: '{{route('admin.config.ss.store')}}',
  731. method: 'POST',
  732. data: {_token: '{{csrf_token()}}', name: name, type: type},
  733. dataType: 'json',
  734. beforeSend: function() {
  735. $('#msg').show().html('正在添加');
  736. },
  737. success: function(ret) {
  738. if (ret.status === 'fail') {
  739. $('#msg').show().html(ret.message);
  740. return false;
  741. }
  742. $('#add_config_modal').modal('hide');
  743. },
  744. error: function() {
  745. $('#msg').show().html('请求错误,请重试');
  746. },
  747. complete: function() {
  748. swal.fire({title: '添加成功', icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  749. },
  750. });
  751. @endcan
  752. @cannot('admin.config.ss.store')
  753. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  754. @endcannot
  755. }
  756. function setDefault(id) { // 置为默认
  757. @can('admin.config.ss.update')
  758. $.ajax({
  759. method: 'PUT',
  760. url: '{{route('admin.config.ss.update', '')}}/' + id,
  761. data: {_token: '{{csrf_token()}}'},
  762. dataType: 'json',
  763. success: function(ret) {
  764. if (ret.status === 'success') {
  765. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  766. } else {
  767. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  768. }
  769. },
  770. });
  771. @endcan
  772. @cannot('admin.config.ss.update')
  773. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  774. @endcannot
  775. }
  776. function delConfig(id, name) { // 删除配置
  777. @can('admin.config.ss.destroy')
  778. swal.fire({
  779. title: '确定删除配置 【' + name + '】 ?',
  780. icon: 'question',
  781. allowEnterKey: false,
  782. showCancelButton: true,
  783. cancelButtonText: '{{trans('common.close')}}',
  784. confirmButtonText: '{{trans('common.confirm')}}',
  785. }).then((result) => {
  786. if (result.value) {
  787. $.ajax({
  788. method: 'DELETE',
  789. url: '{{route('admin.config.ss.destroy', '')}}/' + id,
  790. data: {_token: '{{csrf_token()}}'},
  791. dataType: 'json',
  792. success: function(ret) {
  793. if (ret.status === 'success') {
  794. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  795. } else {
  796. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  797. }
  798. },
  799. });
  800. }
  801. });
  802. @endcan
  803. @cannot('admin.config.ss.destroy')
  804. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  805. @endcannot
  806. }
  807. function addLabel() { // 添加标签
  808. @can('admin.config.label.store')
  809. const name = $('#add_label').val();
  810. const sort = $('#add_label_sort').val();
  811. if (name.trim() === '') {
  812. $('#lable_msg').show().html('标签不能为空');
  813. return false;
  814. }
  815. if (sort.trim() === '') {
  816. $('#lable_msg').show().html('标签排序不能为空');
  817. return false;
  818. }
  819. $.ajax({
  820. url: '{{route('admin.config.label.store')}}',
  821. method: 'POST',
  822. data: {_token: '{{csrf_token()}}', name: name, sort: sort},
  823. beforeSend: function() {
  824. $('#level_msg').show().html('正在添加');
  825. },
  826. success: function(ret) {
  827. if (ret.status === 'fail') {
  828. $('#lable_msg').show().html(ret.message);
  829. return false;
  830. }
  831. $('#add_label_modal').modal('hide');
  832. window.location.reload();
  833. },
  834. error: function() {
  835. $('#lable_msg').show().html('请求错误,请重试');
  836. },
  837. complete: function() {
  838. swal.fire({
  839. title: '添加成功',
  840. icon: 'success',
  841. timer: 1000,
  842. showConfirmButton: false,
  843. }).then(() => window.location.reload());
  844. },
  845. });
  846. @endcan
  847. @cannot('admin.config.label.store')
  848. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  849. @endcannot
  850. }
  851. function updateLabel(id) { // 编辑标签
  852. @can('admin.config.label.update')
  853. $.ajax({
  854. method: 'PUT',
  855. url: '{{route('admin.config.label.update', '')}}/' + id,
  856. data: {
  857. _token: '{{csrf_token()}}',
  858. name: $('#label_name_' + id).val(),
  859. sort: $('#label_sort_' + id).val(),
  860. },
  861. dataType: 'json',
  862. success: function(ret) {
  863. if (ret.status === 'success') {
  864. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  865. } else {
  866. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  867. }
  868. },
  869. });
  870. @endcan
  871. @cannot('admin.config.label.update')
  872. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  873. @endcannot
  874. }
  875. function delLabel(id, name) { // 删除标签
  876. @can('admin.config.label.destroy')
  877. swal.fire({
  878. title: '{{trans('common.warning')}}',
  879. text: '确定删除标签 【' + name + '】 ?',
  880. icon: 'warning',
  881. showCancelButton: true,
  882. cancelButtonText: '{{trans('common.close')}}',
  883. confirmButtonText: '{{trans('common.confirm')}}',
  884. }).then((result) => {
  885. $.ajax({
  886. method: 'DELETE',
  887. url: '{{route('admin.config.label.destroy', '')}}/' + id,
  888. data: {_token: '{{csrf_token()}}'},
  889. dataType: 'json',
  890. success: function(ret) {
  891. if (ret.status === 'success') {
  892. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  893. } else {
  894. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  895. }
  896. },
  897. });
  898. });
  899. @endcan
  900. @cannot('admin.config.label.destroy')
  901. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  902. @endcannot
  903. }
  904. </script>
  905. @endsection