config.blade.php 37 KB

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