feat: 🚀 完整

This commit is contained in:
2026-07-09 11:39:00 +08:00
parent fc627b7666
commit 472dd212f0
15 changed files with 185 additions and 165 deletions

View File

@@ -1,29 +1,33 @@
import http from "@/api"; import http from "@/api";
const PRODUCT_ATTR = `/product/attr`; const PRODUCT_Compatibility = `/product/compat`;
// 产品属性列表 // 列表
export const getProductAttrListApi = (params: any) => { export const getProductCompatibilityListApi = (params: any) => {
return http.get<any>(`${PRODUCT_ATTR}/index`, params); return http.get<any>(`${PRODUCT_Compatibility}/index`, params);
}; };
// 产品属性详情 // 详情
export const getProductAttrDetailsApi = (params: any) => { export const getProductCompatibilityDetailsApi = (params: any) => {
return http.get<any>(`${PRODUCT_ATTR}/read/${params}`); return http.get<any>(`${PRODUCT_Compatibility}/read/${params}`);
}; };
// 产品属性删除 // 删除
export const getProductAttrDelApi = (params: any) => { export const getProductCompatibilityDelApi = (params: any) => {
return http.delete<any>(`${PRODUCT_ATTR}/delete/${params}`); return http.delete<any>(`${PRODUCT_Compatibility}/delete/${params}`);
}; };
// 产品属性更新 // 更新
export const getProductAttrUpApi = (params: any) => { export const getProductCompatibilityUpApi = (params: any) => {
const { id } = params; const { id } = params;
return http.put<any>(`${PRODUCT_ATTR}/update/${id}`, params); return http.put<any>(`${PRODUCT_Compatibility}/update/${id}`, params);
}; };
//产品属性新增 //新增
export const getProductAttrAddApi = (params: any) => { export const getProductCompatibilityAddApi = (params: any) => {
return http.post<any>(`${PRODUCT_ATTR}/save`, params, { return http.post<any>(`${PRODUCT_Compatibility}/save`, params, {
headers: { headers: {
"Content-Type": "application/x-www-form-urlencoded" "Content-Type": "application/x-www-form-urlencoded"
} }
}); });
}; };
// //导入
export const getProductCompatibilityListImportApi = (params: any) => {
return http.post<any>(`${PRODUCT_Compatibility}/import`, params);
};
//getProductCompatibilityListApi,getProductCompatibilityDetailsApi,getProductCompatibilityDelApi,getProductCompatibilityUpApi,getProductCompatibilityUpApi,getProductCompatibilityAddApi,getProductCompatibilityAddApi

3
src/components.d.ts vendored
View File

@@ -12,6 +12,8 @@ declare module "vue" {
ElBreadcrumb: typeof import("element-plus/es")["ElBreadcrumb"]; ElBreadcrumb: typeof import("element-plus/es")["ElBreadcrumb"];
ElBreadcrumbItem: typeof import("element-plus/es")["ElBreadcrumbItem"]; ElBreadcrumbItem: typeof import("element-plus/es")["ElBreadcrumbItem"];
ElButton: typeof import("element-plus/es")["ElButton"]; ElButton: typeof import("element-plus/es")["ElButton"];
ElCheckbox: typeof import("element-plus/es")["ElCheckbox"];
ElCheckboxGroup: typeof import("element-plus/es")["ElCheckboxGroup"];
ElContainer: typeof import("element-plus/es")["ElContainer"]; ElContainer: typeof import("element-plus/es")["ElContainer"];
ElDatePicker: typeof import("element-plus/es")["ElDatePicker"]; ElDatePicker: typeof import("element-plus/es")["ElDatePicker"];
ElDialog: typeof import("element-plus/es")["ElDialog"]; ElDialog: typeof import("element-plus/es")["ElDialog"];
@@ -43,6 +45,7 @@ declare module "vue" {
ElTabPane: typeof import("element-plus/es")["ElTabPane"]; ElTabPane: typeof import("element-plus/es")["ElTabPane"];
ElTabs: typeof import("element-plus/es")["ElTabs"]; ElTabs: typeof import("element-plus/es")["ElTabs"];
ElTag: typeof import("element-plus/es")["ElTag"]; ElTag: typeof import("element-plus/es")["ElTag"];
ElTooltip: typeof import("element-plus/es")["ElTooltip"];
ElTreeSelect: typeof import("element-plus/es")["ElTreeSelect"]; ElTreeSelect: typeof import("element-plus/es")["ElTreeSelect"];
ElUpload: typeof import("element-plus/es")["ElUpload"]; ElUpload: typeof import("element-plus/es")["ElUpload"];
IEpArrowDown: typeof import("~icons/ep/arrow-down")["default"]; IEpArrowDown: typeof import("~icons/ep/arrow-down")["default"];

View File

@@ -39,11 +39,11 @@ export const EDIT_FORM_DATA: FormItem[] = [
options: [ options: [
{ {
label: "是", label: "是",
value: 1 value: 0
}, },
{ {
label: "否", label: "否",
value: 0 value: 1
} }
] ]
} }

View File

@@ -11,12 +11,9 @@
:request-api="getProductAccessoryTypeListApi" :request-api="getProductAccessoryTypeListApi"
:init-param="dataStore.initParam" :init-param="dataStore.initParam"
> >
<template #image="scope"> <template #disabled="scope">
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" /> <el-tag :type="scope.row.stdisabledatus == 1 ? 'danger' : 'success'" effect="dark">{{
</template> scope.row.disabled == 1 ? "禁用" : "启用"
<template #status="scope">
<el-tag :type="scope.row.status == 1 ? 'success' : 'danger'" effect="dark">{{
scope.row.status == 1 ? "启用" : "禁用"
}}</el-tag> }}</el-tag>
</template> </template>
<template #operation="scope"> <template #operation="scope">
@@ -77,8 +74,6 @@ import { RULE_FORM, FORM_DATA, COLUMNS, EDIT_FORM_DATA, EDIT_RULE_FORM, RULES }
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数) // 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
const proTableRef = ref<any>(null); const proTableRef = ref<any>(null);
const formRef: any = ref(null); const formRef: any = ref(null);
//图片地址
import { h } from "@/utils/url";
// 数据源 // 数据源
const dataStore = reactive<any>({ const dataStore = reactive<any>({
title: "添加配件类型", title: "添加配件类型",

View File

@@ -19,64 +19,65 @@ interface FormItem {
} }
export const EDIT_FORM_DATA: FormItem[] = [ export const EDIT_FORM_DATA: FormItem[] = [
{ {
prop: "name", prop: "label_name",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "标签名称: " label: "标签名称: "
}, },
{ {
prop: "name", prop: "part_id",
placeholder: "请输入", placeholder: "请输入",
type: "select", type: "select",
label: "配件类型: " label: "配件类型: ",
options: []
}, },
{ {
prop: "name", prop: "brand_name",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "品牌: " label: "品牌: "
}, },
{ {
prop: "name", prop: "level_name",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "级别: " label: "级别: "
}, },
{ {
prop: "name", prop: "class_name",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "类别: " label: "类别: "
}, },
{ {
prop: "name", prop: "series_name",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "系列: " label: "系列: "
}, },
{ {
prop: "name", prop: "model",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "市场型号: " label: "市场型号: "
}, },
{ {
prop: "name", prop: "capacity",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "容: " label: "容: "
}, },
{ {
prop: "name", prop: "interface_type",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "接口类型: " label: "接口类型: "
}, },
{ {
prop: "name", prop: "compat_status",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "兼容类型: " label: "兼容状态: "
}, },
{ {
prop: "sort", prop: "sort",
@@ -85,18 +86,18 @@ export const EDIT_FORM_DATA: FormItem[] = [
label: "排序: " label: "排序: "
}, },
{ {
prop: "recommend", prop: "disabled",
placeholder: "请输入", placeholder: "请输入",
type: "radio", type: "radio",
label: "是否启用: ", label: "是否启用: ",
options: [ options: [
{ {
label: "是", label: "是",
value: 1 value: 0
}, },
{ {
label: "否", label: "否",
value: 0 value: 1
} }
] ]
} }

View File

@@ -1,5 +1,5 @@
export const RULES = { export const RULES = {
name: [{ required: true, message: "视频名称不能为空 ! ", trigger: "blur" }], label_name: [{ required: true, message: "标签名称不能为空 ! ", trigger: "blur" }],
category_id1: [{ required: true, message: "视频分类不能为空 ! ", trigger: "blur" }], brand_name: [{ required: true, message: "标签名称不能为空 ! ", trigger: "blur" }],
sort: [{ required: true, message: "视频排序不能为空 ! ", trigger: "blur" }] sort: [{ required: true, message: "视频排序不能为空 ! ", trigger: "blur" }]
}; };

View File

@@ -17,13 +17,13 @@ interface FormItem {
} }
export const FORM_DATA: FormItem[] = [ export const FORM_DATA: FormItem[] = [
{ {
prop: "name", prop: "label_name",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "标签名称: " label: "标签名称: "
}, },
{ {
prop: "name", prop: "model",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "型号: " label: "型号: "

View File

@@ -10,56 +10,72 @@ export const COLUMNS = [
{ {
align: "left", align: "left",
label: "标签名称", label: "标签名称",
prop: "name" prop: "label_name",
width: 200,
fixed: true
}, },
{ {
align: "left", align: "left",
label: "配件类型", label: "配件类型",
prop: "category_name" prop: "part_name",
width: 200,
fixed: true
}, },
{ {
align: "left", align: "left",
label: "品牌", label: "品牌",
prop: "sort", prop: "brand_name",
width: 160 width: 200,
fixed: true
}, },
{ {
align: "left", align: "left",
label: "级别", label: "级别",
prop: "sort", prop: "level_name",
width: 160 width: 160
}, },
{ {
align: "left", align: "left",
label: "系列", label: "系列",
prop: "sort", prop: "series_name",
width: 160 width: 200
}, },
{ {
align: "left", align: "left",
label: "型号", label: "型号",
prop: "created_at" prop: "model",
width: 200
}, },
{ {
align: "left", align: "left",
label: "容量", label: "容量",
prop: "created_at" prop: "capacity",
width: 160
}, },
{ {
align: "left", align: "left",
label: "接口型号", label: "接口型号",
prop: "created_at" prop: "interface_type",
width: 200
}, },
{ {
align: "left", align: "left",
label: "兼容性状态", label: "兼容性状态",
prop: "created_at" prop: "compat_status",
width: 160
}, },
{ {
align: "left", align: "left",
label: "排序", label: "排序",
prop: "created_at" prop: "sort",
width: 160
},
{
align: "left",
label: "使用状态",
prop: "disabled",
width: 160
}, },
{ {
align: "left", align: "left",
@@ -69,7 +85,8 @@ export const COLUMNS = [
{ {
align: "left", align: "left",
label: "更新时间", label: "更新时间",
prop: "created_at" prop: "updated_at"
}, },
{ prop: "operation", label: "操作", fixed: "right", width: 200 } { prop: "operation", label: "操作", fixed: "right", width: 200 }
]; ];

View File

@@ -9,15 +9,12 @@
ref="proTableRef" ref="proTableRef"
:formData="dataStore.formData" :formData="dataStore.formData"
:columns="dataStore.columns" :columns="dataStore.columns"
:request-api="getVideoListApi" :request-api="getProductCompatibilityListApi"
:init-param="dataStore.initParam" :init-param="dataStore.initParam"
> >
<template #image="scope"> <template #disabled="scope">
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" /> <el-tag :type="scope.row.stdisabledatus == 1 ? 'danger' : 'success'" effect="dark">{{
</template> scope.row.disabled == 1 ? "禁用" : "启用"
<template #status="scope">
<el-tag :type="scope.row.status == 1 ? 'success' : 'danger'" effect="dark">{{
scope.row.status == 1 ? "启用" : "禁用"
}}</el-tag> }}</el-tag>
</template> </template>
<template #operation="scope"> <template #operation="scope">
@@ -61,20 +58,21 @@
<script setup lang="ts" name="productCompatibilityList"> <script setup lang="ts" name="productCompatibilityList">
import ProTable from "@/components/ProTable/index.vue"; import ProTable from "@/components/ProTable/index.vue";
import rulesForm from "@/components/rulesForm/index.vue"; import rulesForm from "@/components/rulesForm/index.vue";
import ImportExcel from "@/components/ImportExcel/index.vue";
import { messageBox } from "@/utils/messageBox"; import { messageBox } from "@/utils/messageBox";
import { useMsg } from "@/hooks/useMsg"; import { useMsg } from "@/hooks/useMsg";
const importRef = ref();
//列表接口 //列表接口
import { import {
getVideoListApi, getProductCompatibilityListApi,
getVideoListDelApi, getProductCompatibilityDetailsApi,
getVideoReadApi, getProductCompatibilityDelApi,
getVideoUpdateApi, getProductCompatibilityUpApi,
getVideoSaveApi, getProductCompatibilityAddApi,
getVideoClassListApi getProductCompatibilityListImportApi
} from "@/api/modules/videoList"; } from "@/api/modules/productCompatibility";
import { recursiveCompare } from "@/utils/recursiveCompare"; //列表接口
// import { getVideoClassListApi } from "@/api/modules/videoClass"; import { getProductAccessoryTypeListApi } from "@/api/modules/productAccessoryType";
//深拷贝方法 //深拷贝方法
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
//表格和搜索條件 //表格和搜索條件
@@ -83,11 +81,10 @@ import { RULE_FORM, FORM_DATA, COLUMNS, EDIT_FORM_DATA, EDIT_RULE_FORM, RULES }
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数) // 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
const proTableRef = ref<any>(null); const proTableRef = ref<any>(null);
const formRef: any = ref(null); const formRef: any = ref(null);
//图片地址 const importRef = ref(null);
import { h } from "@/utils/url";
// 数据源 // 数据源
const dataStore = reactive<any>({ const dataStore = reactive<any>({
title: "添加视频", title: "添加",
columns: COLUMNS, //列表配置项 columns: COLUMNS, //列表配置项
rules: cloneDeep(RULES), //抽屉表单验证 rules: cloneDeep(RULES), //抽屉表单验证
editRuleForm: cloneDeep(EDIT_RULE_FORM), editRuleForm: cloneDeep(EDIT_RULE_FORM),
@@ -104,7 +101,7 @@ const handleConfirmClick = () => {
if (!formRef.value!.ruleFormRef) return; if (!formRef.value!.ruleFormRef) return;
formRef!.value!.ruleFormRef!.validate((valid: any) => { formRef!.value!.ruleFormRef!.validate((valid: any) => {
if (valid) { if (valid) {
dataStore.title === "添加视频" ? getVideoSave() : getVideoUpdate(); dataStore.title === "添加" ? getSave() : getUpdate();
} else { } else {
console.log("error submit!"); console.log("error submit!");
return false; return false;
@@ -118,54 +115,37 @@ const resetFields = () => {
}; };
//抽屉重置 //抽屉重置
const handleResetClick = () => { const handleResetClick = () => {
if (dataStore.title === "添加视频") { if (dataStore.title === "添加") {
resetFields(); resetFields();
} else { } else {
getVideoRead(dataStore.selectRow.id); getRead(dataStore.selectRow.id);
} }
}; };
//视频分类接口 const getProductAccessoryTypeList = async () => {
const getVideoClassList = async () => { const result = await getProductAccessoryTypeListApi({ is_show: 1 });
const result = await getVideoClassListApi(); console.log(result?.data.data, "==================>");
if (result?.code === 0) { if (result?.code === 0) {
let arr: any[] = []; let arr: any[] = [];
if (result?.data?.length) { if (result?.data?.data?.length) {
result?.data?.forEach((item: any) => { result?.data?.data?.forEach((item: any) => {
let obj = {
value: item.id,
label: item.name
};
arr.push(obj);
});
dataStore.formData[1].options = arr;
}
}
};
getVideoClassList();
const getVideoClassEditList = async () => {
const result = await getVideoClassListApi({ is_show: 1 });
if (result?.code === 0) {
let arr: any[] = [];
if (result?.data?.length) {
result?.data?.forEach((item: any) => {
let obj = { let obj = {
value: item.id, value: item.id,
label: item.name label: item.name
}; };
arr.push(obj); arr.push(obj);
}); });
console.log(arr, "=================");
dataStore.editFormData[1].options = arr; dataStore.editFormData[1].options = arr;
} }
} }
}; };
getVideoClassEditList(); getProductAccessoryTypeList();
//添加 //添加
const handleAdd = () => { const handleAdd = () => {
dataStore.visible = true; dataStore.visible = true;
dataStore.title = "添加视频"; dataStore.title = "添加";
}; };
//抽屉关闭前的钩子 //抽屉关闭前的钩子
const handleBeforeClone = () => { const handleBeforeClone = () => {
@@ -174,32 +154,20 @@ const handleBeforeClone = () => {
dataStore.visible = false; dataStore.visible = false;
}; };
//详情 //详情
const getVideoRead = async (id: any) => { const getRead = async (id: any) => {
const result = await getVideoReadApi(id); const result = await getProductCompatibilityDetailsApi(id);
if (result?.code === 0) { if (result?.code === 0) {
dataStore.editRuleForm = result?.data; dataStore.editRuleForm = result?.data;
// let is = dataStore.editFormData[1].options.some((item: any) => {
// console.log(item.id);
// console.log(dataStore.editRuleForm.category_id);
// return item.value == dataStore.editRuleForm.category_id;
// });
let is = dataStore.editFormData[1].options.some((item: any) =>
recursiveCompare(item, dataStore.editRuleForm.category_id)
);
dataStore.editRuleForm.category_id1 = is ? dataStore.editRuleForm.category_id : dataStore.editRuleForm.category_name;
} }
}; };
const handleSelectChangeEmits = (value: any) => { const handleSelectChangeEmits = (value: any) => {
console.log(value, "========value=33========"); console.log(value, "========value=33========");
if (value.prop === "category_id1") {
dataStore.editRuleForm.category_id = value.id;
}
}; };
//保存 //保存
const getVideoSave = async () => { const getSave = async () => {
const result = await getVideoSaveApi(dataStore.editRuleForm); const result = await getProductCompatibilityAddApi(dataStore.editRuleForm);
if (result?.code === 0) { if (result?.code === 0) {
const { msg } = result; const { msg } = result;
useMsg("success", msg); useMsg("success", msg);
@@ -209,8 +177,8 @@ const getVideoSave = async () => {
} }
}; };
//更新 //更新
const getVideoUpdate = async () => { const getUpdate = async () => {
const result = await getVideoUpdateApi(dataStore.editRuleForm); const result = await getProductCompatibilityUpApi(dataStore.editRuleForm);
if (result?.code === 0) { if (result?.code === 0) {
const { msg } = result; const { msg } = result;
useMsg("success", msg); useMsg("success", msg);
@@ -221,9 +189,9 @@ const getVideoUpdate = async () => {
}; };
//删除 //删除
const getVideoListDel = (id: any) => { const getListDel = (id: any) => {
messageBox("你确定要删除?", async () => { messageBox("你确定要删除?", async () => {
const result = await getVideoListDelApi(id); const result = await getProductCompatibilityDelApi(id);
if (result?.code === 0) { if (result?.code === 0) {
const { msg } = result; const { msg } = result;
useMsg("success", msg); useMsg("success", msg);
@@ -237,13 +205,13 @@ const handleBtnClick = (type: any, row: any) => {
//编辑 //编辑
if (type === "编辑") { if (type === "编辑") {
dataStore.visible = true; dataStore.visible = true;
dataStore.title = "编辑视频"; dataStore.title = "编辑";
getVideoRead(row.id); getRead(row.id);
return; return;
} }
//删除 //删除
if (type === "删除") { if (type === "删除") {
getVideoListDel(row.id); getListDel(row.id);
} }
}; };
@@ -252,7 +220,7 @@ const handleImport = () => {
let params = { let params = {
title: "数据", title: "数据",
tempApi: "", tempApi: "",
importApi: "", importApi: getProductCompatibilityListImportApi,
proTableRef: proTableRef proTableRef: proTableRef
}; };
importRef.value.acceptParams(params); importRef.value.acceptParams(params);

View File

@@ -1,28 +1,15 @@
//兼容性信息(否) //兼容性信息(否)
export const FORM_DATA_LV1: any[] = [ export const FORM_DATA_LV1: any[] = [
{ {
prop: "tag", prop: "compat_id",
placeholder: "请输入", placeholder: "请输入",
type: "selectMultiple", type: "selectMultiple",
label: "关联标签: ", label: "关联标签: ",
options: [ options: []
{
value: 1,
label: "测试1"
},
{
value: 2,
label: "测试2"
},
{
value: 3,
label: "测试3"
}
]
}, },
{ {
prop: "is_show", prop: "show_series_name",
placeholder: "请输入", placeholder: "请输入",
type: "radio", type: "radio",
label: "是否显示系列名: ", label: "是否显示系列名: ",
@@ -47,14 +34,14 @@ export const FORM_DATA_LV1: any[] = [
//兼容性信息(是) //兼容性信息(是)
export const FORM_DATA_LV2: any[] = [ export const FORM_DATA_LV2: any[] = [
{ {
prop: "tag", prop: "compat_id",
placeholder: "请输入", placeholder: "请输入",
type: "selectMultiple", type: "selectMultiple",
label: "关联标签: " label: "关联标签: "
}, },
{ {
prop: "is_show", prop: "show_series_name",
placeholder: "请输入", placeholder: "请输入",
type: "radio", type: "radio",
label: "是否显示系列名: ", label: "是否显示系列名: ",
@@ -72,7 +59,7 @@ export const FORM_DATA_LV2: any[] = [
// //
{ {
prop: "className", prop: "series_name",
placeholder: "请输入", placeholder: "请输入",
type: "input", type: "input",
label: "产品系列名: " label: "产品系列名: "

View File

@@ -1,7 +1,7 @@
export const RULES_LV1 = { export const RULES_LV1 = {
tag: [{ required: true, message: "所属系列名称不能为空 ! ", trigger: "change" }] compat_id: [{ required: true, message: "所属系列名称不能为空 ! ", trigger: "change" }]
}; };
export const RULES_LV2 = { export const RULES_LV2 = {
tag: [{ required: true, message: "所属系列名称不能为空 ! ", trigger: "change" }], compat_id: [{ required: true, message: "所属系列名称不能为空 ! ", trigger: "change" }],
className: [{ required: true, message: "产品系列名不能为空 ! ", trigger: "blur" }] series_name: [{ required: true, message: "产品系列名不能为空 ! ", trigger: "blur" }]
}; };

View File

@@ -54,13 +54,14 @@ import { ref, reactive } from "vue";
import Editor from "@/components/Editor/index.vue"; import Editor from "@/components/Editor/index.vue";
import rulesForm from "@/components/rulesForm/index.vue"; import rulesForm from "@/components/rulesForm/index.vue";
import { FORM_DATA_LV2, FORM_DATA_LV1, RULES_LV1, RULES_LV2 } from "./constant/index"; import { FORM_DATA_LV2, FORM_DATA_LV1, RULES_LV1, RULES_LV2 } from "./constant/index";
console.log(FORM_DATA_LV2, RULES_LV2);
import { import {
getProductDetailsApi, getProductDetailsApi,
getProductListApi, getProductListApi,
getProductAttrsListApi, getProductAttrsListApi,
getProductCategoryListApi getProductCategoryListApi
} from "@/api/modules/productList"; } from "@/api/modules/productList";
import { getProductCompatibilityListApi } from "@/api/modules/productCompatibility";
// import { getProductCategoryListApi } from "@/api/modules/productClass"; // import { getProductCategoryListApi } from "@/api/modules/productClass";
import { RELATED_INFO_COLUMNS } from "./constant/related"; import { RELATED_INFO_COLUMNS } from "./constant/related";
import { cloneDeep, debounce } from "lodash-es"; import { cloneDeep, debounce } from "lodash-es";
@@ -157,6 +158,26 @@ const getProductCategoryList = async () => {
}; };
getProductCategoryList(); getProductCategoryList();
//兼容性信息(后端大佬说直接掉列表接口)
const getProductCompatibilityList = async () => {
const result = await getProductCompatibilityListApi({ is_show: 1 });
if (result?.code === 0) {
let arr: any[] = [];
if (result?.data?.data?.length) {
result?.data?.data?.forEach((item: any) => {
let obj = {
value: item.id,
label: item.label_name
};
arr.push(obj);
});
dataStore.formData[0].options = arr;
}
}
};
getProductCompatibilityList();
//相关信息及行远程搜索下拉框点击 //相关信息及行远程搜索下拉框点击
const handleRemoteClick = (params: any) => { const handleRemoteClick = (params: any) => {
const { item, index } = params; const { item, index } = params;
@@ -188,14 +209,16 @@ const handleRemote = debounce((params: any) => {
getProductList(params.query); getProductList(params.query);
}, 800); }, 800);
const handleTabClick = () => { const handleTabClick = () => {
formRef.value.ruleFormRef.clearValidate("tag"); formRef.value.ruleFormRef.clearValidate("compat_id");
}; };
const handleRadioGroupEmits = (params: any) => { const handleRadioGroupEmits = (params: any) => {
if (params === 1) { if (params === 1) {
dataStore.formData = cloneDeep(FORM_DATA_LV2); dataStore.formData = cloneDeep(FORM_DATA_LV2);
dataStore.rules = cloneDeep(RULES_LV2);
} else { } else {
dataStore.ruleForm.className = ""; dataStore.ruleForm.className = "";
dataStore.formData = cloneDeep(FORM_DATA_LV1); dataStore.formData = cloneDeep(FORM_DATA_LV1);
dataStore.rules = cloneDeep(RULES_LV1);
} }
}; };
</script> </script>

View File

@@ -62,6 +62,7 @@ import {
getProductListExportApi, getProductListExportApi,
getProductCategoryListApi getProductCategoryListApi
} from "@/api/modules/productList"; } from "@/api/modules/productList";
// import { getProductCategoryListApi } from "@/api/modules/productClass"; // import { getProductCategoryListApi } from "@/api/modules/productClass";
import { addLabelValue } from "@/utils/addLabelValue"; import { addLabelValue } from "@/utils/addLabelValue";

View File

@@ -1,4 +1,5 @@
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
import { FORM_DATA_LV2, FORM_DATA_LV1, RULES_LV1, RULES_LV2 } from "../../constant/index";
// import { convertSpanToDiv } from "@/utils/convertSpanToDiv"; // import { convertSpanToDiv } from "@/utils/convertSpanToDiv";
const hasIdRecursive = (data: any, targetId: any) => { const hasIdRecursive = (data: any, targetId: any) => {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
@@ -88,4 +89,20 @@ export const initDetailParams = (dataStore: any, data: any, editorRef: any) => {
if (data.related) { if (data.related) {
dataStore.relatedTableData = cloneDeep(data.related); dataStore.relatedTableData = cloneDeep(data.related);
} }
if (data.compat.length) {
dataStore.ruleForm = data.compat[0];
let ids: any[] = [];
dataStore.ruleForm?.compat.forEach((item: any) => {
ids.push(item.compat_id);
});
dataStore.ruleForm.compat_id = ids;
if (dataStore.ruleForm.show_series_name === 1) {
dataStore.formData = cloneDeep(FORM_DATA_LV2);
dataStore.rules = cloneDeep(RULES_LV2);
} else {
dataStore.ruleForm.className = "";
dataStore.formData = cloneDeep(FORM_DATA_LV1);
dataStore.rules = cloneDeep(RULES_LV1);
}
}
}; };

View File

@@ -7,7 +7,7 @@ const WARN: any = {
category_id: "产品分类不能为空 !", category_id: "产品分类不能为空 !",
sort: "产品排序不能为空 !", sort: "产品排序不能为空 !",
tag: "关联标签不能为空 !", tag: "关联标签不能为空 !",
className: "产品系列名不能为空 !" seriesName: "产品系列名不能为空 !"
}; };
//警告 //警告
const warnFunction = (data: any, data1: any) => { const warnFunction = (data: any, data1: any) => {
@@ -27,12 +27,12 @@ const warnFunction = (data: any, data1: any) => {
useMsg("warning", WARN["sort"]); useMsg("warning", WARN["sort"]);
return false; return false;
} }
if (!data1.tag) { // if (!data1.tag) {
useMsg("warning", WARN["tag"]); // useMsg("warning", WARN["tag"]);
return false; // return false;
} // }
if (data1.is_show && !data1.className) { if (data1.is_show && !data1.series_name) {
useMsg("warning", WARN["className"]); useMsg("warning", WARN["seriesName"]);
return false; return false;
} }
return true; return true;
@@ -71,8 +71,11 @@ export const handleSubmit = async (infoRef: any, imgInfoRef: any, formRef: any,
}); });
console.log(skusClone, "=skusClone="); console.log(skusClone, "=skusClone=");
let skusCloneStr = JSON.stringify(skusClone); let skusCloneStr = JSON.stringify(skusClone);
// cloneDeep
let ruleForm: any = cloneDeep(dataStore.ruleForm);
ruleForm.compat_id = ruleForm.compat_id.join(",");
console.log(typeof skusCloneStr); console.log(typeof skusCloneStr);
console.log(dataStore.ruleForm, "=ruleForm=");
const params = { const params = {
...infoRef.ruleForm, ...infoRef.ruleForm,
cover_image, cover_image,
@@ -80,7 +83,8 @@ export const handleSubmit = async (infoRef: any, imgInfoRef: any, formRef: any,
video_img, video_img,
skus: skusCloneStr, skus: skusCloneStr,
detail: dataStore.detail, detail: dataStore.detail,
related: JSON.stringify(relatedData) || [] related: JSON.stringify(relatedData) || [],
compat: JSON.stringify(ruleForm) || {}
}; };
console.log(params, "===========params============="); console.log(params, "===========params=============");