feat: 联调

This commit is contained in:
zc 2025-10-27 00:05:37 +08:00
parent 016f92ced5
commit dc006fddf6
5 changed files with 94 additions and 37 deletions

View File

@ -16,6 +16,9 @@ const login = {
*/ */
getCategoryPropertyList: ['/category/property/list'], // 获取类目属性列表 getCategoryPropertyList: ['/category/property/list'], // 获取类目属性列表
updateCategoryProperty: ['/category/property/insertOrUpdate'], // 更新类目属性 updateCategoryProperty: ['/category/property/insertOrUpdate'], // 更新类目属性
deleteCategoryProperty: ['/category/property/delete'], // 删除类目属性
updateCategoryPropertyValue: ['/category/property/value/insertOrUpdate'], // 更新类目属性值
deleteCategoryPropertyValue: ['/category/property/value/delete'], // 删除类目属性值
/** /**
* app类目管理 * app类目管理
*/ */

View File

@ -46,7 +46,7 @@
<el-popover <el-popover
:visible="visibleProperty[data.id]" :visible="visibleProperty[data.id]"
placement="bottom" placement="bottom"
title="请输入属性标题" title="请输入属性"
:width="200" :width="200"
trigger="click" trigger="click"
> >
@ -56,7 +56,7 @@
size="small" size="small"
class="ml-2 !text-white" class="ml-2 !text-white"
@click="visibleProperty[data.id] = true" @click="visibleProperty[data.id] = true"
>新增属性</el-button >新增属性</el-button
> >
</template> </template>
<el-input <el-input
@ -66,9 +66,9 @@
></el-input> ></el-input>
</el-popover> </el-popover>
<el-popover <el-popover
:visible="visiblePropertyType" :visible="visiblePropertyType[data.id]"
placement="bottom" placement="bottom"
title="请输入属性类型标题" title="请输入属性标题"
:width="200" :width="200"
trigger="click" trigger="click"
> >
@ -78,7 +78,7 @@
size="small" size="small"
class="ml-2 !text-white" class="ml-2 !text-white"
@click="visiblePropertyType[data.id] = true" @click="visiblePropertyType[data.id] = true"
>新增属性类型</el-button >新增属性</el-button
> >
</template> </template>
<el-input <el-input
@ -87,6 +87,13 @@
@blur="visiblePropertyType[data.id] = false" @blur="visiblePropertyType[data.id] = false"
></el-input> ></el-input>
</el-popover> </el-popover>
<el-button
type="danger"
size="small"
class="ml-2 !text-white"
@click="onDeleteProperty(data.id)"
>删除属性</el-button
>
</dd> </dd>
</dl> </dl>
</template> </template>
@ -108,6 +115,7 @@
import { ElButton, ElMessage } from 'element-plus' import { ElButton, ElMessage } from 'element-plus'
import type { RenderContentContext } from 'element-plus' import type { RenderContentContext } from 'element-plus'
import { handleDragStart, handleDropFinish } from './use-drag' import { handleDragStart, handleDropFinish } from './use-drag'
import { handleMessageBox } from '@/utils/page'
interface Tree { interface Tree {
id: number id: number
@ -230,42 +238,55 @@ const inputPropertyTypeValue = ref('')
// //
const onClosePropertyValue = async (id: number, data: any) => { const onClosePropertyValue = async (id: number, data: any) => {
const i = data.vvPropertyValueList.findIndex((item: any) => item.id === id) const i = data.vvPropertyValueList.findIndex((item: any) => item.id === id)
await api.commodity.updateCategoryProperty.post!({ await api.commodity.deleteCategoryPropertyValue.post!({ id })
...data.vvPropertyValueList[i],
isDelete: 1
})
data.vvPropertyValueList.splice(i, 1) data.vvPropertyValueList.splice(i, 1)
ElMessage.success('删除成功')
} }
// //
const onAddPropertyValue = async (data: any = {}) => { const onAddPropertyValue = async (data: any = {}) => {
if (inputPropertyValue.value) { if (inputPropertyValue.value) {
const params = { const res = await api.commodity.updateCategoryPropertyValue.post!({
categoryPropertyId: data.id,
categoryPropertyValue: inputPropertyValue.value categoryPropertyValue: inputPropertyValue.value
}
const res = await api.commodity.updateCategoryProperty.post!({
...params
}) })
// testzc // testzc
data.vvPropertyValueList.push(params) data.vvPropertyValueList.push(res.data)
} }
visibleProperty.value[data.id] = false visibleProperty.value[data.id] = false
inputPropertyValue.value = '' inputPropertyValue.value = ''
ElMessage.success('新增成功')
} }
//
const onAddPropertyType = async (data: any = {}) => { const onAddPropertyType = async (data: any = {}) => {
console.warn('----- my data is data111: ', data)
if (inputPropertyTypeValue.value) { if (inputPropertyTypeValue.value) {
const params = {
categoryPropertyName: inputPropertyTypeValue.value,
vvCategoryPropertyDTOList: []
}
const res = await api.commodity.updateCategoryProperty.post!({ const res = await api.commodity.updateCategoryProperty.post!({
...params categoryId: data.categoryId,
categoryName: data.categoryName,
categoryPropertyName: inputPropertyTypeValue.value
}) })
console.warn('----- my data is data.id: ', data.id)
res.data.vvPropertyValueList = []
const newData = res.data
// testzc
visiblePropertyType.value[data.id] = false visiblePropertyType.value[data.id] = false
inputPropertyTypeValue.value = '' inputPropertyTypeValue.value = ''
ElMessage.success('新增成功')
} }
} }
//
const onDeleteProperty = async (id: number) => {
handleMessageBox({
msg: `是否删除属性?`,
success: api.commodity.deleteCategoryProperty.post!,
data: { id }
}).then(() => {
// testzc
})
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -251,6 +251,7 @@ const onSubmit = () => {
// if (msg) return ElMessage.error(msg) // if (msg) return ElMessage.error(msg)
console.warn('----- my data is htmlContent: ', htmlContent.value) console.warn('----- my data is htmlContent: ', htmlContent.value)
const params = handleGetSubmitParams( const params = handleGetSubmitParams(
route.query.type === 'add',
$dialog.value.data, $dialog.value.data,
fileList.value, fileList.value,
adminCategoryData.value, adminCategoryData.value,

View File

@ -81,11 +81,18 @@ export const usePropertyValue = () => {
}) })
} }
const onClosePropertyValue = (index: number, id: number, skuList: Ref<TSkuList[]>) => { const onClosePropertyValue = (index: number, id: number, skuList: Ref<TSkuList[]>) => {
debugger
const i = adminCategoryData[index].vvPropertyValueList.findIndex((item: any) => item.id === id) const i = adminCategoryData[index].vvPropertyValueList.findIndex((item: any) => item.id === id)
const temp = adminCategoryData[index].vvPropertyValueList[i]
const filterName = temp.productPropertyName + ':' + temp.productPropertyValue
adminCategoryData[index].vvPropertyValueList.splice(i, 1) adminCategoryData[index].vvPropertyValueList.splice(i, 1)
const deleteIndexs: number[] = [] const deleteIndexs: number[] = []
skuList.value.forEach((item: TSkuList, skuIndex: number) => { skuList.value.forEach((item: TSkuList, skuIndex: number) => {
if (item.vvSkuPropertyValueList.find((it) => it.id === id)) { if (
item.vvSkuPropertyValueList.find(
(it) => it.productPropertyName + ':' + it.productPropertyValue === filterName
)
) {
deleteIndexs.push(skuIndex) deleteIndexs.push(skuIndex)
} }
}) })
@ -325,7 +332,8 @@ export const handleGetNewAdminCategoryData = (data: any) => {
vvPropertyValueList: item.vvProductPropertyValueList.map((item: any) => ({ vvPropertyValueList: item.vvProductPropertyValueList.map((item: any) => ({
...item, ...item,
categoryPropertyValue: item.productPropertyValue categoryPropertyValue: item.productPropertyValue
})) })),
vvProductPropertyValueList: undefined
})) }))
} }
@ -407,12 +415,33 @@ export const handleValidFormData = (
} }
export const handleGetSubmitParams = ( export const handleGetSubmitParams = (
isAdd: boolean,
$dialogData: any, $dialogData: any,
fileList: PreviewItem[], fileList: PreviewItem[],
adminCategoryData: CategoryDataMock, adminCategoryData: CategoryDataMock,
htmlContent: string, htmlContent: string,
skuList: TSkuList[] skuList: TSkuList[]
) => { ) => {
let vvProductPropertyList = []
if (isAdd) {
vvProductPropertyList = adminCategoryData.map((item) => ({
// ...item,
productPropertyName: item.categoryPropertyName,
vvProductPropertyValueList: item.vvPropertyValueList.map((item) => ({
// ...item,
productPropertyValue: item.categoryPropertyValue
}))
}))
} else {
vvProductPropertyList = adminCategoryData.map((item) => ({
...item,
productPropertyName: item.categoryPropertyName,
vvProductPropertyValueList: item.vvPropertyValueList.map((item) => ({
...item,
productPropertyValue: item.categoryPropertyValue
}))
}))
}
return { return {
...$dialogData, ...$dialogData,
mainImageUrl: fileList.find((item) => item.fileType === 'mainImageUrl')?.resourceUrl, mainImageUrl: fileList.find((item) => item.fileType === 'mainImageUrl')?.resourceUrl,
@ -429,20 +458,19 @@ export const handleGetSubmitParams = (
detail: item.resourceUrl, detail: item.resourceUrl,
type: 1 type: 1
})), })),
vvProductPropertyList: adminCategoryData.map((item) => ({ vvProductPropertyList,
...item, vvSkuList: skuList.map((item) => {
productPropertyName: item.categoryPropertyName, const result = {}
vvProductPropertyValueList: item.vvPropertyValueList.map((item) => ({ const canDeleteId = !item.id
return {
...item, ...item,
productPropertyValue: item.categoryPropertyValue vvSkuPropertyValueList: item.vvSkuPropertyValueList.map((child) => ({
})) ...child,
})), id: canDeleteId ? undefined : child.id,
vvSkuList: skuList.map((item) => ({ productPropertyValue: item.categoryPropertyValue, // testzc 编辑提交有问题,没有效果
...item, productPropertyName: item.categoryPropertyName // testzc 编辑提交有问题,没有效果
vvSkuPropertyValueList: item.vvSkuPropertyValueList.map((item) => ({ }))
...item, }
productPropertyValue: item.categoryPropertyValue })
}))
}))
} }
} }

View File

@ -27,7 +27,11 @@ import { useCommodityType } from './use-method'
const router = useRouter() const router = useRouter()
/** 新增&编辑 */ /** 新增&编辑 */
const onAddOrEdit = (type: string, row: any) => { const onAddOrEdit = (type: string, row: any) => {
router.push({ name: '/goods/detail', query: { type, id: row.id } }) if (!row) {
router.push({ name: '/goods/detail', query: { type } })
} else {
router.push({ name: '/goods/detail', query: { type, id: row.id } })
}
} }
/** 复制 */ /** 复制 */