index.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/ueditor/ueditor.config.js"></script>
  2. <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/ueditor/ueditor.all.js?v=1"></script>
  3. <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/ueditor/lang/zh-cn/zh-cn.js"></script>
  4. <table id="dg" class="easyui-datagrid" url="/index.php?r=staticSource/list" toolbar="#toolbar" rownumber="true" fitColumns="true" singleSelect="true">
  5. <thead>
  6. <tr>
  7. <th field="key" width="150">资源名称</th>
  8. <th field="title" width="150">标题</th>
  9. <th field="content_short" width="150">内容</th>
  10. <th field="remark" width="150">备注</th>
  11. </tr>
  12. </thead>
  13. </table>
  14. <div id="toolbar">
  15. <a href="javascript:;" class="easyui-linkbutton" iconCls="icon-add" onclick="newSource();return false;">新资源</a>
  16. <a href="javascript:;" class="easyui-linkbutton" iconCls="icon-edit" onclick="editSource();return false;">修改</a>
  17. </div>
  18. <div id="dialog" class="easyui-dialog" style="width:800px;height:600px;padding:10px 20px;" closed="true" buttons="#dialog-buttons">
  19. <form id="form" method="post" novalidate>
  20. <div class="fitem">
  21. <input name="id" hidden="true">
  22. <label>资源名称</label>
  23. <input name="key" class="easyui-textbox" required="true">
  24. <label>标题</label>
  25. <input name="title" class="easyui-textbox" required="true">
  26. <label>备注</label>
  27. <input name="remark" style="width:250px;">
  28. </div>
  29. <div class="fitem">
  30. <script type="text/plain" id="ueditor_container" style="width:720px;height:420px;"></script>
  31. </div>
  32. </form>
  33. </div>
  34. <div id="dialog-buttons">
  35. <a href="javascript:;" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveSource();">保存</a>
  36. <a href="javascript:;" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dialog').dialog('close');">取消</a>
  37. </div>
  38. <script type="text/javascript">
  39. $(function(){
  40. // 初始化UEditor
  41. UE.getEditor('ueditor_container', {
  42. serverUrl: '/index.php?r=ueditorUploader/UeditorUploader',
  43. toolbars: [
  44. [
  45. 'anchor', //锚点
  46. 'undo', //撤销
  47. 'redo', //重做
  48. 'bold', //加粗
  49. 'indent', //首行缩进
  50. 'snapscreen', //截图
  51. 'italic', //斜体
  52. 'underline', //下划线
  53. 'strikethrough', //删除线
  54. 'subscript', //下标
  55. 'fontborder', //字符边框
  56. 'superscript', //上标
  57. 'formatmatch', //格式刷
  58. 'source', //源代码
  59. 'blockquote', //引用
  60. 'pasteplain', //纯文本粘贴模式
  61. 'selectall', //全选
  62. 'print', //打印
  63. 'preview', //预览
  64. 'horizontal', //分隔线
  65. 'removeformat', //清除格式
  66. 'time', //时间
  67. 'date', //日期
  68. 'unlink', //取消链接
  69. 'insertrow', //前插入行
  70. 'insertcol', //前插入列
  71. 'mergeright', //右合并单元格
  72. 'mergedown', //下合并单元格
  73. 'deleterow', //删除行
  74. 'deletecol', //删除列
  75. 'splittorows', //拆分成行
  76. 'splittocols', //拆分成列
  77. 'splittocells', //完全拆分单元格
  78. 'deletecaption', //删除表格标题
  79. 'inserttitle', //插入标题
  80. 'mergecells', //合并多个单元格
  81. 'deletetable', //删除表格
  82. 'cleardoc', //清空文档
  83. 'insertparagraphbeforetable', //"表格前插入行"
  84. 'insertcode', //代码语言
  85. 'fontfamily', //字体
  86. 'fontsize', //字号
  87. 'paragraph', //段落格式
  88. 'simpleupload', //单图上传
  89. 'insertimage', //多图上传
  90. 'edittable', //表格属性
  91. 'edittd', //单元格属性
  92. 'link', //超链接
  93. 'emotion', //表情
  94. 'spechars', //特殊字符
  95. 'searchreplace', //查询替换
  96. 'map', //Baidu地图
  97. 'gmap', //Google地图
  98. 'insertvideo', //视频
  99. 'help', //帮助
  100. 'justifyleft', //居左对齐
  101. 'justifyright', //居右对齐
  102. 'justifycenter', //居中对齐
  103. 'justifyjustify', //两端对齐
  104. 'forecolor', //字体颜色
  105. 'backcolor', //背景色
  106. 'insertorderedlist', //有序列表
  107. 'insertunorderedlist', //无序列表
  108. 'fullscreen', //全屏
  109. 'directionalityltr', //从左向右输入
  110. 'directionalityrtl', //从右向左输入
  111. 'rowspacingtop', //段前距
  112. 'rowspacingbottom', //段后距
  113. 'pagebreak', //分页
  114. 'insertframe', //插入Iframe
  115. 'imagenone', //默认
  116. 'imageleft', //左浮动
  117. 'imageright', //右浮动
  118. 'attachment', //附件
  119. 'imagecenter', //居中
  120. 'wordimage', //图片转存
  121. 'lineheight', //行间距
  122. 'edittip ', //编辑提示
  123. 'customstyle', //自定义标题
  124. 'autotypeset', //自动排版
  125. 'webapp', //百度应用
  126. 'touppercase', //字母大写
  127. 'tolowercase', //字母小写
  128. 'background', //背景
  129. 'template', //模板
  130. 'scrawl', //涂鸦
  131. 'music', //音乐
  132. 'inserttable', //插入表格
  133. 'drafts', // 从草稿箱加载
  134. 'charts', // 图表
  135. ]
  136. ],
  137. zIndex: 9999
  138. });
  139. });
  140. function editSource() {
  141. var row = $('#dg').datagrid('getSelected');
  142. if (row) {
  143. var content = row.content;
  144. UE.getEditor('ueditor_container').setContent(content, false);
  145. $('#form').form('load', row);
  146. $('#dialog').dialog('open').dialog('setTitle', '编辑内容');
  147. }
  148. }
  149. function newSource() {
  150. $('#form').form('clear');
  151. UE.getEditor('ueditor_container').setContent('', false);
  152. $('#dialog').dialog('open').dialog('setTitle', '新建资源');
  153. }
  154. function saveSource() {
  155. $('#form').form('submit', {
  156. url: '/index.php?r=staticSource/edit',
  157. onSubmit: function() {
  158. return true;
  159. },
  160. success: function (result) {
  161. var data = JSON.parse(result);
  162. if (data.success) {
  163. $('#dialog').dialog('close');
  164. $('#dg').datagrid('reload');
  165. } else {
  166. $.messager.show({
  167. title: '保存失败',
  168. msg: data.msg
  169. });
  170. }
  171. }
  172. });
  173. }
  174. </script>