884
This commit is contained in:
parent
292496dacb
commit
4c4c44ce88
|
@ -36,7 +36,7 @@
|
|||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<div v-for="(item, index) in props.specification_arr" :key="index">
|
||||
<div v-for="(item, index) in newDataList" :key="index">
|
||||
<div
|
||||
style="
|
||||
display: flex;
|
||||
|
@ -76,7 +76,7 @@
|
|||
v-model="item.inputGroup.valueName"
|
||||
:placeholder="item.inputGroup.placeholder"
|
||||
@keydown="
|
||||
item.inputGroup.keydown($event, item.inputGroup.valueName, index)
|
||||
input_child_keydown($event, item.inputGroup.valueName, index)
|
||||
"
|
||||
>
|
||||
</el-input>
|
||||
|
@ -88,7 +88,7 @@
|
|||
:type="el.type"
|
||||
round
|
||||
size="small"
|
||||
@click="el.delete(item, ind)"
|
||||
@click="onDelValueItem(index, ind)"
|
||||
>
|
||||
{{ el.label }}<el-icon class="el-icon--right"><Delete /></el-icon>
|
||||
</el-button>
|
||||
|
@ -106,9 +106,10 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, defineEmits, defineProps, reactive } from "vue";
|
||||
import { ref, defineEmits, defineProps, reactive, onMounted } from "vue";
|
||||
import { Warning, Delete } from "@element-plus/icons-vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { deepClone } from "@/services/commont";
|
||||
const $emit = defineEmits(["specificationClose", "submitSpecification"]);
|
||||
const props = defineProps({
|
||||
specificationDialogVisible: {
|
||||
|
@ -137,22 +138,94 @@ const rules = reactive({
|
|||
{ min: 1, max: 4, message: "字数限制,最多输入4个字符", trigger: "blur" },
|
||||
],
|
||||
});
|
||||
const newDataList = ref([]);
|
||||
const specification_list_index = ref(0);
|
||||
|
||||
onMounted(() => {
|
||||
newDataList.value = deepClone(props.specification_arr);
|
||||
});
|
||||
|
||||
let that = newDataList;
|
||||
|
||||
const submit_specification = (formEl) => {
|
||||
formEl.validate((valid) => {
|
||||
if (!valid || !ruleForm.name) return;
|
||||
if (props.specification_arr.length >= 2)
|
||||
if (newDataList.value.length >= 2)
|
||||
return ElMessage.warning("超过输入限制!");
|
||||
$emit("submitSpecification", ruleForm.name);
|
||||
specification_list_index.value++;
|
||||
newDataList.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) => {
|
||||
newDataList.value.splice(index, 1);
|
||||
},
|
||||
},
|
||||
],
|
||||
inputGroup: {
|
||||
valueName: "",
|
||||
placeholder: "请输入规格属性,按回车健确认",
|
||||
},
|
||||
valueGrop: [],
|
||||
});
|
||||
ruleForm.name = "";
|
||||
});
|
||||
};
|
||||
|
||||
function onDelValueItem(index, ind) {
|
||||
let newdatas = JSON.parse(JSON.stringify(newDataList.value[index].valueGrop));
|
||||
newdatas.splice(ind, 1);
|
||||
newDataList.value[index].valueGrop = newdatas;
|
||||
newDataList.value = Object.assign([], newDataList.value);
|
||||
console.log(newDataList.value, "newDataList.value111");
|
||||
}
|
||||
function input_child_keydown(e, name, index) {
|
||||
if (e.key !== "Enter" || !name) return;
|
||||
if (newDataList.value.length <= 1) {
|
||||
if (newDataList.value[index].valueGrop.length >= 10) return;
|
||||
} else {
|
||||
if (
|
||||
newDataList.value[0].valueGrop.length *
|
||||
newDataList.value[1].valueGrop.length >=
|
||||
100
|
||||
)
|
||||
return;
|
||||
}
|
||||
newDataList.value[index].valueGrop.push({
|
||||
type: "danger",
|
||||
label: newDataList.value[index].inputGroup.valueName,
|
||||
});
|
||||
newDataList.value[index].num = newDataList.value[index].valueGrop.length;
|
||||
newDataList.value[index].inputGroup.valueName = "";
|
||||
}
|
||||
const submitForm = () => {
|
||||
if (!props.specification_arr.length)
|
||||
console.log(newDataList.value, "newDataList.value", newDataList.value.length);
|
||||
if (!newDataList.value.length)
|
||||
return ElMessage.warning("没有添加任何规格属性!");
|
||||
if (!props.specification_arr.every((item) => item.valueGrop.length))
|
||||
if (!newDataList.value.every((item) => item.valueGrop.length))
|
||||
return ElMessage.warning("添加规格后至少添加一个属性值!");
|
||||
$emit("specificationSubmit", props.specification_arr);
|
||||
console.log(newDataList.value, "newDataList.value");
|
||||
$emit("specificationSubmit", newDataList.value);
|
||||
};
|
||||
const specificationClose = () => {
|
||||
$emit("specificationClose");
|
||||
|
|
|
@ -426,6 +426,16 @@
|
|||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div>
|
||||
<el-form-item prop="logistics">
|
||||
<el-input
|
||||
v-model="ruleForm.transportFee"
|
||||
:placeholder="el.label"
|
||||
size="small"
|
||||
>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
|
@ -851,20 +861,20 @@ const logistics = reactive({
|
|||
title: "物流",
|
||||
configured: {
|
||||
label: "物流配置",
|
||||
prop: "",
|
||||
params: "",
|
||||
prop: "logistics",
|
||||
params: "logistics",
|
||||
options: [
|
||||
{
|
||||
label: "包邮",
|
||||
value: "",
|
||||
value: "1",
|
||||
},
|
||||
{
|
||||
label: "统一运费",
|
||||
value: "",
|
||||
value: "2",
|
||||
},
|
||||
{
|
||||
label: "运费模板",
|
||||
value: "",
|
||||
value: "3",
|
||||
},
|
||||
],
|
||||
change: () => {},
|
||||
|
@ -911,7 +921,7 @@ const ruleForm = reactive({
|
|||
whiteBgImage: 0, // 白底图
|
||||
flag: 0, //草稿箱-0 发布-1
|
||||
republishId: 0, //重新发布的商品id
|
||||
logistics: 0, //物流配置 1包邮 2统一运费 3运费模板
|
||||
logistics: "1", //物流配置 1包邮 2统一运费 3运费模板
|
||||
transportFee: "", // 物流配置选择2统一运费时传递
|
||||
templateId: 0, // 物流配置选择3运费模板时候传递
|
||||
});
|
||||
|
@ -925,6 +935,7 @@ const rules = reactive({
|
|||
],
|
||||
stuffStatus: [{ trigger: "blur", required: true, message: "请输入商品成色" }],
|
||||
quantity: [{ trigger: "blur", required: true, message: "请输入库存" }],
|
||||
logistics: [{ trigger: "blur", required: true, message: "请选择物流配置" }],
|
||||
});
|
||||
const createFilter = (queryString) => {
|
||||
return (restaurant) => {
|
||||
|
@ -953,8 +964,11 @@ const specificationSubmit = (row) => {
|
|||
ruleFormRef.value.resetFields();
|
||||
if (!row.length) return;
|
||||
newDataList.value = deepClone(row);
|
||||
priceList.specification_arr = deepClone(row);
|
||||
console.log(priceList, "priceList", row);
|
||||
const specification_list = [];
|
||||
const tabelList = [];
|
||||
|
||||
priceList.fixPrice = [
|
||||
{
|
||||
type: "edit",
|
||||
|
@ -1209,68 +1223,67 @@ onMounted(() => {
|
|||
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: [],
|
||||
});
|
||||
};
|
||||
// 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>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
Loading…
Reference in New Issue