소스 검색

采美百科页面接口调试

yuwenjun1997 2 년 전
부모
커밋
2fede7c3e8

+ 5 - 7
src/main/resources/static/js/supplier-center/encyclopedia/components/content-edit/content-edit.js

@@ -20,11 +20,12 @@ function uuid(len = 16, radix = 16) {
     return value.join('')
 }
 
-let markCount = 1
-
 class ContentEdit {
     constructor(options) {
-        this.options = options
+        this.options = {
+            markCountKey: 'markCount',
+            ...options
+        }
         this.container = document.querySelector(options.el)
         this.hiddenMark = options.hiddenMark
         this.selection = null
@@ -106,9 +107,6 @@ class ContentEdit {
             this.parcelNodeContent()
             this.selection.removeAllRanges()
             this.options.change && this.options.change(this.innerHTML)
-            if(!this.markNum){
-                markCount++
-            }
             return this.ctrid
         } catch (e) {
             return this.ctrid
@@ -201,7 +199,7 @@ class ContentEdit {
     createMark() {
         if (this.hiddenMark) return document.createDocumentFragment()
         const img = document.createElement('img')
-        const index = this.markNum || markCount
+        const index = this.markNum || window[this.options.markCountKey]
         img.classList.add('scapegoat')
         img.setAttribute('height', 20)
         img.setAttribute('data-ctrid', this.ctrid)

+ 1 - 0
src/main/resources/static/js/supplier-center/encyclopedia/components/content-edit/index.js

@@ -65,6 +65,7 @@ const contentEdit = {
             this.contentEdit = new ContentEdit({
                 el: `#${this.editId} .bk-input`,
                 hiddenMark: false,
+                markCountKey: 'markCount',
                 change: (html) => {
                     this.$emit('change', html)
                 }

+ 4 - 0
src/main/resources/static/js/supplier-center/encyclopedia/edit.js

@@ -104,6 +104,8 @@ const ImageUpload = {
     }
 }
 
+var markCount = 1
+
 const edit = new Vue({
     el: '#edit',
     components: {
@@ -237,6 +239,7 @@ const edit = new Vue({
             const infoSize = 4 - this.formData.infoList.length
             const textInfoSize = 4 - this.formData.textInfoList.length
             this.initFormDataList( infoSize, textInfoSize)
+            window.markCount = this.formData.referenceList.length || 1
         },
 
         // 获取图片列表
@@ -321,6 +324,7 @@ const edit = new Vue({
             try {
                 await this.$refs.referenceForm.validate()
                 if (this.referenceEditType === 'add') {
+                    markCount+=1
                     this.referenceData.ctrlId = this.contentEdit.parcel()
                     this.formData.referenceList.push(deepClone(this.referenceData))
                 } else {

+ 4 - 4
src/main/resources/templates/encyclopedia/detail.html

@@ -79,16 +79,16 @@
                     <div class="line"></div>
                 </div>
                 <ul class="bk-literature-list">
-                    <th:block th:each="item :*{referenceList}">
+                    <th:block th:each="item,stat :*{referenceList}">
                         <li th:if="${item.referenceType == 1}" th:id="${item.ctrlId}">
-                            [<em>1</em>]
+                            [<em th:text="${stat.index+1}">1</em>]
                             <i></i>
                             <a class="link" th:href="${item.website}" th:text="${item.articleName}"></a>.
                             <span th:text="${item.websiteName}"></span>
                             <span th:if="${item.acitationTimeStr}">[引用日期:<span th:text="${item.acitationTimeStr}"></span>]</span>
                         </li>
                         <li th:if="${item.referenceType == 2}">
-                            [<em>1</em>]
+                            [<em th:text="${stat.index+1}">1</em>]
                             <i></i>
                             <span th:text="${item.author}"></span>
                             <span th:text="${item.workName}"></span>:
@@ -96,7 +96,7 @@
                             <span th:text="${item.publicationYearStr}"></span>
                         </li>
                         <li th:if="${item.referenceType == 3}">
-                            [<em>1</em>]
+                            [<em th:text="${stat.index+1}">1</em>]
                             <i></i>
                             <span th:text="${item.referenceDescription}"></span>
                             <span th:text="${item.imageDescription}"></span>