Sfoglia il codice sorgente

修改样式及新增文件自由拖动功能

zengyicheng 2 anni fa
parent
commit
6ae60384d9

+ 105 - 48
src/components/pages/race/addRace/projectActpro.vue

@@ -57,58 +57,65 @@
                         class="add_chapters_box"
                         style="display: flex; flex-direction: column"
                       >
-                        <div
-                          class="chapter_upload"
-                          v-for="(item, index) in sa.data"
-                          :key="item.id"
-                        >
-                          <div class="chapter_upload_t"></div>
-                          <div class="chapter_upload_o">
-                            <div class="chapter_upload_l">
-                              <div
-                                v-if="item.type == 2"
-                                class="chapter_upload_l_i1"
-                              ></div>
-                              <div
-                                v-if="item.type == 1 || item.type == 3"
-                                class="chapter_upload_l_i5"
-                              ></div>
-                            </div>
-                            <div class="chapter_upload_ic">
-                              <div class="chapter_upload_ic_l"></div>
-                              <div
-                                class="chapter_upload_ic_r"
-                                @click.stop="
-                                  deleteChapterData($event, saIndex, index)
-                                "
-                              >
-                                <div></div>
-                              </div>
-                            </div>
-                            <div class="chapter_upload_n">
-                              <input
-                                class="first"
-                                v-if="item.type == 1 || item.type == 3"
-                                :placeholder="item.name"
-                              />
-                              <input
-                                class="first"
-                                v-if="item.type == 2"
-                                :placeholder="item.name"
-                              />
-                              <div class="chapter_upload_ud">
+                        <transition-group tag="div">
+                          <div
+                            class="chapter_upload"
+                            v-for="(item, index) in sa.data"
+                            :key="item.id"
+                            draggable="true"
+                            @dragstart="handleDragStart($event, item)"
+                            @dragover.prevent="handleDragOver($event, item)"
+                            @dragenter="handleDragEnter($event, item)"
+                            @dragend="handleDragEnd($event, item, saIndex)"
+                          >
+                            <div class="chapter_upload_t"></div>
+                            <div class="chapter_upload_o">
+                              <div class="chapter_upload_l">
                                 <div
-                                  class="chapter_upload_up"
-                                  @click="upCd($event, saIndex, index)"
+                                  v-if="item.type == 2"
+                                  class="chapter_upload_l_i1"
                                 ></div>
                                 <div
-                                  class="chapter_upload_down"
-                                  @click="downCd($event, saIndex, index)"
+                                  v-if="item.type == 1 || item.type == 3"
+                                  class="chapter_upload_l_i5"
                                 ></div>
                               </div>
+                              <div class="chapter_upload_ic">
+                                <div class="chapter_upload_ic_l"></div>
+                                <div
+                                  class="chapter_upload_ic_r"
+                                  @click.stop="
+                                    deleteChapterData($event, saIndex, index)
+                                  "
+                                >
+                                  <div></div>
+                                </div>
+                              </div>
+                              <div class="chapter_upload_n">
+                                <input
+                                  class="first"
+                                  v-if="item.type == 1 || item.type == 3"
+                                  :placeholder="item.name"
+                                />
+                                <input
+                                  class="first"
+                                  v-if="item.type == 2"
+                                  :placeholder="item.name"
+                                />
+                                <div class="chapter_upload_ud">
+                                  <div
+                                    class="chapter_upload_up"
+                                    @click="upCd($event, saIndex, index)"
+                                  ></div>
+                                  <div
+                                    class="chapter_upload_down"
+                                    @click="downCd($event, saIndex, index)"
+                                  ></div>
+                                </div>
+                              </div>
                             </div>
                           </div>
-                        </div>
+                        </transition-group>
                       </div>
                     </div>
                     <div class="add_info_box">
@@ -200,6 +207,8 @@ export default {
       full: false,
       jdIndex: 0,
       stage: 0,
+      ending: null,
+      dragging: null,
     };
   },
   methods: {
@@ -209,6 +218,37 @@ export default {
     handleClose(done) {
       done();
     },
+
+    handleDragStart(e, item) {
+      this.dragging = item;
+    },
+    handleDragEnd(e, item,i) {
+      if (this.ending.id === this.dragging.id) {
+        return;
+      }
+      let newItems = [...this.raceAct.stageBox[i].data];
+      const src = newItems.indexOf(this.dragging);
+      const dst = newItems.indexOf(this.ending);
+      newItems.splice(src, 1, ...newItems.splice(dst, 1, newItems[src]));
+      console.log(newItems);
+
+      this.raceAct.stageBox[i].data = newItems;
+      this.$nextTick(() => {
+        this.dragging = null;
+        this.ending = null;
+      });
+    },
+    handleDragOver(e) {
+      // 首先把div变成可以放置的元素,即重写dragenter/dragover
+      // 在dragenter中针对放置目标来设置
+      e.dataTransfer.dropEffect = "move";
+    },
+    handleDragEnter(e, item) {
+      // 为需要移动的元素设置dragstart事件
+      e.dataTransfer.effectAllowed = "move";
+      this.ending = item;
+    },
+
     addImg(e) {
       var el = e.currentTarget;
       el.getElementsByTagName("input")[0].click();
@@ -356,6 +396,7 @@ export default {
                 name: file.name,
                 url: data.Location,
                 type: type1,
+                id: "data" + _this.raceAct.stageBox[sindex].data.length,
               });
               _this.imgChange(null, null, type1, sindex);
               _this.upRaceAct();
@@ -485,7 +526,7 @@ export default {
   flex-wrap: nowrap;
   position: relative;
   width: 145px;
-  height: 130px;
+  height: 150px;
 }
 .steps > div:nth-child(1) > img {
   z-index: 9;
@@ -497,10 +538,25 @@ export default {
   flex-wrap: nowrap;
   justify-content: space-between;
   align-items: flex-start;
-  margin: 8px 0 0 10px;
-  height: 40px;
+  margin: 10px 0 0 10px;
   cursor: pointer;
 }
+.stepRightNav > div {
+  margin-bottom: 5px;
+}
+
+.stepRightNav > div:nth-child(2) {
+  width: 130px;
+  height: 63px;
+  max-height: 63px;
+  display: -webkit-box;
+  overflow: hidden;
+  white-space: normal !important;
+  text-overflow: ellipsis;
+  word-wrap: break-word;
+  -webkit-line-clamp: 3;
+  -webkit-box-orient: vertical;
+}
 .stepRightNav:hover {
   color: #999;
 }
@@ -563,6 +619,7 @@ export default {
   align-items: center;
   width: 100%;
   min-height: 50px;
+  transition: all linear 0.3s;
 }
 
 .chapter_upload_t {

+ 90 - 45
src/components/pages/race/addRace/projectEffect.vue

@@ -45,56 +45,63 @@
                         class="add_chapters_box"
                         style="display: flex; flex-direction: column"
                       >
-                        <div
-                          class="chapter_upload"
-                          v-for="(item, index) in raceEff.data"
-                          :key="item.id"
-                        >
-                          <div class="chapter_upload_t"></div>
-                          <div class="chapter_upload_o">
-                            <div class="chapter_upload_l">
-                              <div
-                                v-if="item.type == 2"
-                                class="chapter_upload_l_i1"
-                              ></div>
-                              <div
-                                v-if="item.type == 1 || item.type == 3"
-                                class="chapter_upload_l_i5"
-                              ></div>
-                            </div>
-                            <div class="chapter_upload_ic">
-                              <div class="chapter_upload_ic_l"></div>
-                              <div
-                                class="chapter_upload_ic_r"
-                                @click.stop="deleteChapterData($event, index)"
-                              >
-                                <div></div>
-                              </div>
-                            </div>
-                            <div class="chapter_upload_n">
-                              <input
-                                class="first"
-                                v-if="item.type == 1 || item.type == 3"
-                                :placeholder="item.name"
-                              />
-                              <input
-                                class="first"
-                                v-if="item.type == 2"
-                                :placeholder="item.name"
-                              />
-                              <div class="chapter_upload_ud">
+                        <transition-group tag="div">
+                          <div
+                            class="chapter_upload"
+                            v-for="(item, index) in raceEff.data"
+                            :key="item.id"
+                            draggable="true"
+                            @dragstart="handleDragStart($event, item)"
+                            @dragover.prevent="handleDragOver($event, item)"
+                            @dragenter="handleDragEnter($event, item)"
+                            @dragend="handleDragEnd($event, item)"
+                          >
+                            <div class="chapter_upload_t"></div>
+                            <div class="chapter_upload_o">
+                              <div class="chapter_upload_l">
                                 <div
-                                  class="chapter_upload_up"
-                                  @click="upCd($event, index)"
+                                  v-if="item.type == 2"
+                                  class="chapter_upload_l_i1"
                                 ></div>
                                 <div
-                                  class="chapter_upload_down"
-                                  @click="downCd($event, index)"
+                                  v-if="item.type == 1 || item.type == 3"
+                                  class="chapter_upload_l_i5"
                                 ></div>
                               </div>
+                              <div class="chapter_upload_ic">
+                                <div class="chapter_upload_ic_l"></div>
+                                <div
+                                  class="chapter_upload_ic_r"
+                                  @click.stop="deleteChapterData($event, index)"
+                                >
+                                  <div></div>
+                                </div>
+                              </div>
+                              <div class="chapter_upload_n">
+                                <input
+                                  class="first"
+                                  v-if="item.type == 1 || item.type == 3"
+                                  :placeholder="item.name"
+                                />
+                                <input
+                                  class="first"
+                                  v-if="item.type == 2"
+                                  :placeholder="item.name"
+                                />
+                                <div class="chapter_upload_ud">
+                                  <div
+                                    class="chapter_upload_up"
+                                    @click="upCd($event, index)"
+                                  ></div>
+                                  <div
+                                    class="chapter_upload_down"
+                                    @click="downCd($event, index)"
+                                  ></div>
+                                </div>
+                              </div>
                             </div>
                           </div>
-                        </div>
+                        </transition-group>
                       </div>
                     </div>
                     <div class="add_info_box">
@@ -169,6 +176,8 @@ export default {
       fullBrief: "",
       plaText: "",
       full: false,
+      ending: null,
+      dragging: null,
     };
   },
   methods: {
@@ -181,10 +190,41 @@ export default {
     upproEff() {
       this.$emit("upproEff", this.raceEff);
     },
+
+    handleDragStart(e, item) {
+      this.dragging = item;
+    },
+    handleDragEnd(e, item) {
+      if (this.ending.id === this.dragging.id) {
+        return;
+      }
+      let newItems = [...this.raceEff.data];
+      const src = newItems.indexOf(this.dragging);
+      const dst = newItems.indexOf(this.ending);
+      newItems.splice(src, 1, ...newItems.splice(dst, 1, newItems[src]));
+      console.log(newItems);
+
+      this.raceEff.data = newItems;
+      this.$nextTick(() => {
+        this.dragging = null;
+        this.ending = null;
+      });
+    },
+    handleDragOver(e) {
+      // 首先把div变成可以放置的元素,即重写dragenter/dragover
+      // 在dragenter中针对放置目标来设置
+      e.dataTransfer.dropEffect = "move";
+    },
+    handleDragEnter(e, item) {
+      // 为需要移动的元素设置dragstart事件
+      e.dataTransfer.effectAllowed = "move";
+      this.ending = item;
+    },
+
     addImg(e) {
       var el = e.currentTarget;
       el.getElementsByTagName("input")[0].click();
-      e.target.value = ''
+      e.target.value = "";
     },
     imgChange(file, fileList, type) {
       var _tmp = this.raceEff.data;
@@ -323,6 +363,7 @@ export default {
                 name: file.name,
                 url: data.Location,
                 type: type1,
+                id: "data" + _this.raceEff.data.length,
               });
               _this.imgChange(null, null, type1);
               _this.upproEff();
@@ -464,10 +505,13 @@ export default {
   flex-wrap: nowrap;
   justify-content: space-between;
   align-items: flex-start;
-  margin: 8px 0 0 10px;
+  margin: 10px 0 0 10px;
   height: 40px;
   cursor: pointer;
 }
+.stepRightNav > div {
+  margin-bottom: 5px;
+}
 .stepRightNav:hover {
   color: #999;
 }
@@ -583,6 +627,7 @@ export default {
   align-items: center;
   width: 100%;
   min-height: 50px;
+  transition: all linear 0.3s;
 }
 
 .chapter_upload_t {

+ 89 - 44
src/components/pages/race/addRace/projectExceva.vue

@@ -45,56 +45,63 @@
                         class="add_chapters_box"
                         style="display: flex; flex-direction: column"
                       >
-                        <div
-                          class="chapter_upload"
-                          v-for="(item, index) in raceExc.data"
-                          :key="item.id"
-                        >
-                          <div class="chapter_upload_t"></div>
-                          <div class="chapter_upload_o">
-                            <div class="chapter_upload_l">
-                              <div
-                                v-if="item.type == 2"
-                                class="chapter_upload_l_i1"
-                              ></div>
-                              <div
-                                v-if="item.type == 1 || item.type == 3"
-                                class="chapter_upload_l_i5"
-                              ></div>
-                            </div>
-                            <div class="chapter_upload_ic">
-                              <div class="chapter_upload_ic_l"></div>
-                              <div
-                                class="chapter_upload_ic_r"
-                                @click.stop="deleteChapterData($event, index)"
-                              >
-                                <div></div>
-                              </div>
-                            </div>
-                            <div class="chapter_upload_n">
-                              <input
-                                class="first"
-                                v-if="item.type == 1 || item.type == 3"
-                                :placeholder="item.name"
-                              />
-                              <input
-                                class="first"
-                                v-if="item.type == 2"
-                                :placeholder="item.name"
-                              />
-                              <div class="chapter_upload_ud">
+                        <transition-group tag="div">
+                          <div
+                            class="chapter_upload"
+                            v-for="(item, index) in raceExc.data"
+                            :key="item.id"
+                            draggable="true"
+                            @dragstart="handleDragStart($event, item)"
+                            @dragover.prevent="handleDragOver($event, item)"
+                            @dragenter="handleDragEnter($event, item)"
+                            @dragend="handleDragEnd($event, item)"
+                          >
+                            <div class="chapter_upload_t"></div>
+                            <div class="chapter_upload_o">
+                              <div class="chapter_upload_l">
                                 <div
-                                  class="chapter_upload_up"
-                                  @click="upCd($event, index)"
+                                  v-if="item.type == 2"
+                                  class="chapter_upload_l_i1"
                                 ></div>
                                 <div
-                                  class="chapter_upload_down"
-                                  @click="downCd($event, index)"
+                                  v-if="item.type == 1 || item.type == 3"
+                                  class="chapter_upload_l_i5"
                                 ></div>
                               </div>
+                              <div class="chapter_upload_ic">
+                                <div class="chapter_upload_ic_l"></div>
+                                <div
+                                  class="chapter_upload_ic_r"
+                                  @click.stop="deleteChapterData($event, index)"
+                                >
+                                  <div></div>
+                                </div>
+                              </div>
+                              <div class="chapter_upload_n">
+                                <input
+                                  class="first"
+                                  v-if="item.type == 1 || item.type == 3"
+                                  :placeholder="item.name"
+                                />
+                                <input
+                                  class="first"
+                                  v-if="item.type == 2"
+                                  :placeholder="item.name"
+                                />
+                                <div class="chapter_upload_ud">
+                                  <div
+                                    class="chapter_upload_up"
+                                    @click="upCd($event, index)"
+                                  ></div>
+                                  <div
+                                    class="chapter_upload_down"
+                                    @click="downCd($event, index)"
+                                  ></div>
+                                </div>
+                              </div>
                             </div>
                           </div>
-                        </div>
+                        </transition-group>
                       </div>
                     </div>
                     <div class="add_info_box">
@@ -169,6 +176,8 @@ export default {
       fullBrief: "",
       plaText: "",
       full: false,
+      ending: null,
+      dragging: null,
     };
   },
   methods: {
@@ -181,6 +190,37 @@ export default {
     upExc() {
       this.$emit("upExc", this.raceExc);
     },
+
+    handleDragStart(e, item) {
+      this.dragging = item;
+    },
+    handleDragEnd(e, item) {
+      if (this.ending.id === this.dragging.id) {
+        return;
+      }
+      let newItems = [...this.raceExc.data];
+      const src = newItems.indexOf(this.dragging);
+      const dst = newItems.indexOf(this.ending);
+      newItems.splice(src, 1, ...newItems.splice(dst, 1, newItems[src]));
+      console.log(newItems);
+
+      this.raceExc.data = newItems;
+      this.$nextTick(() => {
+        this.dragging = null;
+        this.ending = null;
+      });
+    },
+    handleDragOver(e) {
+      // 首先把div变成可以放置的元素,即重写dragenter/dragover
+      // 在dragenter中针对放置目标来设置
+      e.dataTransfer.dropEffect = "move";
+    },
+    handleDragEnter(e, item) {
+      // 为需要移动的元素设置dragstart事件
+      e.dataTransfer.effectAllowed = "move";
+      this.ending = item;
+    },
+
     addImg(e) {
       var el = e.currentTarget;
       el.getElementsByTagName("input")[0].click();
@@ -323,6 +363,7 @@ export default {
                 name: file.name,
                 url: data.Location,
                 type: type1,
+                id: "data" + _this.raceExc.data.length,
               });
               _this.imgChange(null, null, type1);
               _this.upExc();
@@ -464,10 +505,13 @@ export default {
   flex-wrap: nowrap;
   justify-content: space-between;
   align-items: flex-start;
-  margin: 8px 0 0 10px;
+  margin: 10px 0 0 10px;
   height: 40px;
   cursor: pointer;
 }
+.stepRightNav > div {
+  margin-bottom: 5px;
+}
 .stepRightNav:hover {
   color: #999;
 }
@@ -583,6 +627,7 @@ export default {
   align-items: center;
   width: 100%;
   min-height: 50px;
+  transition: all linear 0.3s;
 }
 
 .chapter_upload_t {

+ 19 - 3
src/components/pages/race/addRace/projectProcess.vue

@@ -1212,7 +1212,7 @@ export default {
   flex-wrap: nowrap;
   position: relative;
   width: 145px;
-  height: 130px;
+  height: 150px;
 }
 .steps > div:nth-child(1) > img {
   z-index: 9;
@@ -1225,10 +1225,26 @@ export default {
   flex-wrap: nowrap;
   justify-content: space-between;
   align-items: flex-start;
-  margin: 8px 0 0 10px;
-  height: 40px;
+  margin: 10px 0 0 10px;
   cursor: pointer;
 }
+.stepRightNav > div {
+  margin-bottom: 5px;
+}
+
+.stepRightNav > div:nth-child(2) {
+  width: 130px;
+  height: 63px;
+  max-height: 63px;
+  display: -webkit-box;
+  overflow: hidden;
+  white-space: normal !important;
+  text-overflow: ellipsis;
+  word-wrap: break-word;
+  -webkit-line-clamp: 3;
+  -webkit-box-orient: vertical;
+}
+
 .stepRightNav:hover {
   color: #999;
 }

+ 92 - 49
src/components/pages/race/addRace/raceDetail.vue

@@ -469,58 +469,65 @@
                         class="add_chapters_box"
                         style="display: flex; flex-direction: column"
                       >
-                        <div
-                          class="chapter_upload"
-                          v-for="(item, index) in raceDetail.data"
-                          :key="item.id"
-                        >
-                          <div class="chapter_upload_t"></div>
-                          <div class="chapter_upload_o">
-                            <div class="chapter_upload_l">
-                              <div
-                                v-if="item.type == 2"
-                                class="chapter_upload_l_i1"
-                              ></div>
-                              <div
-                                v-if="item.type == 1 || item.type == 3"
-                                class="chapter_upload_l_i5"
-                              ></div>
-                            </div>
-                            <div class="chapter_upload_ic">
-                              <div class="chapter_upload_ic_l"></div>
-                              <div
-                                class="chapter_upload_ic_r"
-                                @click.stop="
-                                  deleteChapterData($event, index, 0)
-                                "
-                              >
-                                <div></div>
-                              </div>
-                            </div>
-                            <div class="chapter_upload_n">
-                              <input
-                                class="first"
-                                v-if="item.type == 1 || item.type == 3"
-                                :placeholder="item.name"
-                              />
-                              <input
-                                class="first"
-                                v-if="item.type == 2"
-                                :placeholder="item.name"
-                              />
-                              <div class="chapter_upload_ud">
+                        <transition-group tag="div">
+                          <div
+                            class="chapter_upload"
+                            v-for="(item, index) in raceDetail.data"
+                            :key="item.id"
+                            draggable="true"
+                            @dragstart="handleDragStart($event, item)"
+                            @dragover.prevent="handleDragOver($event, item)"
+                            @dragenter="handleDragEnter($event, item)"
+                            @dragend="handleDragEnd($event, item)"
+                          >
+                            <div class="chapter_upload_t"></div>
+                            <div class="chapter_upload_o">
+                              <div class="chapter_upload_l">
                                 <div
-                                  class="chapter_upload_up"
-                                  @click="upCd($event, index)"
+                                  v-if="item.type == 2"
+                                  class="chapter_upload_l_i1"
                                 ></div>
                                 <div
-                                  class="chapter_upload_down"
-                                  @click="downCd($event, index)"
+                                  v-if="item.type == 1 || item.type == 3"
+                                  class="chapter_upload_l_i5"
                                 ></div>
                               </div>
+                              <div class="chapter_upload_ic">
+                                <div class="chapter_upload_ic_l"></div>
+                                <div
+                                  class="chapter_upload_ic_r"
+                                  @click.stop="
+                                    deleteChapterData($event, index, 0)
+                                  "
+                                >
+                                  <div></div>
+                                </div>
+                              </div>
+                              <div class="chapter_upload_n">
+                                <input
+                                  class="first"
+                                  v-if="item.type == 1 || item.type == 3"
+                                  :placeholder="item.name"
+                                />
+                                <input
+                                  class="first"
+                                  v-if="item.type == 2"
+                                  :placeholder="item.name"
+                                />
+                                <div class="chapter_upload_ud">
+                                  <div
+                                    class="chapter_upload_up"
+                                    @click="upCd($event, index)"
+                                  ></div>
+                                  <div
+                                    class="chapter_upload_down"
+                                    @click="downCd($event, index)"
+                                  ></div>
+                                </div>
+                              </div>
                             </div>
                           </div>
-                        </div>
+                        </transition-group>
                       </div>
                     </div>
                     <div class="add_info_box">
@@ -538,7 +545,7 @@
                             @change="beforeUpload($event, null, 0)"
                           />
                         </button>
-                        <div style="color:red;">
+                        <div style="color: red">
                           *此处需提交《项目式学习方案设计》、《项目式学习活动案例》的PDF格式文件。
                         </div>
                       </div>
@@ -777,6 +784,8 @@ export default {
         data: [],
       },
       tx: require("../../../../assets/avatar.png"),
+      ending: null,
+      dragging: null,
     };
   },
   mounted() {
@@ -826,6 +835,37 @@ export default {
     handlePictureCardPreview(file) {
       this.dialogImageUrl = file.url;
     },
+
+    handleDragStart(e, item) {
+      this.dragging = item;
+    },
+    handleDragEnd(e, item) {
+      if (this.ending.id === this.dragging.id) {
+        return;
+      }
+      let newItems = [...this.raceDetail.data];
+      const src = newItems.indexOf(this.dragging);
+      const dst = newItems.indexOf(this.ending);
+      newItems.splice(src, 1, ...newItems.splice(dst, 1, newItems[src]));
+      console.log(newItems);
+
+      this.raceDetail.data = newItems;
+      this.$nextTick(() => {
+        this.dragging = null;
+        this.ending = null;
+      });
+    },
+    handleDragOver(e) {
+      // 首先把div变成可以放置的元素,即重写dragenter/dragover
+      // 在dragenter中针对放置目标来设置
+      e.dataTransfer.dropEffect = "move";
+    },
+    handleDragEnter(e, item) {
+      // 为需要移动的元素设置dragstart事件
+      e.dataTransfer.effectAllowed = "move";
+      this.ending = item;
+    },
+
     onExceed() {
       this.$message.error("项目封面仅支持上传一张,请删除后再进行上传");
     },
@@ -1088,6 +1128,7 @@ export default {
                 name: file.name,
                 url: data.Location,
                 type: type1,
+                id: "data" + _this.raceDetail.data.length,
               });
               _this.imgChange(null, null, type1, jsonType);
               console.log(data.Location);
@@ -1341,7 +1382,6 @@ export default {
   .upTips {
     align-items: flex-start !important;
   }
-
 }
 
 .dialog_diy >>> .el-dialog__header {
@@ -1446,11 +1486,13 @@ export default {
   flex-wrap: nowrap;
   justify-content: space-between;
   align-items: flex-start;
-  margin: 8px 0 0 10px;
+  margin: 10px 0 0 10px;
   height: 40px;
   cursor: pointer;
 }
-
+.stepRightNav > div {
+  margin-bottom: 5px;
+}
 .stepRightNav:hover {
   color: #999;
 }
@@ -1972,6 +2014,7 @@ export default {
   align-items: center;
   width: 100%;
   min-height: 50px;
+  transition: all linear 0.3s;
 }
 
 .chapter_upload_t {

+ 211 - 130
src/components/pages/race/addRace/raceOverview.vue

@@ -132,56 +132,65 @@
                       class="add_chapters_box"
                       style="display: flex; flex-direction: column"
                     >
-                      <div
-                        class="chapter_upload"
-                        v-for="(item, index) in raceOver.driQuestion.data"
-                        :key="item.id"
-                      >
-                        <div class="chapter_upload_t"></div>
-                        <div class="chapter_upload_o">
-                          <div class="chapter_upload_l">
-                            <div
-                              v-if="item.type == 2"
-                              class="chapter_upload_l_i1"
-                            ></div>
-                            <div
-                              v-if="item.type == 1 || item.type == 3"
-                              class="chapter_upload_l_i5"
-                            ></div>
-                          </div>
-                          <div class="chapter_upload_ic">
-                            <div class="chapter_upload_ic_l"></div>
-                            <div
-                              class="chapter_upload_ic_r"
-                              @click.stop="deleteChapterData($event, index, 0)"
-                            >
-                              <div></div>
-                            </div>
-                          </div>
-                          <div class="chapter_upload_n">
-                            <input
-                              class="first"
-                              v-if="item.type == 1 || item.type == 3"
-                              :placeholder="item.name"
-                            />
-                            <input
-                              class="first"
-                              v-if="item.type == 2"
-                              :placeholder="item.name"
-                            />
-                            <div class="chapter_upload_ud">
+                      <transition-group tag="div">
+                        <div
+                          class="chapter_upload"
+                          v-for="(item, index) in raceOver.driQuestion.data"
+                          :key="item.id"
+                          draggable="true"
+                          @dragstart="handleDragStart($event, item)"
+                          @dragover.prevent="handleDragOver($event, item)"
+                          @dragenter="handleDragEnter($event, item)"
+                          @dragend="handleDragEnd($event, item, 0)"
+                        >
+                          <div class="chapter_upload_t"></div>
+                          <div class="chapter_upload_o">
+                            <div class="chapter_upload_l">
                               <div
-                                class="chapter_upload_up"
-                                @click="upCd($event, index, 0)"
+                                v-if="item.type == 2"
+                                class="chapter_upload_l_i1"
                               ></div>
                               <div
-                                class="chapter_upload_down"
-                                @click="downCd($event, index, 0)"
+                                v-if="item.type == 1 || item.type == 3"
+                                class="chapter_upload_l_i5"
                               ></div>
                             </div>
+                            <div class="chapter_upload_ic">
+                              <div class="chapter_upload_ic_l"></div>
+                              <div
+                                class="chapter_upload_ic_r"
+                                @click.stop="
+                                  deleteChapterData($event, index, 0)
+                                "
+                              >
+                                <div></div>
+                              </div>
+                            </div>
+                            <div class="chapter_upload_n">
+                              <input
+                                class="first"
+                                v-if="item.type == 1 || item.type == 3"
+                                :placeholder="item.name"
+                              />
+                              <input
+                                class="first"
+                                v-if="item.type == 2"
+                                :placeholder="item.name"
+                              />
+                              <div class="chapter_upload_ud">
+                                <div
+                                  class="chapter_upload_up"
+                                  @click="upCd($event, index, 0)"
+                                ></div>
+                                <div
+                                  class="chapter_upload_down"
+                                  @click="downCd($event, index, 0)"
+                                ></div>
+                              </div>
+                            </div>
                           </div>
                         </div>
-                      </div>
+                      </transition-group>
                     </div>
                   </div>
                   <div class="add_info_box">
@@ -281,56 +290,65 @@
                       class="add_chapters_box"
                       style="display: flex; flex-direction: column"
                     >
-                      <div
-                        class="chapter_upload"
-                        v-for="(item1, index1) in raceOver.tarDesign.data"
-                        :key="item1.id"
-                      >
-                        <div class="chapter_upload_t"></div>
-                        <div class="chapter_upload_o">
-                          <div class="chapter_upload_l">
-                            <div
-                              v-if="item1.type == 2"
-                              class="chapter_upload_l_i1"
-                            ></div>
-                            <div
-                              v-if="item1.type == 1 || item1.type == 3"
-                              class="chapter_upload_l_i5"
-                            ></div>
-                          </div>
-                          <div class="chapter_upload_ic">
-                            <div class="chapter_upload_ic_l"></div>
-                            <div
-                              class="chapter_upload_ic_r"
-                              @click.stop="deleteChapterData($event, index1, 1)"
-                            >
-                              <div></div>
-                            </div>
-                          </div>
-                          <div class="chapter_upload_n">
-                            <input
-                              class="first"
-                              v-if="item1.type == 1 || item1.type == 3"
-                              :placeholder="item1.name"
-                            />
-                            <input
-                              class="first"
-                              v-if="item1.type == 2"
-                              :placeholder="item1.name"
-                            />
-                            <div class="chapter_upload_ud">
+                      <transition-group tag="div">
+                        <div
+                          class="chapter_upload"
+                          v-for="(item1, index1) in raceOver.tarDesign.data"
+                          :key="item1.id"
+                          draggable="true"
+                          @dragstart="handleDragStart($event, item1)"
+                          @dragover.prevent="handleDragOver($event, item1)"
+                          @dragenter="handleDragEnter($event, item1)"
+                          @dragend="handleDragEnd($event, item1, 1)"
+                        >
+                          <div class="chapter_upload_t"></div>
+                          <div class="chapter_upload_o">
+                            <div class="chapter_upload_l">
                               <div
-                                class="chapter_upload_up"
-                                @click="upCd($event, index1, 1)"
+                                v-if="item1.type == 2"
+                                class="chapter_upload_l_i1"
                               ></div>
                               <div
-                                class="chapter_upload_down"
-                                @click="downCd($event, index1, 1)"
+                                v-if="item1.type == 1 || item1.type == 3"
+                                class="chapter_upload_l_i5"
                               ></div>
                             </div>
+                            <div class="chapter_upload_ic">
+                              <div class="chapter_upload_ic_l"></div>
+                              <div
+                                class="chapter_upload_ic_r"
+                                @click.stop="
+                                  deleteChapterData($event, index1, 1)
+                                "
+                              >
+                                <div></div>
+                              </div>
+                            </div>
+                            <div class="chapter_upload_n">
+                              <input
+                                class="first"
+                                v-if="item1.type == 1 || item1.type == 3"
+                                :placeholder="item1.name"
+                              />
+                              <input
+                                class="first"
+                                v-if="item1.type == 2"
+                                :placeholder="item1.name"
+                              />
+                              <div class="chapter_upload_ud">
+                                <div
+                                  class="chapter_upload_up"
+                                  @click="upCd($event, index1, 1)"
+                                ></div>
+                                <div
+                                  class="chapter_upload_down"
+                                  @click="downCd($event, index1, 1)"
+                                ></div>
+                              </div>
+                            </div>
                           </div>
                         </div>
-                      </div>
+                      </transition-group>
                     </div>
                   </div>
                   <div class="add_info_box">
@@ -429,56 +447,65 @@
                       class="add_chapters_box"
                       style="display: flex; flex-direction: column"
                     >
-                      <div
-                        class="chapter_upload"
-                        v-for="(item2, index2) in raceOver.actiDesign.data"
-                        :key="item2.id"
-                      >
-                        <div class="chapter_upload_t"></div>
-                        <div class="chapter_upload_o">
-                          <div class="chapter_upload_l">
-                            <div
-                              v-if="item2.type == 2"
-                              class="chapter_upload_l_i1"
-                            ></div>
-                            <div
-                              v-if="item2.type == 1 || item2.type == 3"
-                              class="chapter_upload_l_i5"
-                            ></div>
-                          </div>
-                          <div class="chapter_upload_ic">
-                            <div class="chapter_upload_ic_l"></div>
-                            <div
-                              class="chapter_upload_ic_r"
-                              @click.stop="deleteChapterData($event, index2, 2)"
-                            >
-                              <div></div>
-                            </div>
-                          </div>
-                          <div class="chapter_upload_n">
-                            <input
-                              class="first"
-                              v-if="item2.type == 1 || item2.type == 3"
-                              :placeholder="item2.name"
-                            />
-                            <input
-                              class="first"
-                              v-if="item2.type == 2"
-                              :placeholder="item2.name"
-                            />
-                            <div class="chapter_upload_ud">
+                      <transition-group tag="div">
+                        <div
+                          class="chapter_upload"
+                          v-for="(item2, index2) in raceOver.actiDesign.data"
+                          :key="item2.id"
+                          draggable="true"
+                          @dragstart="handleDragStart($event, item2)"
+                          @dragover.prevent="handleDragOver($event, item2)"
+                          @dragenter="handleDragEnter($event, item2)"
+                          @dragend="handleDragEnd($event, item2, 2)"
+                        >
+                          <div class="chapter_upload_t"></div>
+                          <div class="chapter_upload_o">
+                            <div class="chapter_upload_l">
                               <div
-                                class="chapter_upload_up"
-                                @click="upCd($event, index2, 2)"
+                                v-if="item2.type == 2"
+                                class="chapter_upload_l_i1"
                               ></div>
                               <div
-                                class="chapter_upload_down"
-                                @click="downCd($event, index2, 2)"
+                                v-if="item2.type == 1 || item2.type == 3"
+                                class="chapter_upload_l_i5"
                               ></div>
                             </div>
+                            <div class="chapter_upload_ic">
+                              <div class="chapter_upload_ic_l"></div>
+                              <div
+                                class="chapter_upload_ic_r"
+                                @click.stop="
+                                  deleteChapterData($event, index2, 2)
+                                "
+                              >
+                                <div></div>
+                              </div>
+                            </div>
+                            <div class="chapter_upload_n">
+                              <input
+                                class="first"
+                                v-if="item2.type == 1 || item2.type == 3"
+                                :placeholder="item2.name"
+                              />
+                              <input
+                                class="first"
+                                v-if="item2.type == 2"
+                                :placeholder="item2.name"
+                              />
+                              <div class="chapter_upload_ud">
+                                <div
+                                  class="chapter_upload_up"
+                                  @click="upCd($event, index2, 2)"
+                                ></div>
+                                <div
+                                  class="chapter_upload_down"
+                                  @click="downCd($event, index2, 2)"
+                                ></div>
+                              </div>
+                            </div>
                           </div>
                         </div>
-                      </div>
+                      </transition-group>
                     </div>
                   </div>
                   <div class="add_info_box">
@@ -617,6 +644,8 @@ export default {
       fullBrief: "",
       plaText: "",
       isBrief: 0,
+      ending: null,
+      dragging: null,
     };
   },
   methods: {
@@ -626,6 +655,51 @@ export default {
     change(val) {
       console.log(val);
     },
+
+    handleDragStart(e, item) {
+      this.dragging = item;
+    },
+    handleDragEnd(e, item, t) {
+      if (this.ending.id === this.dragging.id) {
+        return;
+      }
+      let newItems;
+      if (t == 0) {
+        newItems = [...this.raceOver.driQuestion.data];
+      } else if (t == 1) {
+        newItems = [...this.raceOver.tarDesign.data];
+      } else {
+        newItems = [...this.raceOver.actiDesign.data];
+      }
+      const src = newItems.indexOf(this.dragging);
+      const dst = newItems.indexOf(this.ending);
+      newItems.splice(src, 1, ...newItems.splice(dst, 1, newItems[src]));
+      console.log(newItems);
+
+      if (t == 0) {
+        this.raceOver.driQuestion.data = newItems;
+      } else if (t == 1) {
+        this.raceOver.tarDesign.data = newItems;
+      } else {
+        this.raceOver.actiDesign.data = newItems;
+      }
+
+      this.$nextTick(() => {
+        this.dragging = null;
+        this.ending = null;
+      });
+    },
+    handleDragOver(e) {
+      // 首先把div变成可以放置的元素,即重写dragenter/dragover
+      // 在dragenter中针对放置目标来设置
+      e.dataTransfer.dropEffect = "move";
+    },
+    handleDragEnter(e, item) {
+      // 为需要移动的元素设置dragstart事件
+      e.dataTransfer.effectAllowed = "move";
+      this.ending = item;
+    },
+
     jump(t) {
       var a = document.getElementById(t);
       var b = document.getElementsByClassName("right")[0];
@@ -821,6 +895,7 @@ export default {
                   name: file.name,
                   url: data.Location,
                   type: type1,
+                  id: "driData" + _this.raceOver.driQuestion.data.length,
                 });
                 _this.imgChange(null, null, type1, jsonType);
               } else if (jsonType == 1) {
@@ -828,6 +903,7 @@ export default {
                   name: file.name,
                   url: data.Location,
                   type: type1,
+                  id: "tarData" + _this.raceOver.tarDesign.data.length,
                 });
                 _this.imgChange(null, null, type1, jsonType);
               } else {
@@ -835,6 +911,7 @@ export default {
                   name: file.name,
                   url: data.Location,
                   type: type1,
+                  id: "actData" + _this.raceOver.actiDesign.data.length,
                 });
                 _this.imgChange(null, null, type1, jsonType);
               }
@@ -1157,10 +1234,13 @@ export default {
   flex-wrap: nowrap;
   justify-content: space-between;
   align-items: flex-start;
-  margin: 8px 0 0 10px;
+  margin: 10px 0 0 10px;
   height: 40px;
   cursor: pointer;
 }
+.stepRightNav > div {
+  margin-bottom: 5px;
+}
 .stepRightNav:hover {
   color: #999;
 }
@@ -1262,6 +1342,7 @@ export default {
   align-items: center;
   width: 100%;
   min-height: 50px;
+  transition: all linear 0.3s;
 }
 
 .chapter_upload_t {