提交 df1d40a7 authored 作者: 刘旭's avatar 刘旭

完成排序问题

上级 379ab906
......@@ -45,9 +45,9 @@ let showVisiable = ref(false)
let formRef = ref()
let title = ref('添加规格属性')
let rules = ref({
bomCode: { required: true, message: '', trigger: 'blur' },
model: { required: true, message: '', trigger: 'blur' },
productName: { required: true, message: '', trigger: 'blur' },
bomCode: { required: true, message: 'BOM编码不为空', trigger: 'blur' },
model: { required: true, message: '型号不为空', trigger: 'blur' },
productName: { required: true, message: '商品货品名称不为空', trigger: 'blur' },
url: { required: true, message: '产品图片不为空', trigger: ['blur', 'change'] },
designUrl: { required: true, message: '设计图片不为空', trigger: ['blur', 'change'] }
})
......
......@@ -127,7 +127,6 @@ let handleAscending = (item: any) => {
// 降序
let handleDescending = (item: any) => {
console.log('descending');
emits('handleSort', 'descending', item)
}
......@@ -281,16 +280,33 @@ let showAddSpec = () => {
// 修改规格顺序时触发
let sort = () => {
let resultSpecData = handleSpecData()
specificationData.value.map((item: any) => {
specificationData.value.forEach((item: any) => {
specList.value = item.specifications
if (item.updateTime) item.updateTime = null
if (item.specifications.length === resultSpecData.length) handleSequence(resultSpecData)
else console.log('少数量');
else handleLessSequence(resultSpecData)
item.specifications = specList.value
if (item.updateTime) item.updateTime = null
})
specList.value = []
emits('productsData', specificationData.value)
}
// 处理少的顺序
let handleLessSequence = (data: any) => {
let specListCopy = [...specList.value] // 浅拷贝
let list = [] as any // 存储有的数组
data.map((item: any, i: number) => {
item.value.map((item1: any) => {
let index = specListCopy.indexOf(item1)
if (index !== -1)
// 去除重复规格属性
if (list.indexOf(specListCopy[index]) === -1) list.push(specListCopy[index])
})
})
specList.value = list
}
// 添加规格属性
let clickAdd = (formData: any) => {
let data = {
......
......@@ -431,7 +431,7 @@ let handleSort = (type: string, data: any) => {
if (item.updateTime) item.updateTime = null
}
});
console.log(specifications.value, data);
// console.log(specifications.value, data);
bubbleSort(specifications.value)
selectSpecRef.value.setSpecifications(products.value)
} else {
......@@ -456,7 +456,7 @@ let handleSort = (type: string, data: any) => {
if (item.updateTime) item.updateTime = null
}
});
console.log(specifications.value, data);
// console.log(specifications.value, data);
bubbleSort(specifications.value)
}
}
......@@ -570,28 +570,26 @@ let handleEdit = () => {
categoryIds: categoryIds.value,
parts: partsData.value
};
editGoods(finalGoods)
.then((res: any) => {
if (res.code === 200) {
ElNotification({
type: 'success',
title: "成功",
message: "编辑成功",
});
emits('initShelves')
handleCancel()
} else if (res.code === 401) {
// 因为会有拦截所以的刷新数据
specificationsDeleteData.value = []
init(specQueryId.value)
}
})
.catch((res: any) => {
ElMessageBox.alert("业务错误:" + res.msg, "警告", {
confirmButtonText: "确定",
type: "error",
editGoods(finalGoods).then((res: any) => {
if (res.code === 200) {
ElNotification({
type: 'success',
title: "成功",
message: "编辑成功",
});
emits('initShelves')
handleCancel()
} else if (res.code === 401) {
// 因为会有拦截所以的刷新数据
specificationsDeleteData.value = []
init(specQueryId.value)
}
}).catch((res: any) => {
ElMessageBox.alert("业务错误:" + res.msg, "警告", {
confirmButtonText: "确定",
type: "error",
});
});
} else return false
})
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论