fix: 解决商品上一版遗留的各种小bug关键部分已添加fix注释。完成的TODO也已添加fix标记

This commit is contained in:
puhui999 2023-05-17 18:24:34 +08:00
parent 3c4a39df01
commit 4ddba9d454
10 changed files with 216 additions and 218 deletions

View File

@ -82,3 +82,8 @@ export const getSpu = (id: number) => {
export const deleteSpu = (id: number) => {
return request.delete({ url: `/product/spu/delete?id=${id}` })
}
// 导出商品 Spu
export const exportUser = (params) => {
return request.download({ url: '/product/spu/export', params })
}

View File

@ -1,19 +1,19 @@
<template>
<div class="upload-box">
<el-upload
:action="updateUrl"
list-type="picture-card"
:class="['upload', drag ? 'no-border' : '']"
v-model:file-list="fileList"
:multiple="true"
:limit="limit"
:headers="uploadHeaders"
:accept="fileType.join(',')"
:action="updateUrl"
:before-upload="beforeUpload"
:class="['upload', drag ? 'no-border' : '']"
:drag="drag"
:headers="uploadHeaders"
:limit="limit"
:multiple="true"
:on-error="uploadError"
:on-exceed="handleExceed"
:on-success="uploadSuccess"
:on-error="uploadError"
:drag="drag"
:accept="fileType.join(',')"
list-type="picture-card"
>
<div class="upload-empty">
<slot name="empty">
@ -40,15 +40,15 @@
</div>
<el-image-viewer
v-if="imgViewVisible"
@close="imgViewVisible = false"
:url-list="[viewImageUrl]"
@close="imgViewVisible = false"
/>
</div>
</template>
<script setup lang="ts" name="UploadImgs">
<script lang="ts" name="UploadImgs" setup>
import { PropType } from 'vue'
import type { UploadFile, UploadProps, UploadUserFile } from 'element-plus'
import { ElNotification } from 'element-plus'
import type { UploadProps, UploadFile, UploadUserFile } from 'element-plus'
import { propTypes } from '@/utils/propTypes'
import { getAccessToken, getTenantId } from '@/utils/auth'
@ -88,8 +88,19 @@ const uploadHeaders = ref({
'tenant-id': getTenantId()
})
const fileList = ref<UploadUserFile[]>(props.modelValue)
const fileList = ref<UploadUserFile[]>()
// fix:
watch(
() => props.modelValue,
(data) => {
if (!data) return
fileList.value = data
},
{
deep: true,
immediate: true
}
)
/**
* @description 文件上传之前判断
* @param rawFile 上传的文件
@ -116,9 +127,11 @@ const beforeUpload: UploadProps['beforeUpload'] = (rawFile) => {
interface UploadEmits {
(e: 'update:modelValue', value: UploadUserFile[]): void
}
const emit = defineEmits<UploadEmits>()
const uploadSuccess = (response, uploadFile: UploadFile) => {
if (!response) return
// TODO urlfileList
uploadFile.url = response.data
emit('update:modelValue', fileList.value)
message.success('上传成功')
@ -159,35 +172,40 @@ const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
}
</script>
<style scoped lang="scss">
<style lang="scss" scoped>
.is-error {
.upload {
:deep(.el-upload--picture-card),
:deep(.el-upload-dragger) {
border: 1px dashed var(--el-color-danger) !important;
&:hover {
border-color: var(--el-color-primary) !important;
}
}
}
}
:deep(.disabled) {
.el-upload--picture-card,
.el-upload-dragger {
cursor: not-allowed;
background: var(--el-disabled-bg-color) !important;
border: 1px dashed var(--el-border-color-darker);
&:hover {
border-color: var(--el-border-color-darker) !important;
}
}
}
.upload-box {
.no-border {
:deep(.el-upload--picture-card) {
border: none !important;
}
}
:deep(.upload) {
.el-upload-dragger {
display: flex;
@ -199,14 +217,17 @@ const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
overflow: hidden;
border: 1px dashed var(--el-border-color-darker);
border-radius: v-bind(borderRadius);
&:hover {
border: 1px dashed var(--el-color-primary);
}
}
.el-upload-dragger.is-dragover {
background-color: var(--el-color-primary-light-9);
border: 2px dashed var(--el-color-primary) !important;
}
.el-upload-list__item,
.el-upload--picture-card {
width: v-bind(width);
@ -214,11 +235,13 @@ const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
background-color: transparent;
border-radius: v-bind(borderRadius);
}
.upload-image {
width: 100%;
height: 100%;
object-fit: contain;
}
.upload-handle {
position: absolute;
top: 0;
@ -233,6 +256,7 @@ const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
background: rgb(0 0 0 / 60%);
opacity: 0;
transition: var(--el-transition-duration-fast);
.handle-icon {
display: flex;
flex-direction: column;
@ -240,15 +264,18 @@ const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
justify-content: center;
padding: 0 6%;
color: aliceblue;
.el-icon {
margin-bottom: 15%;
font-size: 140%;
}
span {
font-size: 100%;
}
}
}
.el-upload-list__item {
&:hover {
.upload-handle {
@ -256,6 +283,7 @@ const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
}
}
}
.upload-empty {
display: flex;
flex-direction: column;
@ -263,12 +291,14 @@ const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
font-size: 12px;
line-height: 30px;
color: var(--el-color-info);
.el-icon {
font-size: 28px;
color: var(--el-text-color-secondary);
}
}
}
.el-upload__tip {
line-height: 15px;
text-align: center;

View File

@ -349,22 +349,35 @@ const remainingRouter: AppRouteRecordRaw[] = [
{
path: '/product',
component: Layout,
name: 'ProductManagementEdit',
name: 'Product',
meta: {
hidden: true
},
children: [
{
path: 'productManagementAdd', // TODO @puhui999最好拆成 add 和 edit 两个路由;添加商品;修改商品
path: 'productSpuAdd', // TODO @puhui999最好拆成 add 和 edit 两个路由;添加商品;修改商品 fix
component: () => import('@/views/mall/product/spu/addForm.vue'),
name: 'ProductManagementAdd',
name: 'ProductSpuAdd',
meta: {
noCache: true,
hidden: true,
canTo: true,
icon: 'ep:edit',
title: '添加商品',
activeMenu: '/product/product-management'
activeMenu: '/product/product-spu'
}
},
{
path: 'productSpuEdit/:spuId(\\d+)',
component: () => import('@/views/mall/product/spu/addForm.vue'),
name: 'productSpuEdit',
meta: {
noCache: true,
hidden: true,
canTo: true,
icon: 'ep:edit',
title: '编辑商品',
activeMenu: '/product/product-spu'
}
}
]

View File

@ -3,21 +3,21 @@
<el-tabs v-model="activeName">
<el-tab-pane label="商品信息" name="basicInfo">
<BasicInfoForm
ref="BasicInfoRef"
ref="basicInfoRef"
v-model:activeName="activeName"
:propFormData="formData"
/>
</el-tab-pane>
<el-tab-pane label="商品详情" name="description">
<DescriptionForm
ref="DescriptionRef"
ref="descriptionRef"
v-model:activeName="activeName"
:propFormData="formData"
/>
</el-tab-pane>
<el-tab-pane label="其他设置" name="otherSettings">
<OtherSettingsForm
ref="OtherSettingsRef"
ref="otherSettingsRef"
v-model:activeName="activeName"
:propFormData="formData"
/>
@ -31,88 +31,55 @@
</el-form>
</ContentWrap>
</template>
<script lang="ts" name="ProductManagementForm" setup>
<script lang="ts" name="ProductSpuForm" setup>
import { cloneDeep } from 'lodash-es'
import { useTagsViewStore } from '@/store/modules/tagsView'
import { BasicInfoForm, DescriptionForm, OtherSettingsForm } from './components'
import type { SpuType } from '@/api/mall/product/management/type/spuType' // api
import * as managementApi from '@/api/mall/product/management/spu'
// api
import * as ProductSpuApi from '@/api/mall/product/spu'
import * as PropertyApi from '@/api/mall/product/property'
const { t } = useI18n() //
const message = useMessage() //
const { push, currentRoute } = useRouter() //
const { query } = useRoute() //
const { params } = useRoute() //
const { delView } = useTagsViewStore() //
const formLoading = ref(false) // 12
const activeName = ref('basicInfo') // Tag
const BasicInfoRef = ref<ComponentRef<typeof BasicInfoForm>>() // Ref
const DescriptionRef = ref<ComponentRef<typeof DescriptionForm>>() // Ref
const OtherSettingsRef = ref<ComponentRef<typeof OtherSettingsForm>>() // Ref
const formData = ref<SpuType>({
name: '213', //
const basicInfoRef = ref<ComponentRef<typeof BasicInfoForm>>() // Ref
const descriptionRef = ref<ComponentRef<typeof DescriptionForm>>() // Ref
const otherSettingsRef = ref<ComponentRef<typeof OtherSettingsForm>>() // Ref
// spu
const formData = ref<ProductSpuApi.SpuType>({
name: '', //
categoryId: null, //
keyword: '213', //
keyword: '', //
unit: null, //
picUrl:
'http://127.0.0.1:48080/admin-api/infra/file/4/get/6ffdf8f5dfc03f7ceec1ff1ebc138adb8b721a057d505ccfb0e61a8783af1371.png', //
sliderPicUrls: [
{
name: 'http://127.0.0.1:48080/admin-api/infra/file/4/get/6ffdf8f5dfc03f7ceec1ff1ebc138adb8b721a057d505ccfb0e61a8783af1371.png',
url: 'http://127.0.0.1:48080/admin-api/infra/file/4/get/6ffdf8f5dfc03f7ceec1ff1ebc138adb8b721a057d505ccfb0e61a8783af1371.png'
}
], //
introduction: '213', //
deliveryTemplateId: 0, //
picUrl: '', //
sliderPicUrls: [], //
introduction: '', //
deliveryTemplateId: 1, //
specType: false, //
subCommissionType: false, //
skus: [
{
/**
* 商品价格单位 TODO @puhui999注释放在尾巴哈简洁一点~
*/
price: 0,
/**
* 市场价单位
*/
marketPrice: 0,
/**
* 成本价单位
*/
costPrice: 0,
/**
* 商品条码
*/
barCode: '',
/**
* 图片地址
*/
picUrl: '',
/**
* 库存
*/
stock: 0,
/**
* 商品重量单位kg 千克
*/
weight: 0,
/**
* 商品体积单位m^3 平米
*/
volume: 0,
/**
* 一级分销的佣金单位
*/
subCommissionFirstPrice: 0,
/**
* 二级分销的佣金单位
*/
subCommissionSecondPrice: 0
price: 0, //
marketPrice: 0, //
costPrice: 0, //
barCode: '', //
picUrl: '', //
stock: 0, //
weight: 0, //
volume: 0, //
subCommissionFirstPrice: 0, //
subCommissionSecondPrice: 0 //
}
],
description: '5425', //
sort: 1, //
giveIntegral: 1, //
virtualSalesCount: 1, //
description: '', //
sort: 0, //
giveIntegral: 0, //
virtualSalesCount: 0, //
recommendHot: false, //
recommendBenefit: false, //
recommendBest: false, //
@ -122,11 +89,11 @@ const formData = ref<SpuType>({
/** 获得详情 */
const getDetail = async () => {
const id = query.id as unknown as number
const id = params.spuId as number
if (id) {
formLoading.value = true
try {
const res = (await managementApi.getSpu(id)) as SpuType
const res = (await ProductSpuApi.getSpu(id)) as ProductSpuApi.SpuType
formData.value = res
// id
// TODO @puhui999 propertyName id + uniapp
@ -134,7 +101,7 @@ const getDetail = async () => {
const PropertyS = await PropertyApi.getPropertyListAndValue({ propertyIds })
await nextTick()
//
BasicInfoRef.value.addAttribute(PropertyS)
basicInfoRef.value.addAttribute(PropertyS)
} finally {
formLoading.value = false
}
@ -145,54 +112,37 @@ const getDetail = async () => {
const submitForm = async () => {
//
formLoading.value = true
const newSkus = JSON.parse(JSON.stringify(formData.value.skus)) //skus使
// TODO
//
//
try {
await unref(BasicInfoRef)?.validate()
await unref(DescriptionRef)?.validate()
await unref(OtherSettingsRef)?.validate()
// TODO @puhui server
await unref(basicInfoRef)?.validate()
await unref(descriptionRef)?.validate()
await unref(otherSettingsRef)?.validate()
const deepCopyFormData = cloneDeep(unref(formData.value)) // fix: server
//
formData.value.skus.forEach((item) => {
deepCopyFormData.skus.forEach((item) => {
// sku name
item.name = formData.value.name
// skusvalue
if (formData.value.specType) {
item.properties.forEach((item2) => {
delete item2.valueName
})
}
item.name = deepCopyFormData.name
})
//
const newSliderPicUrls = []
formData.value.sliderPicUrls.forEach((item) => {
deepCopyFormData.sliderPicUrls.forEach((item) => {
//
// TODO @puhui999 object
if (typeof item === 'object') {
newSliderPicUrls.push(item.url)
} else {
newSliderPicUrls.push(item)
}
// TODO @puhui999 object fix
typeof item === 'object' ? newSliderPicUrls.push(item.url) : newSliderPicUrls.push(item)
})
formData.value.sliderPicUrls = newSliderPicUrls
deepCopyFormData.sliderPicUrls = newSliderPicUrls
//
const data = formData.value as SpuType
// skus.
const id = query.id as unknown as number
const data = deepCopyFormData as ProductSpuApi.SpuType
const id = params.spuId as number
if (!id) {
await managementApi.createSpu(data)
await ProductSpuApi.createSpu(data)
message.success(t('common.createSuccess'))
} else {
await managementApi.updateSpu(data)
await ProductSpuApi.updateSpu(data)
message.success(t('common.updateSuccess'))
}
close()
} catch (e) {
// ,skus
if (typeof e === 'string') {
formData.value.skus = newSkus
}
} finally {
formLoading.value = false
}
@ -200,41 +150,40 @@ const submitForm = async () => {
/**
* 重置表单
* fix:先注释保留如果后期没有使用到则移除
*/
const resetForm = async () => {
formData.value = {
name: '', //
categoryId: 0, //
keyword: '', //
unit: '', //
picUrl: '', //
sliderPicUrls: [], //
introduction: '', //
deliveryTemplateId: 0, //
selectRule: '',
specType: false, //
subCommissionType: false, //
description: '', //
sort: 1, //
giveIntegral: 1, //
virtualSalesCount: 1, //
recommendHot: false, //
recommendBenefit: false, //
recommendBest: false, //
recommendNew: false, //
recommendGood: false //
}
}
// const resetForm = async () => {
// formData.value = {
// name: '', //
// categoryId: 0, //
// keyword: '', //
// unit: '', //
// picUrl: '', //
// sliderPicUrls: [], //
// introduction: '', //
// deliveryTemplateId: 0, //
// selectRule: '',
// specType: false, //
// subCommissionType: false, //
// description: '', //
// sort: 1, //
// giveIntegral: 1, //
// virtualSalesCount: 1, //
// recommendHot: false, //
// recommendBenefit: false, //
// recommendBest: false, //
// recommendNew: false, //
// recommendGood: false //
// }
// }
/** 关闭按钮 */
const close = () => {
// TODO @puhui999 reset close
resetForm()
delView(unref(currentRoute))
push('/product/product-management')
push('/product/product-spu')
}
/** 初始化 */
onMounted(() => {
getDetail()
onMounted(async () => {
await getDetail()
})
</script>

View File

@ -1,5 +1,5 @@
<template>
<el-form ref="ProductManagementBasicInfoRef" :model="formData" :rules="rules" label-width="120px">
<el-form ref="productSpuBasicInfoRef" :model="formData" :rules="rules" label-width="120px">
<el-row>
<el-col :span="12">
<el-form-item label="商品名称" prop="name">
@ -54,7 +54,7 @@
</el-col>
<el-col :span="24">
<el-form-item label="商品轮播图" prop="sliderPicUrls">
<UploadImgs v-model="formData.sliderPicUrls" />
<UploadImgs v-model:modelValue="formData.sliderPicUrls" />
</el-form-item>
</el-col>
<el-col :span="12">
@ -86,36 +86,36 @@
<!-- 多规格添加-->
<el-col :span="24">
<el-form-item v-if="formData.specType" label="商品属性">
<!-- TODO @puhui999参考 https://admin.java.crmeb.net/store/list/creatProduct -->
<el-button class="mr-15px mb-10px" @click="AttributesAddFormRef.open">添加规格</el-button>
<ProductAttributes :attribute-data="attributeList" />
<!-- TODO @puhui999参考 https://admin.java.crmeb.net/store/list/creatProduct fix-->
<el-button class="mr-15px mb-10px" @click="attributesAddFormRef.open">添加规格</el-button>
<ProductAttributes :propertyList="propertyList" />
</el-form-item>
<template v-if="formData.specType && attributeList.length > 0">
<template v-if="formData.specType && propertyList.length > 0">
<el-form-item label="批量设置">
<SkuList :attributeList="attributeList" :is-batch="true" :prop-form-data="formData" />
<SkuList :is-batch="true" :prop-form-data="formData" :propertyList="propertyList" />
</el-form-item>
<el-form-item label="属性列表">
<SkuList :attributeList="attributeList" :prop-form-data="formData" />
<SkuList :prop-form-data="formData" :propertyList="propertyList" />
</el-form-item>
</template>
<el-form-item v-if="!formData.specType">
<SkuList :attributeList="attributeList" :prop-form-data="formData" />
<SkuList :prop-form-data="formData" :propertyList="propertyList" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<ProductAttributesAddForm ref="AttributesAddFormRef" @success="addAttribute" />
<ProductAttributesAddForm ref="attributesAddFormRef" @success="addAttribute" />
</template>
<script lang="ts" name="ProductManagementBasicInfoForm" setup>
<script lang="ts" name="ProductSpuBasicInfoForm" setup>
import { PropType } from 'vue'
import { defaultProps, handleTree } from '@/utils/tree'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import type { SpuType } from '@/api/mall/product/management/type/spuType'
import type { SpuType } from '@/api/mall/product/spu'
import { UploadImg, UploadImgs } from '@/components/UploadFile'
import { copyValueToTarget } from '@/utils'
import { ProductAttributes, ProductAttributesAddForm, SkuList } from './index'
import * as ProductCategoryApi from '@/api/mall/product/category'
import { propTypes } from '@/utils/propTypes'
import { copyValueToTarget } from '@/utils'
const message = useMessage() //
@ -126,17 +126,14 @@ const props = defineProps({
},
activeName: propTypes.string.def('')
})
const AttributesAddFormRef = ref() // TODO @puhui999
const ProductManagementBasicInfoRef = ref() // Ref TODO @puhui999
// TODO @puhui999attributeList propertyList
const attributeList = ref([]) //
/** 添加商品属性 */ // TODO @puhui999propFormData
const attributesAddFormRef = ref() // TODO @puhui999 fix
const productSpuBasicInfoRef = ref() // Ref TODO @puhui999 fix
// TODO @puhui999attributeList propertyList fix
const propertyList = ref([]) //
/** 添加商品属性 */
// TODO @puhui999propFormData fix: ProductAttributesAddForm使propFormData
const addAttribute = (property: any) => {
if (Array.isArray(property)) {
attributeList.value = property
return
}
attributeList.value.push(property)
Array.isArray(property) ? (propertyList.value = property) : propertyList.value.push(property)
}
const formData = reactive<SpuType>({
name: '', //
@ -171,10 +168,15 @@ watch(
() => props.propFormData,
(data) => {
if (!data) return
// fix使 copyValueToTarget 使 formData.value = data
copyValueToTarget(formData, data)
// fix: url
formData.sliderPicUrls = data['sliderPicUrls'].map((item) => ({
url: item
}))
},
{
deep: true,
// fix: ,
immediate: true
}
)
@ -185,8 +187,8 @@ watch(
const emit = defineEmits(['update:activeName'])
const validate = async () => {
//
if (!ProductManagementBasicInfoRef) return
return await unref(ProductManagementBasicInfoRef).validate((valid) => {
if (!productSpuBasicInfoRef) return
return await unref(productSpuBasicInfoRef).validate((valid) => {
if (!valid) {
message.warning('商品信息未完善!!')
emit('update:activeName', 'basicInfo')
@ -212,7 +214,7 @@ const changeSubCommissionType = () => {
/** 选择规格 */
const onChangeSpec = () => {
//
attributeList.value = []
propertyList.value = []
// sku
formData.skus = [
{

View File

@ -1,5 +1,5 @@
<template>
<el-form ref="DescriptionFormRef" :model="formData" :rules="rules" label-width="120px">
<el-form ref="descriptionFormRef" :model="formData" :rules="rules" label-width="120px">
<!--富文本编辑器组件-->
<el-form-item label="商品详情" prop="description">
<Editor v-model:modelValue="formData.description" />
@ -7,11 +7,11 @@
</el-form>
</template>
<script lang="ts" name="DescriptionForm" setup>
import type { SpuType } from '@/api/mall/product/management/type/spuType'
import type { SpuType } from '@/api/mall/product/spu'
import { Editor } from '@/components/Editor'
import { PropType } from 'vue'
import { copyValueToTarget } from '@/utils'
import { propTypes } from '@/utils/propTypes'
import { copyValueToTarget } from '@/utils'
const message = useMessage() //
const props = defineProps({
@ -21,7 +21,7 @@ const props = defineProps({
},
activeName: propTypes.string.def('')
})
const DescriptionFormRef = ref() // Ref
const descriptionFormRef = ref() // Ref
const formData = ref<SpuType>({
description: '' //
})
@ -29,7 +29,6 @@ const formData = ref<SpuType>({
const rules = reactive({
description: [required]
})
/**
* 富文本编辑器如果输入过再清空会有残留需再重置一次
*/
@ -45,7 +44,6 @@ watch(
immediate: true
}
)
/**
* 将传进来的值赋值给formData
*/
@ -53,10 +51,11 @@ watch(
() => props.propFormData,
(data) => {
if (!data) return
// fix使 copyValueToTarget 使 formData.value = data
copyValueToTarget(formData.value, data)
},
{
deep: true,
// fix: ,
immediate: true
}
)
@ -67,8 +66,8 @@ watch(
const emit = defineEmits(['update:activeName'])
const validate = async () => {
//
if (!DescriptionFormRef) return
return unref(DescriptionFormRef).validate((valid) => {
if (!descriptionFormRef) return
return await unref(descriptionFormRef).validate((valid) => {
if (!valid) {
message.warning('商品详情为完善!!')
emit('update:activeName', 'description')

View File

@ -1,5 +1,5 @@
<template>
<el-form ref="OtherSettingsFormRef" :model="formData" :rules="rules" label-width="120px">
<el-form ref="otherSettingsFormRef" :model="formData" :rules="rules" label-width="120px">
<el-row>
<!-- TODO @puhui999横着三个哈 fix-->
<el-col :span="24">
@ -55,8 +55,8 @@
<script lang="ts" name="OtherSettingsForm" setup>
import type { SpuType } from '@/api/mall/product/spu'
import { PropType } from 'vue'
import { copyValueToTarget } from '@/utils'
import { propTypes } from '@/utils/propTypes'
import { copyValueToTarget } from '@/utils'
const message = useMessage() //
@ -68,7 +68,7 @@ const props = defineProps({
activeName: propTypes.string.def('')
})
const OtherSettingsFormRef = ref() // Ref
const otherSettingsFormRef = ref() // Ref
//
const formData = ref<SpuType>({
sort: 1, //
@ -100,7 +100,7 @@ const checkboxGroup = ref<string[]>([]) // 选中的推荐选项
const onChangeGroup = () => {
// TODO @puhui999 recommendfix
recommendOptions.forEach(({ value }) => {
formData.value[value] = checkboxGroup.value.includes(value) ? true : false
formData.value[value] = checkboxGroup.value.includes(value)
})
}
@ -111,22 +111,28 @@ watch(
() => props.propFormData,
(data) => {
if (!data) return
// fix使 copyValueToTarget 使 formData.value = data
copyValueToTarget(formData.value, data)
recommendOptions.forEach(({ value }) => {
// TODO fix:
if (formData.value[value] && !checkboxGroup.value.includes(value)) {
checkboxGroup.value.push(value)
}
})
},
{
deep: true,
// fix: ,
immediate: true
}
)
/**
* 表单校验
*/
const emit = defineEmits(['update:activeName'])
const validate = async () => {
//
if (!OtherSettingsFormRef) return
return await unref(OtherSettingsFormRef).validate((valid) => {
if (!otherSettingsFormRef) return
return await unref(otherSettingsFormRef).validate((valid) => {
if (!valid) {
message.warning('商品其他设置未完善!!')
emit('update:activeName', 'otherSettings')
@ -139,14 +145,4 @@ const validate = async () => {
})
}
defineExpose({ validate })
onMounted(async () => {
await nextTick()
// TODO fix:
checkboxGroup.value = []
recommendOptions.forEach(({ value }) => {
if (formData.value[value]) {
checkboxGroup.value.push(value)
}
})
})
</script>

View File

@ -54,14 +54,14 @@ const inputVisible = computed(() => (index) => {
const InputRef = ref() //Ref
const attributeList = ref([]) //
const props = defineProps({
attributeData: {
propertyList: {
type: Array,
default: () => {}
}
})
watch(
() => props.attributeData,
() => props.propertyList,
(data) => {
if (!data) return
attributeList.value = data
@ -80,6 +80,7 @@ const handleClose = (index, valueIndex) => {
/** 显示输入框并获取焦点 */
const showInput = async (index) => {
attributeIndex.value = index
// TODO
// refRef
InputRef.value[index]!.input!.focus()
}

View File

@ -25,13 +25,13 @@
</template>
</el-table-column>
</template>
<!-- TODO @puhui999 controls-position=" " 可以去掉哈不然太长了手动输入更方便 -->
<!-- TODO @puhui999 controls-position=" " 可以去掉哈不然太长了手动输入更方便 fix -->
<el-table-column align="center" label="商品条码" min-width="168">
<template #default="{ row }">
<el-input v-model="row.barCode" class="w-100%" />
</template>
</el-table-column>
<!-- TODO @puhui999用户输入的时候是按照元分主要是我们自己用 -->
<!-- TODO @puhui999用户输入的时候是按照元分主要是我们自己用fix -->
<el-table-column align="center" label="销售价(元)" min-width="168">
<template #default="{ row }">
<el-input-number v-model="row.price" :min="0" class="w-100%" />
@ -96,7 +96,7 @@ const props = defineProps({
type: Object as PropType<SpuType>,
default: () => {}
},
attributeList: {
propertyList: {
type: Array,
default: () => []
},
@ -142,7 +142,7 @@ watch(
}
)
// TODO @ chatgpt
// TODO @ chatgpt fix
/** 生成表数据 */
const generateTableData = (data: any[]) => {
// fix: 使mapfor
@ -207,8 +207,8 @@ const build = (propertyValuesList: Property[][]) => {
/** 监听属性列表生成相关参数和表头 */
watch(
() => props.attributeList,
(attributeList) => {
() => props.propertyList,
(propertyList) => {
//
if (!formData.value.specType) return
// 使
@ -229,15 +229,15 @@ watch(
]
}
//
if (JSON.stringify(attributeList) === '[]') return
if (JSON.stringify(propertyList) === '[]') return
//
tableHeaders.value = []
//
attributeList.forEach((item, index) => {
propertyList.forEach((item, index) => {
// nameindex
tableHeaders.value.push({ prop: `name${index}`, label: item.name })
})
generateTableData(attributeList)
generateTableData(propertyList)
},
{
deep: true,

View File

@ -8,7 +8,7 @@
class="-mb-15px"
label-width="68px"
>
<!-- TODO @puhui999https://admin.java.crmeb.net/store/index使 + -->
<!-- TODO @puhui999https://admin.java.crmeb.net/store/index使 + fix-->
<el-form-item label="品牌名称" prop="name">
<el-input
v-model="queryParams.name"
@ -351,11 +351,11 @@ const resetQuery = () => {
const openForm = (id?: number) => {
//
if (typeof id === 'number') {
push('/product/productManagementAdd?id=' + id)
push('/product/productSpuEdit/' + id)
return
}
//
push('/product/productManagementAdd')
push('/product/productSpuAdd')
}
// TODO @puhui999fix:
@ -377,8 +377,11 @@ onMounted(async () => {
</script>
<style lang="scss" scoped>
.demo-table-expand {
padding-left: 42px;
:deep(.el-form-item__label) {
width: 82px;
font-weight: bold;
color: #99a9bf;
}
}