fix: 🧩 修复bug
This commit is contained in:
@@ -57,7 +57,6 @@
|
||||
@check="handleCheck"
|
||||
placeholder="请选择"
|
||||
style="padding: 0"
|
||||
@visible-change="visibleChange"
|
||||
/>
|
||||
</template>
|
||||
</el-input>
|
||||
@@ -81,7 +80,7 @@ import { useMsg } from "@/hooks/useMsg";
|
||||
import { useExport } from "@/hooks/useExport";
|
||||
import { integerRexg } from "@/utils/regexp/index";
|
||||
// 图片地址
|
||||
const h = import.meta.env.VITE_APP_API_BASE_UPLOAD_URL;
|
||||
import { h } from "@/utils/url";
|
||||
// 列表接口
|
||||
import {
|
||||
getBannerListApi,
|
||||
@@ -90,9 +89,10 @@ import {
|
||||
getBannerListSortApi,
|
||||
getBannerUpApi,
|
||||
getBannerListSaveApi,
|
||||
getBannerListExportApi
|
||||
getBannerListExportApi,
|
||||
getBannerClassListApi
|
||||
} from "@/api/modules/banner";
|
||||
import { getBannerClassListApi } from "@/api/modules/bannerClass";
|
||||
// import { getBannerClassListApi } from "@/api/modules/bannerClass";
|
||||
import { getSystemUrlsApi } from "@/api/modules/home";
|
||||
// 深拷贝方法
|
||||
import { cloneDeep } from "lodash-es";
|
||||
@@ -113,7 +113,7 @@ const dataStore = reactive<any>({
|
||||
formData: FORM_DATA, // 搜索配置项 dataStore.formData
|
||||
visible: false,
|
||||
data: [],
|
||||
is: false
|
||||
isFirstRequest: true
|
||||
});
|
||||
|
||||
const selectedNodes = ref(null);
|
||||
@@ -126,11 +126,7 @@ const treeProps = {
|
||||
label: "label",
|
||||
value: "value"
|
||||
};
|
||||
const visibleChange = (is: any) => {
|
||||
dataStore.is = is;
|
||||
if (dataStore.is) {
|
||||
}
|
||||
};
|
||||
|
||||
const buildTree = (data: any, outerLinkTo: any = "") => {
|
||||
return data.map((item: any) => {
|
||||
const { name, id, url, data: childData = [], children: nestedChildren = [] } = item;
|
||||
@@ -149,15 +145,27 @@ const buildTree = (data: any, outerLinkTo: any = "") => {
|
||||
};
|
||||
});
|
||||
};
|
||||
let isFirstRequest = true;
|
||||
// let isFirstRequest = true;
|
||||
const handleRadioGroupEmits = (value: any) => {
|
||||
getBannerClassList();
|
||||
if (value === "image") {
|
||||
dataStore.isFirstRequest = true;
|
||||
dataStore.editFormData = EDIT_FORM_DATA;
|
||||
dataStore.rules = RULES;
|
||||
} else {
|
||||
dataStore.editFormData = EDIT_FORM_DATA1;
|
||||
dataStore.rules = RULES1;
|
||||
}
|
||||
};
|
||||
|
||||
const getSystemUrls = async (node: any, resolve: any) => {
|
||||
//第一次请求
|
||||
if (isFirstRequest) {
|
||||
if (dataStore.isFirstRequest) {
|
||||
const result = await getSystemUrlsApi();
|
||||
if (result?.code === 0) {
|
||||
const children = buildTree(result?.data);
|
||||
resolve(children);
|
||||
isFirstRequest = false;
|
||||
dataStore.isFirstRequest = false;
|
||||
}
|
||||
} else {
|
||||
//第二次请求
|
||||
@@ -212,23 +220,32 @@ const handleCheck = (checkedNodes: any, values: any) => {
|
||||
|
||||
// 更新
|
||||
const getBannerUp = async () => {
|
||||
if (dataStore.editRuleForm.type === "video") {
|
||||
dataStore.editRuleForm.link_to = "";
|
||||
dataStore.editRuleForm.link = "";
|
||||
}
|
||||
if (dataStore.editRuleForm.type === "image") {
|
||||
dataStore.editRuleForm.video = "";
|
||||
}
|
||||
const result = await getBannerUpApi(dataStore.editRuleForm);
|
||||
if (result?.code === 0) {
|
||||
dataStore.visible = false;
|
||||
dataStore.editRuleForm = cloneDeep(EDIT_RULE_FORM);
|
||||
formRef!.value!.ruleFormRef.resetFields();
|
||||
proTableRef?.value?.getTableList();
|
||||
dataStore.isFirstRequest = true;
|
||||
}
|
||||
};
|
||||
|
||||
// 分类
|
||||
const getBannerClassList = async () => {
|
||||
const result = await getBannerClassListApi({ page: 1, size: 500 });
|
||||
const result = await getBannerClassListApi();
|
||||
if (result?.code === 0) {
|
||||
let arr: any = [];
|
||||
result?.data?.data?.forEach((item: any) => {
|
||||
result?.data?.forEach((item: any) => {
|
||||
arr.push({ value: item.id, label: item.name });
|
||||
});
|
||||
console.log(arr, "========arr===============");
|
||||
dataStore.formData[1].options = arr;
|
||||
dataStore.editFormData[4].options = arr;
|
||||
}
|
||||
@@ -241,13 +258,17 @@ const getBannerListSave = async () => {
|
||||
dataStore.visible = false;
|
||||
dataStore.editRuleForm = cloneDeep(EDIT_RULE_FORM);
|
||||
useMsg("success", result?.msg);
|
||||
dataStore.isFirstRequest = true;
|
||||
formRef!.value!.ruleFormRef.resetFields();
|
||||
proTableRef?.value?.getTableList();
|
||||
}
|
||||
};
|
||||
// 导出接口
|
||||
const getArticleListExport = async () => {
|
||||
const result = await getBannerListExportApi(dataStore.ruleForm);
|
||||
const result = await getBannerListExportApi({
|
||||
...proTableRef?.value?.searchParam,
|
||||
...proTableRef?.value?.pageable
|
||||
});
|
||||
await useExport(result);
|
||||
};
|
||||
// 导出
|
||||
@@ -290,17 +311,9 @@ const handleBeforeClone = () => {
|
||||
dataStore.editRuleForm = cloneDeep(EDIT_RULE_FORM);
|
||||
resetFields();
|
||||
dataStore.visible = false;
|
||||
dataStore.isFirstRequest = true;
|
||||
};
|
||||
|
||||
const handleRadioGroupEmits = (value: any) => {
|
||||
if (value === "image") {
|
||||
dataStore.editFormData = EDIT_FORM_DATA;
|
||||
dataStore.rules = RULES;
|
||||
} else {
|
||||
dataStore.editFormData = EDIT_FORM_DATA1;
|
||||
dataStore.rules = RULES1;
|
||||
}
|
||||
};
|
||||
// 删除
|
||||
const getBannerDel = async (id: any) => {
|
||||
messageBox("你确定要删除?", async () => {
|
||||
|
||||
Reference in New Issue
Block a user