3232 <h3 >{{ $t("team.snapshotEdit.participants") }}</h3 >
3333 <p >{{ $t("team.snapshotEdit.participantHint") }}</p >
3434 </div >
35- <span >{{ $t("team.snapshotEdit.people", { count: list.length }) }}</span >
35+ <span >{{ $t("team.snapshotEdit.people", { count: memberCount }) }}</span >
3636 </div >
3737 <div class =" m-snapshot-edit__group-head" :aria-label =" $t('team.snapshotEdit.groupAria')" >
3838 <span v-for =" group in 5" :key =" group" >{{ $t("team.snapshotEdit.group", { group }) }}</span >
3939 </div >
40- <VueDraggable v-model =" list " class="m-snapshot-edit__member-list">
41- <div v-for =" (item, index) in list" :key =" dragKey(item, 'snapshot-dialog-role')" class =" u-member" >
42- <img :src =" showMountIcon(item[3])" alt =" " />
43- <span >{{ item[0] }}</span >
44- <button type =" button" :aria-label =" $t('team.snapshotEdit.remove')" @click.stop =" delRole(index)" >
45- <i class =" el-icon-close" ></i >
46- </button >
40+ <VueDraggable v-model =" list " class="m-snapshot-edit__member-list" :animation =" 150 " >
41+ <div
42+ v-for =" (item, index) in list"
43+ :key =" dragKey(item, 'snapshot-dialog-role')"
44+ class =" u-member"
45+ :class =" { 'is-empty': !item[0] }"
46+ >
47+ <template v-if =" item [0 ]" >
48+ <img :src =" showMountIcon(item[3])" alt =" " />
49+ <span >{{ item[0] }}</span >
50+ <button type =" button" :aria-label =" $t('team.snapshotEdit.remove')" @click.stop =" delRole(index)" >
51+ <i class =" el-icon-close" ></i >
52+ </button >
53+ </template >
4754 </div >
4855 </VueDraggable >
4956 <div class =" m-snapshot-edit__role-adder" >
@@ -118,6 +125,14 @@ import { ensureDragKey } from "@/utils/draggable";
118125import { showMountIcon } from " @/utils/filters" ;
119126import xfmap from " @jx3box/jx3box-data/data/xf/xf.json" ;
120127
128+ const SNAPSHOT_SLOT_COUNT = 25 ;
129+ const createEmptySlot = () => [" " , 0 , 0 , " " ];
130+ const fillSnapshotSlots = (members = []) => {
131+ const slots = members .slice (0 , SNAPSHOT_SLOT_COUNT );
132+ while (slots .length < SNAPSHOT_SLOT_COUNT ) slots .push (createEmptySlot ());
133+ return slots;
134+ };
135+
121136export default {
122137 name: " EditSnapshotDialog" ,
123138 components: {
@@ -147,7 +162,7 @@ export default {
147162 },
148163 selectedTeamId: " " ,
149164 teams: [],
150- list: [] ,
165+ list: fillSnapshotSlots () ,
151166 roleForm: {
152167 name: " " ,
153168 xf: " " ,
@@ -184,6 +199,9 @@ export default {
184199 teammate () {
185200 return this .list .map ((item ) => item .join (" ," )).join (" ;" );
186201 },
202+ memberCount () {
203+ return this .list .filter ((item ) => item[0 ]).length ;
204+ },
187205 xflist () {
188206 return Object .values (xfmap).filter ((item ) => item .id !== 0 );
189207 },
@@ -211,6 +229,7 @@ export default {
211229 const targetId = Number (this .targetTeamId );
212230 const targetTeam = this .teams .find ((item ) => Number (item .ID ) === targetId);
213231 this .selectedTeamId = targetTeam ? targetId : this .teams [0 ]? .ID || " " ;
232+ this .list = fillSnapshotSlots ();
214233 } finally {
215234 if (requestId === this .loadRequestId ) this .loading = false ;
216235 }
@@ -231,21 +250,24 @@ export default {
231250 };
232251 this .selectedTeamId = data .team_id ;
233252 this .teams = teamsRes .data .data .list || [];
234- this . list = (data .teammate || " " )
253+ const members = (data .teammate || " " )
235254 .split (" ;" )
236255 .filter (Boolean )
237256 .map ((item ) => item .split (" ," ));
257+ this .list = fillSnapshotSlots (members);
238258 } finally {
239259 if (requestId === this .loadRequestId ) this .loading = false ;
240260 }
241261 },
242262 delRole (index ) {
243- this .list .splice (index, 1 );
263+ this .list .splice (index, 1 , createEmptySlot () );
244264 },
245265 addMember () {
246266 this .$refs .roleForm .validate ((valid ) => {
247267 if (! valid) return ;
248- this .list .push ([this .roleForm .name , 0 , 0 , this .roleForm .xf ]);
268+ const emptyIndex = this .list .findIndex ((item ) => ! item[0 ]);
269+ if (emptyIndex === - 1 ) return ;
270+ this .list .splice (emptyIndex, 1 , [this .roleForm .name , 0 , 0 , this .roleForm .xf ]);
249271 this .$refs .roleForm .resetFields ();
250272 });
251273 },
@@ -283,7 +305,7 @@ export default {
283305 this .form = { title: " " , desc: " " };
284306 this .selectedTeamId = " " ;
285307 this .teams = [];
286- this .list = [] ;
308+ this .list = fillSnapshotSlots () ;
287309 this .roleForm = { name: " " , xf: " " };
288310 },
289311 },
0 commit comments