|
|
@@ -9,7 +9,7 @@ export class SeatingPlanPageViewModel{
|
|
|
@Trace safeTop: number = 0
|
|
|
// 学生列表
|
|
|
@Trace dataSource: string[] = ['张三', '李四', '王五', '赵六', '孙七', '周八', '吴九', '小十', '张三', '李四', '王五', '赵六', '孙七', '周八', '吴九', '小十']
|
|
|
- // 座位表 - 二维数组
|
|
|
+ // 座位表 - 二维数组 8*8
|
|
|
@Trace seatingPlan: Array<string[]> = new Array(4).fill(new Array(8).fill(''))
|
|
|
// 当前显示的模式: 1 - 单列 2 - 双列
|
|
|
@Trace columnMode: number = 1
|
|
|
@@ -72,6 +72,8 @@ export class SeatingPlanPageViewModel{
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
+ // 拖拽结束了吗
|
|
|
+ isDragEnd: boolean = true
|
|
|
|
|
|
constructor(conText: UIContext) {
|
|
|
this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
|
|
|
@@ -109,6 +111,7 @@ export class SeatingPlanPageViewModel{
|
|
|
* @param value 接收到的学生
|
|
|
*/
|
|
|
_onDrag(seat: string[], x : number, y : number, value: string){
|
|
|
+ this.isDragEnd = true
|
|
|
let arr = [...seat]
|
|
|
|
|
|
// 原位置上有学生
|
|
|
@@ -129,11 +132,9 @@ export class SeatingPlanPageViewModel{
|
|
|
* @param event 拖拽事件传递的事件参数
|
|
|
*/
|
|
|
_onDragEnd(event: DragEvent){
|
|
|
- // onDragEnd里取到的result值在接收方onDrop设置
|
|
|
- if (event.getResult() === DragResult.DRAG_SUCCESSFUL) {
|
|
|
-
|
|
|
- } else if (event.getResult() === DragResult.DRAG_FAILED) {
|
|
|
- // 拖拽结束 - 没有在接收方接收到数据, 撤销本次操作
|
|
|
+ // 1. 拖拽失败 - 没有在接收方接收到数据, 撤销本次操作
|
|
|
+ // 2. 拖拽成功 - 但是数据接收是系统控件接收,数据源并没有发生变化, 撤销本次操作
|
|
|
+ if (event.getResult() === DragResult.DRAG_FAILED || !this.isDragEnd) {
|
|
|
this._onUndo()
|
|
|
}
|
|
|
}
|
|
|
@@ -145,6 +146,8 @@ export class SeatingPlanPageViewModel{
|
|
|
let x = this.seatingPlan.length
|
|
|
let y = this.seatingPlan[0].length
|
|
|
|
|
|
+ if(x == 8) return
|
|
|
+
|
|
|
this._addUndoData()
|
|
|
this.seatingPlan.push(new Array(y).fill(''))
|
|
|
}
|
|
|
@@ -155,6 +158,9 @@ export class SeatingPlanPageViewModel{
|
|
|
_onAddColumn() {
|
|
|
let x = this.seatingPlan.length
|
|
|
let y = this.seatingPlan[0].length
|
|
|
+
|
|
|
+ if(y == 13) return
|
|
|
+
|
|
|
this._addUndoData()
|
|
|
for (let index = 0; index < this.seatingPlan.length; index++) {
|
|
|
let arr = [...this.seatingPlan[index]]
|
|
|
@@ -171,8 +177,8 @@ export class SeatingPlanPageViewModel{
|
|
|
let x = this.seatingPlan.length
|
|
|
let y = this.seatingPlan[0].length
|
|
|
|
|
|
- if(x == 1){
|
|
|
- IBestToast.show('行数不足1行')
|
|
|
+ if(x == 4){
|
|
|
+ IBestToast.show('行数不足4行')
|
|
|
return
|
|
|
}
|
|
|
this._addUndoData()
|
|
|
@@ -186,8 +192,8 @@ export class SeatingPlanPageViewModel{
|
|
|
let x = this.seatingPlan.length
|
|
|
let y = this.seatingPlan[0].length
|
|
|
|
|
|
- if(y == 1) {
|
|
|
- IBestToast.show('列数不足1列')
|
|
|
+ if(y == 8) {
|
|
|
+ IBestToast.show('列数不足8列')
|
|
|
return
|
|
|
}
|
|
|
this._addUndoData()
|