added downloding file
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
import { a as useConfigStore, aS as useRoute, aX as useRouter, _ as __nuxt_component_0 } from './server.mjs';
|
||||
import { defineComponent, ref, reactive, computed, watch, nextTick, useSSRContext } from 'vue';
|
||||
import { ssrRenderComponent } from 'vue/server-renderer';
|
||||
import { f as formFields, s as selectedFeatures, a as setItems, i as items, v as variants, b as updateMyAttrs, c as myAttributes, u as useProductStore } from './product-qwehvGHt.mjs';
|
||||
import { differenceBy, cloneDeep } from 'lodash-es';
|
||||
|
||||
const _sfc_main = /* @__PURE__ */ defineComponent({
|
||||
__name: "index",
|
||||
__ssrInlineRender: true,
|
||||
emits: ["update:visible", "update:isEdit", "success"],
|
||||
setup(__props, { emit: __emit }) {
|
||||
useConfigStore();
|
||||
const collections = ref(null);
|
||||
ref(false);
|
||||
ref(false);
|
||||
useRoute();
|
||||
useRouter();
|
||||
const loading = ref(false);
|
||||
const dragKey = ref(0);
|
||||
let selectedFeaturesLength = 0;
|
||||
reactive({
|
||||
height: "40px",
|
||||
lineHeight: "40px"
|
||||
});
|
||||
const childCollections = ref(null);
|
||||
computed(() => {
|
||||
const parentId = parentCollectionId.value;
|
||||
if (!parentId) return false;
|
||||
const parentCollection = collections.value?.find((c) => c.id === parentId);
|
||||
childCollections.value = parentCollection?.children;
|
||||
return parentCollection?.children?.length > 0;
|
||||
});
|
||||
const parentCollectionId = computed({
|
||||
get() {
|
||||
return formFields?.collections?.parent_id || formFields?.collections?.id;
|
||||
},
|
||||
set(newVal) {
|
||||
console.log(newVal, "cooool");
|
||||
formFields.collections.parent_id = newVal;
|
||||
formFields.collections.id = void 0;
|
||||
formFields.collection_id = newVal;
|
||||
}
|
||||
});
|
||||
computed(() => formFields.collection_id === 1 || formFields.collection_id === 2 || parentCollectionId.value == 1 || parentCollectionId.value == 2);
|
||||
computed({
|
||||
get() {
|
||||
if (formFields?.collections?.parent_id == formFields.collections?.id)
|
||||
return void 0;
|
||||
return formFields?.collections?.parent_id ? formFields?.collections.id : void 0;
|
||||
},
|
||||
set(newVal) {
|
||||
formFields.collections.id = newVal;
|
||||
formFields.collection_id = newVal;
|
||||
if (!formFields.collection_id)
|
||||
formFields.collection_id = formFields?.collections?.parent_id;
|
||||
}
|
||||
});
|
||||
watch(selectedFeatures, async (new_features, oldFeatures) => {
|
||||
if (new_features?.length > selectedFeaturesLength) {
|
||||
try {
|
||||
loading.value = true;
|
||||
await setItems(new_features);
|
||||
if (new_features[new_features.length - 1] != null) selectedFeaturesLength = selectedFeatures.value.length;
|
||||
dragKey.value++;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
} else {
|
||||
const deletedObject = differenceBy(oldFeatures, new_features);
|
||||
selectedFeaturesLength = selectedFeatures.value.length;
|
||||
const index = items.value.findIndex((x) => deletedObject[0] === x.id);
|
||||
if (index !== -1) {
|
||||
variants.value?.forEach((val) => {
|
||||
val.attribute_values[index] = null;
|
||||
});
|
||||
items.value.splice(index, 1);
|
||||
dragKey.value++;
|
||||
}
|
||||
}
|
||||
}, { deep: true });
|
||||
watch(
|
||||
items,
|
||||
(newValue) => {
|
||||
console.log("**********************");
|
||||
updateMyAttrs(items.value);
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
watch(() => formFields.variants, () => {
|
||||
variants.value = formFields.variants;
|
||||
}, { deep: true });
|
||||
watch(() => formFields.variants?.map((v) => v?.attribute_values), () => {
|
||||
nextTick(() => {
|
||||
if (formRef.value && (formFields.variants?.length ?? 0) > 0 && myAttributes.value?.length > 0) {
|
||||
formFields.variants?.forEach((variant, variantIndex) => {
|
||||
if (!variant) return;
|
||||
const attrValues = variant.attribute_values || {};
|
||||
myAttributes.value.forEach((attr, attrIndex) => {
|
||||
if (!attr?.valueKey) return;
|
||||
["variants", variantIndex, "attribute_values", attr.valueKey];
|
||||
const currentValue = attrValues[attr.valueKey];
|
||||
if (currentValue != null && currentValue !== "" && currentValue !== void 0) {
|
||||
for (let i = 0; i < attrIndex; i++) {
|
||||
const prevAttr = myAttributes.value[i];
|
||||
if (!prevAttr?.valueKey) continue;
|
||||
const prevFieldName = ["variants", variantIndex, "attribute_values", prevAttr.valueKey];
|
||||
formRef.value.validateFields([prevFieldName]).catch(() => {
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}, { deep: true });
|
||||
useProductStore();
|
||||
const formRef = ref();
|
||||
ref(["0"]);
|
||||
cloneDeep(formFields);
|
||||
ref(false);
|
||||
ref([]);
|
||||
return (_ctx, _push, _parent, _attrs) => {
|
||||
const _component_ClientOnly = __nuxt_component_0;
|
||||
_push(ssrRenderComponent(_component_ClientOnly, _attrs, {}, _parent));
|
||||
};
|
||||
}
|
||||
});
|
||||
const _sfc_setup = _sfc_main.setup;
|
||||
_sfc_main.setup = (props, ctx) => {
|
||||
const ssrContext = useSSRContext();
|
||||
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/add/product/information/index.vue");
|
||||
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
||||
};
|
||||
|
||||
export { _sfc_main as _ };
|
||||
Reference in New Issue
Block a user