feat: 联调
This commit is contained in:
parent
016f92ced5
commit
dc006fddf6
@ -16,6 +16,9 @@ const login = {
|
||||
*/
|
||||
getCategoryPropertyList: ['/category/property/list'], // 获取类目属性列表
|
||||
updateCategoryProperty: ['/category/property/insertOrUpdate'], // 更新类目属性
|
||||
deleteCategoryProperty: ['/category/property/delete'], // 删除类目属性
|
||||
updateCategoryPropertyValue: ['/category/property/value/insertOrUpdate'], // 更新类目属性值
|
||||
deleteCategoryPropertyValue: ['/category/property/value/delete'], // 删除类目属性值
|
||||
/**
|
||||
* app类目管理
|
||||
*/
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
<el-popover
|
||||
:visible="visibleProperty[data.id]"
|
||||
placement="bottom"
|
||||
title="请输入属性标题"
|
||||
title="请输入属性值"
|
||||
:width="200"
|
||||
trigger="click"
|
||||
>
|
||||
@ -56,7 +56,7 @@
|
||||
size="small"
|
||||
class="ml-2 !text-white"
|
||||
@click="visibleProperty[data.id] = true"
|
||||
>新增属性</el-button
|
||||
>新增属性值</el-button
|
||||
>
|
||||
</template>
|
||||
<el-input
|
||||
@ -66,9 +66,9 @@
|
||||
></el-input>
|
||||
</el-popover>
|
||||
<el-popover
|
||||
:visible="visiblePropertyType"
|
||||
:visible="visiblePropertyType[data.id]"
|
||||
placement="bottom"
|
||||
title="请输入属性类型标题"
|
||||
title="请输入属性标题"
|
||||
:width="200"
|
||||
trigger="click"
|
||||
>
|
||||
@ -78,7 +78,7 @@
|
||||
size="small"
|
||||
class="ml-2 !text-white"
|
||||
@click="visiblePropertyType[data.id] = true"
|
||||
>新增属性类型</el-button
|
||||
>新增属性</el-button
|
||||
>
|
||||
</template>
|
||||
<el-input
|
||||
@ -87,6 +87,13 @@
|
||||
@blur="visiblePropertyType[data.id] = false"
|
||||
></el-input>
|
||||
</el-popover>
|
||||
<el-button
|
||||
type="danger"
|
||||
size="small"
|
||||
class="ml-2 !text-white"
|
||||
@click="onDeleteProperty(data.id)"
|
||||
>删除属性</el-button
|
||||
>
|
||||
</dd>
|
||||
</dl>
|
||||
</template>
|
||||
@ -108,6 +115,7 @@
|
||||
import { ElButton, ElMessage } from 'element-plus'
|
||||
import type { RenderContentContext } from 'element-plus'
|
||||
import { handleDragStart, handleDropFinish } from './use-drag'
|
||||
import { handleMessageBox } from '@/utils/page'
|
||||
|
||||
interface Tree {
|
||||
id: number
|
||||
@ -230,42 +238,55 @@ const inputPropertyTypeValue = ref('')
|
||||
// 删除类目的属性
|
||||
const onClosePropertyValue = async (id: number, data: any) => {
|
||||
const i = data.vvPropertyValueList.findIndex((item: any) => item.id === id)
|
||||
await api.commodity.updateCategoryProperty.post!({
|
||||
...data.vvPropertyValueList[i],
|
||||
isDelete: 1
|
||||
})
|
||||
await api.commodity.deleteCategoryPropertyValue.post!({ id })
|
||||
data.vvPropertyValueList.splice(i, 1)
|
||||
ElMessage.success('删除成功')
|
||||
}
|
||||
|
||||
// 新增回车确认
|
||||
// 新增属性值回车确认
|
||||
const onAddPropertyValue = async (data: any = {}) => {
|
||||
if (inputPropertyValue.value) {
|
||||
const params = {
|
||||
const res = await api.commodity.updateCategoryPropertyValue.post!({
|
||||
categoryPropertyId: data.id,
|
||||
categoryPropertyValue: inputPropertyValue.value
|
||||
}
|
||||
const res = await api.commodity.updateCategoryProperty.post!({
|
||||
...params
|
||||
})
|
||||
// testzc 将新增的数据返回到页面中
|
||||
data.vvPropertyValueList.push(params)
|
||||
data.vvPropertyValueList.push(res.data)
|
||||
}
|
||||
visibleProperty.value[data.id] = false
|
||||
inputPropertyValue.value = ''
|
||||
ElMessage.success('新增成功')
|
||||
}
|
||||
|
||||
// 新增属性类型
|
||||
const onAddPropertyType = async (data: any = {}) => {
|
||||
console.warn('----- my data is data111: ', data)
|
||||
if (inputPropertyTypeValue.value) {
|
||||
const params = {
|
||||
categoryPropertyName: inputPropertyTypeValue.value,
|
||||
vvCategoryPropertyDTOList: []
|
||||
}
|
||||
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
|
||||
inputPropertyTypeValue.value = ''
|
||||
ElMessage.success('新增成功')
|
||||
}
|
||||
}
|
||||
|
||||
// 删除属性
|
||||
const onDeleteProperty = async (id: number) => {
|
||||
handleMessageBox({
|
||||
msg: `是否删除属性?`,
|
||||
success: api.commodity.deleteCategoryProperty.post!,
|
||||
data: { id }
|
||||
}).then(() => {
|
||||
// testzc 删除成功后,删除树中的数据
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@ -251,6 +251,7 @@ const onSubmit = () => {
|
||||
// if (msg) return ElMessage.error(msg)
|
||||
console.warn('----- my data is htmlContent: ', htmlContent.value)
|
||||
const params = handleGetSubmitParams(
|
||||
route.query.type === 'add',
|
||||
$dialog.value.data,
|
||||
fileList.value,
|
||||
adminCategoryData.value,
|
||||
|
||||
@ -81,11 +81,18 @@ export const usePropertyValue = () => {
|
||||
})
|
||||
}
|
||||
const onClosePropertyValue = (index: number, id: number, skuList: Ref<TSkuList[]>) => {
|
||||
debugger
|
||||
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)
|
||||
const deleteIndexs: 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)
|
||||
}
|
||||
})
|
||||
@ -325,7 +332,8 @@ export const handleGetNewAdminCategoryData = (data: any) => {
|
||||
vvPropertyValueList: item.vvProductPropertyValueList.map((item: any) => ({
|
||||
...item,
|
||||
categoryPropertyValue: item.productPropertyValue
|
||||
}))
|
||||
})),
|
||||
vvProductPropertyValueList: undefined
|
||||
}))
|
||||
}
|
||||
|
||||
@ -407,12 +415,33 @@ export const handleValidFormData = (
|
||||
}
|
||||
|
||||
export const handleGetSubmitParams = (
|
||||
isAdd: boolean,
|
||||
$dialogData: any,
|
||||
fileList: PreviewItem[],
|
||||
adminCategoryData: CategoryDataMock,
|
||||
htmlContent: string,
|
||||
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 {
|
||||
...$dialogData,
|
||||
mainImageUrl: fileList.find((item) => item.fileType === 'mainImageUrl')?.resourceUrl,
|
||||
@ -429,20 +458,19 @@ export const handleGetSubmitParams = (
|
||||
detail: item.resourceUrl,
|
||||
type: 1
|
||||
})),
|
||||
vvProductPropertyList: adminCategoryData.map((item) => ({
|
||||
...item,
|
||||
productPropertyName: item.categoryPropertyName,
|
||||
vvProductPropertyValueList: item.vvPropertyValueList.map((item) => ({
|
||||
vvProductPropertyList,
|
||||
vvSkuList: skuList.map((item) => {
|
||||
const result = {}
|
||||
const canDeleteId = !item.id
|
||||
return {
|
||||
...item,
|
||||
productPropertyValue: item.categoryPropertyValue
|
||||
}))
|
||||
})),
|
||||
vvSkuList: skuList.map((item) => ({
|
||||
...item,
|
||||
vvSkuPropertyValueList: item.vvSkuPropertyValueList.map((item) => ({
|
||||
...item,
|
||||
productPropertyValue: item.categoryPropertyValue
|
||||
}))
|
||||
}))
|
||||
vvSkuPropertyValueList: item.vvSkuPropertyValueList.map((child) => ({
|
||||
...child,
|
||||
id: canDeleteId ? undefined : child.id,
|
||||
productPropertyValue: item.categoryPropertyValue, // testzc 编辑提交有问题,没有效果
|
||||
productPropertyName: item.categoryPropertyName // testzc 编辑提交有问题,没有效果
|
||||
}))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,11 @@ import { useCommodityType } from './use-method'
|
||||
const router = useRouter()
|
||||
/** 新增&编辑 */
|
||||
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 } })
|
||||
}
|
||||
}
|
||||
|
||||
/** 复制 */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user