Commit 5438d4c2 by haojie

1

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