Commit 5438d4c2 by haojie

1

parent 0747fc0d
......@@ -35,6 +35,7 @@ const props = withDefaults(
);
const emit = defineEmits(['update:modelValue']);
const SelectValue = ref(props.modelValue);
watch(
() => SelectValue.value,
(v) => {
......
......@@ -7,6 +7,7 @@
:cancelBtn="null"
>
<template #confirmBtn>
<ResetButton @click="ResetSearch">重置</ResetButton>
<ResetButton @click="ConfirmEnvent">确认</ResetButton>
</template>
<template #header>
......@@ -14,13 +15,15 @@
</template>
<template #body>
<div class="model-dialog-box">
<div class="chose-category-box">
<CustomSelect
className="custom-chose-category"
:options="SelectOptions"
v-model="SelectValue"
></CustomSelect>
</div>
<template v-if="SelectOptions.length">
<div class="chose-category-box">
<CustomSelect
className="custom-chose-category"
:options="SelectOptions"
v-model="SelectValue"
></CustomSelect>
</div>
</template>
<div ref="ScrollELement" class="search-area-box narrow-scrollbar">
<OnWaitVue
v-if="SearchStatus == 'wait'"
......@@ -49,8 +52,8 @@
</div>
<ScrollLoad
:el="ScrollELement"
:maxLen="maxLen"
:curLen="SearchList.list.length"
:maxLen="pageSize - 1"
:curLen="curLen"
:hasMorePages="hasMorePages"
:loadingMore="loadingMore"
@submit="onSearchSubmit"
......@@ -100,9 +103,10 @@ const props = withDefaults(
);
const emit = defineEmits(['update:value', 'update:modelValue']);
const ScrollELement = ref<HTMLElement>();
const maxLen = ref(19);
const hasMorePages = ref(false);
const loadingMore = ref(false);
// 本次请求到的数组长度
const curLen = ref(0);
const pageNum = ref(1);
const pageSize = ref(20);
const visible = ref(props.modelValue);
......@@ -125,6 +129,7 @@ watch(
() => SelectValue.value,
(v) => {
if (v) {
onReset();
// 搜索
Search();
}
......@@ -142,6 +147,20 @@ const getSelect = async (url: string) => {
console.log(e);
}
};
// 重置
const onReset = () => {
pageNum.value = 1;
SearchList.list = [];
SearchList.url = '';
SearchList.index = null;
};
const ResetSearch = () => {
onReset();
SelectValue.value = '';
// 请求接口
Search();
};
onMounted(() => {
const { query } = props;
if (query && query.length) {
......@@ -176,7 +195,6 @@ const onSearchSubmit = () => {
Search();
};
const Search = async () => {
console.log('开始搜索');
try {
const { tool_url } = props;
if (!tool_url) {
......@@ -190,12 +208,12 @@ const Search = async () => {
page: pageNum.value,
limit: pageSize.value,
};
if (SearchName.value) {
if (SearchName.value && SelectValue.value) {
params[SearchName.value] = SelectValue.value;
}
const res: any = await useRequest('post', tool_url, params);
console.log(res);
if (res.code == 0) {
curLen.value = res.data.data.length;
if (pageNum.value == 1) {
SearchList.list = res.data.data;
} else {
......@@ -232,7 +250,7 @@ watch(
() => visible.value,
(v) => {
if (v) {
pageNum.value = 1;
onReset();
Search();
}
emit('update:modelValue', v);
......
......@@ -123,3 +123,20 @@ export const FilterFormType = (list: any[]) => {
obj.list = list;
return obj;
};
// 重置form表单里的value
export const ResetFormValue = (list: any[]) => {
list.forEach((item: any) => {
item.lists.forEach((it: any) => {
if (it.name !== 'sub_type') {
if (typeof it.value == 'string') {
it.value = '';
} else if (
Object.prototype.toString.call(it.value) === '[object Array]'
) {
it.value = [];
}
}
});
});
};
......@@ -57,7 +57,7 @@ import { show_message } from '@/utils/tdesign_tool';
import { FormExample, ConversationKey } from '@/utils/api/Task';
import CustomLoading from '@/components/custom/loading2.vue';
import { Validationrules, ChangePageHeight } from '@/utils/tool';
import { FilterFormType, FilterForm } from '@/constants/form';
import { FilterFormType, FilterForm, ResetFormValue } from '@/constants/form';
import ContinuesChatSvg from '@/assets/svg/gpt/continues_chat.svg';
const route = useRoute();
// 任务锁
......@@ -135,13 +135,7 @@ const getAdminComponent = async () => {
// 重置
const onReset = () => {
// 遍历整个列表,清空value
AdminData.list.forEach((item: any) => {
item.lists.forEach((it: any) => {
if (it.value) {
it.value = '';
}
});
});
ResetFormValue(AdminData.list);
};
// 提交
const onSubmit = async (
......
......@@ -45,7 +45,7 @@ import {
useSubmitConversationImage,
useImageCallback,
} from '@/utils/api/scenes';
import { FilterFormType } from '@/constants/form';
import { FilterFormType, ResetFormValue } from '@/constants/form';
import { FormExample2, CustomNum } from '@/utils/api/Task';
import { Validationrules } from '@/utils/tool';
import { useRoute } from 'vue-router';
......@@ -177,13 +177,7 @@ const closeInterval = () => {
// 重置
const onReset = () => {
// 遍历整个列表,清空value
AdminData.list.forEach((item: any) => {
item.lists.forEach((it: any) => {
if (it.value) {
it.value = '';
}
});
});
ResetFormValue(AdminData.list);
// 恢复默认状态
AdminData.status = '';
AdminData.callback_list = [];
......
......@@ -71,7 +71,7 @@ import { ChangePageHeight } from '@/utils/tool';
import { useRoute } from 'vue-router';
import { show_message } from '@/utils/tdesign_tool';
import CompositeImage from './components/CompositeImage.vue';
import { FilterForm, FilterFormType } from '@/constants/form';
import { FilterForm, FilterFormType, ResetFormValue } from '@/constants/form';
const loading = ref(false);
// 提交图片时的加载状态
const submit_loading = ref(false);
......@@ -242,13 +242,7 @@ const closeInterval = () => {
// 重置
const onReset = () => {
// 遍历整个列表,清空value
AdminData.list.forEach((item: any) => {
item.lists.forEach((it: any) => {
if (it.value) {
it.value = '';
}
});
});
ResetFormValue(AdminData.list);
// 恢复默认状态
AdminData.status = '';
AdminData.callback_list = [];
......
......@@ -60,7 +60,7 @@ import {
} from '@/utils/api/scenes';
import { FormExample4, ModelStatus } from '@/utils/api/Task';
import { ChangePageHeight } from '@/utils/tool';
import { FilterForm, FilterFormType } from '@/constants/form';
import { FilterForm, FilterFormType, ResetFormValue } from '@/constants/form';
import { useRoute } from 'vue-router';
import { show_message } from '@/utils/tdesign_tool';
const loading = ref(false);
......@@ -175,14 +175,8 @@ const closeInterval = () => {
};
// 重置
const onReset = () => {
// 遍历整个列表,清空value
AdminData.list.forEach((item: any) => {
item.lists.forEach((it: any) => {
if (it.value) {
it.value = '';
}
});
});
// 清空value
ResetFormValue(AdminData.list);
// 恢复默认状态
AdminData.status = '';
AdminData.callback_list = [];
......
......@@ -37,7 +37,7 @@ import {
useSubmitImage,
} from '@/utils/api/scenes';
import { FilterForm } from '@/constants/form';
import { FilterFormType } from '@/constants/form';
import { FilterFormType, ResetFormValue } from '@/constants/form';
import { FormExample2 } from '@/utils/api/Task';
import { useRoute } from 'vue-router';
import { show_message } from '@/utils/tdesign_tool';
......@@ -123,13 +123,7 @@ watch(
// 重置
const onReset = () => {
// 遍历整个列表,清空value
AdminData.list.forEach((item: any) => {
item.lists.forEach((it: any) => {
if (it.value) {
it.value = '';
}
});
});
ResetFormValue(AdminData.list);
// 恢复默认状态
AdminData.status = '';
AdminData.callback_list = [];
......@@ -149,6 +143,8 @@ const onSubmit = async () => {
});
if (res.code == 0) {
show_message('上传成功', 'success');
// 清空数据
onReset();
}
loading_2.value = false;
} catch (e) {
......
......@@ -57,55 +57,23 @@ export const FormExample = [
{
type: 'text',
name: 'category_1',
label: '产品类目',
label: '小说类型',
value: null,
span: 24,
placeholder: '产品类目',
rules: [
{
type: 'required',
message: '必填',
},
],
},
{
type: 'text',
name: 'category_2',
value: null,
label: '产品关键词',
span: 24,
placeholder: '产品关键词',
rules: [
{
type: 'required',
message: '必填',
},
],
placeholder: '小说类型',
rules: [{ type: 'required', message: '必填' }],
},
// 下拉选择
{
type: 'select',
placeholder: '选择产品名称',
label: '产品名称',
placeholder: '选择小说读者性别',
label: '读者性别',
name: 'category_3',
options: [
{
label: '充电器',
value: '充电器',
},
{
label: '衣服',
value: '衣服',
},
],
// 可设置默认值
value: '衣服',
rules: [
{
type: 'required',
message: '必填',
},
{ label: '男生', value: '男生' },
{ label: '女生', value: '女生' },
],
value: '男生',
rules: [{ type: 'required', message: '必填' }],
},
],
},
......@@ -113,7 +81,6 @@ export const FormExample = [
name: '详细描述',
lists: [
{
// 长文本输入框
type: 'textarea',
name: 'category_4',
label: '产品描述',
......@@ -123,12 +90,20 @@ export const FormExample = [
minRows: '5',
placeholder: '详细描述产品细节,生成的文案更加完美。',
maxlength: 1000,
rules: [
{
type: 'required',
message: '必填',
},
],
rules: [{ type: 'required', message: '必填' }],
},
{
type: 'text',
name: 'sub_type',
label: '类型',
value: 'chatGpt',
span: 24,
is_hidden: true,
maxRows: '5',
minRows: '5',
placeholder: '类型不能为空',
maxlength: 1000,
rules: [{ type: 'required', message: '必填' }],
},
{
type: 'gpt_continues_chat',
......
......@@ -13,7 +13,7 @@ export default defineConfig(({ mode }) => {
const newDate = `${date.getFullYear()}-${
date.getMonth() + 1
}-${date.getDate()}--${date.getHours()}.${date.getMinutes()}`;
const api = 0 ? 'http://156.247.11.21:85' : 'http://ai-gpt.test';
const api = 1 ? 'http://156.247.11.21:85' : 'http://ai-gpt.test';
return {
base: '/',
resolve: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment