config.blade.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. @extends('admin.layouts')
  2. @section('css')
  3. <script src="//at.alicdn.com/t/font_682457_e6aq10jsbq0yhkt9.js" type="text/javascript"></script>
  4. <link rel="stylesheet" href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css">
  5. @endsection
  6. @section('content')
  7. <div class="page-content container">
  8. <div class="panel">
  9. <div class="panel-heading">
  10. <h3 class="panel-title">通用配置</h3>
  11. </div>
  12. <div class="panel-body">
  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="#tab1" aria-controls="tab1" role="tab">加密</a>
  17. </li>
  18. <li class="nav-item" role="presentation">
  19. <a class="nav-link" data-toggle="tab" href="#tab2" aria-controls="tab2" role="tab">协议</a>
  20. </li>
  21. <li class="nav-item" role="presentation">
  22. <a class="nav-link" data-toggle="tab" href="#tab3" aria-controls="tab3" role="tab">混淆</a>
  23. </li>
  24. <li class="nav-item" role="presentation">
  25. <a class="nav-link" data-toggle="tab" href="#tab4" aria-controls="tab4" role="tab">等级</a>
  26. </li>
  27. <li class="nav-item" role="presentation">
  28. <a class="nav-link" data-toggle="tab" href="#tab5" aria-controls="tab5" role="tab">国家地区</a>
  29. </li>
  30. </ul>
  31. <div class="tab-content">
  32. <div class="tab-pane active" id="tab1" role="tabpanel">
  33. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_config_modal"> 新增
  34. <i class="icon wb-plus"></i></button>
  35. <table class="text-center" data-toggle="table" data-mobile-responsive="true">
  36. <thead class="thead-default">
  37. <tr>
  38. <th> 名称</th>
  39. <th> 操作</th>
  40. </tr>
  41. </thead>
  42. <tbody>
  43. @if($method_list->isEmpty())
  44. <tr>
  45. <td colspan="2">暂无数据</td>
  46. </tr>
  47. @else
  48. @foreach($method_list as $method)
  49. <tr>
  50. <td> {{$method->name}}</td>
  51. <td>
  52. @if($method->is_default)
  53. <span class='badge badge-lg badge-default'>默认</span>
  54. @else
  55. <div class="btn-group">
  56. <button class="btn btn-primary" onclick="setDefault('1', '{{$method->id}}')">默认</button>
  57. <button class="btn btn-danger" onclick="delConfig('1', '{{$method->id}}')">
  58. <i class="icon wb-trash"></i>
  59. </button>
  60. </div>
  61. @endif
  62. </td>
  63. </tr>
  64. @endforeach
  65. @endif
  66. </tbody>
  67. </table>
  68. </div>
  69. <div class="tab-pane" id="tab2" 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></button>
  72. <table class="text-center" data-toggle="table" data-mobile-responsive="true">
  73. <thead class="thead-default">
  74. <tr>
  75. <th> 名称</th>
  76. <th> 操作</th>
  77. </tr>
  78. </thead>
  79. <tbody>
  80. @if($method_list->isEmpty())
  81. <tr>
  82. <td colspan="2">暂无数据</td>
  83. </tr>
  84. @else
  85. @foreach($protocol_list as $protocol)
  86. <tr>
  87. <td> {{$protocol->name}}</td>
  88. <td>
  89. @if($protocol->is_default)
  90. <span class="badge badge-lg badge-default">默认</span>
  91. @else
  92. <div class="btn-group">
  93. <button class="btn btn-primary" onclick="setDefault('2', '{{$protocol->id}}')">默认</button>
  94. <button class="btn btn-danger" onclick="delConfig('2', '{{$protocol->id}}')">
  95. <i class="icon wb-trash"></i>
  96. </button>
  97. </div>
  98. @endif
  99. </td>
  100. </tr>
  101. @endforeach
  102. @endif
  103. </tbody>
  104. </table>
  105. </div>
  106. <div class="tab-pane" id="tab3" role="tabpanel">
  107. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_config_modal"> 新增
  108. <i class="icon wb-plus"></i></button>
  109. <table class="text-center" data-toggle="table" data-mobile-responsive="true">
  110. <thead class="thead-default">
  111. <tr>
  112. <th> 名称</th>
  113. <th> 操作</th>
  114. </tr>
  115. </thead>
  116. <tbody>
  117. @if($obfs_list->isEmpty())
  118. <tr>
  119. <td colspan="2">暂无数据</td>
  120. </tr>
  121. @else
  122. @foreach($obfs_list as $obfs)
  123. <tr>
  124. <td> {{$obfs->name}}</td>
  125. <td>
  126. @if($obfs->is_default)
  127. <span class="badge badge-lg badge-default">默认</span>
  128. @else
  129. <button class="btn btn-primary" onclick="setDefault('3', '{{$obfs->id}}')">默认</button>
  130. <button class="btn btn-danger" onclick="delConfig('3', '{{$obfs->id}}')">
  131. <i class="icon wb-trash"></i>
  132. </button>
  133. @endif
  134. </td>
  135. </tr>
  136. @endforeach
  137. @endif
  138. </tbody>
  139. </table>
  140. </div>
  141. <div class="tab-pane" id="tab4" role="tabpanel">
  142. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_level_modal"> 新增
  143. <i class="icon wb-plus"></i></button>
  144. <table class="text-center" data-toggle="table" data-mobile-responsive="true">
  145. <thead class="thead-default">
  146. <tr>
  147. <th> 等级</th>
  148. <th> 名称</th>
  149. <th> 操作</th>
  150. </tr>
  151. </thead>
  152. <tbody>
  153. @if($level_list->isEmpty())
  154. <tr>
  155. <td colspan="3">暂无数据</td>
  156. </tr>
  157. @else
  158. @foreach($level_list as $level)
  159. <tr>
  160. <td>
  161. <input id="level_{{$level->id}}" name="level" value="{{$level->level}}" type="text" class="form-control">
  162. </td>
  163. <td>
  164. <input id="level_name_{{$level->id}}" name="level_name" value="{{$level->level_name}}" type="text" class="form-control">
  165. </td>
  166. <td>
  167. <div class="btn-group">
  168. <button type="button" class="btn btn-primary" onclick="updateLevel('4', '{{$level->id}}')">修改</button>
  169. <button type="button" class="btn btn-danger" onclick="delLevel('4', '{{$level->id}}')">
  170. <i class="icon wb-trash"></i>
  171. </button>
  172. </div>
  173. </td>
  174. </tr>
  175. @endforeach
  176. @endif
  177. </tbody>
  178. </table>
  179. </div>
  180. <div class="tab-pane" id="tab5" role="tabpanel">
  181. <button class="btn btn-primary float-right mb-10" data-toggle="modal" data-target="#add_country_modal"> 新增
  182. <i class="icon wb-plus"></i></button>
  183. <table class="table text-center" data-toggle="table" data-mobile-responsive="true">
  184. <thead class="thead-default">
  185. <tr>
  186. <th> 图标</th>
  187. <th> 国家/地区名称</th>
  188. <th> 代码</th>
  189. <th> 操作</th>
  190. </tr>
  191. </thead>
  192. <tbody>
  193. @if($country_list->isEmpty())
  194. <tr>
  195. <td colspan="4">暂无数据</td>
  196. </tr>
  197. @else
  198. @foreach($country_list as $country)
  199. <tr>
  200. <td>
  201. <svg class="w-50 h-50 text-center" aria-hidden="true">
  202. <use xlink:href="@if($country->country_code)#icon-{{$country->country_code}}@endif"></use>
  203. </svg>
  204. </td>
  205. <td>
  206. <input id="country_name_{{$country->id}}" name="country_name" value="{{$country->country_name}}" type="text" class="form-control">
  207. </td>
  208. <td>
  209. <input id="country_code_{{$country->id}}" name="country_code" value="{{$country->country_code}}" type="text" class="form-control">
  210. </td>
  211. <td>
  212. <div class="btn-group">
  213. <button type="button" class="btn btn-primary" onclick="updateCountry('5', '{{$country->id}}')">修改</button>
  214. <button type="button" class="btn btn-danger" onclick="delCountry('5', '{{$country->id}}')"><i class="icon wb-trash"></i></button>
  215. </div>
  216. </td>
  217. </tr>
  218. @endforeach
  219. @endif
  220. </tbody>
  221. </table>
  222. </div>
  223. </div>
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. <div class="modal fade" id="add_config_modal" aria-hidden="true" role="dialog" tabindex="-1">
  229. <div class="modal-dialog modal-simple modal-center">
  230. <div class="modal-content">
  231. <div class="modal-header">
  232. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  233. <span aria-hidden="true">×</span>
  234. </button>
  235. <h4 class="modal-title">新增配置</h4>
  236. </div>
  237. <form action="#" method="post" class="modal-body">
  238. <div class="alert alert-danger" style="display: none;" id="msg"></div>
  239. <div class="row">
  240. <div class="col-md-6 form-group">
  241. <select class="form-control" name="type" id="type" placeholder="类型">
  242. <option value="1" selected>加密方式</option>
  243. <option value="2">协议</option>
  244. <option value="3">混淆</option>
  245. </select>
  246. </div>
  247. <div class="col-md-6 form-group">
  248. <input type="text" class="form-control" name="name" id="name" placeholder="名称">
  249. </div>
  250. </div>
  251. </form>
  252. <div class="modal-footer">
  253. <button class="btn btn-danger" data-dismiss="modal">关闭</button>
  254. <button class="btn btn-primary" onclick="return addConfig();">提交</button>
  255. </div>
  256. </div>
  257. </div>
  258. </div>
  259. <div class="modal fade" id="add_level_modal" aria-hidden="true" role="dialog" tabindex="-1">
  260. <div class="modal-dialog modal-simple modal-center">
  261. <div class="modal-content">
  262. <div class="modal-header">
  263. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  264. <span aria-hidden="true">×</span>
  265. </button>
  266. <h4 class="modal-title">新增配置</h4>
  267. </div>
  268. <form action="#" method="post" class="modal-body">
  269. <div class="alert alert-danger" style="display: none;" id="level_msg"></div>
  270. <div class="row">
  271. <div class="col-md-6 form-group">
  272. <input type="text" class="form-control" name="level" id="add_level" placeholder="等级">
  273. </div>
  274. <div class="col-md-6 form-group">
  275. <input type="text" class="form-control" name="level_name" id="add_level_name" placeholder="等级名称">
  276. </div>
  277. </div>
  278. </form>
  279. <div class="modal-footer">
  280. <button data-dismiss="modal" class="btn btn-danger">关闭</button>
  281. <button class="btn btn-primary" onclick="return addLevel(4);">提交</button>
  282. </div>
  283. </div>
  284. </div>
  285. </div>
  286. <div class="modal fade" id="add_country_modal" aria-hidden="true" role="dialog" tabindex="-1">
  287. <div class="modal-dialog modal-simple modal-center">
  288. <div class="modal-content">
  289. <div class="modal-header">
  290. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  291. <span aria-hidden="true">×</span>
  292. </button>
  293. <h4 class="modal-title">新增国家/地区</h4>
  294. </div>
  295. <form action="#" method="post" class="modal-body">
  296. <div class="alert alert-danger" style="display: none;" id="country_msg"></div>
  297. <div class="row">
  298. <div class="col-md-6 form-group">
  299. <input type="text" class="form-control" name="country_name" id="add_country_name" placeholder=" 国家/地区名称">
  300. </div>
  301. <div class="col-md-6 form-group">
  302. <input type="text" class="form-control" name="country_code" id="add_country_code" placeholder="国家代码">
  303. </div>
  304. </div>
  305. </form>
  306. <div class="modal-footer">
  307. <button data-dismiss="modal" class="btn btn-danger">关闭</button>
  308. <button class="btn btn-primary" onclick="return addCountry(5);">提交</button>
  309. </div>
  310. </div>
  311. </div>
  312. </div>
  313. @endsection
  314. @section('script')
  315. <script src="/assets/global/vendor/matchheight/jquery.matchHeight-min.js"></script>
  316. <script src="/assets/global/js/Plugin/tabs.js"></script>
  317. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js"></script>
  318. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
  319. <script type="text/javascript">
  320. // 添加等级
  321. function addLevel(tabId) {
  322. const level = $('#add_level').val();
  323. const level_name = $('#add_level_name').val();
  324. if (level.trim() === '') {
  325. $("#level_msg").show().html("等级不能为空");
  326. $("#level").focus();
  327. return false;
  328. }
  329. if (level_name.trim() === '') {
  330. $("#level_msg").show().html("等级名称不能为空");
  331. $("#level_name").focus();
  332. return false;
  333. }
  334. $.ajax({
  335. url: '/admin/addLevel',
  336. type: "POST",
  337. data: {_token: '{{csrf_token()}}', level: level, level_name: level_name},
  338. beforeSend: function () {
  339. $("#level_msg").show().html("正在添加");
  340. },
  341. success: function (ret) {
  342. if (ret.status === 'fail') {
  343. $("#level_msg").show().html(ret.message);
  344. return false;
  345. }
  346. $("#add_level_modal").modal("hide");
  347. window.location.href = '/admin/config?tab=' + tabId;
  348. },
  349. error: function () {
  350. $("#level_msg").show().html("请求错误,请重试");
  351. },
  352. complete: function () {
  353. }
  354. });
  355. }
  356. // 更新等级
  357. function updateLevel(tabId, id) {
  358. const level = $('#level_' + id).val();
  359. const level_name = $('#level_name_' + id).val();
  360. $.ajax({
  361. type: "POST",
  362. url: "/admin/updateLevel",
  363. async: false,
  364. data: {_token: '{{csrf_token()}}', id: id, level: level, level_name: level_name},
  365. dataType: 'json',
  366. success: function (ret) {
  367. if (ret.status === 'success') {
  368. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  369. .then(() => window.location.href = '/admin/config?tab=' + tabId)
  370. } else {
  371. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  372. }
  373. }
  374. });
  375. }
  376. // 删除等级
  377. function delLevel(tabId, id) {
  378. swal.fire({
  379. title: '确定删除该等级吗?',
  380. type: 'question',
  381. allowEnterKey: false,
  382. showCancelButton: true,
  383. cancelButtonText: '{{trans('home.ticket_close')}}',
  384. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  385. }).then((result) => {
  386. if (result.value) {
  387. $.post("/admin/delLevel", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  388. if (ret.status === 'success') {
  389. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  390. .then(() => window.location.href = '/admin/config?tab=' + tabId)
  391. } else {
  392. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  393. }
  394. });
  395. }
  396. })
  397. }
  398. // 添加国家/地区
  399. function addCountry(tabId) {
  400. var country_name = $('#add_country_name').val();
  401. var country_code = $('#add_country_code').val();
  402. if (country_name.trim() === '') {
  403. $("#country_msg").show().html("国家/地区名称不能为空");
  404. $("#add_country_name").focus();
  405. return false;
  406. }
  407. if (country_code.trim() === '') {
  408. $("#country_msg").show().html("国家/地区代码不能为空");
  409. $("#add_country_code").focus();
  410. return false;
  411. }
  412. $.ajax({
  413. url: '/admin/addCountry',
  414. type: "POST",
  415. data: {_token: '{{csrf_token()}}', country_name: country_name, country_code: country_code},
  416. beforeSend: function () {
  417. $("#country_msg").show().html("正在添加");
  418. },
  419. success: function (ret) {
  420. if (ret.status === 'fail') {
  421. $("#country_msg").show().html(ret.message);
  422. return false;
  423. }
  424. $("#add_country_modal").modal("hide");
  425. window.location.href = '/admin/config?tab=' + tabId;
  426. },
  427. error: function () {
  428. $("#country_msg").show().html("请求错误,请重试");
  429. },
  430. complete: function () {
  431. }
  432. });
  433. }
  434. // 更新国家/地区
  435. function updateCountry(tabId, id) {
  436. const country_name = $('#country_name_' + id).val();
  437. const country_code = $('#country_code_' + id).val();
  438. $.ajax({
  439. type: "POST",
  440. url: "/admin/updateCountry",
  441. async: false,
  442. data: {_token: '{{csrf_token()}}', id: id, country_name: country_name, country_code: country_code},
  443. dataType: 'json',
  444. success: function (ret) {
  445. if (ret.status === 'success') {
  446. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  447. .then(() => window.location.href = '/admin/config?tab=' + tabId)
  448. } else {
  449. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  450. }
  451. }
  452. });
  453. }
  454. // 删除国家/地区
  455. function delCountry(tabId, id) {
  456. swal.fire({
  457. title: '确定删除该国家/地区吗?',
  458. type: 'question',
  459. allowEnterKey: false,
  460. showCancelButton: true,
  461. cancelButtonText: '{{trans('home.ticket_close')}}',
  462. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  463. }).then((result) => {
  464. if (result.value) {
  465. $.post("/admin/delCountry", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  466. if (ret.status === 'success') {
  467. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  468. .then(() => window.location.href = '/admin/config?tab=' + tabId)
  469. } else {
  470. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  471. }
  472. });
  473. }
  474. })
  475. }
  476. // 添加配置
  477. function addConfig() {
  478. const _token = '{{csrf_token()}}';
  479. const name = $("#name").val();
  480. const type = $("#type").val();
  481. if (name.trim() === '') {
  482. $("#msg").show().html("名称不能为空");
  483. $("#name").focus();
  484. return false;
  485. }
  486. $.ajax({
  487. url: '/admin/config',
  488. type: "POST",
  489. data: {_token: _token, name: name, type: type},
  490. beforeSend: function () {
  491. $("#msg").show().html("正在添加");
  492. },
  493. success: function (ret) {
  494. if (ret.status === 'fail') {
  495. $("#msg").show().html(ret.message);
  496. return false;
  497. }
  498. $("#add_config_modal").modal("hide");
  499. },
  500. error: function () {
  501. $("#msg").show().html("请求错误,请重试");
  502. },
  503. complete: function () {
  504. }
  505. });
  506. }
  507. // 删除配置
  508. function delConfig(tabId, id) {
  509. swal.fire({
  510. title: '确定删除配置?',
  511. type: 'question',
  512. allowEnterKey: false,
  513. showCancelButton: true,
  514. cancelButtonText: '{{trans('home.ticket_close')}}',
  515. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  516. }).then((result) => {
  517. if (result.value) {
  518. $.post("/admin/delConfig", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  519. if (ret.status === 'success') {
  520. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  521. .then(() => window.location.href = '/admin/config?tab=' + tabId)
  522. } else {
  523. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  524. }
  525. });
  526. }
  527. })
  528. }
  529. // 置为默认
  530. function setDefault(tabId, id) {
  531. const _token = '{{csrf_token()}}';
  532. $.ajax({
  533. type: "POST",
  534. url: "/admin/setDefaultConfig",
  535. async: false,
  536. data: {_token: _token, id: id},
  537. dataType: 'json',
  538. success: function (ret) {
  539. if (ret.status === 'success') {
  540. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  541. .then(() => window.location.href = '/admin/config?tab=' + tabId)
  542. } else {
  543. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  544. }
  545. }
  546. });
  547. }
  548. </script>
  549. @endsection