123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- import { queenApi } from "queenjs";
- import { CollocationModule } from "../..";
- export const collocationAction = CollocationModule.action({
- async queryStyleDetail(id: string) {
- const res = await this.https.getStyleDetail(id);
- this.store.setDesignDetail(res.result);
- },
- async addMatchCategory() {
- const res = await queenApi.showInput({ title: "请输入分类名称" });
- if (!res) return;
- const data = {
- index: -1,
- category: res,
- group: "",
- productIds: [],
- };
- this.store.addMatchCategory(data);
- this.store.setEditType(res);
- },
- async renameMatchCategory() {
- const name = await queenApi.showInput({
- title: "请输入分类名称",
- defaultValue: this.store.editType,
- });
- if (!name) return;
- this.store.currentGroupList.forEach((element: ProductMatching) => {
- element.category = name;
- });
- this.store.setEditType(name);
- },
- async deleteMatchCategory() {
- const res = await queenApi.showConfirm({
- type: "danger",
- content: `删除以后不可恢复,确认要删除:${this.store.editType}?`,
- });
- if (!res) return;
- const prodMatchs = this.store.designDetail.prodMatchs.filter(
- (m: ProductMatching) => m.category != this.store.editType
- );
- this.store.setEditType("mat");
- this.store.setMatchCategory(prodMatchs);
- },
- async addCategoryGroup() {
- const res = await queenApi.showInput({ title: "请输入分组名称" });
- if (!res) return;
- const group = {
- index: -1,
- category: this.store.editType,
- group: res,
- productIds: [],
- };
- this.store.addMatchCategory(group);
- },
- async renameMatGroup() {
- const res = await queenApi.showInput({
- title: "重命名",
- defaultValue: "***",
- });
- if (!res) return;
- },
- async clearMatGroup(matsGroup: MatsMatchComp) {
- matsGroup.matIds = [];
- matsGroup.index = 0;
- },
- async lockMatGroup() {
- //
- },
- async switchMatGroup() {
- //
- },
- async renameProductGroup(prodGroup) {
- const name = await queenApi.showInput({
- title: "重命名",
- defaultValue: prodGroup.group,
- });
- if (!name) return;
- prodGroup.group = name;
- },
- async deleteProductGroup(record) {
- if (this.store.currentGroupList.length == 1) {
- queenApi.messageError("至少保留一个分组!");
- return;
- }
- const res = await queenApi.showConfirm({
- type: "danger",
- content: `删除以后不可恢复,确认要删除:${record.group}?`,
- });
- if (!res) return;
- const i = this.store.designDetail.prodMatchs.findIndex(
- (e: ProductMatching) =>
- e.group == record.group && e.category == record.category
- );
- this.store.designDetail.prodMatchs.splice(i, 1);
- },
- async clearProductGroup() {
- //
- },
- dropProduct(product, extraData) {
- //
- },
- async deleteGroupMat(matsGroup: MatsMatchComp, index) {
- // const res = await queenApi.showConfirm({
- // content: `删除后不可恢复,确认要删除?`,
- // type: "danger",
- // });
- // if (!res) return;
- matsGroup.matIds.splice(index, 1);
- if (matsGroup.index > matsGroup.matIds.length - 1) {
- matsGroup.index = matsGroup?.matIds?.length - 1;
- }
- //
- },
- switchMatsGroup() {
- // switchSceneProdComp.call(this, sceneProductId, compName);
- // queditor.controls.queen3dCtrl.queen3d.
- },
- async switchMatsGroupIndex(matsGroup: MatsMatchComp, index: number) {
- matsGroup.index = index;
- this.actions.renderGroupMat(matsGroup, false);
- },
- renderGroupMat(matsGroup: MatsMatchComp, isCreate = true) {
- // 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: IMaterial) => m.id == matsGroup.matIds[matsGroup.index]
- // );
- // if (!mat) return;
- // queditor.actions.updatePackProductCompMat(targetCom, mat, isCreate);
- },
- async renameGroupMat(mat) {
- const name = await queenApi.showInput({
- title: "重命名",
- defaultValue: mat.name,
- });
- if (!name) return;
- mat.name = name;
- },
- });
|