common.blade.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. @extends('admin.table_layouts')
  2. @section('content')
  3. <div class="page-content container">
  4. <x-ui.panel icon="wb-settings" :title="trans('admin.menu.setting.universal')">
  5. <div class="nav-tabs-vertical" data-plugin="tabs">
  6. <ul class="nav nav-tabs mr-25" role="tablist">
  7. <li class="nav-item" role="presentation">
  8. <a class="nav-link active" data-toggle="tab" href="#method" role="tab" aria-controls="method">{{ trans('model.node.method') }}</a>
  9. </li>
  10. <li class="nav-item" role="presentation">
  11. <a class="nav-link" data-toggle="tab" href="#protocol" role="tab" aria-controls="protocol">{{ trans('model.node.protocol') }}</a>
  12. </li>
  13. <li class="nav-item" role="presentation">
  14. <a class="nav-link" data-toggle="tab" href="#obfs" role="tab" aria-controls="obfs">{{ trans('model.node.obfs') }}</a>
  15. </li>
  16. <li class="nav-item" role="presentation">
  17. <a class="nav-link" data-toggle="tab" href="#level" role="tab" aria-controls="level">{{ trans('model.common.level') }}</a>
  18. </li>
  19. <li class="nav-item" role="presentation">
  20. <a class="nav-link" data-toggle="tab" href="#country" role="tab" aria-controls="country">{{ trans('model.node.country') }}</a>
  21. </li>
  22. <li class="nav-item" role="presentation">
  23. <a class="nav-link" data-toggle="tab" href="#label" role="tab" aria-controls="label">{{ trans('model.node.label') }}</a>
  24. </li>
  25. <li class="nav-item" role="presentation">
  26. <a class="nav-link" data-toggle="tab" href="#category" role="tab" aria-controls="category">{{ trans('model.goods.category') }}</a>
  27. </li>
  28. </ul>
  29. <div class="tab-content py-15">
  30. <div class="tab-pane active" id="method" role="tabpanel">
  31. @can('admin.config.ss.store')
  32. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_config_modal">
  33. <i class="icon wb-plus"></i>
  34. </button>
  35. @endcan
  36. <table class="text-md-center" data-toggle="table" data-height="700" data-mobile-responsive="true">
  37. <thead class="thead-default">
  38. <tr>
  39. <th> {{ ucfirst(trans('validation.attributes.name')) }}</th>
  40. <th> {{ trans('common.action') }}</th>
  41. </tr>
  42. </thead>
  43. <tbody>
  44. @foreach ($methods as $method)
  45. <tr>
  46. <td> {{ $method->name }}</td>
  47. <td>
  48. @if ($method->is_default)
  49. <span class='badge badge-lg badge-default'>{{ trans('common.default') }}</span>
  50. @else
  51. <div class="btn-group">
  52. @can('admin.config.ss.update')
  53. <button class="btn btn-primary" onclick="setDefault('{{ $method->id }}')">
  54. {{ trans('admin.setting.common.set_default') }}
  55. </button>
  56. @endcan
  57. @can('admin.config.ss.destroy')
  58. <button class="btn btn-danger" onclick="delConfig('{{ $method->id }}','{{ $method->name }}')">
  59. <i class="icon wb-trash"></i>
  60. </button>
  61. @endcan
  62. </div>
  63. @endif
  64. </td>
  65. </tr>
  66. @endforeach
  67. </tbody>
  68. </table>
  69. </div>
  70. <div class="tab-pane" id="protocol" role="tabpanel">
  71. @can('admin.config.ss.store')
  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. @endcan
  76. <table class="text-md-center" data-toggle="table" data-height="700" data-mobile-responsive="true">
  77. <thead class="thead-default">
  78. <tr>
  79. <th> {{ ucfirst(trans('validation.attributes.name')) }}</th>
  80. <th> {{ trans('common.action') }}</th>
  81. </tr>
  82. </thead>
  83. <tbody>
  84. @foreach ($protocols as $protocol)
  85. <tr>
  86. <td> {{ $protocol->name }}</td>
  87. <td>
  88. @if ($protocol->is_default)
  89. <span class="badge badge-lg badge-default">{{ trans('common.default') }}</span>
  90. @else
  91. <div class="btn-group">
  92. @can('admin.config.ss.update')
  93. <button class="btn btn-primary" onclick="setDefault('{{ $protocol->id }}')">
  94. {{ trans('admin.setting.common.set_default') }}
  95. </button>
  96. @endcan
  97. @can('admin.config.ss.destroy')
  98. <button class="btn btn-danger" onclick="delConfig('{{ $protocol->id }}','{{ $protocol->name }}')">
  99. <i class="icon wb-trash"></i>
  100. </button>
  101. @endcan
  102. </div>
  103. @endif
  104. </td>
  105. </tr>
  106. @endforeach
  107. </tbody>
  108. </table>
  109. </div>
  110. <div class="tab-pane" id="obfs" role="tabpanel">
  111. @can('admin.config.ss.store')
  112. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_config_modal">
  113. <i class="icon wb-plus"></i>
  114. </button>
  115. @endcan
  116. <table class="text-md-center" data-toggle="table" data-height="700" data-mobile-responsive="true">
  117. <thead class="thead-default">
  118. <tr>
  119. <th> {{ ucfirst(trans('validation.attributes.name')) }}</th>
  120. <th> {{ trans('common.action') }}</th>
  121. </tr>
  122. </thead>
  123. <tbody>
  124. @foreach ($obfsList as $obfs)
  125. <tr>
  126. <td> {{ $obfs->name }}</td>
  127. <td>
  128. @if ($obfs->is_default)
  129. <span class="badge badge-lg badge-default">{{ trans('common.default') }}</span>
  130. @else
  131. <div class="btn-group">
  132. @can('admin.config.ss.update')
  133. <button class="btn btn-primary" onclick="setDefault('{{ $obfs->id }}')">
  134. {{ trans('admin.setting.common.set_default') }}
  135. </button>
  136. @endcan
  137. @can('admin.config.ss.destroy')
  138. <button class="btn btn-danger" onclick="delConfig('{{ $obfs->id }}','{{ $obfs->name }}')">
  139. <i class="icon wb-trash"></i>
  140. </button>
  141. @endcan
  142. </div>
  143. @endif
  144. </td>
  145. </tr>
  146. @endforeach
  147. </tbody>
  148. </table>
  149. </div>
  150. <div class="tab-pane" id="level" role="tabpanel">
  151. @can('admin.config.level.store')
  152. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_level_modal">
  153. <i class="icon wb-plus"></i>
  154. </button>
  155. @endcan
  156. <table class="text-md-center" data-toggle="table" data-height="700" data-mobile-responsive="true">
  157. <thead class="thead-default">
  158. <tr>
  159. <th> {{ trans('model.common.level') }}</th>
  160. <th> {{ ucfirst(trans('validation.attributes.name')) }}</th>
  161. <th> {{ trans('common.action') }}</th>
  162. </tr>
  163. </thead>
  164. <tbody>
  165. @foreach ($levels as $level)
  166. <tr>
  167. <td>
  168. <input class="form-control" id="level_{{ $level->id }}" name="level" type="text"
  169. value="{{ $level->level }}" />
  170. </td>
  171. <td>
  172. <input class="form-control" id="level_name_{{ $level->id }}" name="level_name" type="text"
  173. value="{{ $level->name }}" />
  174. </td>
  175. <td>
  176. <div class="btn-group">
  177. @can('admin.config.level.update')
  178. <button class="btn btn-primary" type="button" onclick="updateLevel('{{ $level->id }}')">
  179. <i class="icon wb-edit" aria-hidden="true"></i></button>
  180. @endcan
  181. @can('admin.config.level.destroy')
  182. <button class="btn btn-danger" type="button" onclick="delLevel('{{ $level->id }}','{{ $level->name }}')">
  183. <i class="icon wb-trash"></i></button>
  184. @endcan
  185. </div>
  186. </td>
  187. </tr>
  188. @endforeach
  189. </tbody>
  190. </table>
  191. </div>
  192. <div class="tab-pane" id="category" role="tabpanel">
  193. @can('admin.config.category.store')
  194. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_category_modal">
  195. <i class="icon wb-plus"></i>
  196. </button>
  197. @endcan
  198. <table class="text-md-center" data-toggle="table" data-height="700" data-mobile-responsive="true">
  199. <thead class="thead-default">
  200. <tr>
  201. <th> {{ ucfirst(trans('validation.attributes.name')) }}</th>
  202. <th> {{ trans('model.common.sort') }}</th>
  203. <th> {{ trans('common.action') }}</th>
  204. </tr>
  205. </thead>
  206. <tbody>
  207. @foreach ($categories as $category)
  208. <tr>
  209. <td>
  210. <input class="form-control" id="category_name_{{ $category->id }}" name="name" type="text"
  211. value="{{ $category->name }}" />
  212. </td>
  213. <td>
  214. <input class="form-control" id="category_sort_{{ $category->id }}" name="sort" type="text"
  215. value="{{ $category->sort }}" />
  216. </td>
  217. <td>
  218. <div class="btn-group">
  219. @can('admin.config.category.update')
  220. <button class="btn btn-primary" type="button" onclick="updateCategory('{{ $category->id }}')">
  221. <i class="icon wb-edit" aria-hidden="true"></i></button>
  222. @endcan
  223. @can('admin.config.category.destroy')
  224. <button class="btn btn-danger" type="button"
  225. onclick="delCategory('{{ $category->id }}','{{ $category->name }}')">
  226. <i class="icon wb-trash"></i></button>
  227. @endcan
  228. </div>
  229. </td>
  230. </tr>
  231. @endforeach
  232. </tbody>
  233. </table>
  234. </div>
  235. <div class="tab-pane" id="country" role="tabpanel">
  236. @can('admin.config.country.store')
  237. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_country_modal">
  238. <i class="icon wb-plus"></i>
  239. </button>
  240. @endcan
  241. <table class="text-md-center" data-toggle="table" data-height="700" data-mobile-responsive="true">
  242. <thead class="thead-default">
  243. <tr>
  244. <th> {{ trans('model.country.icon') }}</th>
  245. <th> {{ trans('model.country.code') }}</th>
  246. <th> {{ trans('model.country.name') }}</th>
  247. <th> {{ trans('common.action') }}</th>
  248. </tr>
  249. </thead>
  250. <tbody>
  251. @foreach ($countries as $country)
  252. <tr>
  253. <td>
  254. <i class="fi fis fi-{{ $country->code }} h-40 w-40" aria-hidden="true"></i>
  255. </td>
  256. <td>
  257. {{ $country->code }}
  258. </td>
  259. <td>
  260. <input class="form-control" id="country_{{ $country->code }}" name="country_name" type="text"
  261. value="{{ $country->name }}" />
  262. </td>
  263. <td>
  264. <div class="btn-group">
  265. @can('admin.config.country.update')
  266. <button class="btn btn-primary" type="button" onclick="updateCountry('{{ $country->code }}')">
  267. <i class="icon wb-edit" aria-hidden="true"></i></button>
  268. @endcan
  269. @can('admin.config.country.destroy')
  270. <button class="btn btn-danger" type="button"
  271. onclick="delCountry('{{ $country->code }}','{{ $country->name }}')">
  272. <i class="icon wb-trash"></i></button>
  273. @endcan
  274. </div>
  275. </td>
  276. </tr>
  277. @endforeach
  278. </tbody>
  279. </table>
  280. </div>
  281. <div class="tab-pane" id="label" role="tabpanel">
  282. @can('admin.config.label.store')
  283. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_label_modal">
  284. <i class="icon wb-plus"></i>
  285. </button>
  286. @endcan
  287. <table class="text-md-center" data-toggle="table" data-height="700" data-mobile-responsive="true">
  288. <thead class="thead-default">
  289. <tr>
  290. <th> {{ ucfirst(trans('validation.attributes.name')) }}</th>
  291. <th> {{ trans('admin.setting.common.connect_nodes') }}</th>
  292. <th> {{ trans('model.common.sort') }}</th>
  293. <th> {{ trans('common.action') }}</th>
  294. </tr>
  295. </thead>
  296. <tbody>
  297. @foreach ($labels as $label)
  298. <tr>
  299. <td>
  300. <input class="form-control" id="label_name_{{ $label->id }}" name="label_name" type="text"
  301. value="{{ $label->name }}" />
  302. </td>
  303. <td> {{ $label->nodes_count }} </td>
  304. <td>
  305. <input class="form-control" id="label_sort_{{ $label->id }}" name="label_sort" type="number"
  306. value="{{ $label->sort }}" />
  307. </td>
  308. <td>
  309. <div class="btn-group">
  310. @can('admin.config.label.update')
  311. <button class="btn btn-primary" type="button" onclick="updateLabel('{{ $label->id }}')">
  312. <i class="icon wb-edit" aria-hidden="true"></i></button>
  313. @endcan
  314. @can('admin.config.label.destroy')
  315. <button class="btn btn-danger" type="button" onclick="delLabel('{{ $label->id }}','{{ $label->name }}')">
  316. <i class="icon wb-trash"></i></button>
  317. @endcan
  318. </div>
  319. </td>
  320. </tr>
  321. @endforeach
  322. </tbody>
  323. </table>
  324. </div>
  325. </div>
  326. </div>
  327. </x-ui.panel>
  328. </div>
  329. @can('admin.config.ss.store')
  330. <x-ui.modal id="add_config_modal" form :title="trans('common.add')">
  331. <form class="modal-body" action="#" method="post">
  332. <div class="alert alert-danger" id="msg" style="display: none;"></div>
  333. <div class="row">
  334. <div class="col-md-6 form-group">
  335. <select class="form-control" id="type" name="type">
  336. <option value="1" selected>{{ trans('model.node.method') }}</option>
  337. <option value="2">{{ trans('model.node.protocol') }}</option>
  338. <option value="3">{{ trans('model.node.obfs') }}</option>
  339. </select>
  340. </div>
  341. <div class="col-md-6 form-group">
  342. <input class="form-control" id="name" name="name" type="text" placeholder="{{ ucfirst(trans('validation.attributes.name')) }}">
  343. </div>
  344. </div>
  345. </form>
  346. <x-slot:actions>
  347. <button class="btn btn-primary" onclick="addConfig()">{{ trans('common.submit') }}</button>
  348. </x-slot:actions>
  349. </x-ui.modal>
  350. @endcan
  351. @can('admin.config.level.store')
  352. <x-ui.modal id="add_level_modal" form :title="trans('admin.action.add_item', ['attribute' => trans('model.common.level')])">
  353. <form class="modal-body" action="#" method="post">
  354. <div class="alert alert-danger" id="level_msg" style="display: none;"></div>
  355. <div class="row">
  356. <div class="col-md-6 form-group">
  357. <input class="form-control" id="add_level" name="level" type="text" placeholder="{{ trans('model.common.level') }}">
  358. </div>
  359. <div class="col-md-6 form-group">
  360. <input class="form-control" id="add_level_name" name="level_name" type="text"
  361. placeholder="{{ ucfirst(trans('validation.attributes.name')) }}">
  362. </div>
  363. </div>
  364. </form>
  365. <x-slot:actions>
  366. <button class="btn btn-primary" onclick="addLevel()">{{ trans('common.submit') }}</button>
  367. </x-slot:actions>
  368. </x-ui.modal>
  369. @endcan
  370. @can('admin.config.category.store')
  371. <x-ui.modal id="add_category_modal" form :title="trans('admin.action.add_item', ['attribute' => trans('model.goods.category')])">
  372. <form class="modal-body" action="#" method="post">
  373. <div class="alert alert-danger" id="category_msg" style="display: none;"></div>
  374. <div class="row">
  375. <div class="col-md-6 form-group">
  376. <input class="form-control" id="add_category_name" name="name" type="text"
  377. placeholder="{{ ucfirst(trans('validation.attributes.name')) }}">
  378. </div>
  379. <div class="col-md-6 form-group">
  380. <input class="form-control" id="add_category_sort" name="sort" type="text" placeholder="{{ trans('model.common.sort') }}">
  381. </div>
  382. </div>
  383. </form>
  384. <x-slot:actions>
  385. <button class="btn btn-primary" onclick="addCategory()">{{ trans('common.submit') }}</button>
  386. </x-slot:actions>
  387. </x-ui.modal>
  388. @endcan
  389. @can('admin.config.country.store')
  390. <x-ui.modal id="add_country_modal" form :title="trans('admin.action.add_item', ['attribute' => trans('model.country.name')])">
  391. <form class="modal-body" action="#" method="post">
  392. <div class="alert alert-danger" id="country_msg" style="display: none;"></div>
  393. <div class="row">
  394. <div class="col-md-6 form-group">
  395. <input class="form-control" id="add_country_code" name="country_code" type="text" placeholder="{{ trans('model.country.code') }}">
  396. </div>
  397. <div class="col-md-6 form-group">
  398. <input class="form-control" id="add_country_name" name="country_name" type="text" placeholder="{{ trans('model.country.name') }}">
  399. </div>
  400. </div>
  401. </form>
  402. <x-slot:actions>
  403. <button class="btn btn-primary" onclick="addCountry()">{{ trans('common.submit') }}</button>
  404. </x-slot:actions>
  405. </x-ui.modal>
  406. @endcan
  407. @can('admin.config.label.store')
  408. <x-ui.modal id="add_label_modal" form :title="trans('admin.action.add_item', ['attribute' => trans('model.node.label')])">
  409. <form class="modal-body" action="#" method="post">
  410. <div class="alert alert-danger" id="label_msg" style="display: none;"></div>
  411. <div class="row">
  412. <div class="col-md-6 form-group">
  413. <input class="form-control" id="add_label" name="label" type="text" placeholder="{{ ucfirst(trans('validation.attributes.name')) }}">
  414. </div>
  415. <div class="col-md-6 form-group">
  416. <input class="form-control" id="add_label_sort" name="label_sort" type="text" placeholder="{{ trans('model.common.sort') }}">
  417. </div>
  418. </div>
  419. </form>
  420. <x-slot:actions>
  421. <button class="btn btn-primary" onclick="addLabel()">{{ trans('common.submit') }}</button>
  422. </x-slot:actions>
  423. </x-ui.modal>
  424. @endcan
  425. @endsection
  426. @push('javascript')
  427. <script src="/assets/custom/jump-tab.js"></script>
  428. <script>
  429. @can('admin.config.level.store')
  430. function addLevel() { // 添加等级
  431. const level = $("#add_level").val();
  432. const name = $("#add_level_name").val();
  433. if (level.trim() === "") {
  434. $("#level_msg").show().html('{{ trans('validation.required', ['attribute' => trans('model.common.level')]) }}');
  435. $("#add_level").focus();
  436. return false;
  437. }
  438. if (name.trim() === "") {
  439. $("#level_msg").show().html('{{ trans('validation.required', ['attribute' => ucfirst(trans('validation.attributes.name'))]) }}');
  440. $("#add_level_name").focus();
  441. return false;
  442. }
  443. ajaxPost("{{ route('admin.config.level.store') }}", {
  444. level: level,
  445. name: name
  446. }, {
  447. beforeSend: function() {
  448. $("#level_msg").show().html('{{ trans('admin.creating') }}');
  449. },
  450. success: function(ret) {
  451. if (ret.status === "fail") {
  452. $("#level_msg").show().html(ret.message);
  453. return false;
  454. }
  455. $("#add_level_modal").modal("hide");
  456. handleResponse(ret);
  457. },
  458. error: function() {
  459. $("#level_msg").show().html('{{ trans('common.request_failed') }}');
  460. }
  461. });
  462. }
  463. @endcan
  464. @can('admin.config.level.update')
  465. function updateLevel(id) { // 更新等级
  466. ajaxPut(jsRoute('{{ route('admin.config.level.update', 'PLACEHOLDER') }}', id), {
  467. level: $(`#level_${id}`).val(),
  468. name: $(`#level_name_${id}`).val()
  469. });
  470. }
  471. @endcan
  472. @can('admin.config.level.destroy')
  473. function delLevel(id, name) { // 删除配置
  474. confirmDelete(jsRoute('{{ route('admin.config.level.destroy', 'PLACEHOLDER') }}', id), name);
  475. }
  476. @endcan
  477. @can('admin.config.category.store')
  478. function addCategory() { // 添加分类
  479. const name = $("#add_category_name").val();
  480. const sort = $("#add_category_sort").val();
  481. if (name.trim() === "") {
  482. $("#category_msg").show().html('{{ trans('validation.required', ['attribute' => ucfirst(trans('validation.attributes.name'))]) }}');
  483. $("#add_category_name").focus();
  484. return false;
  485. }
  486. if (sort.trim() === "") {
  487. $("#category_msg").show().html('{{ trans('validation.required', ['attribute' => trans('model.common.sort')]) }}');
  488. $("#add_category_sort").focus();
  489. return false;
  490. }
  491. ajaxPost("{{ route('admin.config.category.store') }}", {
  492. name: name,
  493. sort: sort
  494. }, {
  495. beforeSend: function() {
  496. $("#category_msg").show().html('{{ trans('admin.creating') }}');
  497. },
  498. success: function(ret) {
  499. if (ret.status === "fail") {
  500. $("#category_msg").show().html(ret.message);
  501. return false;
  502. }
  503. $("#add_category_modal").modal("hide");
  504. handleResponse(ret);
  505. },
  506. error: function() {
  507. $("#category_msg").show().html('{{ trans('common.request_failed') }}');
  508. }
  509. });
  510. }
  511. @endcan
  512. @can('admin.config.category.update')
  513. function updateCategory(id) { // 更新分类
  514. ajaxPut(jsRoute('{{ route('admin.config.category.update', 'PLACEHOLDER') }}', id), {
  515. name: $(`#category_name_${id}`).val(),
  516. sort: $(`#category_sort_${id}`).val()
  517. });
  518. }
  519. @endcan
  520. @can('admin.config.category.destroy')
  521. function delCategory(id, name) { // 删除分类
  522. confirmDelete(jsRoute('{{ route('admin.config.category.destroy', 'PLACEHOLDER') }}', id), name);
  523. }
  524. @endcan
  525. @can('admin.config.country.store')
  526. function addCountry() { // 添加国家/地区
  527. const country_name = $("#add_country_name").val();
  528. const country_code = $("#add_country_code").val();
  529. if (country_code.trim() === "") {
  530. $("#country_msg").show().html('{{ trans('validation.required', ['attribute' => ucfirst(trans('validation.attributes.national_code'))]) }}');
  531. $("#add_country_code").focus();
  532. return false;
  533. }
  534. if (country_name.trim() === "") {
  535. $("#country_msg").show().html('{{ trans('validation.required', ['attribute' => trans('model.country.name')]) }}');
  536. $("#add_country_name").focus();
  537. return false;
  538. }
  539. ajaxPost("{{ route('admin.config.country.store') }}", {
  540. code: country_code,
  541. name: country_name
  542. }, {
  543. beforeSend: function() {
  544. $("#country_msg").show().html('{{ trans('admin.creating') }}');
  545. },
  546. success: function(ret) {
  547. if (ret.status === "fail") {
  548. $("#country_msg").show().html(ret.message);
  549. return false;
  550. }
  551. $("#add_country_modal").modal("hide");
  552. handleResponse(ret);
  553. },
  554. error: function() {
  555. $("#country_msg").show().html('{{ trans('common.request_failed') }}');
  556. }
  557. });
  558. }
  559. @endcan
  560. @can('admin.config.country.update')
  561. function updateCountry(code) { // 更新国家/地区
  562. ajaxPut(jsRoute('{{ route('admin.config.country.update', 'PLACEHOLDER') }}', code), {
  563. name: $("#country_" + code).val()
  564. });
  565. }
  566. @endcan
  567. @can('admin.config.country.destroy')
  568. function delCountry(code, name) { // 删除国家/地区
  569. confirmDelete(jsRoute('{{ route('admin.config.country.destroy', 'PLACEHOLDER') }}', code), name, '{{ trans('model.node.country') }}');
  570. }
  571. @endcan
  572. @can('admin.config.ss.store')
  573. function addConfig() { // 添加配置
  574. const name = $("#name").val();
  575. const type = $("#type").val();
  576. if (name.trim() === "") {
  577. $("#msg").show().html('{{ trans('validation.required', ['attribute' => ucfirst(trans('validation.attributes.name'))]) }}');
  578. $("#name").focus();
  579. return false;
  580. }
  581. ajaxPost("{{ route('admin.config.ss.store') }}", {
  582. name: name,
  583. type: type
  584. }, {
  585. beforeSend: function() {
  586. $("#msg").show().html('{{ trans('admin.creating') }}');
  587. },
  588. success: function(ret) {
  589. if (ret.status === "fail") {
  590. $("#msg").show().html(ret.message);
  591. return false;
  592. }
  593. $("#add_config_modal").modal("hide");
  594. handleResponse(ret);
  595. },
  596. error: function() {
  597. $("#msg").show().html('{{ trans('common.request_failed') }}');
  598. }
  599. });
  600. }
  601. @endcan
  602. @can('admin.config.ss.update')
  603. function setDefault(id) { // 置为默认
  604. ajaxPut(jsRoute('{{ route('admin.config.ss.update', 'PLACEHOLDER') }}', id));
  605. }
  606. @endcan
  607. @can('admin.config.ss.destroy')
  608. function delConfig(id, name) { // 删除配置
  609. confirmDelete(jsRoute('{{ route('admin.config.ss.destroy', 'PLACEHOLDER') }}', id), name);
  610. }
  611. @endcan
  612. @can('admin.config.label.store')
  613. function addLabel() { // 添加标签
  614. const name = $("#add_label").val();
  615. const sort = $("#add_label_sort").val();
  616. if (name.trim() === "") {
  617. $("#label_msg").show().html('{{ trans('validation.required', ['attribute' => ucfirst(trans('validation.attributes.name'))]) }}');
  618. return false;
  619. }
  620. if (sort.trim() === "") {
  621. $("#label_msg").show().html('{{ trans('validation.required', ['attribute' => trans('model.common.sort')]) }}');
  622. return false;
  623. }
  624. ajaxPost("{{ route('admin.config.label.store') }}", {
  625. name: name,
  626. sort: sort
  627. }, {
  628. beforeSend: function() {
  629. $("#label_msg").show().html('{{ trans('admin.creating') }}');
  630. },
  631. success: function(ret) {
  632. if (ret.status === "fail") {
  633. $("#label_msg").show().html(ret.message);
  634. return false;
  635. }
  636. $("#add_label_modal").modal("hide");
  637. handleResponse(ret);
  638. },
  639. error: function() {
  640. $("#label_msg").show().html('{{ trans('common.request_failed') }}');
  641. }
  642. });
  643. }
  644. @endcan
  645. @can('admin.config.label.update')
  646. function updateLabel(id) { // 编辑标签
  647. ajaxPut(jsRoute('{{ route('admin.config.label.update', 'PLACEHOLDER') }}', id), {
  648. name: $(`#label_name_${id}`).val(),
  649. sort: $(`#label_sort_${id}`).val()
  650. });
  651. }
  652. @endcan
  653. @can('admin.config.label.destroy')
  654. function delLabel(id, name) { // 删除标签
  655. confirmDelete(jsRoute('{{ route('admin.config.label.destroy', 'PLACEHOLDER') }}', id), name, '{{ trans('model.node.label') }}');
  656. }
  657. @endcan
  658. </script>
  659. @endpush