config.blade.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. @extends('admin.layouts')
  2. @section('css')
  3. <script src="//at.alicdn.com/t/font_682457_e6aq10jsbq0yhkt9.js"></script>
  4. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.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($methods 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($protocols 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($levels 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($countries 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($labels 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/custom/jump-tab.js"></script>
  367. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js"></script>
  368. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
  369. <script>
  370. @can('admin.config.level.store')
  371. // 添加等级
  372. function addLevel() {
  373. const level = $('#add_level').val();
  374. const level_name = $('#add_level_name').val();
  375. if (level.trim() === '') {
  376. $('#level_msg').show().html('等级不能为空');
  377. $('#level').focus();
  378. return false;
  379. }
  380. if (level_name.trim() === '') {
  381. $('#level_msg').show().html('等级名称不能为空');
  382. $('#level_name').focus();
  383. return false;
  384. }
  385. $.ajax({
  386. url: '{{route('admin.config.level.store')}}',
  387. method: 'POST',
  388. data: {_token: '{{csrf_token()}}', level: level, level_name: level_name},
  389. beforeSend: function() {
  390. $('#level_msg').show().html('正在添加');
  391. },
  392. success: function(ret) {
  393. if (ret.status === 'fail') {
  394. $('#level_msg').show().html(ret.message);
  395. return false;
  396. }
  397. $('#add_level_modal').modal('hide');
  398. window.location.reload();
  399. },
  400. error: function() {
  401. $('#level_msg').show().html('请求错误,请重试');
  402. },
  403. complete: function() {
  404. swal.fire({title: '添加成功', icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  405. },
  406. });
  407. }
  408. @else
  409. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  410. @endcan
  411. @can('admin.config.level.update')
  412. // 更新等级
  413. function updateLevel(id) {
  414. $.ajax({
  415. method: 'PUT',
  416. url: '{{route('admin.config.level.update', '')}}/' + id,
  417. data: {
  418. _token: '{{csrf_token()}}',
  419. level: $('#level_' + id).val(),
  420. level_name: $('#level_name_' + id).val(),
  421. },
  422. dataType: 'json',
  423. success: function(ret) {
  424. if (ret.status === 'success') {
  425. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  426. } else {
  427. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  428. }
  429. },
  430. });
  431. }
  432. @else
  433. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  434. @endcan
  435. @can('admin.config.level.destroy')
  436. // 删除等级
  437. function delLevel(id, name) {
  438. swal.fire({
  439. title: '确定删除等级 【' + name + '】 ?',
  440. icon: 'question',
  441. allowEnterKey: false,
  442. showCancelButton: true,
  443. cancelButtonText: '{{trans('home.ticket_close')}}',
  444. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  445. }).then((result) => {
  446. if (result.value) {
  447. $.ajax({
  448. method: 'DELETE',
  449. url: '{{route('admin.config.level.destroy', '')}}/' + id,
  450. data: {_token: '{{csrf_token()}}'},
  451. dataType: 'json',
  452. success: function(ret) {
  453. if (ret.status === 'success') {
  454. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  455. } else {
  456. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  457. }
  458. },
  459. });
  460. }
  461. });
  462. }
  463. @else
  464. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  465. @endcan
  466. @can('admin.config.country.store')
  467. // 添加国家/地区
  468. function addCountry() {
  469. const country_name = $('#add_country_name').val();
  470. const country_code = $('#add_country_code').val();
  471. if (country_code.trim() === '') {
  472. $('#country_msg').show().html('国家/地区代码不能为空');
  473. $('#add_country_code').focus();
  474. return false;
  475. }
  476. if (country_name.trim() === '') {
  477. $('#country_msg').show().html('国家/地区名称不能为空');
  478. $('#add_country_name').focus();
  479. return false;
  480. }
  481. $.ajax({
  482. url: '{{route('admin.config.country.store')}}',
  483. method: 'POST',
  484. data: {_token: '{{csrf_token()}}', code: country_code, name: country_name},
  485. beforeSend: function() {
  486. $('#country_msg').show().html('正在添加');
  487. },
  488. success: function(ret) {
  489. if (ret.status === 'fail') {
  490. $('#country_msg').show().html(ret.message);
  491. return false;
  492. }
  493. $('#add_country_modal').modal('hide');
  494. window.location.reload();
  495. },
  496. error: function() {
  497. $('#country_msg').show().html('请求错误,请重试');
  498. },
  499. complete: function() {
  500. swal.fire({
  501. title: '添加成功',
  502. icon: 'success',
  503. timer: 1000,
  504. showConfirmButton: false,
  505. }).then(() => window.location.reload());
  506. },
  507. });
  508. }
  509. @else
  510. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  511. @endcan
  512. @can('admin.config.country.update')
  513. // 更新国家/地区
  514. function updateCountry(code) {
  515. $.ajax({
  516. method: 'PUT',
  517. url: '{{route('admin.config.country.update', '')}}/' + code,
  518. data: {_token: '{{csrf_token()}}', name: $('#country_' + code).val()},
  519. dataType: 'json',
  520. success: function(ret) {
  521. if (ret.status === 'success') {
  522. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  523. } else {
  524. swal.fire({title: ret.message, icon: 'error'});
  525. }
  526. },
  527. });
  528. }
  529. @else
  530. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  531. @endcan
  532. @can('admin.config.country.destroy')
  533. // 删除国家/地区
  534. function delCountry(code, name) {
  535. swal.fire({
  536. title: '确定删除 【' + name + '】 信息?',
  537. icon: 'question',
  538. allowEnterKey: false,
  539. showCancelButton: true,
  540. cancelButtonText: '{{trans('home.ticket_close')}}',
  541. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  542. }).then((result) => {
  543. if (result.value) {
  544. $.ajax({
  545. method: 'DELETE',
  546. url: '{{route('admin.config.country.destroy', '')}}/' + code,
  547. data: {_token: '{{csrf_token()}}'},
  548. dataType: 'json',
  549. success: function(ret) {
  550. if (ret.status === 'success') {
  551. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  552. } else {
  553. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  554. }
  555. },
  556. });
  557. }
  558. });
  559. }
  560. @else
  561. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  562. @endcan
  563. @can('admin.config.ss.store')
  564. // 添加配置
  565. function addConfig() {
  566. const name = $('#name').val();
  567. const type = $('#type').val();
  568. if (name.trim() === '') {
  569. $('#msg').show().html('名称不能为空');
  570. $('#name').focus();
  571. return false;
  572. }
  573. $.ajax({
  574. url: '{{route('admin.config.ss.store')}}',
  575. method: 'POST',
  576. data: {_token: '{{csrf_token()}}', name: name, type: type},
  577. dataType: 'json',
  578. beforeSend: function() {
  579. $('#msg').show().html('正在添加');
  580. },
  581. success: function(ret) {
  582. if (ret.status === 'fail') {
  583. $('#msg').show().html(ret.message);
  584. return false;
  585. }
  586. $('#add_config_modal').modal('hide');
  587. },
  588. error: function() {
  589. $('#msg').show().html('请求错误,请重试');
  590. },
  591. complete: function() {
  592. swal.fire({title: '添加成功', icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  593. },
  594. });
  595. }
  596. @else
  597. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  598. @endcan
  599. @can('admin.config.ss.update')
  600. // 置为默认
  601. function setDefault(id) {
  602. $.ajax({
  603. method: 'PUT',
  604. url: '{{route('admin.config.ss.update', '')}}/' + id,
  605. data: {_token: '{{csrf_token()}}'},
  606. dataType: 'json',
  607. success: function(ret) {
  608. if (ret.status === 'success') {
  609. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  610. } else {
  611. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  612. }
  613. },
  614. });
  615. }
  616. @else
  617. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  618. @endcan
  619. @can('admin.config.ss.destroy')
  620. // 删除配置
  621. function delConfig(id, name) {
  622. swal.fire({
  623. title: '确定删除配置 【' + name + '】 ?',
  624. icon: 'question',
  625. allowEnterKey: false,
  626. showCancelButton: true,
  627. cancelButtonText: '{{trans('home.ticket_close')}}',
  628. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  629. }).then((result) => {
  630. if (result.value) {
  631. $.ajax({
  632. method: 'DELETE',
  633. url: '{{route('admin.config.ss.destroy', '')}}/' + id,
  634. data: {_token: '{{csrf_token()}}'},
  635. dataType: 'json',
  636. success: function(ret) {
  637. if (ret.status === 'success') {
  638. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  639. } else {
  640. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  641. }
  642. },
  643. });
  644. }
  645. });
  646. }
  647. @else
  648. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  649. @endcan
  650. @can('admin.config.label.store')
  651. // 添加标签
  652. function addLabel() {
  653. const name = $('#add_label').val();
  654. const sort = $('#add_label_sort').val();
  655. if (name.trim() === '') {
  656. $('#lable_msg').show().html('标签不能为空');
  657. return false;
  658. }
  659. if (sort.trim() === '') {
  660. $('#lable_msg').show().html('标签排序不能为空');
  661. return false;
  662. }
  663. $.ajax({
  664. url: '{{route('admin.config.label.store')}}',
  665. method: 'POST',
  666. data: {_token: '{{csrf_token()}}', name: name, sort: sort},
  667. beforeSend: function() {
  668. $('#level_msg').show().html('正在添加');
  669. },
  670. success: function(ret) {
  671. if (ret.status === 'fail') {
  672. $('#lable_msg').show().html(ret.message);
  673. return false;
  674. }
  675. $('#add_label_modal').modal('hide');
  676. window.location.reload();
  677. },
  678. error: function() {
  679. $('#lable_msg').show().html('请求错误,请重试');
  680. },
  681. complete: function() {
  682. swal.fire({
  683. title: '添加成功',
  684. icon: 'success',
  685. timer: 1000,
  686. showConfirmButton: false,
  687. }).then(() => window.location.reload());
  688. },
  689. });
  690. }
  691. @else
  692. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  693. @endcan
  694. @can('admin.config.label.update')
  695. // 编辑标签
  696. function updateLabel(id) {
  697. $.ajax({
  698. method: 'PUT',
  699. url: '{{route('admin.config.label.update', '')}}/' + id,
  700. data: {
  701. _token: '{{csrf_token()}}',
  702. name: $('#label_name_' + id).val(),
  703. sort: $('#label_sort_' + id).val(),
  704. },
  705. dataType: 'json',
  706. success: function(ret) {
  707. if (ret.status === 'success') {
  708. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  709. } else {
  710. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  711. }
  712. },
  713. });
  714. }
  715. @else
  716. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  717. @endcan
  718. @can('admin.config.label.destroy')
  719. // 删除标签
  720. function delLabel(id, name) {
  721. swal.fire({
  722. title: '警告',
  723. text: '确定删除标签 【' + name + '】 ?',
  724. icon: 'warning',
  725. showCancelButton: true,
  726. cancelButtonText: '{{trans('home.ticket_close')}}',
  727. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  728. }).then((result) => {
  729. $.ajax({
  730. method: 'DELETE',
  731. url: '{{route('admin.config.label.destroy', '')}}/' + id,
  732. data: {_token: '{{csrf_token()}}'},
  733. dataType: 'json',
  734. success: function(ret) {
  735. if (ret.status === 'success') {
  736. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  737. } else {
  738. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  739. }
  740. },
  741. });
  742. });
  743. }
  744. @else
  745. swal.fire({title: '您没有权限修改参数!', icon: 'error', timer: 1500, showConfirmButton: false});
  746. @endcan
  747. </script>
  748. @endsection