feat: 🚀 配件类型接口

This commit is contained in:
2026-07-08 17:45:48 +08:00
parent d5512ad8d3
commit fc627b7666
13 changed files with 122 additions and 103 deletions

View File

@@ -0,0 +1,28 @@
import http from "@/api";
const URL = `product/compat/parts/`;
// 配件类型列表
export const getProductAccessoryTypeListApi = (params: any) => {
return http.get<any>(`${URL}/index`, params);
};
// 配件类型详情
export const getProductAccessoryTypeDetailsApi = (params: any) => {
return http.get<any>(`${URL}/read/${params}`);
};
// 配件类型删除
export const getProductAccessoryTypeDelApi = (params: any) => {
return http.delete<any>(`${URL}/delete/${params}`);
};
// 配件类型更新
export const getProductAccessoryTypeUpApi = (params: any) => {
const { id } = params;
return http.put<any>(`${URL}/update/${id}`, params);
};
//配件类型新增
export const getProductAccessoryTypeAddApi = (params: any) => {
return http.post<any>(`${URL}/save`, params, {
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
});
};

View File

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

4
src/components.d.ts vendored
View File

@@ -12,8 +12,6 @@ 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"];
@@ -45,8 +43,6 @@ 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"];
ElTree: typeof import("element-plus/es")["ElTree"];
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

@@ -32,7 +32,7 @@ export const EDIT_FORM_DATA: FormItem[] = [
label: "排序: " label: "排序: "
}, },
{ {
prop: "recommend", prop: "disabled",
placeholder: "请输入", placeholder: "请输入",
type: "radio", type: "radio",
label: "是否启用: ", label: "是否启用: ",

View File

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

View File

@@ -15,7 +15,7 @@ export const COLUMNS = [
{ {
align: "left", align: "left",
label: "使用状态", label: "使用状态",
prop: "category_name" prop: "disabled"
}, },
{ {
@@ -26,7 +26,7 @@ export const COLUMNS = [
{ {
align: "left", align: "left",
label: "更新时间", label: "更新时间",
prop: "created_at" prop: "updated_at"
}, },
// { // {
// align: "center", // align: "center",

View File

@@ -3,13 +3,12 @@
<div class="table-box"> <div class="table-box">
<div style="padding-bottom: 16px"> <div style="padding-bottom: 16px">
<el-button type="primary" @click="handleAdd"> 添加 </el-button> <el-button type="primary" @click="handleAdd"> 添加 </el-button>
<el-button type="primary" @click="handleExport"> 导出 </el-button>
</div> </div>
<ProTable <ProTable
ref="proTableRef" ref="proTableRef"
:formData="dataStore.formData" :formData="dataStore.formData"
:columns="dataStore.columns" :columns="dataStore.columns"
:request-api="getVideoListApi" :request-api="getProductAccessoryTypeListApi"
:init-param="dataStore.initParam" :init-param="dataStore.initParam"
> >
<template #image="scope"> <template #image="scope">
@@ -43,7 +42,6 @@
:formData="dataStore.editFormData" :formData="dataStore.editFormData"
:rules="dataStore.rules" :rules="dataStore.rules"
ref="formRef" ref="formRef"
@handleSelectChangeEmits="handleSelectChangeEmits"
> >
</rulesForm> </rulesForm>
</div> </div>
@@ -65,21 +63,17 @@ import { useMsg } from "@/hooks/useMsg";
//列表接口 //列表接口
import { import {
getVideoListApi, getProductAccessoryTypeUpApi,
getVideoListExportApi, getProductAccessoryTypeAddApi,
getVideoListDelApi, getProductAccessoryTypeDelApi,
getVideoReadApi, getProductAccessoryTypeDetailsApi,
getVideoUpdateApi, getProductAccessoryTypeListApi
getVideoSaveApi, } from "@/api/modules/productAccessoryType";
getVideoClassListApi
} from "@/api/modules/videoList";
import { recursiveCompare } from "@/utils/recursiveCompare";
// import { getVideoClassListApi } from "@/api/modules/videoClass";
//深拷贝方法 //深拷贝方法
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
//表格和搜索條件 //表格和搜索條件
import { RULE_FORM, FORM_DATA, COLUMNS, EDIT_FORM_DATA, EDIT_RULE_FORM, RULES } from "./constant/index"; import { RULE_FORM, FORM_DATA, COLUMNS, EDIT_FORM_DATA, EDIT_RULE_FORM, RULES } from "./constant/index";
import { useExport } from "@/hooks/useExport";
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数) // 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
const proTableRef = ref<any>(null); const proTableRef = ref<any>(null);
const formRef: any = ref(null); const formRef: any = ref(null);
@@ -87,7 +81,7 @@ const formRef: any = ref(null);
import { h } from "@/utils/url"; 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 +98,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 === "添加配件类型" ? getProductAccessoryTypeSave() : getProductAccessoryTypeUpdate();
} else { } else {
console.log("error submit!"); console.log("error submit!");
return false; return false;
@@ -118,54 +112,54 @@ const resetFields = () => {
}; };
//抽屉重置 //抽屉重置
const handleResetClick = () => { const handleResetClick = () => {
if (dataStore.title === "添加视频") { if (dataStore.title === "添加配件类型") {
resetFields(); resetFields();
} else { } else {
getVideoRead(dataStore.selectRow.id); getProductAccessoryTypeRead(dataStore.selectRow.id);
} }
}; };
//视频分类接口 // //视频分类接口
const getVideoClassList = async () => { // const getProductAccessoryTypeClassList = async () => {
const result = await getVideoClassListApi(); // const result = await getProductAccessoryTypeClassListApi();
if (result?.code === 0) { // if (result?.code === 0) {
let arr: any[] = []; // let arr: any[] = [];
if (result?.data?.length) { // if (result?.data?.length) {
result?.data?.forEach((item: any) => { // 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);
}); // });
dataStore.formData[1].options = arr; // dataStore.formData[1].options = arr;
} // }
} // }
}; // };
getVideoClassList(); // getProductAccessoryTypeClassList();
const getVideoClassEditList = async () => { // const getProductAccessoryTypeClassEditList = async () => {
const result = await getVideoClassListApi({ is_show: 1 }); // const result = await getProductAccessoryTypeClassListApi({ is_show: 1 });
if (result?.code === 0) { // if (result?.code === 0) {
let arr: any[] = []; // let arr: any[] = [];
if (result?.data?.length) { // if (result?.data?.length) {
result?.data?.forEach((item: any) => { // 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);
}); // });
dataStore.editFormData[1].options = arr; // dataStore.editFormData[1].options = arr;
} // }
} // }
}; // };
getVideoClassEditList(); // getProductAccessoryTypeClassEditList();
//添加 //添加
const handleAdd = () => { const handleAdd = () => {
dataStore.visible = true; dataStore.visible = true;
dataStore.title = "添加视频"; dataStore.title = "添加配件类型";
}; };
//抽屉关闭前的钩子 //抽屉关闭前的钩子
const handleBeforeClone = () => { const handleBeforeClone = () => {
@@ -174,32 +168,16 @@ const handleBeforeClone = () => {
dataStore.visible = false; dataStore.visible = false;
}; };
//详情 //详情
const getVideoRead = async (id: any) => { const getProductAccessoryTypeRead = async (id: any) => {
const result = await getVideoReadApi(id); const result = await getProductAccessoryTypeDetailsApi(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) => {
console.log(value, "========value=33========");
if (value.prop === "category_id1") {
dataStore.editRuleForm.category_id = value.id;
} }
}; };
//保存 //保存
const getVideoSave = async () => { const getProductAccessoryTypeSave = async () => {
const result = await getVideoSaveApi(dataStore.editRuleForm); const result = await getProductAccessoryTypeAddApi(dataStore.editRuleForm);
if (result?.code === 0) { if (result?.code === 0) {
const { msg } = result; const { msg } = result;
useMsg("success", msg); useMsg("success", msg);
@@ -209,8 +187,8 @@ const getVideoSave = async () => {
} }
}; };
//更新 //更新
const getVideoUpdate = async () => { const getProductAccessoryTypeUpdate = async () => {
const result = await getVideoUpdateApi(dataStore.editRuleForm); const result = await getProductAccessoryTypeUpApi(dataStore.editRuleForm);
if (result?.code === 0) { if (result?.code === 0) {
const { msg } = result; const { msg } = result;
useMsg("success", msg); useMsg("success", msg);
@@ -219,18 +197,11 @@ const getVideoUpdate = async () => {
proTableRef?.value?.getTableList(); proTableRef?.value?.getTableList();
} }
}; };
//导出接口
const getProductListExport = async () => {
const result = await getVideoListExportApi({
...proTableRef?.value?.searchParam,
...proTableRef?.value?.pageable
});
await useExport(result);
};
//删除 //删除
const getVideoListDel = (id: any) => { const getProductAccessoryTypeListDel = (id: any) => {
messageBox("你确定要删除?", async () => { messageBox("你确定要删除?", async () => {
const result = await getVideoListDelApi(id); const result = await getProductAccessoryTypeDelApi(id);
if (result?.code === 0) { if (result?.code === 0) {
const { msg } = result; const { msg } = result;
useMsg("success", msg); useMsg("success", msg);
@@ -244,19 +215,15 @@ const handleBtnClick = (type: any, row: any) => {
//编辑 //编辑
if (type === "编辑") { if (type === "编辑") {
dataStore.visible = true; dataStore.visible = true;
dataStore.title = "编辑视频"; dataStore.title = "编辑配件类型";
getVideoRead(row.id); getProductAccessoryTypeRead(row.id);
return; return;
} }
//删除 //删除
if (type === "删除") { if (type === "删除") {
getVideoListDel(row.id); getProductAccessoryTypeListDel(row.id);
} }
}; };
//导出
const handleExport = () => {
getProductListExport();
};
</script> </script>
<style scoped></style> <style scoped></style>