config.blade.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  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. <button class="btn btn-primary" onclick="setDefault('{{$obfs->id}}')">
  123. 默认
  124. </button>
  125. <button class="btn btn-danger" onclick="delConfig('{{$obfs->id}}','{{$obfs->name}}')">
  126. <i class="icon wb-trash"></i>
  127. </button>
  128. @endif
  129. </td>
  130. </tr>
  131. @endforeach
  132. </tbody>
  133. </table>
  134. </div>
  135. <div class="tab-pane" id="level" role="tabpanel">
  136. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_level_modal">
  137. 新增<i class="icon wb-plus"></i>
  138. </button>
  139. <table class="text-md-center" data-toggle="table" data-height="700" data-virtual-scroll="true" data-mobile-responsive="true">
  140. <thead class="thead-default">
  141. <tr>
  142. <th> 等级</th>
  143. <th> 名称</th>
  144. <th> 操作</th>
  145. </tr>
  146. </thead>
  147. <tbody>
  148. @foreach($levelList as $level)
  149. <tr>
  150. <td>
  151. <input type="text" class="form-control" name="level" id="level_{{$level->id}}" value="{{$level->level}}"/>
  152. </td>
  153. <td>
  154. <input type="text" class="form-control" name="level_name" id="level_name_{{$level->id}}" value="{{$level->name}}"/>
  155. </td>
  156. <td>
  157. <div class="btn-group">
  158. <button type="button" class="btn btn-primary" onclick="updateLevel('{{$level->id}}')">
  159. <i class="icon wb-edit" aria-hidden="true"></i></button>
  160. <button type="button" class="btn btn-danger" onclick="delLevel('{{$level->id}}','{{$level->name}}')">
  161. <i class="icon wb-trash"></i></button>
  162. </div>
  163. </td>
  164. </tr>
  165. @endforeach
  166. </tbody>
  167. </table>
  168. </div>
  169. <div class="tab-pane" id="country" role="tabpanel">
  170. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_country_modal">
  171. 新增<i class="icon wb-plus"></i>
  172. </button>
  173. <table class="text-md-center" data-toggle="table" data-height="700" data-virtual-scroll="true" data-mobile-responsive="true">
  174. <thead class="thead-default">
  175. <tr>
  176. <th> 图标</th>
  177. <th> 代码</th>
  178. <th> 国家/地区名称</th>
  179. <th> 操作</th>
  180. </tr>
  181. </thead>
  182. <tbody>
  183. @foreach($countryList as $country)
  184. <tr>
  185. <td>
  186. <svg class="w-40 h-40 text-center" aria-hidden="true">
  187. <use xlink:href="@if($country->code)#icon-{{$country->code}}@endif"></use>
  188. </svg>
  189. </td>
  190. <td>
  191. {{$country->code}}
  192. </td>
  193. <td>
  194. <input type="text" class="form-control" name="country_name" id="country_{{$country->code}}" value="{{$country->name}}"/>
  195. </td>
  196. <td>
  197. <div class="btn-group">
  198. <button type="button" class="btn btn-primary" onclick="updateCountry('{{$country->code}}')">
  199. <i class="icon wb-edit" aria-hidden="true"></i></button>
  200. <button type="button" class="btn btn-danger" onclick="delCountry('{{$country->code}}','{{$country->name}}')">
  201. <i class="icon wb-trash"></i></button>
  202. </div>
  203. </td>
  204. </tr>
  205. @endforeach
  206. </tbody>
  207. </table>
  208. </div>
  209. <div class="tab-pane" id="label" role="tabpanel">
  210. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_label_modal">
  211. 新增<i class="icon wb-plus"></i>
  212. </button>
  213. <table class="text-md-center" data-toggle="table" data-height="700" data-virtual-scroll="true" data-mobile-responsive="true">
  214. <thead class="thead-default">
  215. <tr>
  216. <th> 名称</th>
  217. <th> 关联节点数</th>
  218. <th> 排序</th>
  219. <th> 操作</th>
  220. </tr>
  221. </thead>
  222. <tbody>
  223. @foreach($labelList as $label)
  224. <tr>
  225. <td>
  226. <input type="text" class="form-control" name="label_name" id="label_name_{{$label->id}}" value="{{$label->name}}"/>
  227. </td>
  228. <td> {{$label->nodes->count()}} </td>
  229. <td>
  230. <input type="number" class="form-control" name="label_sort" id="label_sort_{{$label->id}}" value="{{$label->sort}}"/>
  231. </td>
  232. <td>
  233. <div class="btn-group">
  234. <button type="button" class="btn btn-primary" onclick="updateLabel('{{$label->id}}')">
  235. <i class="icon wb-edit" aria-hidden="true"></i></button>
  236. <button type="button" class="btn btn-danger" onclick="delLabel('{{$label->id}}','{{$label->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>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. <div class="modal fade" id="add_config_modal" aria-hidden="true" role="dialog" tabindex="-1">
  251. <div class="modal-dialog modal-simple modal-center">
  252. <div class="modal-content">
  253. <div class="modal-header">
  254. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  255. <span aria-hidden="true">×</span>
  256. </button>
  257. <h4 class="modal-title">新增配置</h4>
  258. </div>
  259. <form action="#" method="post" class="modal-body">
  260. <div class="alert alert-danger" style="display: none;" id="msg"></div>
  261. <div class="row">
  262. <div class="col-md-6 form-group">
  263. <select class="form-control" name="type" id="type" placeholder="类型">
  264. <option value="1" selected>加密方式</option>
  265. <option value="2">协议</option>
  266. <option value="3">混淆</option>
  267. </select>
  268. </div>
  269. <div class="col-md-6 form-group">
  270. <input type="text" class="form-control" name="name" id="name" placeholder="名称">
  271. </div>
  272. </div>
  273. </form>
  274. <div class="modal-footer">
  275. <button class="btn btn-danger" data-dismiss="modal">关 闭</button>
  276. <button class="btn btn-primary" onclick="addConfig()">提 交</button>
  277. </div>
  278. </div>
  279. </div>
  280. </div>
  281. <div class="modal fade" id="add_level_modal" aria-hidden="true" role="dialog" tabindex="-1">
  282. <div class="modal-dialog modal-simple modal-center">
  283. <div class="modal-content">
  284. <div class="modal-header">
  285. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  286. <span aria-hidden="true">×</span>
  287. </button>
  288. <h4 class="modal-title">新增等级</h4>
  289. </div>
  290. <form action="#" method="post" class="modal-body">
  291. <div class="alert alert-danger" style="display: none;" id="level_msg"></div>
  292. <div class="row">
  293. <div class="col-md-6 form-group">
  294. <input type="text" class="form-control" name="level" id="add_level" placeholder="等级">
  295. </div>
  296. <div class="col-md-6 form-group">
  297. <input type="text" class="form-control" name="level_name" id="add_level_name" placeholder="等级名称">
  298. </div>
  299. </div>
  300. </form>
  301. <div class="modal-footer">
  302. <button data-dismiss="modal" class="btn btn-danger">关 闭</button>
  303. <button class="btn btn-primary" onclick="addLevel()">提 交</button>
  304. </div>
  305. </div>
  306. </div>
  307. </div>
  308. <div class="modal fade" id="add_country_modal" aria-hidden="true" role="dialog" tabindex="-1">
  309. <div class="modal-dialog modal-simple modal-center">
  310. <div class="modal-content">
  311. <div class="modal-header">
  312. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  313. <span aria-hidden="true">×</span>
  314. </button>
  315. <h4 class="modal-title">新增国家/地区</h4>
  316. </div>
  317. <form action="#" method="post" class="modal-body">
  318. <div class="alert alert-danger" style="display: none;" id="country_msg"></div>
  319. <div class="row">
  320. <div class="col-md-6 form-group">
  321. <input type="text" class="form-control" name="country_code" id="add_country_code" placeholder="ISO国家代码">
  322. </div>
  323. <div class="col-md-6 form-group">
  324. <input type="text" class="form-control" name="country_name" id="add_country_name" placeholder=" 国家/地区名称">
  325. </div>
  326. </div>
  327. </form>
  328. <div class="modal-footer">
  329. <button data-dismiss="modal" class="btn btn-danger">关 闭</button>
  330. <button class="btn btn-primary" onclick="addCountry()">提 交</button>
  331. </div>
  332. </div>
  333. </div>
  334. </div>
  335. <div class="modal fade" id="add_label_modal" aria-hidden="true" role="dialog" tabindex="-1">
  336. <div class="modal-dialog modal-simple modal-center">
  337. <div class="modal-content">
  338. <div class="modal-header">
  339. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  340. <span aria-hidden="true">×</span>
  341. </button>
  342. <h4 class="modal-title">新增标签</h4>
  343. </div>
  344. <form action="#" method="post" class="modal-body">
  345. <div class="alert alert-danger" style="display: none;" id="lable_msg"></div>
  346. <div class="row">
  347. <div class="col-md-6 form-group">
  348. <input type="text" class="form-control" name="label" id="add_label" placeholder="标签">
  349. </div>
  350. <div class="col-md-6 form-group">
  351. <input type="text" class="form-control" name="label_sort" id="add_label_sort" placeholder="排序">
  352. </div>
  353. </div>
  354. </form>
  355. <div class="modal-footer">
  356. <button data-dismiss="modal" class="btn btn-danger">关 闭</button>
  357. <button class="btn btn-primary" onclick="addLabel()">提 交</button>
  358. </div>
  359. </div>
  360. </div>
  361. </div>
  362. @endsection
  363. @section('script')
  364. <script src="/assets/global/js/Plugin/tabs.js" type="text/javascript"></script>
  365. <script src="/assets/custom/jump-tab.js" type="text/javascript"></script>
  366. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  367. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  368. <script type="text/javascript">
  369. // 添加等级
  370. function addLevel() {
  371. const level = $('#add_level').val();
  372. const level_name = $('#add_level_name').val();
  373. if (level.trim() === '') {
  374. $('#level_msg').show().html('等级不能为空');
  375. $('#level').focus();
  376. return false;
  377. }
  378. if (level_name.trim() === '') {
  379. $('#level_msg').show().html('等级名称不能为空');
  380. $('#level_name').focus();
  381. return false;
  382. }
  383. $.ajax({
  384. url: '{{route('admin.config.level.store')}}',
  385. method: 'POST',
  386. data: {_token: '{{csrf_token()}}', level: level, level_name: level_name},
  387. beforeSend: function() {
  388. $('#level_msg').show().html('正在添加');
  389. },
  390. success: function(ret) {
  391. if (ret.status === 'fail') {
  392. $('#level_msg').show().html(ret.message);
  393. return false;
  394. }
  395. $('#add_level_modal').modal('hide');
  396. window.location.reload();
  397. },
  398. error: function() {
  399. $('#level_msg').show().html('请求错误,请重试');
  400. },
  401. complete: function() {
  402. swal.fire({title: '添加成功', type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  403. },
  404. });
  405. }
  406. // 更新等级
  407. function updateLevel(id) {
  408. $.ajax({
  409. method: 'PUT',
  410. url: '{{route('admin.config.level.update', '')}}/' + id,
  411. data: {
  412. _token: '{{csrf_token()}}',
  413. level: $('#level_' + id).val(),
  414. level_name: $('#level_name_' + id).val(),
  415. },
  416. dataType: 'json',
  417. success: function(ret) {
  418. if (ret.status === 'success') {
  419. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  420. }
  421. else {
  422. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  423. }
  424. },
  425. });
  426. }
  427. // 删除等级
  428. function delLevel(id, name) {
  429. swal.fire({
  430. title: '确定删除等级 【' + name + '】 ?',
  431. type: 'question',
  432. allowEnterKey: false,
  433. showCancelButton: true,
  434. cancelButtonText: '{{trans('home.ticket_close')}}',
  435. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  436. }).then((result) => {
  437. if (result.value) {
  438. $.ajax({
  439. method: 'DELETE',
  440. url: '{{route('admin.config.level.destroy', '')}}/' + id,
  441. data: {_token: '{{csrf_token()}}'},
  442. dataType: 'json',
  443. success: function(ret) {
  444. if (ret.status === 'success') {
  445. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  446. }
  447. else {
  448. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  449. }
  450. },
  451. });
  452. }
  453. });
  454. }
  455. // 添加国家/地区
  456. function addCountry() {
  457. const country_name = $('#add_country_name').val();
  458. const country_code = $('#add_country_code').val();
  459. if (country_code.trim() === '') {
  460. $('#country_msg').show().html('国家/地区代码不能为空');
  461. $('#add_country_code').focus();
  462. return false;
  463. }
  464. if (country_name.trim() === '') {
  465. $('#country_msg').show().html('国家/地区名称不能为空');
  466. $('#add_country_name').focus();
  467. return false;
  468. }
  469. $.ajax({
  470. url: '{{route('admin.config.country.store')}}',
  471. method: 'POST',
  472. data: {_token: '{{csrf_token()}}', code: country_code, name: country_name},
  473. beforeSend: function() {
  474. $('#country_msg').show().html('正在添加');
  475. },
  476. success: function(ret) {
  477. if (ret.status === 'fail') {
  478. $('#country_msg').show().html(ret.message);
  479. return false;
  480. }
  481. $('#add_country_modal').modal('hide');
  482. window.location.reload();
  483. },
  484. error: function() {
  485. $('#country_msg').show().html('请求错误,请重试');
  486. },
  487. complete: function() {
  488. swal.fire({
  489. title: '添加成功',
  490. type: 'success',
  491. timer: 1000,
  492. showConfirmButton: false,
  493. }).then(() => window.location.reload());
  494. },
  495. });
  496. }
  497. // 更新国家/地区
  498. function updateCountry(code) {
  499. $.ajax({
  500. method: 'PUT',
  501. url: '{{route('admin.config.country.update', '')}}/' + code,
  502. data: {_token: '{{csrf_token()}}', name: $('#country_' + code).val()},
  503. dataType: 'json',
  504. success: function(ret) {
  505. if (ret.status === 'success') {
  506. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  507. }
  508. else {
  509. swal.fire({title: ret.message, type: 'error'});
  510. }
  511. },
  512. });
  513. }
  514. // 删除国家/地区
  515. function delCountry(code, name) {
  516. swal.fire({
  517. title: '确定删除 【' + name + '】 信息?',
  518. type: 'question',
  519. allowEnterKey: false,
  520. showCancelButton: true,
  521. cancelButtonText: '{{trans('home.ticket_close')}}',
  522. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  523. }).then((result) => {
  524. if (result.value) {
  525. $.ajax({
  526. method: 'DELETE',
  527. url: '{{route('admin.config.country.destroy', '')}}/' + code,
  528. data: {_token: '{{csrf_token()}}'},
  529. dataType: 'json',
  530. success: function(ret) {
  531. if (ret.status === 'success') {
  532. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  533. }
  534. else {
  535. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  536. }
  537. },
  538. });
  539. }
  540. });
  541. }
  542. // 添加配置
  543. function addConfig() {
  544. const name = $('#name').val();
  545. const type = $('#type').val();
  546. if (name.trim() === '') {
  547. $('#msg').show().html('名称不能为空');
  548. $('#name').focus();
  549. return false;
  550. }
  551. $.ajax({
  552. url: '{{route('admin.config.ss.store')}}',
  553. method: 'POST',
  554. data: {_token: '{{csrf_token()}}', name: name, type: type},
  555. dataType: 'json',
  556. beforeSend: function() {
  557. $('#msg').show().html('正在添加');
  558. },
  559. success: function(ret) {
  560. if (ret.status === 'fail') {
  561. $('#msg').show().html(ret.message);
  562. return false;
  563. }
  564. $('#add_config_modal').modal('hide');
  565. },
  566. error: function() {
  567. $('#msg').show().html('请求错误,请重试');
  568. },
  569. complete: function() {
  570. swal.fire({title: '添加成功', type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  571. },
  572. });
  573. }
  574. // 置为默认
  575. function setDefault(id) {
  576. $.ajax({
  577. method: 'PUT',
  578. url: '{{route('admin.config.ss.update', '')}}/' + id,
  579. data: {_token: '{{csrf_token()}}'},
  580. dataType: 'json',
  581. success: function(ret) {
  582. if (ret.status === 'success') {
  583. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  584. }
  585. else {
  586. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  587. }
  588. },
  589. });
  590. }
  591. // 删除配置
  592. function delConfig(id, name) {
  593. swal.fire({
  594. title: '确定删除配置 【' + name + '】 ?',
  595. type: 'question',
  596. allowEnterKey: false,
  597. showCancelButton: true,
  598. cancelButtonText: '{{trans('home.ticket_close')}}',
  599. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  600. }).then((result) => {
  601. if (result.value) {
  602. $.ajax({
  603. method: 'DELETE',
  604. url: '{{route('admin.config.ss.destroy', '')}}/' + id,
  605. data: {_token: '{{csrf_token()}}'},
  606. dataType: 'json',
  607. success: function(ret) {
  608. if (ret.status === 'success') {
  609. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  610. }
  611. else {
  612. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  613. }
  614. },
  615. });
  616. }
  617. });
  618. }
  619. // 添加标签
  620. function addLabel() {
  621. const name = $('#add_label').val();
  622. const sort = $('#add_label_sort').val();
  623. if (name.trim() === '') {
  624. $('#lable_msg').show().html('标签不能为空');
  625. return false;
  626. }
  627. if (sort.trim() === '') {
  628. $('#lable_msg').show().html('标签排序不能为空');
  629. return false;
  630. }
  631. $.ajax({
  632. url: '{{route('admin.config.label.store')}}',
  633. method: 'POST',
  634. data: {_token: '{{csrf_token()}}', name: name, sort: sort},
  635. beforeSend: function() {
  636. $('#level_msg').show().html('正在添加');
  637. },
  638. success: function(ret) {
  639. if (ret.status === 'fail') {
  640. $('#lable_msg').show().html(ret.message);
  641. return false;
  642. }
  643. $('#add_label_modal').modal('hide');
  644. window.location.reload();
  645. },
  646. error: function() {
  647. $('#lable_msg').show().html('请求错误,请重试');
  648. },
  649. complete: function() {
  650. swal.fire({
  651. title: '添加成功',
  652. type: 'success',
  653. timer: 1000,
  654. showConfirmButton: false,
  655. }).then(() => window.location.reload());
  656. },
  657. });
  658. }
  659. // 编辑标签
  660. function updateLabel(id) {
  661. $.ajax({
  662. method: 'PUT',
  663. url: '{{route('admin.config.label.update', '')}}/' + id,
  664. data: {
  665. _token: '{{csrf_token()}}',
  666. name: $('#label_name_' + id).val(),
  667. sort: $('#label_sort_' + id).val(),
  668. },
  669. dataType: 'json',
  670. success: function(ret) {
  671. if (ret.status === 'success') {
  672. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  673. }
  674. else {
  675. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  676. }
  677. },
  678. });
  679. }
  680. // 删除标签
  681. function delLabel(id, name) {
  682. swal.fire({
  683. title: '警告',
  684. text: '确定删除标签 【' + name + '】 ?',
  685. type: 'warning',
  686. showCancelButton: true,
  687. cancelButtonText: '{{trans('home.ticket_close')}}',
  688. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  689. }).then((result) => {
  690. $.ajax({
  691. method: 'DELETE',
  692. url: '{{route('admin.config.label.destroy', '')}}/' + id,
  693. data: {_token: '{{csrf_token()}}'},
  694. dataType: 'json',
  695. success: function(ret) {
  696. if (ret.status === 'success') {
  697. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  698. }
  699. else {
  700. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  701. }
  702. },
  703. });
  704. });
  705. }
  706. </script>
  707. @endsection