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

完成排序问题

上级 379ab906
...@@ -45,9 +45,9 @@ let showVisiable = ref(false) ...@@ -45,9 +45,9 @@ let showVisiable = ref(false)
let formRef = ref() let formRef = ref()
let title = ref('添加规格属性') let title = ref('添加规格属性')
let rules = ref({ let rules = ref({
bomCode: { required: true, message: '', trigger: 'blur' }, bomCode: { required: true, message: 'BOM编码不为空', trigger: 'blur' },
model: { required: true, message: '', trigger: 'blur' }, model: { required: true, message: '型号不为空', trigger: 'blur' },
productName: { required: true, message: '', trigger: 'blur' }, productName: { required: true, message: '商品货品名称不为空', trigger: 'blur' },
url: { required: true, message: '产品图片不为空', trigger: ['blur', 'change'] }, url: { required: true, message: '产品图片不为空', trigger: ['blur', 'change'] },
designUrl: { required: true, message: '设计图片不为空', trigger: ['blur', 'change'] } designUrl: { required: true, message: '设计图片不为空', trigger: ['blur', 'change'] }
}) })
......
...@@ -127,7 +127,6 @@ let handleAscending = (item: any) => { ...@@ -127,7 +127,6 @@ let handleAscending = (item: any) => {
// 降序 // 降序
let handleDescending = (item: any) => { let handleDescending = (item: any) => {
console.log('descending');
emits('handleSort', 'descending', item) emits('handleSort', 'descending', item)
} }
...@@ -281,16 +280,33 @@ let showAddSpec = () => { ...@@ -281,16 +280,33 @@ let showAddSpec = () => {
// 修改规格顺序时触发 // 修改规格顺序时触发
let sort = () => { let sort = () => {
let resultSpecData = handleSpecData() let resultSpecData = handleSpecData()
specificationData.value.map((item: any) => { specificationData.value.forEach((item: any) => {
specList.value = item.specifications specList.value = item.specifications
if (item.updateTime) item.updateTime = null
if (item.specifications.length === resultSpecData.length) handleSequence(resultSpecData) 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 = [] specList.value = []
emits('productsData', specificationData.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 clickAdd = (formData: any) => {
let data = { let data = {
......
...@@ -431,7 +431,7 @@ let handleSort = (type: string, data: any) => { ...@@ -431,7 +431,7 @@ let handleSort = (type: string, data: any) => {
if (item.updateTime) item.updateTime = null if (item.updateTime) item.updateTime = null
} }
}); });
console.log(specifications.value, data); // console.log(specifications.value, data);
bubbleSort(specifications.value) bubbleSort(specifications.value)
selectSpecRef.value.setSpecifications(products.value) selectSpecRef.value.setSpecifications(products.value)
} else { } else {
...@@ -456,7 +456,7 @@ let handleSort = (type: string, data: any) => { ...@@ -456,7 +456,7 @@ let handleSort = (type: string, data: any) => {
if (item.updateTime) item.updateTime = null if (item.updateTime) item.updateTime = null
} }
}); });
console.log(specifications.value, data); // console.log(specifications.value, data);
bubbleSort(specifications.value) bubbleSort(specifications.value)
} }
} }
...@@ -570,8 +570,7 @@ let handleEdit = () => { ...@@ -570,8 +570,7 @@ let handleEdit = () => {
categoryIds: categoryIds.value, categoryIds: categoryIds.value,
parts: partsData.value parts: partsData.value
}; };
editGoods(finalGoods) editGoods(finalGoods).then((res: any) => {
.then((res: any) => {
if (res.code === 200) { if (res.code === 200) {
ElNotification({ ElNotification({
type: 'success', type: 'success',
...@@ -585,8 +584,7 @@ let handleEdit = () => { ...@@ -585,8 +584,7 @@ let handleEdit = () => {
specificationsDeleteData.value = [] specificationsDeleteData.value = []
init(specQueryId.value) init(specQueryId.value)
} }
}) }).catch((res: any) => {
.catch((res: any) => {
ElMessageBox.alert("业务错误:" + res.msg, "警告", { ElMessageBox.alert("业务错误:" + res.msg, "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
type: "error", type: "error",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论