config.blade.php 24 KB

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