This commit is contained in:
make
2025-04-13 18:00:59 +08:00
parent a1c507eaf1
commit 3c1df922e1
2 changed files with 43 additions and 4 deletions

View File

@@ -159,7 +159,7 @@ const columns = reactive<ColumnProps<NovelList.ResList>[]>([
width: 120, width: 120,
render(scope) { render(scope) {
return <img src={'http://tp2.novel2.com'+scope.row.n_cover_path } alt="封面" style="width: 100%; height: auto;" />; return <img src={import.meta.env.VITE_API_URL+scope.row.n_cover_path } alt="封面" style="width: 100%; height: auto;" />;
} }
}, },

View File

@@ -118,10 +118,18 @@
</el-form-item> </el-form-item>
</div> </div>
<div class="c-one-columns">
<el-form-item style="width: 45%" label="URL模板" prop="url_type">
<el-select v-model="drawerProps.row.url_type" placeholder="请选择URL模板" clearable @change="handleSelectChangeUrl">
<el-option v-for="item in urlSubjectFomartGroup" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
</div>
<div class="c-two-columns"> <div class="c-two-columns">
<div v-for="(i, v) in drawerProps.row.t_cfg" :key="v" style="width: 50%"> <div v-for="(i, v) in drawerProps.row.t_cfg" :key="v" style="width: 50%">
<el-form-item :label="i.description" prop="t_cfg" label-width="260px!important" > <el-form-item :label="i.description" prop="t_cfg" label-width="260px!important" >
<el-select v-model="i.sfg_id" placeholder="请选择替换模板分组" > <el-select v-model="i.sfg_id" placeholder="请选择URL替换模板分组" >
<el-option v-for="item in subjectFomartGroup" :key="item.sfg_id" :label="item.sfg_name" :value="item.sfg_id" /> <el-option v-for="item in subjectFomartGroup" :key="item.sfg_id" :label="item.sfg_name" :value="item.sfg_id" />
</el-select> </el-select>
</el-form-item> </el-form-item>
@@ -150,17 +158,32 @@ type Options = {
value: string | number; value: string | number;
}; };
function countNovelInfoUrl(array) {
return array.filter(item => item.sfg_name.includes('排行榜URL')).length;
}
const templateList = ref(); const templateList = ref();
// 获取分组ID列表 // 获取分组ID列表
getAllList().then(res => { getAllList().then(res => {
templateList.value = res.data.items; templateList.value = res.data.items;
}); });
var urlSubjectFomartGroup = ref();
const subjectFomartGroup = ref(); const subjectFomartGroup = ref();
// 获取替换分组模板列表 // 获取替换分组模板列表
getSubjectFomartGroup().then(res => { getSubjectFomartGroup().then(res => {
subjectFomartGroup.value = res.data.items; subjectFomartGroup.value = res.data.items;
const intUrlTotal = countNovelInfoUrl(res.data.items);
urlSubjectFomartGroup = Array.from({ length: intUrlTotal }, (_, index) => ({
name: `URL 模板 ${index+=1}`,
id: index // id 循环生成 1, 2, 3, 4, 5, 6
}));
}); });
const actions = ref<any[]>([]); const actions = ref<any[]>([]);
// 添加参数配置 // 添加参数配置
const addParams = () => { const addParams = () => {
@@ -482,6 +505,7 @@ const drawerProps = ref<DrawerProps>({
// 接收父组件传过来的参数 // 接收父组件传过来的参数
const acceptParams = (params: DrawerProps) => { const acceptParams = (params: DrawerProps) => {
drawerProps.value = params; drawerProps.value = params;
drawerProps.value.row['url_type'] = 1;
rules.value = generateRules(formColumns.value); rules.value = generateRules(formColumns.value);
drawerVisible.value = true; drawerVisible.value = true;
actions.value = []; actions.value = [];
@@ -495,11 +519,26 @@ const acceptParams = (params: DrawerProps) => {
// } // }
}; };
const handleSelectChange = (value) => { const handleSelectChange = (value) => {
console.log("选中的模板 ID:", value);
const matchedTemplate = templateList.value.find(item => item.t_id === value); const matchedTemplate = templateList.value.find(item => item.t_id === value);
// console.log(matchedTemplate.t_cfg_template)
drawerProps.value.row.t_cfg = matchedTemplate.t_cfg_template drawerProps.value.row.t_cfg = matchedTemplate.t_cfg_template
} }
const handleSelectChangeUrl = (value) => {
var strKey = '模板';
var temp = drawerProps.value.row.t_cfg;
for (const key in temp) {
if (key.includes("_URL") && key != 'PC_URL_PATH') {
var newKey = temp[key].description.replace(/模板(\d+)/g, `模板${value}`);
subjectFomartGroup.value.forEach((item) => {
if (item.sfg_description === newKey) {
temp[key].sfg_id = item.sfg_id;
temp[key].description = item.sfg_name;
}
});
}
}
drawerProps.value.row.t_cfg = temp
}
// 提交数据(新增/编辑) // 提交数据(新增/编辑)