加入属性分类值的可选项

pull/744/head
没钱 2025-03-10 15:36:48 +08:00
parent 031140a241
commit 42c2b69124
3 changed files with 101 additions and 53 deletions

View File

@ -87,7 +87,7 @@
"source.fixAll.stylelint": "explicit" "source.fixAll.stylelint": "explicit"
}, },
"[vue]": { "[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "Vue.volar"
}, },
"i18n-ally.localesPaths": ["src/locales"], "i18n-ally.localesPaths": ["src/locales"],
"i18n-ally.keystyle": "nested", "i18n-ally.keystyle": "nested",

View File

@ -1,42 +1,45 @@
<template> <template>
<Dialog title="新增分类属性值" v-model="valueDialogVisible">
<el-form ref="valueFormRef" :model="valueFormData" :rules="valueFormRules" label-width="100px" v-loading="formLoading">
<el-form-item label="分类属性值" prop="productCategoryPropertiesValue">
<el-input v-model="valueFormData.productCategoryPropertiesValue" placeholder="请输入分类属性值" clearable />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="addProductCategoryPropertiesValue" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="valueDialogVisible = false"> </el-button>
</template>
</Dialog>
<Dialog :title="dialogTitle" v-model="dialogVisible"> <Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form <el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px" v-loading="formLoading">
ref="formRef" <el-form-item label="分类属性" prop="productCategoryPropertiesId" v-show="false">
:model="formData" <el-input v-model="formData.productCategoryPropertiesId" placeholder="请输入分类属性" clearable />
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="类别属性" prop="productCategoryPropertiesId"
v-show="false"
>
<el-input
v-model="formData.productCategoryPropertiesId"
placeholder="请输入类别属性"
clearable
/>
</el-form-item> </el-form-item>
<el-form-item label="类别属性" prop="productPropertiesCn"> <el-form-item label="分类属性" prop="productPropertiesCn">
<el-input <el-input v-model="formData.productPropertiesCn" placeholder="请输入分类属性" clearable disabled />
v-model="formData.productPropertiesCn"
placeholder="请输入类别属性"
clearable
disabled
/>
</el-form-item> </el-form-item>
<el-form-item label="产品分类" prop="productCategoryId" v-if="productPropertiesCategory===1"> <el-form-item label="产品分类" prop="productCategoryId" v-if="productPropertiesCategory === 1">
<el-tree-select <el-tree-select v-model="formData.productCategoryId" :data="productCategoryTree" :props="defaultProps"
v-model="formData.productCategoryId" check-strictly default-expand-all placeholder="请选择上级编号" />
:data="productCategoryTree"
:props="defaultProps"
check-strictly
default-expand-all
placeholder="请选择上级编号"
/>
</el-form-item> </el-form-item>
<el-form-item label="类别属性值" prop="productCategoryPropertiesValue" v-if="productPropertiesCategory===0"> <el-row>
<el-input v-model="formData.productCategoryPropertiesValue" placeholder="请输入类别属性值" /> <el-col :span="21">
<el-form-item label="分类属性值" prop="productCategoryPropertiesValue" v-if="productPropertiesCategory === 0">
<el-select v-model="formData.productCategoryPropertiesValue" placeholder="请选择产品分类属性值" clearable>
<el-option v-for="dict in productCategoryPropertiesValueList" :key="dict.id"
:label="dict.productCategoryPropertiesValue" :value="dict.productCategoryPropertiesValue" />
</el-select>
</el-form-item> </el-form-item>
</el-col>
<el-col :span="1">
<span></span>
</el-col>
<el-col :span="1">
<el-button type="primary" @click="openValueForm"> </el-button>
</el-col>
</el-row>
</el-form> </el-form>
<template #footer> <template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button> <el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
@ -46,9 +49,11 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ProductCategoryPropertiesCategoryMapApi, ProductCategoryPropertiesCategoryMapVO } from '@/api/erp/product/category/productcategoryproperties/propertiescategorymap' import { ProductCategoryPropertiesCategoryMapApi, ProductCategoryPropertiesCategoryMapVO } from '@/api/erp/product/category/productcategoryproperties/propertiescategorymap'
import { ProductCategoryApi,ProductCategoryVO} from '@/api/erp/product/category' import { ProductCategoryApi } from '@/api/erp/product/category'
import { defaultProps, handleTree } from '@/utils/tree' import { defaultProps, handleTree } from '@/utils/tree'
import { ProductCategoryPropertiesApi,ProductCategoryPropertiesVO } from '@/api/erp/product/category/productcategoryproperties' import { ProductCategoryPropertiesApi } from '@/api/erp/product/category/productcategoryproperties'
import { ProductCategoryPropertiesValueApi, ProductCategoryPropertiesValueVO } from '@/api/erp/product/category/productcategoryproperties/productcategorypropertiesvalue'
/** 产品属性类别 */ /** 产品属性类别 */
let productPropertiesCategory = ref() let productPropertiesCategory = ref()
@ -69,6 +74,16 @@ const { t } = useI18n() // 国际化
const message = useMessage() // const message = useMessage() //
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
//
const valueDialogVisible = ref(false) //
const valueFormData = ref({
productCategoryPropertiesValue: null as any
})
const valueFormRules = reactive({
productCategoryPropertiesValue: [
{ required: true, message: '请输入分类属性值', trigger: 'blur' },
]
})
const dialogTitle = ref('') // const dialogTitle = ref('') //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const formType = ref('') // create - update - const formType = ref('') // create - update -
@ -82,12 +97,44 @@ const formData = ref({
const formRules = reactive({ const formRules = reactive({
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
/** 分类属性值list */
const productCategoryPropertiesValueList = ref()
/** 新增分类属性值 */
const addProductCategoryPropertiesValue = async () => {
const data = {
productCategoryPropertiesId: props.productCategoryPropertiesId,
productCategoryPropertiesValue: valueFormData.value.productCategoryPropertiesValue
}
await ProductCategoryPropertiesValueApi.createProductCategoryPropertiesValue(data).then((res) => {
getAllProductCategoryPropertiesValue()
valueDialogVisible.value = false
message.success(t('common.createSuccess'))
})
}
/** 查询分类属性值的可选项 */
const getAllProductCategoryPropertiesValue = async () => {
await ProductCategoryPropertiesValueApi.getProductCategoryPropertiesValuePage({
pageNo: 1,
pageSize: 100,
productCategoryPropertiesId: props.productCategoryPropertiesId
}).then((res) => {
productCategoryPropertiesValueList.value = res.list
})
}
/** 判断使用下拉还是使用自定义属性 */ /** 判断使用下拉还是使用自定义属性 */
const getProductPropertiesCategory = async () => { const getProductPropertiesCategory = async () => {
ProductCategoryPropertiesApi.getProductCategoryProperties(props.productCategoryPropertiesId).then((res) => { ProductCategoryPropertiesApi.getProductCategoryProperties(props.productCategoryPropertiesId).then((res) => {
productPropertiesCategory.value = res.productPropertiesCategory productPropertiesCategory.value = res.productPropertiesCategory
}) })
}
/** 打开分类属性值弹窗 */
const openValueForm = () => {
valueDialogVisible.value = true
} }
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
@ -98,6 +145,7 @@ const open = async (type: string, id?: number) => {
formData.value.productCategoryPropertiesId = props.productCategoryPropertiesId formData.value.productCategoryPropertiesId = props.productCategoryPropertiesId
formData.value.productPropertiesCn = props.productPropertiesCn formData.value.productPropertiesCn = props.productPropertiesCn
await getProductPropertiesCategory() await getProductPropertiesCategory()
await getAllProductCategoryPropertiesValue()
getAllProductCategory() getAllProductCategory()
// //
if (id) { if (id) {
@ -144,7 +192,7 @@ const resetForm = () => {
productCategoryId: undefined, productCategoryId: undefined,
productCategoryPropertiesValue: undefined, productCategoryPropertiesValue: undefined,
productCategoryPropertiesId: null as any productCategoryPropertiesId: null as any
} }
formRef.value?.resetFields() formRef.value?.resetFields()
} }

View File

@ -8,10 +8,10 @@
:inline="true" :inline="true"
label-width="68px" label-width="68px"
> >
<el-form-item label="属性"> <el-form-item label="类属性">
<el-input <el-input
v-model="productPropertiesCn" v-model="productPropertiesCn"
placeholder="请输入属性" placeholder="请输入类属性"
clearable clearable
disabled disabled
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
@ -59,7 +59,7 @@
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="编号" align="center" prop="id" /> <el-table-column label="编号" align="center" prop="id" />
<el-table-column label="产品分类" align="center" prop="productCategoryValue" /> <el-table-column label="产品分类" align="center" prop="productCategoryValue" />
<el-table-column label="属性值" align="center" prop="productCategoryPropertiesValue" /> <el-table-column label="类属性值" align="center" prop="productCategoryPropertiesValue" />
<el-table-column <el-table-column
label="创建时间" label="创建时间"
align="center" align="center"
@ -130,7 +130,7 @@ const queryParams = reactive({
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) // const exportLoading = ref(false) //
/** 属性中文 */ /** 类属性中文 */
let productPropertiesCn = ref('') let productPropertiesCn = ref('')
/** 查询列表 */ /** 查询列表 */
@ -207,7 +207,7 @@ const searchProductCategoryProperties = async () => {
productPropertiesCn.value = res.productPropertiesCn productPropertiesCn.value = res.productPropertiesCn
}) })
}catch (error) { }catch (error) {
message.error('查询属性失败') message.error('查询类属性失败')
} }
} }