|
@@ -1,4 +1,7 @@
|
|
|
import { useResource } from "@/modules/resource";
|
|
|
+import { useQueditor } from "@queenjs-modules/queditor";
|
|
|
+import { Pack, PackMat } from "@queenjs-modules/queditor/objects";
|
|
|
+import { IQueentree } from "@queenjs-modules/queentree";
|
|
|
import { AssetItemFile } from "@queenjs-modules/queentree-explorer/objects/fileSystem/assetFiles";
|
|
|
import { Image, List } from "@queenjs/ui";
|
|
|
import { Button } from "ant-design-vue";
|
|
@@ -9,18 +12,52 @@ import LibraryModal from "./LibraryModal";
|
|
|
export default defineComponent({
|
|
|
setup() {
|
|
|
const resource = useResource();
|
|
|
+ const queditor = useQueditor();
|
|
|
|
|
|
const replaceMat = async () => {
|
|
|
- const res = await resource.showModal<AssetItemFile>(
|
|
|
+ const branchFolder = await resource.showModal<AssetItemFile>(
|
|
|
<LibraryModal nodeTypes={["matGroupItem", "mat", "packMat"]} />,
|
|
|
{
|
|
|
width: "900px",
|
|
|
}
|
|
|
);
|
|
|
- console.log("res: ", res);
|
|
|
+ console.log("branchFolder: ", branchFolder);
|
|
|
|
|
|
- const data = await res.getAssetDetail();
|
|
|
+ const data = await branchFolder.getAssetDetail();
|
|
|
console.log("data: ", data);
|
|
|
+
|
|
|
+ let mat;
|
|
|
+ switch (branchFolder.nodeType) {
|
|
|
+ case "matGroupItem":
|
|
|
+ mat = (data as IQueentree.IAssetMatGroup).source.colorCards.find(
|
|
|
+ (d: PackMat) => d.id == branchFolder.state.id
|
|
|
+ );
|
|
|
+ break;
|
|
|
+ case "packMat":
|
|
|
+ mat = (data.source as Pack["source"]).mats.find(
|
|
|
+ (d: PackMat) => d.id == branchFolder.state.id
|
|
|
+ );
|
|
|
+ break;
|
|
|
+ case "mat":
|
|
|
+ mat = data.source as PackMat;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ const targetComp = getTargetProCom();
|
|
|
+ console.error("targetComp: ", targetComp);
|
|
|
+
|
|
|
+ if (!targetComp || !mat) return;
|
|
|
+
|
|
|
+ queditor.actions.updatePackProductCompMat(targetComp, mat);
|
|
|
+ };
|
|
|
+
|
|
|
+ const getTargetProCom = () => {
|
|
|
+ const source: Pack["source"] = queditor.store.pack;
|
|
|
+ const targetPro = source.products[0];
|
|
|
+ const targetComp = targetPro?.components.find(
|
|
|
+ (c) => c.name == resource.store.currentMesh.meshName
|
|
|
+ );
|
|
|
+ return targetComp;
|
|
|
};
|
|
|
|
|
|
return () => {
|