118118 </span >
119119 </template >
120120 </div >
121- <el-button type =" primary" size =" medium" @click =" addSkill" icon =" Plus" >新增技能</el-button >
121+ <el-button type =" primary" class =" u-add-skill" size =" medium" @click =" addSkill" icon =" Plus"
122+ >新增技能</el-button
123+ >
122124 </el-form-item >
123125 <el-form-item label =" 连招说明" class =" m-macro-desc" >
124126 <el-input
@@ -165,6 +167,8 @@ import SkillDialog from "@/components/publish/skill_dialog.vue";
165167import { iconLink } from " @jx3box/jx3box-common/js/utils" ;
166168
167169import Sortable from " sortablejs" ;
170+ import ContextMenu from " @imengyu/vue3-context-menu" ;
171+ import " @imengyu/vue3-context-menu/lib/vue3-context-menu.css" ;
168172import publish_qixue from " ./publish_qixue.vue" ;
169173// META空模板
170174const default_meta = {
@@ -218,6 +222,8 @@ export default {
218222
219223 zhNum: [" 一" , " 二" , " 三" , " 四" , " 五" , " 六" , " 七" , " 八" , " 九" , " 十" ],
220224 showSkillDialog: false ,
225+ tabsSortable: null ,
226+ skillSortable: null ,
221227 };
222228 },
223229 emits: [" update" , " update:modelValue" ],
@@ -263,6 +269,19 @@ export default {
263269 });
264270 },
265271 },
272+ " pvpData.has_sq" : {
273+ immediate: true ,
274+ handler (val ) {
275+ this .$nextTick (() => {
276+ if (! val) {
277+ this .destroySortables ();
278+ return ;
279+ }
280+ this .initTabsSort ();
281+ this .initSkillSort ();
282+ });
283+ },
284+ },
266285 },
267286 methods: {
268287 // 添加连招
@@ -281,6 +300,10 @@ export default {
281300 desc: " " ,
282301 });
283302 this .activeIndex = index;
303+ this .$nextTick (() => {
304+ this .initTabsSort ();
305+ this .initSkillSort ();
306+ });
284307 },
285308 // 删除宏
286309 removeCombo : function (name ) {
@@ -300,6 +323,10 @@ export default {
300323 this .pvpData .data .splice (i, 1 );
301324 // 调整focus位置
302325 this .activeIndex = " 1" ;
326+ this .$nextTick (() => {
327+ this .initTabsSort ();
328+ this .initSkillSort ();
329+ });
303330 }
304331 },
305332 });
@@ -347,12 +374,19 @@ export default {
347374 const sq = this .pvpData .data [this .activeIndex - 1 ].sq ? .push (... _skill) || _skill;
348375 },
349376 iconLink,
377+ destroySortables () {
378+ this .tabsSortable ? .destroy ();
379+ this .skillSortable ? .destroy ();
380+ this .tabsSortable = null ;
381+ this .skillSortable = null ;
382+ },
350383 // 初始化技能排序
351384 initSkillSort () {
352385 const el = document .querySelector (` .tabs-sort .tab-content${ this .activeIndex } .u-skills` );
353386 if (! el) return ;
387+ this .skillSortable ? .destroy ();
354388 const _this = this ;
355- const sortSkills = Sortable .create (el, {
389+ this . skillSortable = Sortable .create (el, {
356390 animation: 200 ,
357391 onEnd ({ newIndex, oldIndex }) {
358392 const data = cloneDeep (_this .pvpData .data [_this .activeIndex - 1 ].sq );
@@ -365,19 +399,42 @@ export default {
365399 },
366400 });
367401 },
402+ initTabsSort () {
403+ const el = document .querySelector (" .tabs-sort .el-tabs__nav" );
404+ if (! el) return ;
405+ this .tabsSortable ? .destroy ();
406+ const _this = this ;
407+ this .tabsSortable = Sortable .create (el, {
408+ animation: 200 ,
409+ filter: " .el-icon-close" ,
410+ onEnd ({ newIndex, oldIndex }) {
411+ const data = cloneDeep (_this .pvpData .data );
412+ const currRow = cloneDeep (data .splice (oldIndex, 1 )[0 ]);
413+ data .splice (newIndex, 0 , currRow);
414+ _this .pvpData .data = [];
415+ _this .$nextTick (function () {
416+ _this .pvpData .data = data;
417+ _this .$nextTick (() => {
418+ _this .initTabsSort ();
419+ _this .initSkillSort ();
420+ });
421+ });
422+ },
423+ });
424+ },
368425 onContextmenu (event , skill ) {
369- // console.log(skill)
370- this .$contextmenu ({
426+ event .preventDefault ();
427+ ContextMenu .showContextMenu ({
428+ x: event .x ?? event .clientX ,
429+ y: event .y ?? event .clientY ,
371430 items: [
372431 {
373432 label: ! skill? .WithoutGcd ? " 设置为无GCD技能" : " 设置为有GCD技能" ,
374433 onClick: () => {
375434 skill .WithoutGcd = ! skill .WithoutGcd ;
376435 },
377- icon: ! skill? .WithoutGcd ? " el-icon-check" : " el-icon-close" ,
378436 },
379437 ],
380- event ,
381438 customClass: " custom-class" ,
382439 zIndex: 3 ,
383440 minWidth: 230 ,
@@ -386,23 +443,14 @@ export default {
386443 },
387444 },
388445 mounted: function () {
389- let el = document .querySelector (" .tabs-sort .el-tabs__nav" );
390- if (! el) return ;
391- const _this = this ;
392- let sortTabs = Sortable .create (el, {
393- animation: 200 ,
394- filter: " .el-icon-close" ,
395- onEnd ({ newIndex, oldIndex }) {
396- const data = cloneDeep (_this .pvpData .data );
397- const currRow = cloneDeep (data .splice (oldIndex, 1 )[0 ]);
398- data .splice (newIndex, 0 , currRow);
399- _this .pvpData .data = [];
400- _this .$nextTick (function () {
401- _this .pvpData .data = data;
402- });
403- },
446+ this .$nextTick (() => {
447+ this .initTabsSort ();
448+ this .initSkillSort ();
404449 });
405450 },
451+ beforeUnmount () {
452+ this .destroySortables ();
453+ },
406454};
407455< / script>
408456
@@ -411,5 +459,8 @@ export default {
411459 .u - skill .u - skill- icon {
412460 .size (48px );
413461 }
462+ .u - add- skill {
463+ margin- left: 10px ;
464+ }
414465}
415466< / style>
0 commit comments