555
This commit is contained in:
parent
2d03273085
commit
292496dacb
|
@ -36,7 +36,7 @@
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div v-for="(item, index) in specification_list" :key="index">
|
<div v-for="(item, index) in props.specification_arr" :key="index">
|
||||||
<div
|
<div
|
||||||
style="
|
style="
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
import { ref, defineEmits, defineProps, reactive } from "vue";
|
import { ref, defineEmits, defineProps, reactive } from "vue";
|
||||||
import { Warning, Delete } from "@element-plus/icons-vue";
|
import { Warning, Delete } from "@element-plus/icons-vue";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
const $emit = defineEmits(["specificationClose"]);
|
const $emit = defineEmits(["specificationClose", "submitSpecification"]);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
specificationDialogVisible: {
|
specificationDialogVisible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -138,83 +138,21 @@ const rules = reactive({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const specification_list = ref(props.specification_arr);
|
|
||||||
const specification_list_index = ref(0);
|
|
||||||
|
|
||||||
const submit_specification = (formEl) => {
|
const submit_specification = (formEl) => {
|
||||||
formEl.validate((valid) => {
|
formEl.validate((valid) => {
|
||||||
if (!valid || !ruleForm.name) return;
|
if (!valid || !ruleForm.name) return;
|
||||||
if (specification_list.value.length >= 2)
|
if (props.specification_arr.length >= 2)
|
||||||
return ElMessage.warning("超过输入限制!");
|
return ElMessage.warning("超过输入限制!");
|
||||||
specification_list_index.value++;
|
$emit("submitSpecification", ruleForm.name);
|
||||||
specification_list.value.push({
|
|
||||||
label: ruleForm.name,
|
|
||||||
num: 0,
|
|
||||||
index: specification_list_index.value,
|
|
||||||
disabled: false,
|
|
||||||
keydown: (e, item, index) => {
|
|
||||||
if (e.key !== "Enter") return;
|
|
||||||
if (item.label.length <= 4) {
|
|
||||||
item.disabled = false;
|
|
||||||
} else {
|
|
||||||
ElMessage.warning("字数限制4个字符!");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
buttonGroup: [
|
|
||||||
{
|
|
||||||
type: "primary",
|
|
||||||
label: "编辑",
|
|
||||||
handler: (item) => {
|
|
||||||
item.disabled = true;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "danger",
|
|
||||||
label: "删除",
|
|
||||||
handler: (item, index) => {
|
|
||||||
specification_list.value.splice(index, 1);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
inputGroup: {
|
|
||||||
valueName: "",
|
|
||||||
placeholder: "请输入规格属性,按回车健确认",
|
|
||||||
keydown: (e, name, index) => {
|
|
||||||
if (e.key !== "Enter" || !name) return;
|
|
||||||
if (specification_list.value.length <= 1) {
|
|
||||||
if (specification_list.value[index].valueGrop.length >= 10) return;
|
|
||||||
} else {
|
|
||||||
if (
|
|
||||||
specification_list.value[0].valueGrop.length *
|
|
||||||
specification_list.value[1].valueGrop.length >=
|
|
||||||
100
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
specification_list.value[index].valueGrop.push({
|
|
||||||
type: "danger",
|
|
||||||
label: specification_list.value[index].inputGroup.valueName,
|
|
||||||
delete: (item, ind) => {
|
|
||||||
specification_list.value[index].valueGrop.splice(ind, 1);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
specification_list.value[index].num =
|
|
||||||
specification_list.value[index].valueGrop.length;
|
|
||||||
specification_list.value[index].inputGroup.valueName = "";
|
|
||||||
},
|
|
||||||
},
|
|
||||||
valueGrop: [],
|
|
||||||
});
|
|
||||||
ruleForm.name = "";
|
ruleForm.name = "";
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const submitForm = () => {
|
const submitForm = () => {
|
||||||
if (!specification_list.value.length)
|
if (!props.specification_arr.length)
|
||||||
return ElMessage.warning("没有添加任何规格属性!");
|
return ElMessage.warning("没有添加任何规格属性!");
|
||||||
if (!specification_list.value.every((item) => item.valueGrop.length))
|
if (!props.specification_arr.every((item) => item.valueGrop.length))
|
||||||
return ElMessage.warning("添加规格后至少添加一个属性值!");
|
return ElMessage.warning("添加规格后至少添加一个属性值!");
|
||||||
$emit("specificationSubmit", specification_list.value);
|
$emit("specificationSubmit", props.specification_arr);
|
||||||
specificationClose();
|
|
||||||
};
|
};
|
||||||
const specificationClose = () => {
|
const specificationClose = () => {
|
||||||
$emit("specificationClose");
|
$emit("specificationClose");
|
||||||
|
|
|
@ -443,6 +443,7 @@
|
||||||
:specification_arr="priceList.specification_arr"
|
:specification_arr="priceList.specification_arr"
|
||||||
@specificationClose="specificationClose"
|
@specificationClose="specificationClose"
|
||||||
@specificationSubmit="specificationSubmit"
|
@specificationSubmit="specificationSubmit"
|
||||||
|
@submitSpecification="submitSpecification"
|
||||||
></SpecificationDialog>
|
></SpecificationDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -453,6 +454,7 @@ import { ref, reactive, onMounted } from "vue";
|
||||||
import UploadImage from "@components/Upload/newfileupload.vue";
|
import UploadImage from "@components/Upload/newfileupload.vue";
|
||||||
import SpecificationDialog from "./components/specificationDialog.vue";
|
import SpecificationDialog from "./components/specificationDialog.vue";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
|
import { deepClone } from "@/services/commont";
|
||||||
const ruleFormRef = ref(null);
|
const ruleFormRef = ref(null);
|
||||||
const tableRef = ref(null);
|
const tableRef = ref(null);
|
||||||
import {
|
import {
|
||||||
|
@ -946,12 +948,11 @@ const select_store = (item) => {
|
||||||
ruleForm.xyShopId = item.id;
|
ruleForm.xyShopId = item.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
const specificationClose = () => {
|
const newDataList = ref([]);
|
||||||
priceList.specificationDialogVisible = false;
|
|
||||||
};
|
|
||||||
const specificationSubmit = (row) => {
|
const specificationSubmit = (row) => {
|
||||||
ruleFormRef.value.resetFields();
|
ruleFormRef.value.resetFields();
|
||||||
if (!row) return;
|
if (!row.length) return;
|
||||||
|
newDataList.value = deepClone(row);
|
||||||
const specification_list = [];
|
const specification_list = [];
|
||||||
const tabelList = [];
|
const tabelList = [];
|
||||||
priceList.fixPrice = [
|
priceList.fixPrice = [
|
||||||
|
@ -970,7 +971,7 @@ const specificationSubmit = (row) => {
|
||||||
label: "编辑",
|
label: "编辑",
|
||||||
handler: () => {
|
handler: () => {
|
||||||
priceList.specificationDialogVisible = true;
|
priceList.specificationDialogVisible = true;
|
||||||
priceList.specification_arr = row;
|
priceList.specification_arr = newDataList.value;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1126,6 +1127,7 @@ const specificationSubmit = (row) => {
|
||||||
item.tabelList = [...tabelList, ...item.tabelList];
|
item.tabelList = [...tabelList, ...item.tabelList];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
priceList.specificationDialogVisible = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const get_filters = (arr) => {
|
const get_filters = (arr) => {
|
||||||
|
@ -1160,8 +1162,13 @@ const generateCombinations = (attributeGroups) => {
|
||||||
|
|
||||||
let result = []; // 存储所有组合的数组
|
let result = []; // 存储所有组合的数组
|
||||||
generate(0, {}); // 从第一个属性组开始生成组合
|
generate(0, {}); // 从第一个属性组开始生成组合
|
||||||
|
console.log(result, "result");
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
const specificationClose = () => {
|
||||||
|
priceList.specification_arr = newDataList;
|
||||||
|
priceList.specificationDialogVisible = false;
|
||||||
|
};
|
||||||
//获取店铺信息
|
//获取店铺信息
|
||||||
const get_shopInfo = () => {
|
const get_shopInfo = () => {
|
||||||
getshopInfo().then((res) => {
|
getshopInfo().then((res) => {
|
||||||
|
@ -1190,6 +1197,7 @@ const get_region = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
//保存草稿
|
||||||
const SaveDraft = () => {};
|
const SaveDraft = () => {};
|
||||||
const publish = (formRef) => {
|
const publish = (formRef) => {
|
||||||
if (!formRef) return;
|
if (!formRef) return;
|
||||||
|
@ -1200,6 +1208,69 @@ onMounted(() => {
|
||||||
get_region();
|
get_region();
|
||||||
createGoods.radio_group_sell.change();
|
createGoods.radio_group_sell.change();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const specification_list_index = ref(0);
|
||||||
|
const submitSpecification = (valName) => {
|
||||||
|
specification_list_index.value++;
|
||||||
|
priceList.specification_arr.push({
|
||||||
|
label: valName,
|
||||||
|
num: 0,
|
||||||
|
index: specification_list_index.value,
|
||||||
|
disabled: false,
|
||||||
|
keydown: (e, item, index) => {
|
||||||
|
if (e.key !== "Enter") return;
|
||||||
|
if (item.label.length <= 4) {
|
||||||
|
item.disabled = false;
|
||||||
|
} else {
|
||||||
|
ElMessage.warning("字数限制4个字符!");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buttonGroup: [
|
||||||
|
{
|
||||||
|
type: "primary",
|
||||||
|
label: "编辑",
|
||||||
|
handler: (item) => {
|
||||||
|
item.disabled = true;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "danger",
|
||||||
|
label: "删除",
|
||||||
|
handler: (item, index) => {
|
||||||
|
priceList.specification_arr.splice(index, 1);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
inputGroup: {
|
||||||
|
valueName: "",
|
||||||
|
placeholder: "请输入规格属性,按回车健确认",
|
||||||
|
keydown: (e, name, index) => {
|
||||||
|
if (e.key !== "Enter" || !name) return;
|
||||||
|
if (priceList.specification_arr.length <= 1) {
|
||||||
|
if (priceList.specification_arr[index].valueGrop.length >= 10) return;
|
||||||
|
} else {
|
||||||
|
if (
|
||||||
|
priceList.specification_arr[0].valueGrop.length *
|
||||||
|
priceList.specification_arr[1].valueGrop.length >=
|
||||||
|
100
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
priceList.specification_arr[index].valueGrop.push({
|
||||||
|
type: "danger",
|
||||||
|
label: priceList.specification_arr[index].inputGroup.valueName,
|
||||||
|
delete: (item, ind) => {
|
||||||
|
priceList.specification_arr[index].valueGrop.splice(ind, 1);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
priceList.specification_arr[index].num =
|
||||||
|
priceList.specification_arr[index].valueGrop.length;
|
||||||
|
priceList.specification_arr[index].inputGroup.valueName = "";
|
||||||
|
},
|
||||||
|
},
|
||||||
|
valueGrop: [],
|
||||||
|
});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Loading…
Reference in New Issue