Commit a9962782 authored by 李维's avatar 李维

多选题增加样式选择功能,去掉背景装饰框

parent 7f8a47d8
......@@ -470,7 +470,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
// 检查是否可以提交 - 设置完进行检查 防止没有配置分数 导致的无法提交
this.checkCanSubmit();
// this.checkCanSubmit();
};
// 初始化分数牌
......@@ -534,7 +534,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.totalScorePanel.initTotalScore(totalScore);
}
// 检查是否可以提交 - 完成全部配置的问题
// 检查是否可以提交 - 完成全部配置的问题 [这个方法的调用全部注释掉了,暂时保留,后续可删除]
checkCanSubmit() {
let result = true;
this.scoreValidater.some(validater =>{
......@@ -719,7 +719,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
// 检查是否可以提交
this.checkCanSubmit();
// this.checkCanSubmit();
}
rect.on("click", handleClick)
......@@ -846,7 +846,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
currentSelectIsCorrect = option.isCorrect;
// 校验必须在上面更新了校验器之后进行 否则本次选择不会生效
this.checkCanSubmit();
// this.checkCanSubmit();
})
});
return validater;
......@@ -860,6 +860,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
let currentCheckList = [];
// 存储对应的样式节点
const maskNodes = [];
const lineNodes = [];
const rightIconNodes = [];
// 选中和未选中样式
const selStyle = contentData.selectedStyle ? contentData.selectedStyle : "border";
const unselStyle = contentData.unselectedStyle ? contentData.unselectedStyle : "mask";
// 正确校验方法 - 默认返null
let validater = () => {
if(currentCheckList.length != contentData.contentList.length) {
......@@ -916,37 +924,69 @@ export default class SceneComponent extends MyCocosSceneComponent {
contentData.contentList.forEach((option, index) => {
const hotZoneData = this.data.hotZoneItemArr[option.selectHotZoneIndex];
const resultRect = this.newRectNode(hotZoneData, layer_2, debugMode);
this.newDecorativeFrame(hotZoneData, layer_1, "#FFFFFF", "#6dbef6", debugMode);
// this.newDecorativeFrame(hotZoneData, layer_1, "#FFFFFF", "#6dbef6", debugMode);
const rect = this.newRectNode(hotZoneData, layer_3, debugMode);
// 创建 结果节点 颜色区域 和 边框
const maskNode = this.newMaskRectNode(hotZoneData, layer_2, "#00000033");
const lineNode = this.newOutlineNode(hotZoneData, layer_2, "#6dbef6");
const {sprNode, picNode} = this.newSprNodeByResName(hotZoneData, "icon_right", true);
maskNode.active = unselStyle == "mask";
lineNode.active = false;
sprNode.active = false;
maskNodes.push(maskNode);
lineNodes.push(lineNode);
rightIconNodes.push(sprNode);
currentCheckList.push({
checked: false,
rect: resultRect,
mask: null
});
rect.index = index;
rect.on("click", ()=>{
if(this.submitted) {
return;
}
if(currentCheckList[index].checked) {
currentCheckList[index].checked = false;
currentCheckList[index].mask.destroy();
currentCheckList[index].mask = null
// 恢复未选中状态
if(unselStyle == "mask") {
maskNodes[index].active = true;
}
// 隐藏边框
if(selStyle == "border") {
lineNodes[index].active = false;
}
// 显示对号
if(selStyle == "right") {
rightIconNodes[index].active = false;
}
} else {
// picNode 是 sprNode 的父节点,点击事件需要加载sprNode上面,销毁时,需要销毁父节点 - 否则当用户第二次点击时。会无法点击
const {sprNode, picNode} = this.newSprNodeByResName(hotZoneData, "icon_right", true);
picNode.zIndex = layer_3;
currentCheckList[index].mask = picNode;
currentCheckList[index].checked = true;
sprNode.on("click", ()=>{
currentCheckList[index].checked = false;
currentCheckList[index].mask.destroy();
currentCheckList[index].mask = null
})
// 恢复未选中状态
if(unselStyle == "mask") {
maskNodes[index].active = false;
}
// 隐藏边框
if(selStyle == "border") {
lineNodes[index].active = true;
}
// 显示对号
if(selStyle == "right") {
rightIconNodes[index].active = true;
}
}
// 检查是否可以提交
this.checkCanSubmit();
// this.checkCanSubmit();
})
});
return validater;
......@@ -1071,7 +1111,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 启用页面滚动
this.enableScroll();
// 检查是否可以提交
this.checkCanSubmit();
// this.checkCanSubmit();
// 把命中的节点的连接索引更新
if(tempConnectResultIndex >= 0) {
......@@ -1090,7 +1130,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 启动页面滚动
this.enableScroll();
// 检查是否可以提交
this.checkCanSubmit();
// this.checkCanSubmit();
// 把命中的节点的连接索引更新
if(tempConnectResultIndex >= 0) {
......@@ -1314,7 +1354,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
// 校验必须在上面更新了校验器之后进行 否则本次选择不会生效
this.checkCanSubmit();
// this.checkCanSubmit();
})
}
})
......@@ -1390,7 +1430,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
// 校验必须在上面更新了校验器之后进行 否则本次选择不会生效
this.checkCanSubmit();
// this.checkCanSubmit();
rect.addChild(inputLabel);
})
......@@ -1505,7 +1545,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
// 校验必须在上面更新了校验器之后进行 否则本次选择不会生效
this.checkCanSubmit();
// this.checkCanSubmit();
rect.addChild(inputLabel);
})
......@@ -1660,7 +1700,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
// 校验必须在上面更新了校验器之后进行 否则本次选择不会生效
this.checkCanSubmit();
// this.checkCanSubmit();
rect.addChild(inputLabel);
});
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -13,8 +13,6 @@ import {
ViewChild,
ElementRef
} from '@angular/core';
import { JsonPipe } from '@angular/common';
import { removeItemFromArr } from '../play/Unit';
import { NzMessageService } from 'ng-zorro-antd';
import { NzModalService } from 'ng-zorro-antd/modal';
import { v4 as uuidv4 } from 'uuid';
......@@ -38,8 +36,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
withoutBgData = false;
// 快速创建热区的字符串
fastHotZoneStr = ""
// 表格编辑缓存
editCache: { [key: string]: { edit: boolean; data } } = {};
// 题目类型
TEXT_SELECT = "0";
IMAGE_SELECT = "1";
......@@ -85,31 +82,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
this.fastHotZoneStr = this.fastHotZoneStr.replace(/,/g, ",");
const hotZoneNames = this.fastHotZoneStr.split(",");
hotZoneNames.forEach((hotZoneName, index) => {
this.customHotZone["addHotZone"](hotZoneName)
// newHotZoneItemArr.push({
// "index": index,
// "itemType": "rect",
// "itemName": hotZoneName,
// "fontSize": 50,
// "fontName": "BRLNSR_1",
// "fontColor": "#8f3758",
// "fontScale": 0.734375,
// "imgScale": 1,
// "mapScale": 0.734375,
// "rect": {
// "x": 0,
// "y": 0,
// "width": 100,
// "height": 100
// }
// })
this.customHotZone["addHotZone"](hotZoneName);
})
// const data = this.item;
// data.hotZoneItemArr = newHotZoneItemArr;
this.fastHotZoneStr = "";
this.nzMessageService.success('创建成功,需要保存热区');
// this.item = JSON.parse(JSON.stringify(data));
// this.save()
}
// 添加热区配置
......@@ -156,16 +132,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
if(!it.contentList) {
it.contentList = [];
}
it.contentList = [
...it.contentList,
this.getDefaultConfigContentItem()
];
const lastIndex = it.contentList.length - 1;
const lastItem = it.contentList[lastIndex];
this.startHotZoneConfigEdit(lastIndex, lastItem);
this.save();
}
......@@ -201,33 +173,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
}
}
// 开始编辑表格的一行
startHotZoneConfigEdit(uuid, originData) {
if(!this.editCache[uuid]) {
this.editCache[uuid] = {
edit: true,
data: { ...originData }
};
} else {
this.editCache[uuid].edit = true;
}
}
// 取消表格一行的编辑
cancelHotZoneConfigEdit(uuid, originData): void {
this.editCache[uuid] = {
data: { ...originData },
edit: false
};
}
// 保存表格内容
saveHotZoneConfigEdit(uuid, it): void {
const itemSave = it.contentList.find(item=>item.uuid == uuid)
Object.assign(itemSave, this.editCache[uuid].data);
this.editCache[uuid].edit = false;
this.save();
}
// 添加分数组
addScoreConfig() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment