123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667 |
- <style>
- .content-header {
- display: none;
- }
- .left-panel {
- background-color:
- height: 100vh;
- }
- .main-panel {
- background-color:
- height: 95.8vh;
- }
- .main-panel-header {
- background-color:
- padding: 5px;
- }
- .main-card-body {
- max-height: 75vh;
- overflow-y: auto;
- overflow-x: hidden;
- border-radius: 1px;
- }
- .main-card-body ul li {
- white-space: nowrap;
- padding: 0px;
- }
-
- background-color:
- }
- .modal-body {
- background-color:
- }
- .submenu {
- list-style: none;
- padding-left: 3px;
- }
- .list-group-flush .float-right {
- padding-right: 5px;
- }
- .list-group-flush .icon-x {
- color:
- }
- .submenu .list-group-item {
- padding: 10px 0px 10px 20px;
- }
- .submenu .list-group-item:hover {
- background-color: rgba(221, 251, 239, 0.56);
- }
- .submenu .list-group-item.active {
- background-color: rgba(221, 251, 239, 0.56);
- border-color:
- color:
- }
- .custom-blue-bold {
- color:
- font-weight: bold;
- }
- .modal-xxl {
- max-width: 75%;
- }
- .field_dist_id {
- max-height: 30px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .field_dist_id .form-control {
- height: 17px;
- overflow: hidden;
- display: flex;
- align-items: center;
- }
- .field_dist_id .option {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- display: flex;
- align-items: center;
- }
- .field_dist_id .pull-right {
- margin-left: auto;
- }
-
- display: flex;
- align-items: center;
- height: 100px;
- background-color:
- }
-
- display: flex;
- align-items: center;
- }
-
- padding-left: 5px;
- padding-right: 5px;
- }
-
- max-width:320px;
- }
-
- position: absolute;
- top: 45%;
- left: 50%;
- transform: translate(-40%, -50%);
- }
-
- margin-right: 5px;
- }
- .btn-warning.disabled, .btn-warning:disabled {
- color:
- }
- .modal-body {
- background-color:
- }
- .selected-row {
- background-color: rgba(221, 251, 239, 0.56);
- }
-
- max-height: 550px;
- overflow-y: auto;
- display: block;
- }
-
- display: block;
- width: 100%;
- }
-
- display: block;
- width: 100%;
- }
-
- display: block;
- width: 90%;
- }
- </style>
- </style>
- <div class="container-fluid" style="padding: 0px;">
- <div class="row">
- <div class="col-2 left-panel"> <!-- 左侧20% -->
- {!!$leftForm!!}
- <!-- 代码树 start-->
- <div class="main-card-body"></div>
- <!-- 代码树 end-->
- </div>
- <div class="col-10 main-panel" style="padding-right: 0px;"> <!-- 右侧80% -->
- <div class="main-panel-header">
- <button type="button" class="btn btn-info btn-sm" id="save-btn" disabled>Save</button>
- <button type="button" class="btn btn-warning btn-sm" data-toggle="modal" id="variable-btn" data-target="#iframeModal" disabled>Variable</button>
- <button type="button" class="btn btn-success btn-sm" id="publish-btn" disabled>Publish</button>
- <button type="button" class="btn btn-info btn-sm float-right" id="history-btn" disabled>History</button>
- </div>
- <div class="main-panel-content" id="editor" style="width: 100%; height: 100%;"></div>
- <input type="hidden" name="template_id" id="template_id" />
- </div>
- </div>
- </div>
- <!-- 变量管理弹窗 -->
- <div class="modal fade" id="iframeModal" tabindex="-1" aria-labelledby="iframeModalLabel" aria-hidden="true">
- <div class="modal-dialog modal-dialog-centered modal-xxl">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title" id="iframeModalLabel">Variable Management</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body">
- <iframe src="/prime-control/dist-template-var" width="100%" height="750px" frameborder="0" style="max-width: 100%;overflow: hidden"></iframe>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
- </div>
- </div>
- </div>
- </div>
- <!-- Modal -->
- <!-- Modal -->
- <div class="modal fade" id="addFileModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
- <div class="modal-dialog modal-sm" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
- </div>
- <div class="modal-body">
- <div class="row">
- <div class="col-xs-2 text-right">
- File Name:
- </div>
- <div class="col-xs-8">
- <input type="hidden" class="form-control" id="file_path_name" name="file_path_name">
- <input type="text" class="form-control" id="file_name_input" name="file_name_input">
- </div>
- <div class="col-xs-2">
- <button type="button" class="btn btn-success" id="addFileButton">OK</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- Bootstrap Modal -->
- <div class="modal fade" id="templateLogModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
- <div class="modal-dialog modal-xl" role="document" >
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title" id="exampleModalLabel">Template Logs</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body" style="height: 600px;">
- <div class="row" style="height: 100%;">
- <!-- 左侧显示 Previous Content -->
- <div class="col-md-8">
- <h5>Content</h5>
- <textarea id="contentDetails" style="height: 550px; overflow-y: auto; border: 1px solid #ededed; padding: 10px;width: 100%;"></textarea>
- </div>
- <!-- 右侧显示 Version 和 Created At 列表 -->
- <div class="col-md-4">
- <h5>Version</h5>
- <table class="table table-condensed table-hover" id="templateLogTable">
- <tbody id="templateLogTableBody">
- <!-- 动态生成的列表 -->
- </tbody>
- </table>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <input type="hidden" id="templateLogId" name="templateLogId"/>
- <input type="hidden" id="templateVersion" name="templateVersion"/>
- <button type="button" class="btn btn-success" id="restoreTemplateLog">Restore Version</button>
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
- </div>
- <script src="/vendor/ace/ace.js" type="text/javascript"></script>
- <script>
- //https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js
- // 创建 Ace 编辑器实例
- var editor = ace.edit("editor");
- // 设置语言
- editor.getSession().setMode("ace/mode/html");
- // 设置主题
- editor.setTheme("ace/theme/monokai");
- editor.setAutoScrollEditorIntoView(true);
- // 其他配置
- editor.setOptions({
- showPrintMargin: true
- });
- $(document).ready(function() {
- var loadingIndex = '';
- var fileId = '';
- var changeButtonDisabled = function (status) {
- $('#save-btn').prop('disabled', status);
- $('#variable-btn').prop('disabled', status);
- $('#publish-btn').prop('disabled', status);
- $('#history-btn').prop('disabled', status);
- }
- var changeIframeUrl = function() {
- appearance_id = $('select[name="appearance_id"]').val();
- dist_id = $('input[name="dist_id"]').val();
- var iframeUrl = '/prime-control/dist-template-var?templateCode=' + fileId + '&appearanceId=' + appearance_id+'&distId=' + dist_id;
- $('#iframeModal iframe').attr('src', iframeUrl);
- }
-
- var actionclick = function() {
- $('.file-action').click(function() {
-
- $('.active').removeClass('active');
-
- var $li = $(this).closest('li');
- $li.addClass('active');
-
- changeButtonDisabled(false);
-
- loadingIndex = layer.load(1, {
- shade: [0.5, '#000']
- });
- var appearance_id = $('select[name="appearance_id"]').val();
- var dist_id = $('input[name="dist_id"]').val();
- fileId = $(this).attr('file_id');
-
- fileName = $(this).html();
- if (fileName.endsWith('.css')) {
- editor.getSession().setMode("ace/mode/css");
- } else if (fileName.endsWith('.js')) {
- editor.getSession().setMode("ace/mode/javascript");
- }else {
- editor.getSession().setMode("ace/mode/html");
- }
-
- changeIframeUrl();
-
- $.ajax({
- url: '/prime-control/dist-template/ace',
- type: 'POST',
- data: {
- act:'content',
- appearance_id: appearance_id,
- dist_id: dist_id,
- id: fileId
- },
- success: function(response) {
- $("#template_id").val(fileId);
- editor.setValue(response);
- layer.close(loadingIndex);
- }
- });
- });
- }
-
- var postData = function () {
- var appearance_id = $('select[name="appearance_id"]').val();
- var dist_id = $('input[name="dist_id"]').val();
-
- changeIframeUrl();
- $.ajax({
- url: '/prime-control/dist-template/ace',
- type: 'POST',
- data: {
- act:'tree',
- appearance_id: appearance_id,
- dist_id: dist_id
- },
- success: function(response) {
- layer.close(loadingIndex);
- $('.main-card-body').html(response);
- actionclick();
- delFileButtonClick();
- }
- });
- }
-
- $('select[name="appearance_id"]').change(function() {
-
- if ($(this).val() == '') {
- changeButtonDisabled(true);
- }
- loadingIndex = layer.load(1, {
- shade: [0.5, '#000']
- });
-
- editor.setValue('');
-
- $('.main-card-body').html('');
-
- postData();
- });
-
- $('input[name="dist_id"]').change(function() {
-
- loadingIndex = layer.load(1, {
- shade: [0.5, '#000']
- });
-
- editor.setValue('');
-
- $('.main-card-body').html('');
- dist_id = $(this).val();
-
- setTimeout(function() {
- $("div[name='dist_id'] .option").prepend(dist_id+" - ");
- }, 100);
-
- $.ajax({
- url: '/prime-control/dist-template/ace',
- type: 'POST',
- data: {
- act:'get_appearance_id',
- dist_id: dist_id,
- },
- success: function(response) {
-
-
- var $select = $('select[name="appearance_id"]');
- $select.select2('val', response);
-
-
- }
- });
- });
-
- $("#save-btn").click(function() {
- var appearance_id = $('select[name="appearance_id"]').val();
- var dist_id = $('input[name="dist_id"]').val();
- var template_id = $("#template_id").val();
- var content = editor.getValue();
- if (template_id == '') {
- Dcat.error('操作失败:请先选择模板');
- return false;
- }
- if (appearance_id == '') {
- Dcat.error('操作失败:请先选择主题');
- return false;
- }
- loadingIndex = layer.load(1, {
- shade: [0.5, '#000']
- });
- $.ajax({
- url: '/prime-control/dist-template/ace',
- type: 'POST',
- data: {
- act:'content_save',
- template_code: template_id,
- appearance_id: appearance_id,
- dist_id: dist_id,
- content: content
- },
- success: function(response) {
- layer.close(loadingIndex);
- if (response == '1') {
- Dcat.success('保存成功');
- }else{
- Dcat.error('保存失败');
- }
- }
- });
- })
-
- $("#publish-btn").click(function() {
- var appearance_id = $('select[name="appearance_id"]').val();
- var dist_id = $('input[name="dist_id"]').val();
- if (appearance_id == '') {
- Dcat.error('操作失败:请先选择主题');
- return false;
- }
- loadingIndex = layer.load(1, {
- shade: [0.5, '#000']
- });
- $.ajax({
- url: '/prime-control/dist-template/ace',
- type: 'POST',
- data: {
- act:'publish',
- appearance_id: appearance_id,
- dist_id: dist_id
- },
- success: function(response) {
- layer.close(loadingIndex);
- Dcat.success('保存成功');
- }
- });
- })
-
- $('#addFileModal').on('show.bs.modal', function (event) {
-
- var button = $(event.relatedTarget);
-
- var filePathName = button.attr('file_path_name');
- $('#file_path_name').val(filePathName);
- });
- var ajaxAddDelFile = function (appearance_id,dist_id,fileId,filePathName,fileInputName,type) {
- $.ajax({
- url: '/prime-control/dist-template/ace',
- type: 'POST',
- data: {
- act:'add_del_tree',
- type: type,
- appearance_id: appearance_id,
- dist_id: dist_id,
- file_path_name: filePathName,
- file_name_input: fileInputName,
- file_id: fileId
- },
- success: function(response) {
- layer.close(loadingIndex);
- $("#file_name_input").val('')
- if (response.status == '1') {
- Dcat.success('保存成功');
-
- postData();
- }else{
- Dcat.error(response.msg);
- }
- }
- });
- }
-
- $("#addFileButton").click(function () {
- var filePathName = $('#file_path_name').val();
- var fileInputName = $('#file_name_input').val();
- var appearanceId = $('select[name="appearance_id"]').val();
- var distId = $('input[name="dist_id"]').val();
- if (fileInputName == '') {
- Dcat.error('文件名不能为空');
- return false;
- }
- loadingIndex = layer.load(1, {
- shade: [0.5, '#000']
- });
- $('#addFileModal').modal('hide');
- ajaxAddDelFile(appearanceId,distId,0,filePathName,fileInputName,'add');
- });
-
- function delFileButtonClick() {
- $(".delFileButton").click(function () {
- var filePathName = "";
- var fileInputName = "";
- var appearanceId = $('select[name="appearance_id"]').val();
- var distId = $('input[name="dist_id"]').val();
- var fileId = $(this).attr('file_id');
- var fileName = $(this).attr('file_name');
- msg = '确定要删除'+fileName+'吗?';
- Dcat.confirm('确认删除',msg , function () {
- loadingIndex = layer.load(1, {
- shade: [0.5, '#000']
- });
- ajaxAddDelFile(appearanceId,distId,fileId,filePathName,fileInputName,'del');
- });
- });
- }
-
- $("#history-btn").click(function () {
- loadingIndex = layer.load(1, {
- shade: [0.5, '#000']
- });
- var appearanceId = $('select[name="appearance_id"]').val();
- var distId = $('input[name="dist_id"]').val();
- if (fileId == '') {
- Dcat.error('操作失败:请先选择模板');
- return false;
- }
-
- $('#contentDetails').html('');
- $.ajax({
- url: '/prime-control/dist-template/ace',
- method: 'POST',
- data: {
- act: 'fetch_template_logs',
- file_id: fileId,
- dist_id: distId,
- appearance_id: appearanceId,
- },
- success: function(data) {
- const tableBody = $('#templateLogTableBody');
- tableBody.empty();
- data.forEach(log => {
- const row = `<tr log_id="${log.id}">
- <td>Version:${log.version} <br /> ${log.created_at}</td>
- </tr>`;
- tableBody.append(row);
- });
- layer.close(loadingIndex);
-
- $('#templateLogModal').modal('show');
- },
- error: function(error) {
- layer.close(loadingIndex);
- alert('Error fetching data!');
- }
- });
- });
-
- $(document).on('click', '#templateLogTableBody tr', function() {
- loadingIndex = layer.load(1, {
- shade: [0.5, '#000']
- });
-
- $('#templateLogTableBody tr').removeClass('selected-row');
-
- $(this).addClass('selected-row');
-
- var logId = $(this).attr('log_id');
- var appearanceId = $('select[name="appearance_id"]').val();
- var distId = $('input[name="dist_id"]').val();
- $.ajax({
- url: '/prime-control/dist-template/ace',
- method: 'POST',
- data: {
- act: 'fetch_template_log_content',
- log_id: logId,
- dist_id: distId,
- appearance_id: appearanceId,
- },
- success: function(data) {
- layer.close(loadingIndex);
- $('#contentDetails').html(data.previous_content);
- $("#templateLogId").val(data.id);
- $("#templateVersion").val(data.version);
- },
- error: function(error) {
- layer.close(loadingIndex);
- alert('Error fetching data!');
- }
- });
- });
- $("#restoreTemplateLog").click(function () {
- var logId = $("#templateLogId").val();
- var templateVersion = $("#templateVersion").val();
-
- msg = 'Are you sure to restore to version: '+templateVersion+'?';
- Dcat.confirm('Confirm Recovery',msg , function () {
- loadingIndex = layer.load(1, {
- shade: [0.5, '#000']
- });
-
- $.ajax({
- url: '/prime-control/dist-template/ace',
- method: 'POST',
- data: {
- act:'restore_template_log',
- log_id: logId,
- },
- success: function(data) {
- layer.close(loadingIndex);
- if (data.status == '1') {
- Dcat.success('Recovery Successful');
-
- $('#templateLogModal').modal('hide');
-
- editor.setValue('');
-
- postData();
- }else{
- Dcat.error(data.msg);
- }
- },
- error: function(error) {
- layer.close(loadingIndex);
- alert('Error fetching data!');
- }
- });
- });
- });
- });
- </script>
|