77 placeholder =" source"
88 @change =" hanldeTrans"
99 v-model =" source" ></el-input >
10- <!-- < el-button size="mini" type="success " @click="hanldeTrans">点击转换</el-button> -->
11- < el-button size = " mini " type = " info " @click = " getData " v-if =" selectedList.length > 0" >
10+ <el-button size =" mini" type =" info " @click =" getData "
11+ v-if =" selectedList.length > 0 || (nowIsSort && this.list.length > 0) " >
1212 下载json
1313 </el-button >
14+ <el-button size =" mini" type =" info" @click =" doSort" >整理源</el-button >
1415 <el-button size =" mini" @click =" fetchData" v-if =" this.list.length > 0 && !nowIsCheck" >
1516 检查链接是否正常
1617 </el-button >
2526 :rows =" 2"
2627 v-model =" selectedData" ></el-input >
2728 </div >
29+ <div class =" sort-container" v-show =" nowIsSort" >
30+ <ul id =" items" class =" sort-ul" >
31+ <li class =" item-li" v-for =" (value, index) in list" :key =" index" >
32+ {{index+1}}. {{value.name}} <el-link @click =" doDelete(index)" >删除</el-link >
33+ </li >
34+ </ul >
35+ </div >
2836 <div >
2937 <el-table
30- v-if =" list.length > 0"
38+ v-if =" list.length > 0 && !nowIsSort "
3139 ref =" dataTable"
3240 @selection-change =" handleSelectionChange"
3341 :data =" list"
5462 label =" tvg-language" >
5563 <template slot-scope="scope">
5664 <div >{{scope.row.name}}</div >
57- <!-- <img height="20" :src="scope.row.tvgLogo" > -->
5865 </template >
5966 </el-table-column >
6067 <el-table-column
8895 </div >
8996</template >
9097<script >
98+ import Sortable from ' sortablejs' ;
9199import { fetchGet } from ' ../utils/axios' ;
92100
93101export default {
@@ -101,6 +109,7 @@ export default {
101109 selectedList: [],
102110 nowCheckCount: 0 ,
103111 nowIsCheck: false ,
112+ nowIsSort: false ,
104113 };
105114 },
106115 watch: {
@@ -110,17 +119,54 @@ export default {
110119 }
111120 },
112121 },
122+ mounted () {
123+ this .parseList ();
124+ },
113125 methods: {
126+ doDelete (index ) {
127+ this .list .splice (index, 1 );
128+ },
129+ doSort () {
130+ if (this .nowIsSort ) {
131+ this .nowIsSort = false ;
132+ } else {
133+ this .nowIsSort = true ;
134+ this .enableSort ();
135+ }
136+ },
137+ enableSort () {
138+ const el = document .getElementById (' items' );
139+ const _this = this ;
140+ Sortable .create (el, {
141+ onEnd ({ newIndex, oldIndex }) {
142+ const current = _this .list .splice (oldIndex, 1 )[0 ];
143+ _this .list .splice (newIndex, 0 , current);
144+ const rows = _this .list ;
145+ _this .list = [];
146+ setTimeout (() => {
147+ _this .list = rows;
148+ }, 5 );
149+ },
150+ });
151+ },
114152 handleSelectionChange (val ) {
115153 this .selectedList = val;
116154 this .selectedData = ' ' ;
117155 },
118156 getData () {
119- let name = ` ${ this .firstTitle } \n ` ;
120- for (let i = 0 ; i < this .selectedList .length ; i += 1 ) {
121- name += ` ${ this .selectedList [i].originalData } \n ` ;
157+ if (this .nowIsSort ) {
158+ let name = ` ${ this .firstTitle } \n ` ;
159+ for (let i = 0 ; i < this .list .length ; i += 1 ) {
160+ name += ` ${ this .list [i].originalData } \n ` ;
161+ }
162+ this .selectedData = name;
163+ } else {
164+ let name = ` ${ this .firstTitle } \n ` ;
165+ for (let i = 0 ; i < this .selectedList .length ; i += 1 ) {
166+ name += ` ${ this .selectedList [i].originalData } \n ` ;
167+ }
168+ this .selectedData = name;
122169 }
123- this .selectedData = name;
124170 },
125171 autoSelect () {
126172 for (let i = 0 ; i < this .list .length ; i += 1 ) {
@@ -241,4 +287,14 @@ export default {
241287 </script >
242288<style lang="sass" scoped>
243289.iptv-container
290+ .sort-container
291+ .sort-ul
292+ display : flex ;
293+ flex-direction : column ;
294+ .item-li
295+ justify-content : space-between ;
296+ width : 400px
297+ padding : 10px ;
298+ display : flex ;
299+ border-bottom : 1px solid #000
244300 </style >
0 commit comments