diff --git a/pages/product/components/propertyDetail.vue b/pages/product/components/propertyDetail.vue
index c3ec683..9c7a76f 100644
--- a/pages/product/components/propertyDetail.vue
+++ b/pages/product/components/propertyDetail.vue
@@ -1,78 +1,77 @@
-
-
-
-
- 规格名
- {{ item.name }}
-
-
- 规格值
-
- {{ sitem.name }}
-
-
-
-
-
+
+
+
+
+ 规格名
+ {{ item.name }}
+
+
+ 规格值
+
+ {{ sitem.name }}
+
+
+
+
+
diff --git a/pages/product/components/propertyList.vue b/pages/product/components/propertyList.vue
index 65d9487..446e7f6 100644
--- a/pages/product/components/propertyList.vue
+++ b/pages/product/components/propertyList.vue
@@ -1,122 +1,129 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/pages/product/js/sku.js b/pages/product/js/sku.js
index fb8a97d..c4f5f1d 100644
--- a/pages/product/js/sku.js
+++ b/pages/product/js/sku.js
@@ -1,89 +1,93 @@
-import { ref, computed } from 'vue'
-import { onLoad } from '@dcloudio/uni-app'
-import peach from '@/peach'
-import GoodsApi from '@/peach/api/trade/goods'
-import { SPEC_TYPE } from './config'
+import { ref, computed } from "vue";
+import { onLoad } from "@dcloudio/uni-app";
+import peach from "@/peach";
+import GoodsApi from "@/peach/api/trade/goods";
+import { SPEC_TYPE } from "./config";
-const pickerRef = ref(null)
+const pickerRef = ref(null);
-const propertyList = ref([
- {
- id: 36,
- children: [68],
- },
- {
- id: 37,
- children: [],
- },
-])
+const propertyList = ref([]);
-const goodsPropertyList = ref([])
+const goodsPropertyList = ref([]);
-const propertyListRef = ref(null)
+const propertyListRef = ref(null);
const formData = ref({
- specType: true,
- specText: SPEC_TYPE[0].label,
-})
+ specType: true,
+ specText: SPEC_TYPE[0].label,
+});
async function showPropertyList() {
- await getGoodsProperty()
- propertyListRef.value.onOpen()
+ await getGoodsProperty();
+ propertyListRef.value.onOpen();
}
function onRDPickerConfirm(e) {
- peach.$store('trade').specType = SPEC_TYPE[e.value[0]].value
- formData.value.specText = SPEC_TYPE[e.value[0]].label
- formData.value.specType = SPEC_TYPE[e.value[0]].value
+ peach.$store("trade").specType = SPEC_TYPE[e.value[0]].value;
+ formData.value.specText = SPEC_TYPE[e.value[0]].label;
+ formData.value.specType = SPEC_TYPE[e.value[0]].value;
}
function pickerProperty() {
- let index = specType ? 1 : 0
- pickerRef.value.onOpen([index])
+ let index = specType ? 1 : 0;
+ pickerRef.value.onOpen([index]);
}
function onPropertyConfirm(e) {
- console.log(e)
+ getGoodsProperty();
+ console.log(e);
}
async function getGoodsProperty() {
- let { data } = await GoodsApi.getHistoryProperty()
- // 根据已经选择数据,设置默认选中
- data.forEach((item) => {
- // 判断属性是否已经选中
- let propertyParent = propertyList.value.find((sitem) => sitem?.id === item.id)
+ let { data } = await GoodsApi.getHistoryProperty();
+ propertyList.value = [];
- item.checked = propertyParent ? true : false
+ // 把 propertyList 中 id 相同的属性合并,并去重
+ propertyList.value = peach.$store("trade").selectedProperty;
- // 如果属性已经选中,查询子类中是否有选中
- if (item.checked) {
- item.propertyValues.forEach((child) => {
- let childResult = propertyParent?.children.some((schild) => schild?.id === child.id)
- child.checked = childResult ? true : false
- })
- }
- })
- goodsPropertyList.value = data
+ // 根据已经选择数据,设置默认选中
+ data.forEach((item) => {
+ // 判断属性是否已经选中
+ let propertyParent = propertyList.value.find(
+ (sitem) => sitem?.id === item.id
+ );
+
+ item.checked = propertyParent ? true : false;
+
+ // 如果属性已经选中,查询子类中是否有选中
+ if (item.checked) {
+ item.propertyValues.forEach((child) => {
+ let childResult = propertyParent?.children.some(
+ (schild) => schild?.id === child.id
+ );
+ console.log(childResult);
+ child.checked = childResult ? true : false;
+ });
+ }
+ });
+
+ goodsPropertyList.value = data;
}
-const specType = computed(() => peach.$store('trade').specType)
+const specType = computed(() => peach.$store("trade").specType);
function initial() {
- onLoad(() => {
- formData.value.specType = specType ? true : false
- formData.value.specText = SPEC_TYPE[specType ? 1 : 0].label
- })
+ onLoad(() => {
+ formData.value.specType = specType ? true : false;
+ formData.value.specText = SPEC_TYPE[specType ? 1 : 0].label;
+ getGoodsProperty();
+ });
}
export {
- initial,
- pickerRef,
- pickerProperty,
- propertyListRef,
- formData,
- onRDPickerConfirm,
- onPropertyConfirm,
- propertyList,
- showPropertyList,
- goodsPropertyList,
-}
+ initial,
+ pickerRef,
+ pickerProperty,
+ propertyListRef,
+ formData,
+ onRDPickerConfirm,
+ onPropertyConfirm,
+ propertyList,
+ showPropertyList,
+ goodsPropertyList,
+};
diff --git a/pages/product/manageGoods.vue b/pages/product/manageGoods.vue
index cb21612..d402948 100644
--- a/pages/product/manageGoods.vue
+++ b/pages/product/manageGoods.vue
@@ -1,129 +1,61 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+