config.blade.php 24 KB

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