From 2694a0c9059441ba6a6c172fb94adf14bf7bed52 Mon Sep 17 00:00:00 2001 From: yangchunlong <292345300@qq.com> Date: Thu, 27 Mar 2025 10:34:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=A7=A9=20=E4=BF=AE=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/modules/productAttributeList.ts | 1 - src/api/modules/productLink.ts | 5 ++ src/views/articleManagement/list/edit.vue | 39 ++++++++-- .../productManagement/attributeList/index.vue | 4 + src/views/productManagement/link/index.vue | 76 +++++++------------ 5 files changed, 69 insertions(+), 56 deletions(-) diff --git a/src/api/modules/productAttributeList.ts b/src/api/modules/productAttributeList.ts index 87cbfe9..8497c9a 100644 --- a/src/api/modules/productAttributeList.ts +++ b/src/api/modules/productAttributeList.ts @@ -16,7 +16,6 @@ export const getProductAttrDelApi = (params: any) => { // 产品属性更新 export const getProductAttrUpApi = (params: any) => { const { id } = params; - return http.put(`${PRODUCT_ATTR}/update/${id}`, params); }; //产品属性新增 diff --git a/src/api/modules/productLink.ts b/src/api/modules/productLink.ts index 24bd8fa..99cec3a 100644 --- a/src/api/modules/productLink.ts +++ b/src/api/modules/productLink.ts @@ -23,3 +23,8 @@ export const getProductBuypassUpdateApi = (params: any) => { const { id, param } = params; return http.put(`${PRODUCT_BUYPASS}/update/${id}`, param); }; + +//新增 +export const getProductBuypassListSaveApi = (params: any) => { + return http.post(`${PRODUCT_BUYPASS}/save`, params); +}; diff --git a/src/views/articleManagement/list/edit.vue b/src/views/articleManagement/list/edit.vue index 6f77248..88fca86 100644 --- a/src/views/articleManagement/list/edit.vue +++ b/src/views/articleManagement/list/edit.vue @@ -54,14 +54,7 @@ const dataStore = reactive({ editRuleForm: cloneDeep(EDIT_RULE_FORM), editFormData: cloneDeep(EDIT_FORM_DATA) //抽屉表单配置项 }); -//新增 -const getArticleListAddSave = async () => { - const result = await getArticleListAddSaveApi(dataStore.editRuleForm); - if (result.code === 0) { - const { msg } = result; - useMsg("success", msg); - } -}; + //文章分类 const getArticleClassData = async () => { const result = await getArticleClassDataApi(); @@ -89,8 +82,38 @@ const getArticleListDetails = async () => { console.log(data); } }; + +const convertDateFormat = (dateString: any) => { + const date = new Date(dateString); + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, "0"); + const day = String(date.getDate()).padStart(2, "0"); + const hours = String(date.getHours()).padStart(2, "0"); + const minutes = String(date.getMinutes()).padStart(2, "0"); + const seconds = String(date.getSeconds()).padStart(2, "0"); + + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; +}; +//新增 +const getArticleListAddSave = async () => { + if (dataStore.editRuleForm.release_time) { + dataStore.editRuleForm.release_time = convertDateFormat(dataStore.editRuleForm.release_time); + } else { + dataStore.editRuleForm.release_time = null; + } + const result = await getArticleListAddSaveApi(dataStore.editRuleForm); + if (result.code === 0) { + const { msg } = result; + useMsg("success", msg); + } +}; //更新 const getArticleListUp = async () => { + if (dataStore.editRuleForm.release_time) { + dataStore.editRuleForm.release_time = convertDateFormat(dataStore.editRuleForm.release_time); + } else { + dataStore.editRuleForm.release_time = null; + } const result = await getArticleListUpApi({ id: $route.query.id, ...dataStore.editRuleForm }); if (result?.code === 0) { diff --git a/src/views/productManagement/attributeList/index.vue b/src/views/productManagement/attributeList/index.vue index 4e06278..cae1f39 100644 --- a/src/views/productManagement/attributeList/index.vue +++ b/src/views/productManagement/attributeList/index.vue @@ -105,6 +105,10 @@ const getProductAttrUp = async () => { if (obj.prop_name) { dataStore.editRuleForm.props.push(obj); } + + let dataClone = cloneDeep(dataStore.editRuleForm.props); + let props = JSON.stringify([...dataClone]); + dataStore.editRuleForm.props = props; const result = await getProductAttrUpApi(dataStore.editRuleForm); if (result?.code === 0) { useMsg("success", result?.msg); diff --git a/src/views/productManagement/link/index.vue b/src/views/productManagement/link/index.vue index 95e9966..39f3863 100644 --- a/src/views/productManagement/link/index.vue +++ b/src/views/productManagement/link/index.vue @@ -63,6 +63,7 @@ import { useUserStore } from "@/stores/modules/user"; //列表接口 // getProductBuypassListImportApi import { + getProductBuypassListSaveApi, getProductBuypassListApi, getProductPlatformsListApi, getProductBuypassListExportApi, @@ -92,53 +93,22 @@ const dataStore = reactive({ ruleForm: cloneDeep(RULE_FORM), // 搜索參數 formData: FORM_DATA //搜索配置项 }); - +//添加 +const getProductBuypassListSave = async (params: any) => { + const result = await getProductBuypassListSaveApi(params); + if (result?.code === 0) { + // proTableRef?.value?.getTableList(); + // console.log(result?.data); + } +}; //更新 const getProductBuypassUpdate = async (params: any) => { const result = await getProductBuypassUpdateApi(params); if (result?.code === 0) { - console.log(result?.data); - } else { + // console.log(result?.data); } }; -// const handleChange=()=>{ -// } - -// const up=(it: any, scope: any, itIndex: any)=>{ -// const { link, platform_name, link_id } = it; -// let is = scope.row.rowspan.some((item: any, index: number) => { -// if (index !== itIndex && item.platform_name === platform_name) { -// return true; -// } -// }); -// if (is) { -// useMsg("warning", "同型号平台不能重复 !"); -// return; -// } -// if (!platform_name) { -// useMsg("warning", "平台不能为空 !"); -// return; -// } -// if (!link) { -// useMsg("warning", "链接不能为空 !"); -// return; -// } -// //获取ID -// let platform_id: any = null; -// dataStore.options.forEach((item: any) => { -// if (item.platform === platform_name) { -// platform_id = item.id; -// } -// }); -// getProductBuypassUpdate({ -// id: link_id, -// param: { -// platform_id, -// link -// } -// }); -// } //输入框失焦 const handleInputOrChange = (it: any, scope: any, itIndex: any) => { const { link, platform_name, link_id } = it; @@ -166,13 +136,25 @@ const handleInputOrChange = (it: any, scope: any, itIndex: any) => { platform_id = item.id; } }); - getProductBuypassUpdate({ - id: link_id, - param: { - platform_id, - link - } - }); + //更新 + if (link_id) { + getProductBuypassListSave({ + id: link_id, + param: { + platform_id, + link + } + }); + } else { + //添加 + getProductBuypassUpdate({ + id: link_id, + param: { + platform_id, + link + } + }); + } }; //平台 const getProductPlatformsList = async () => {