config.blade.php 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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('javascript')
  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: '添加成功', icon: '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, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  420. } else {
  421. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  422. }
  423. },
  424. });
  425. }
  426. // 删除等级
  427. function delLevel(id, name) {
  428. swal.fire({
  429. title: '确定删除等级 【' + name + '】 ?',
  430. icon: 'question',
  431. allowEnterKey: false,
  432. showCancelButton: true,
  433. cancelButtonText: '{{trans('home.ticket_close')}}',
  434. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  435. }).then((result) => {
  436. if (result.value) {
  437. $.ajax({
  438. method: 'DELETE',
  439. url: '{{route('admin.config.level.destroy', '')}}/' + id,
  440. data: {_token: '{{csrf_token()}}'},
  441. dataType: 'json',
  442. success: function(ret) {
  443. if (ret.status === 'success') {
  444. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  445. } else {
  446. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  447. }
  448. },
  449. });
  450. }
  451. });
  452. }
  453. // 添加国家/地区
  454. function addCountry() {
  455. const country_name = $('#add_country_name').val();
  456. const country_code = $('#add_country_code').val();
  457. if (country_code.trim() === '') {
  458. $('#country_msg').show().html('国家/地区代码不能为空');
  459. $('#add_country_code').focus();
  460. return false;
  461. }
  462. if (country_name.trim() === '') {
  463. $('#country_msg').show().html('国家/地区名称不能为空');
  464. $('#add_country_name').focus();
  465. return false;
  466. }
  467. $.ajax({
  468. url: '{{route('admin.config.country.store')}}',
  469. method: 'POST',
  470. data: {_token: '{{csrf_token()}}', code: country_code, name: country_name},
  471. beforeSend: function() {
  472. $('#country_msg').show().html('正在添加');
  473. },
  474. success: function(ret) {
  475. if (ret.status === 'fail') {
  476. $('#country_msg').show().html(ret.message);
  477. return false;
  478. }
  479. $('#add_country_modal').modal('hide');
  480. window.location.reload();
  481. },
  482. error: function() {
  483. $('#country_msg').show().html('请求错误,请重试');
  484. },
  485. complete: function() {
  486. swal.fire({
  487. title: '添加成功',
  488. icon: 'success',
  489. timer: 1000,
  490. showConfirmButton: false,
  491. }).then(() => window.location.reload());
  492. },
  493. });
  494. }
  495. // 更新国家/地区
  496. function updateCountry(code) {
  497. $.ajax({
  498. method: 'PUT',
  499. url: '{{route('admin.config.country.update', '')}}/' + code,
  500. data: {_token: '{{csrf_token()}}', name: $('#country_' + code).val()},
  501. dataType: 'json',
  502. success: function(ret) {
  503. if (ret.status === 'success') {
  504. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  505. } else {
  506. swal.fire({title: ret.message, icon: 'error'});
  507. }
  508. },
  509. });
  510. }
  511. // 删除国家/地区
  512. function delCountry(code, name) {
  513. swal.fire({
  514. title: '确定删除 【' + name + '】 信息?',
  515. icon: 'question',
  516. allowEnterKey: false,
  517. showCancelButton: true,
  518. cancelButtonText: '{{trans('home.ticket_close')}}',
  519. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  520. }).then((result) => {
  521. if (result.value) {
  522. $.ajax({
  523. method: 'DELETE',
  524. url: '{{route('admin.config.country.destroy', '')}}/' + code,
  525. data: {_token: '{{csrf_token()}}'},
  526. dataType: 'json',
  527. success: function(ret) {
  528. if (ret.status === 'success') {
  529. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  530. } else {
  531. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  532. }
  533. },
  534. });
  535. }
  536. });
  537. }
  538. // 添加配置
  539. function addConfig() {
  540. const name = $('#name').val();
  541. const type = $('#type').val();
  542. if (name.trim() === '') {
  543. $('#msg').show().html('名称不能为空');
  544. $('#name').focus();
  545. return false;
  546. }
  547. $.ajax({
  548. url: '{{route('admin.config.ss.store')}}',
  549. method: 'POST',
  550. data: {_token: '{{csrf_token()}}', name: name, type: type},
  551. dataType: 'json',
  552. beforeSend: function() {
  553. $('#msg').show().html('正在添加');
  554. },
  555. success: function(ret) {
  556. if (ret.status === 'fail') {
  557. $('#msg').show().html(ret.message);
  558. return false;
  559. }
  560. $('#add_config_modal').modal('hide');
  561. },
  562. error: function() {
  563. $('#msg').show().html('请求错误,请重试');
  564. },
  565. complete: function() {
  566. swal.fire({title: '添加成功', icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  567. },
  568. });
  569. }
  570. // 置为默认
  571. function setDefault(id) {
  572. $.ajax({
  573. method: 'PUT',
  574. url: '{{route('admin.config.ss.update', '')}}/' + id,
  575. data: {_token: '{{csrf_token()}}'},
  576. dataType: 'json',
  577. success: function(ret) {
  578. if (ret.status === 'success') {
  579. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  580. } else {
  581. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  582. }
  583. },
  584. });
  585. }
  586. // 删除配置
  587. function delConfig(id, name) {
  588. swal.fire({
  589. title: '确定删除配置 【' + name + '】 ?',
  590. icon: 'question',
  591. allowEnterKey: false,
  592. showCancelButton: true,
  593. cancelButtonText: '{{trans('home.ticket_close')}}',
  594. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  595. }).then((result) => {
  596. if (result.value) {
  597. $.ajax({
  598. method: 'DELETE',
  599. url: '{{route('admin.config.ss.destroy', '')}}/' + id,
  600. data: {_token: '{{csrf_token()}}'},
  601. dataType: 'json',
  602. success: function(ret) {
  603. if (ret.status === 'success') {
  604. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  605. } else {
  606. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  607. }
  608. },
  609. });
  610. }
  611. });
  612. }
  613. // 添加标签
  614. function addLabel() {
  615. const name = $('#add_label').val();
  616. const sort = $('#add_label_sort').val();
  617. if (name.trim() === '') {
  618. $('#lable_msg').show().html('标签不能为空');
  619. return false;
  620. }
  621. if (sort.trim() === '') {
  622. $('#lable_msg').show().html('标签排序不能为空');
  623. return false;
  624. }
  625. $.ajax({
  626. url: '{{route('admin.config.label.store')}}',
  627. method: 'POST',
  628. data: {_token: '{{csrf_token()}}', name: name, sort: sort},
  629. beforeSend: function() {
  630. $('#level_msg').show().html('正在添加');
  631. },
  632. success: function(ret) {
  633. if (ret.status === 'fail') {
  634. $('#lable_msg').show().html(ret.message);
  635. return false;
  636. }
  637. $('#add_label_modal').modal('hide');
  638. window.location.reload();
  639. },
  640. error: function() {
  641. $('#lable_msg').show().html('请求错误,请重试');
  642. },
  643. complete: function() {
  644. swal.fire({
  645. title: '添加成功',
  646. icon: 'success',
  647. timer: 1000,
  648. showConfirmButton: false,
  649. }).then(() => window.location.reload());
  650. },
  651. });
  652. }
  653. // 编辑标签
  654. function updateLabel(id) {
  655. $.ajax({
  656. method: 'PUT',
  657. url: '{{route('admin.config.label.update', '')}}/' + id,
  658. data: {
  659. _token: '{{csrf_token()}}',
  660. name: $('#label_name_' + id).val(),
  661. sort: $('#label_sort_' + id).val(),
  662. },
  663. dataType: 'json',
  664. success: function(ret) {
  665. if (ret.status === 'success') {
  666. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  667. } else {
  668. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  669. }
  670. },
  671. });
  672. }
  673. // 删除标签
  674. function delLabel(id, name) {
  675. swal.fire({
  676. title: '警告',
  677. text: '确定删除标签 【' + name + '】 ?',
  678. icon: 'warning',
  679. showCancelButton: true,
  680. cancelButtonText: '{{trans('home.ticket_close')}}',
  681. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  682. }).then((result) => {
  683. $.ajax({
  684. method: 'DELETE',
  685. url: '{{route('admin.config.label.destroy', '')}}/' + id,
  686. data: {_token: '{{csrf_token()}}'},
  687. dataType: 'json',
  688. success: function(ret) {
  689. if (ret.status === 'success') {
  690. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  691. } else {
  692. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  693. }
  694. },
  695. });
  696. });
  697. }
  698. </script>
  699. @endsection