form.ftl 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <!-- 新建图文 -->
  2. <link rel="stylesheet" href="../../../../static/mweixin/css/article.css">
  3. <div id='article' class="ms-article" v-show="menuVue.menuActive == '新建图文'">
  4. <el-container class="ms-admin-picture">
  5. <!--右侧头部-->
  6. <el-header class="ms-header" height="50px">
  7. <el-row>
  8. <el-button class="ms-fr" size="small" icon="el-icon-arrow-left" @click="menuVue.menuActive = '关键词回复'">返回</el-button>
  9. <el-button class="ms-fr" size="small" icon="el-icon-refresh">更新</el-button>
  10. <el-button class="ms-fr" type="success" size="small" icon="el-icon-tickets" @click="menuVue.menuActive = '关键词回复'">保存</el-button>
  11. </el-row>
  12. </el-header>
  13. <el-container class=" ms-container">
  14. <el-aside width="280px">
  15. <!-- 主图文章 -->
  16. <div class="ms-main-article">
  17. <img :src="mainArticle.basicPic || ms.base+'/WEB-INF/manager/images/data/article-default.png'">
  18. <div class="ms-article-mask"></div>
  19. <span v-text='mainArticle.basicTitle'></span>
  20. </div>
  21. <draggable v-model="subArticleList" :options="{draggable:'.ms-article-item'}">
  22. <div v-for="(element,index) in subArticleList" :key="index" class="ms-article-item">
  23. <p>
  24. <span v-text='element.basicTitle'></span>
  25. </p>
  26. <img :src='element.basicThumbnails'>
  27. </div>
  28. </draggable>
  29. <div class="ms-article-footer">
  30. <el-button size='medium' icon='el-icon-plus' @click='addArticle'>添加图文</el-button>
  31. </div>
  32. </el-aside>
  33. <el-main>
  34. <div class="ms-main-header">
  35. <el-upload
  36. class="ms-pic-upload"
  37. :show-file-list="false"
  38. :on-success="basicPicSuccess"
  39. :before-upload='beforeBasicPicUpload'
  40. :action="ms.web + '/file/upload.do'"
  41. :limit='1'
  42. :data={uploadFloderPath:"/mweixin/news"}
  43. >
  44. <div class="ms-article-mask" v-show='headMask' @mouseover='headMask=true;' @mouseleave='headMask=false'>
  45. <i class="el-icon-delete" @click='delThumbnail'></i>
  46. </div>
  47. <img v-if="thumbnailShow" :src="thumbnailUrl"
  48. class="article-thumbnail" @mouseover='headMask=true;' @mouseleave='headMask=false;'>
  49. <template v-else>
  50. <i class="el-icon-picture"></i>
  51. <span>添加封面</span>
  52. </template>
  53. </el-upload>
  54. <el-form label-width='40px'>
  55. <el-form-item label="标题" prop="">
  56. <el-input size='small' placeholder="请输入图文标题" v-model='articleForm.basicTitle' @input="resetWordNum('basicTitle',64)">
  57. <span slot='suffix' v-text="titleWordNumber+'/64'"></span>
  58. </el-input>
  59. </el-form-item>
  60. <el-form-item label="作者" prop="">
  61. <el-input size='small' placeholder="请输入图文作者" v-model='articleForm.articleAuthor' @input="resetWordNum('articleAuthor',8)">
  62. <span slot='suffix' v-text="authorWordNumber+'/8'"></span>
  63. </el-input>
  64. </el-form-item>
  65. <el-form-item label="摘要" prop="">
  66. <el-input size='small' type='textarea' placeholder="选填,如果不写会默认抓取正文前54个字" :autosize="{ minRows: 2, maxRows: 2}" resize='none' v-model='articleForm.basicDescription' @input="resetWordNum(120)">
  67. <span slot='suffix' v-text="descWordNumber+'/54'"></span>
  68. </el-input>
  69. </el-form-item>
  70. </el-form>
  71. </div>
  72. <div class="ms-main-body">
  73. <!-- 百度编辑器 -->
  74. <script id="ueditorArticle" type="text/plain" name="articleContent"></script>
  75. </div>
  76. </el-main>
  77. </el-container>
  78. </el-container>
  79. </div>
  80. <script>
  81. var articleVue = new Vue({
  82. el: '#article',
  83. data: {
  84. mainArticle: {
  85. basicPic: '', //主图
  86. basicTitle: '', //标题
  87. },
  88. defaultMainArticle:'',//拷贝主图信息
  89. subArticleList: [],// 子文章列表
  90. titleWordNumber: 64, //图文标题剩余字数
  91. authorWordNumber: 8, //图文作者剩余字数
  92. descWordNumber: 54, //摘要
  93. editor: null, //富文本实例
  94. articleForm: {
  95. basicTitle: '', //标题
  96. articleAuthor: '', //作者
  97. basicDescription: '', //摘要
  98. articleContent: '', //正文
  99. },
  100. defaultArticleForm:'',//拷贝表单值
  101. thumbnailShow:false,//显示缩略图
  102. thumbnailUrl:'',//缩略图路径
  103. headMask:false,//缩略图删除
  104. },
  105. watch:{
  106. articleForm:{
  107. handler:function(n,o){
  108. this.mainArticle.basicTitle = n.basicTitle
  109. },
  110. deep:true,
  111. }
  112. },
  113. methods: {
  114. open:function(material){
  115. menuVue.menuActive = '新建图文';
  116. if(material && material.newsId>0){
  117. // 编辑
  118. this.subArticleList = material.articleList
  119. this.mainArticle = material.newsArticle
  120. }else{
  121. // 新增
  122. console.log('this.defaultArticleForm',this.defaultArticleForm);
  123. this.articleForm = this.defaultArticleForm
  124. this.mainArticle = this.defaultMainArticle
  125. }
  126. console.log('"material',material);
  127. },
  128. // 图片上传之前的钩子
  129. beforeBasicPicUpload:function(file){
  130. var fileType = false;
  131. if(file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg'){
  132. fileType = true;
  133. }
  134. const isLt2M = file.size / 1024 / 1024 < 2;
  135. if (!fileType) {
  136. this.$message.error('文章配图只能是 JPG、JPEG、PNG 格式!');
  137. }
  138. if (!isLt2M) {
  139. this.$message.error('文章配图大小不能超过 2MB!');
  140. }
  141. return fileType && isLt2M;
  142. },
  143. // 图片上传成功函数
  144. basicPicSuccess:function(url){
  145. this.thumbnailShow = true
  146. this.thumbnailUrl = ms.web + url
  147. this.mainArticle.basicPic = this.thumbnailUrl
  148. },
  149. // 添加文章
  150. addArticle: function() {
  151. if(this.subArticleList.length > 6) {
  152. this.$notify({
  153. title: '添加失败',
  154. message: '最大图文数量为7',
  155. type: 'warning'
  156. });
  157. return;
  158. }
  159. this.subArticleList.push({
  160. basicTitle: '新增文章标题',
  161. basicThumbnailsl: 'https://img03.sogoucdn.com/app/a/100520091/20190125113148'
  162. })
  163. },
  164. delThumbnail:function(){
  165. },
  166. // 计算剩余字数
  167. resetWordNum: function(type,limit) {
  168. var result = event.target.value;
  169. if(type.indexOf('Title') > -1){
  170. this.titleWordNumber = this.titleWordNumber - result.length
  171. }else{
  172. this.authorWordNumber = this.authorWordNumber - result.length
  173. }
  174. if(result.length >= limit){
  175. this.$message.error('超出字数限制,请输入不超过'+limit+'字符');
  176. this.$nextTick(function(){
  177. this.articleForm[type] = result.slice(0,limit);
  178. })
  179. }
  180. }
  181. },
  182. mounted: function() {
  183. let that = this;
  184. //富文本加载
  185. var URL = window.UEDITOR_HOME_URL || "http://mpm.mingsoft.net/static/plugins/ueditor/1.4.3.1/";
  186. if(this.editor == null) {
  187. this.editor = UE.getEditor('ueditorArticle', {
  188. toolbars: [
  189. ['fullscreen', 'undo', 'redo', '|', 'bold', 'italic', 'underline',
  190. 'strikethrough',
  191. 'removeformat', 'blockquote',
  192. '|', 'forecolor', 'backcolor', 'insertorderedlist',
  193. 'insertunorderedlist', '|', 'attachment', 'simpleupload', 'link'
  194. ]
  195. ],
  196. imageScaleEnabled: true,
  197. // 服务器统一请求接口路径
  198. serverUrl: URL +
  199. "jsp/msController.jsp?jsonConfig=%7BvideoUrlPrefix:'http://mpm.mingsoft.net/',fileUrlPrefix:'http://mpm.mingsoft.net/',imageUrlPrefix:'http://mpm.mingsoft.net/',imagePathFormat:'/upload/pm/editor/%7Btime%7D',filePathFormat:'/upload/pm/editor/%7Btime%7D',videoPathFormat:'/upload/pm/editor/%7Btime%7D'%7D",
  200. autoHeightEnabled: true,
  201. autoFloatEnabled: true,
  202. scaleEnabled: false,
  203. compressSide: 0,
  204. maxImageSideLength: 2000,
  205. maximumWords: 80000,
  206. zIndex: 10000,
  207. elementPathEnabled: false,
  208. wordCount: false,
  209. initialFrameWidth: '100%',
  210. initialFrameHeight: 500,
  211. });
  212. this.editor.ready(function() {
  213. var a = $("#ueditor_0").contents()[0].activeElement;
  214. $(a).addClass("ms-webkit-scrollbar").before(
  215. "<style>.ms-webkit-scrollbar::-webkit-scrollbar,::-webkit-scrollbar{width:10px;/*滚动条宽度*/height:1.5%;/*滚动条高度*/}/*定义滚动条轨道内阴影+圆角*/.ms-webkit-scrollbar::-webkit-scrollbar-track,::-webkit-scrollbar-track{border-radius:10px;/*滚动条的背景区域的圆角*/background-color:#eeeeee;/*滚动条的背景颜色*/}.ms-task-content::-webkit-scrollbar-track{border-radius:10px;background-color:#FFFFFF;}/*定义滑块内阴影+圆角*/.ms-webkit-scrollbar::-webkit-scrollbar-thumb,::-webkit-scrollbar-thumb{border-radius:10px;/*滚动条的圆角*/background-color:#dddddd;/*滚动条的背景颜色*/}</style>"
  216. );
  217. });
  218. }
  219. // 初始化默认值
  220. this.defaultArticleForm = JSON.parse(JSON.stringify(this.articleForm))
  221. this.defaultMainArticle = JSON.parse(JSON.stringify(this.mainArticle))
  222. }
  223. })
  224. </script>