fix: 🧩 修复bug
This commit is contained in:
@@ -16,11 +16,12 @@
|
||||
|
||||
<el-tree-select
|
||||
clearable
|
||||
v-model="_ruleFormParam.category_id"
|
||||
v-model="_ruleFormParam.category_id1"
|
||||
:data="options"
|
||||
:render-after-expand="false"
|
||||
show-checkbox
|
||||
check-strictly
|
||||
@change="handleTreeChange()"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
@@ -59,12 +60,12 @@
|
||||
<el-radio :value="0" :label="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否启用" style="width: 440px">
|
||||
<!-- <el-form-item label="是否启用" style="width: 440px">
|
||||
<el-radio-group v-model="_ruleFormParam.status">
|
||||
<el-radio :value="1" :label="1">是</el-radio>
|
||||
<el-radio :value="0" :label="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="SEO标题">
|
||||
<el-input v-model="_ruleFormParam.seo_title" style="width: 440px" />
|
||||
</el-form-item>
|
||||
@@ -95,6 +96,11 @@ const reset = () => {
|
||||
};
|
||||
|
||||
let _ruleFormParam: any = computed(() => props.data);
|
||||
|
||||
const handleTreeChange = () => {
|
||||
_ruleFormParam.value.category_id = _ruleFormParam.value.category_id1;
|
||||
};
|
||||
|
||||
// 暴露给父组件的参数和方法(外部需要什么,都可以从这里暴露出去)
|
||||
defineExpose({
|
||||
ruleForm: _ruleFormParam,
|
||||
|
||||
@@ -113,7 +113,7 @@ export const BASIC_INFO_FORM_DATA: FormItem[] = [
|
||||
prop: "is_show1",
|
||||
placeholder: "",
|
||||
type: "radio",
|
||||
label: "是否启动: ",
|
||||
label: "是否启用: ",
|
||||
options: [
|
||||
{
|
||||
label: "是",
|
||||
|
||||
@@ -43,8 +43,13 @@
|
||||
<script setup lang="ts" name="productEditIndex">
|
||||
import { ref, reactive } from "vue";
|
||||
//getProductAttrsApi
|
||||
import { getProductDetailsApi, getProductListApi, getProductAttrsListApi } from "@/api/modules/productList";
|
||||
import { getProductCategoryListApi } from "@/api/modules/productClass";
|
||||
import {
|
||||
getProductDetailsApi,
|
||||
getProductListApi,
|
||||
getProductAttrsListApi,
|
||||
getProductCategoryListApi
|
||||
} from "@/api/modules/productList";
|
||||
// import { getProductCategoryListApi } from "@/api/modules/productClass";
|
||||
import { RELATED_INFO_COLUMNS } from "./constant/related";
|
||||
import { cloneDeep, debounce } from "lodash-es";
|
||||
import { messageBox } from "@/utils/messageBox";
|
||||
@@ -123,7 +128,7 @@ const getProductList = async (query: any) => {
|
||||
|
||||
//产品分类(后端大佬说直接掉列表接口)
|
||||
const getProductCategoryList = async () => {
|
||||
const result = await getProductCategoryListApi({ page: 1, size: 500 });
|
||||
const result = await getProductCategoryListApi({ is_show: 1 });
|
||||
if (result?.code === 0) {
|
||||
let dataClone: any = cloneDeep(result?.data);
|
||||
dataStore.options = addLabelValue(dataClone);
|
||||
|
||||
@@ -1,13 +1,33 @@
|
||||
import { cloneDeep } from "lodash-es";
|
||||
|
||||
const hasIdRecursive = (data: any, targetId: any) => {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const item = data[i];
|
||||
if (item.id === targetId) {
|
||||
return true;
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
if (hasIdRecursive(item.children, targetId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
//将参数分离
|
||||
export const initDetailParams = (dataStore: any, data: any) => {
|
||||
let is = hasIdRecursive(dataStore.options, data.category_id);
|
||||
//基本信息
|
||||
dataStore.basicInfoRuleForm = cloneDeep({
|
||||
name: data.name,
|
||||
short_name: data.short_name,
|
||||
spu: data.spu,
|
||||
is: is,
|
||||
category_id1: is ? data.category_id : data.category_name,
|
||||
category_id: data.category_id,
|
||||
params: data.category_id,
|
||||
category_name: data.category_name,
|
||||
params: data.params,
|
||||
sort: data.sort,
|
||||
is_show: data.is_show,
|
||||
is_new: data.is_new,
|
||||
|
||||
Reference in New Issue
Block a user