|
@@ -20,18 +20,27 @@ export default defineComponent({
|
|
|
if (type == "asset3d.mat") {
|
|
|
dropMat(dropData, extraData);
|
|
|
} else if (type == "asset3d.mesh") {
|
|
|
- dropMesh(dropData);
|
|
|
+ dropMesh(dropData, extraData);
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
|
|
|
- function dropMesh(dropData: any) {
|
|
|
- console.log("dropData: ", dropData);
|
|
|
+ function dropMesh(dropData: any, target: any) {
|
|
|
+ console.log("dropData: ", dropData, target);
|
|
|
//
|
|
|
}
|
|
|
|
|
|
// 拖拽面料
|
|
|
function dropMat(mat: IMaterial, extraData: any) {
|
|
|
+ const currGroup = findmatsGroup(extraData);
|
|
|
+ if (!currGroup.matIds) currGroup.matIds = [];
|
|
|
+
|
|
|
+ // TODO 判断重复拖拽
|
|
|
+ if (currGroup.matIds.includes(mat.id)) {
|
|
|
+ queenApi.messageError("不能重复添加色卡");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // update
|
|
|
const targetPro = queditor.store.pack.products.find(
|
|
|
(p) => p.id == extraData.productId
|
|
|
);
|
|
@@ -39,57 +48,19 @@ export default defineComponent({
|
|
|
(c) => c.name == extraData.name
|
|
|
);
|
|
|
if (!targetCom) return;
|
|
|
-
|
|
|
queditor.actions.updatePackProductCompMat(targetCom, mat, true);
|
|
|
-
|
|
|
- const currComp = findCurrentComp(extraData);
|
|
|
- if (!currComp.matIds) currComp.matIds = [];
|
|
|
-
|
|
|
- // TODO 判断重复拖拽
|
|
|
- if (currComp.matIds.includes(mat.id)) {
|
|
|
- queenApi.messageError("不能重复添加色卡");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- currComp.matIds.push(mat.id);
|
|
|
- currComp.index = currComp.matIds.length - 1;
|
|
|
+ currGroup.matIds.push(mat.id);
|
|
|
+ currGroup.index = currGroup.matIds.length - 1;
|
|
|
}
|
|
|
|
|
|
- function findCurrentComp(target: MatsMatchComp) {
|
|
|
- const currComp = collocation.store.menuOptions.sourceData.mat.find(
|
|
|
+ function findmatsGroup(target: MatsMatchComp) {
|
|
|
+ const currGroup = collocation.store.menuOptions.sourceData.mat.find(
|
|
|
(r: MatsMatchComp) =>
|
|
|
r.name == target.name && r.productId == target.productId
|
|
|
);
|
|
|
- return currComp;
|
|
|
+ return currGroup;
|
|
|
}
|
|
|
|
|
|
- async function switchMatsGroupIndex(
|
|
|
- matsGroup: MatsMatchComp,
|
|
|
- index: number
|
|
|
- ) {
|
|
|
- const currComp = findCurrentComp(matsGroup);
|
|
|
- currComp.index = index;
|
|
|
-
|
|
|
- //
|
|
|
- const targetPro = queditor.store.pack.products.find(
|
|
|
- (p) => p.id == matsGroup.productId
|
|
|
- );
|
|
|
- const targetCom = targetPro?.components.find(
|
|
|
- (c) => c.name == matsGroup.name
|
|
|
- );
|
|
|
- if (!targetCom) return;
|
|
|
- const mat = queditor.store.pack.mats.find(
|
|
|
- (m) => m.id == currComp.matIds[index]
|
|
|
- );
|
|
|
- if (!mat) return;
|
|
|
- queditor.actions.updatePackProductCompMat(targetCom, mat, false);
|
|
|
- }
|
|
|
-
|
|
|
- const switchMatsGroup = () => {
|
|
|
- // switchSceneProdComp.call(this, sceneProductId, compName);
|
|
|
- // queditor.controls.queen3dCtrl.queen3d.
|
|
|
- };
|
|
|
-
|
|
|
const handleChange = (key: string, matsGroup: MatsMatchComp) => {
|
|
|
switch (key) {
|
|
|
case "rename":
|
|
@@ -120,6 +91,7 @@ export default defineComponent({
|
|
|
return (
|
|
|
<PanelGroup
|
|
|
key={index}
|
|
|
+ class="cursor-pointer"
|
|
|
type="asset3d.mat"
|
|
|
active={
|
|
|
queditor.store.currActiveProdComp?.name == matsGroup.name
|
|
@@ -128,19 +100,39 @@ export default defineComponent({
|
|
|
tools={["rename", "lock", "clear"]}
|
|
|
target={matsGroup}
|
|
|
onChange={(key) => handleChange(key, matsGroup)}
|
|
|
- onSelect={switchMatsGroup}
|
|
|
+ onSelect={collocation.actions.switchMatsGroup}
|
|
|
>
|
|
|
<List data={matsGroup.matIds || []} columns={5} gap="5px">
|
|
|
{{
|
|
|
item: (matId: string, index: number) => {
|
|
|
+ const currentMats =
|
|
|
+ collocation.helper.findMatById(matId);
|
|
|
return (
|
|
|
<MatItem
|
|
|
key={matId}
|
|
|
- mat={collocation.helper.findMatById(matId)}
|
|
|
+ mat={currentMats}
|
|
|
active={index == matsGroup.index}
|
|
|
onClick={() =>
|
|
|
- switchMatsGroupIndex(matsGroup, index)
|
|
|
+ collocation.actions.switchMatsGroupIndex(
|
|
|
+ matsGroup,
|
|
|
+ index
|
|
|
+ )
|
|
|
}
|
|
|
+ onAction={(key: string) => {
|
|
|
+ switch (key) {
|
|
|
+ case "delete":
|
|
|
+ collocation.actions.deleteGroupMat(
|
|
|
+ matsGroup,
|
|
|
+ index
|
|
|
+ );
|
|
|
+ break;
|
|
|
+ case "rename":
|
|
|
+ collocation.actions.renameGroupMat(
|
|
|
+ currentMats
|
|
|
+ );
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }}
|
|
|
/>
|
|
|
);
|
|
|
},
|
|
@@ -155,6 +147,9 @@ export default defineComponent({
|
|
|
);
|
|
|
}
|
|
|
)}
|
|
|
+ <div class="mt-20px text-12px text-center text-gray-400">
|
|
|
+ 没有更多了
|
|
|
+ </div>
|
|
|
</PanelCard>
|
|
|
);
|
|
|
};
|