44 <div v-if =" !showExport" >
55 <el-button icon =" el-icon-edit" size =" mini" v-if =" nowType !== 0"
66 @click =" cancelLinkFun" >取消</el-button >
7- <el-button icon =" el-icon-circle-plus-outline" size =" mini"
8- @click =" addLinkFun" v-if =" nowType === 0" >添加</el-button >
97 <el-button icon =" el-icon-success" size =" mini"
108 @click =" saveLinkFun" v-if =" nowType === 1" >保存</el-button >
119 <el-button icon =" el-icon-edit" size =" mini"
3432 <el-table-column
3533 label =" 链接名" >
3634 <template slot-scope="scope">
37- <div v-if =" !scope.row.canEdit" >
38- <a :href =" scope.row.url" target =" __blank" >
39- {{scope.row.title}}<i class =" el-icon-s-promotion" ></i ></a >
40- </div >
41- <div v-else >
42- <el-input size =" mini" v-model =" scope.row.title" placeholder =" 请输入标题" ></el-input >
43- </div >
35+ <el-input size =" mini" v-model =" scope.row.title" placeholder =" 请输入标题" ></el-input >
4436 </template >
4537 </el-table-column >
4638 <el-table-column
4739 label =" url" >
4840 <template slot-scope="scope">
49- <div v-if =" !scope.row.canEdit" >
50- {{scope.row.url}}
51- </div >
52- <div v-else >
53- <el-input size =" mini" v-model =" scope.row.url" placeholder =" 请输入链接" ></el-input >
54- </div >
41+ <el-input size =" mini" v-model =" scope.row.url" placeholder =" 请输入链接" ></el-input >
5542 </template >
5643 </el-table-column >
5744 <el-table-column
5845 width =" 90"
5946 label =" 操作" v-if =" showDelete" >
6047 <template slot-scope="scope">
61- <div v-if = " scope.row.canEdit " @click =" deleteRowFun(scope.$index)"
48+ <div @click =" deleteRowFun(scope.$index)"
6249 style =" cursor : pointer ;" ><i class =" el-icon-delete" ></i ></div >
6350 </template >
6451 </el-table-column >
@@ -81,6 +68,7 @@ export default {
8168 showExport: false ,
8269 showImport: false ,
8370 exportJson: ' ' ,
71+ tempLink: [],
8472 nowType: 0 ,
8573 showDelete: false ,
8674 mode: 0 , // 0 链接 1 显示表格
@@ -134,26 +122,19 @@ export default {
134122 }
135123 },
136124 getEmptyObj () {
137- return this .setObj (' ' , ' ' , true );
125+ return this .setObj (' ' , ' ' );
138126 },
139- setObj (title , url , canEdit ) {
127+ setObj (title , url ) {
140128 return {
141129 title,
142130 url,
143- canEdit,
144131 };
145132 },
146- addLinkFun () {
147- this .nowType = 1 ;
148- this .linkList .push (this .getEmptyObj ());
149- this .mode = 1 ;
150- },
151133 saveLinkFun () {
152134 this .showDelete = false ;
153135 this .nowType = 0 ;
154136 const newList = [];
155137 for (let i = 0 ; i < this .linkList .length ; i += 1 ) {
156- this .linkList [i].canEdit = false ;
157138 if (this .linkList [i].title !== ' ' || this .linkList [i].url !== ' ' ) {
158139 newList .push (this .linkList [i]);
159140 }
@@ -163,24 +144,19 @@ export default {
163144 },
164145 editLinkFun () {
165146 this .showDelete = true ;
147+ this .tempLink = this .linkList .slice ();
148+ this .linkList .push (this .getEmptyObj ());
166149 this .nowType = 1 ;
167- for (let i = 0 ; i < this .linkList .length ; i += 1 ) {
168- this .linkList [i].canEdit = true ;
169- }
170150 this .mode = 1 ;
171151 },
172152 deleteRowFun (index ) {
173153 this .linkList .splice (index, 1 );
174154 this .mode = 1 ;
175155 },
176156 cancelLinkFun () {
177- if (this .nowType === 1 && ! this .showDelete ) {
178- this .linkList .splice (this .linkList .length - 1 , 1 );
179- }
157+ this .linkList = this .tempLink ;
158+ this .tempLink = [];
180159 this .nowType = 0 ;
181- for (let i = 0 ; i < this .linkList .length ; i += 1 ) {
182- this .linkList [i].canEdit = false ;
183- }
184160 this .showDelete = false ;
185161 this .mode = 0 ;
186162 },
0 commit comments