|
|
@@ -114,32 +114,33 @@ function customSelectorSelection(value, title) { |
|
|
|
if (title == triggerType) { |
|
|
|
// 清空相关字段值 |
|
|
|
clearRelatedFields(value) |
|
|
|
|
|
|
|
// 根据触发类型配置字段显示/隐藏和必填状态 |
|
|
|
// 触发类型相关字段显示/隐藏 |
|
|
|
if (value === 'THIRD_PARTY_LINK') { |
|
|
|
// 第三方链接:hyperLink必填,routeUrl、text、textType不显示 |
|
|
|
updateFieldVisibility('hyperLink', true, true) |
|
|
|
updateFieldVisibility('routeUrl', false, false) |
|
|
|
// updateFieldVisibility('text', false, false) |
|
|
|
updateFieldVisibility('text', false, false) |
|
|
|
updateFieldVisibility('textType', false, false) |
|
|
|
removeAppidField() |
|
|
|
} else if (value === 'NATIVE_ROUTE') { |
|
|
|
// 本地路由:routeUrl必填,hyperLink、text、textType不显示 |
|
|
|
updateFieldVisibility('hyperLink', false, false) |
|
|
|
updateFieldVisibility('routeUrl', true, true) |
|
|
|
// updateFieldVisibility('text', false, false) |
|
|
|
updateFieldVisibility('text', false, false) |
|
|
|
updateFieldVisibility('textType', false, false) |
|
|
|
removeAppidField() |
|
|
|
} else if (value === 'TEXT') { |
|
|
|
// 文本:text、textType必填,hyperLink、routeUrl不显示 |
|
|
|
updateFieldVisibility('hyperLink', false, false) |
|
|
|
updateFieldVisibility('routeUrl', false, false) |
|
|
|
// updateFieldVisibility('text', true, true) |
|
|
|
updateFieldVisibility('text', true, true) |
|
|
|
updateFieldVisibility('textType', true, true) |
|
|
|
removeAppidField() |
|
|
|
} else if (value === 'THIRD_PARTY_MINI') { |
|
|
|
// 第三方小程序:routeUrl必填,hyperLink、text、textType不显示 |
|
|
|
updateFieldVisibility('hyperLink', false, false) |
|
|
|
updateFieldVisibility('routeUrl', true, true) |
|
|
|
// updateFieldVisibility('routeUrl', true, true) |
|
|
|
// updateFieldVisibility('text', false, false) |
|
|
|
updateFieldVisibility('text', false, false) |
|
|
|
updateFieldVisibility('textType', false, false) |
|
|
|
addAppidField() |
|
|
|
} else { |
|
|
|
removeAppidField() |
|
|
|
} |
|
|
|
} else if (title == type) { |
|
|
|
changeFile(true) |
|
|
@@ -207,9 +208,58 @@ function customSelectorSelection(value, title) { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} else if (title === 'flashType') { |
|
|
|
// 快讯类型变化时处理排序字段 |
|
|
|
handleFlashTypeChange(value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function handleFlashTypeChange(flashTypeValue) { |
|
|
|
// 获取 FLASH_TYPE 的 label-value 对应 |
|
|
|
let flashTypeList = FLASH_TYPE.value || []; |
|
|
|
let textValue = ''; |
|
|
|
let carouselValue = ''; |
|
|
|
flashTypeList.forEach(item => { |
|
|
|
if (item.label === '文案') textValue = item.value; |
|
|
|
if (item.label === '轮播图') carouselValue = item.value; |
|
|
|
}); |
|
|
|
// 删除/添加排序字段 |
|
|
|
let idx = field.value.field?.findIndex(f => f.prop === 'sequence'); |
|
|
|
if (flashTypeValue === textValue) { |
|
|
|
// 文案,移除排序 |
|
|
|
if (idx !== undefined && idx !== -1) field.value.field?.splice(idx, 1); |
|
|
|
} else if (flashTypeValue === carouselValue) { |
|
|
|
// 轮播图,添加排序且必填 |
|
|
|
if (idx === undefined || idx === -1) { |
|
|
|
field.value.field?.push({ |
|
|
|
prop: "sequence", |
|
|
|
label: "排序", |
|
|
|
form: { |
|
|
|
formLabelWidth: formLabelWidth, |
|
|
|
type: 'input', |
|
|
|
required: true |
|
|
|
} |
|
|
|
}); |
|
|
|
} else if (idx !== undefined) { |
|
|
|
field.value.field[idx].form.required = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function addAppidField() { |
|
|
|
if (!field.value.field?.find(f => f.prop === 'appid')) { |
|
|
|
// 插入到触发类型后面 |
|
|
|
let idx = field.value.field?.findIndex(f => f.prop === 'triggerType'); |
|
|
|
if (idx !== undefined && idx !== -1) { |
|
|
|
field.value.field?.splice(idx + 1, 0, JSON.parse(JSON.stringify(appidField))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
function removeAppidField() { |
|
|
|
let idx = field.value.field?.findIndex(f => f.prop === 'appid'); |
|
|
|
if (idx !== undefined && idx !== -1) field.value.field?.splice(idx, 1); |
|
|
|
} |
|
|
|
|
|
|
|
// 更新字段显示/隐藏和必填状态 |
|
|
|
function updateFieldVisibility(fieldName: string, show: boolean, required: boolean) { |
|
|
|
field.value.field.forEach((item: any) => { |
|
|
@@ -222,23 +272,43 @@ function updateFieldVisibility(fieldName: string, show: boolean, required: boole |
|
|
|
|
|
|
|
// 清空相关字段值 |
|
|
|
function clearRelatedFields(triggerTypeValue: string) { |
|
|
|
if (crudRef.value && crudRef.value.dialogForm) { |
|
|
|
console.log('clearRelatedFields called with:', triggerTypeValue); |
|
|
|
console.log('crudRef.value:', crudRef.value); |
|
|
|
console.log('crudRef.value.form:', crudRef.value?.form); |
|
|
|
|
|
|
|
if (crudRef.value?.form) { |
|
|
|
console.log('Before clearing - form:', JSON.stringify(crudRef.value.form)); |
|
|
|
|
|
|
|
if (triggerTypeValue === 'THIRD_PARTY_LINK') { |
|
|
|
crudRef.value.dialogForm.routeUrl = '' |
|
|
|
crudRef.value.dialogForm.text = '' |
|
|
|
crudRef.value.dialogForm.textType = '' |
|
|
|
crudRef.value.form.routeUrl = null |
|
|
|
crudRef.value.form.text = null |
|
|
|
crudRef.value.form.appid = null |
|
|
|
} else if (triggerTypeValue === 'NATIVE_ROUTE') { |
|
|
|
crudRef.value.dialogForm.hyperLink = '' |
|
|
|
crudRef.value.dialogForm.text = '' |
|
|
|
crudRef.value.dialogForm.textType = '' |
|
|
|
crudRef.value.form.hyperLink = null |
|
|
|
crudRef.value.form.text = null |
|
|
|
crudRef.value.form.appid = null |
|
|
|
} else if (triggerTypeValue === 'TEXT') { |
|
|
|
crudRef.value.dialogForm.hyperLink = '' |
|
|
|
crudRef.value.dialogForm.routeUrl = '' |
|
|
|
crudRef.value.form.hyperLink = null |
|
|
|
crudRef.value.form.routeUrl = null |
|
|
|
crudRef.value.form.appid = null |
|
|
|
} else if (triggerTypeValue === 'THIRD_PARTY_MINI') { |
|
|
|
crudRef.value.dialogForm.hyperLink = '' |
|
|
|
crudRef.value.dialogForm.text = '' |
|
|
|
crudRef.value.dialogForm.textType = '' |
|
|
|
crudRef.value.form.hyperLink = null |
|
|
|
crudRef.value.form.text = null |
|
|
|
crudRef.value.form.routeUrl = null |
|
|
|
} else { |
|
|
|
// 默认情况,清空所有相关字段 |
|
|
|
crudRef.value.form.hyperLink = null |
|
|
|
crudRef.value.form.routeUrl = null |
|
|
|
crudRef.value.form.text = null |
|
|
|
crudRef.value.form.appid = null |
|
|
|
} |
|
|
|
|
|
|
|
console.log('After clearing - form:', JSON.stringify(crudRef.value.form)); |
|
|
|
|
|
|
|
// 强制触发响应式更新 |
|
|
|
crudRef.value.form = { ...crudRef.value.form }; |
|
|
|
} else { |
|
|
|
console.log('form is not available, skipping field clearing'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -247,7 +317,8 @@ function resetFieldVisibility() { |
|
|
|
updateFieldVisibility('hyperLink', false, false) |
|
|
|
updateFieldVisibility('routeUrl', false, false) |
|
|
|
updateFieldVisibility('text', false, false) |
|
|
|
updateFieldVisibility('textType', false, false) |
|
|
|
updateFieldVisibility('textType', true, true) |
|
|
|
updateFieldVisibility('sequence', false, false) |
|
|
|
} |
|
|
|
|
|
|
|
// 路由地址字段 |
|
|
@@ -334,7 +405,21 @@ function submit(data: any) { |
|
|
|
} |
|
|
|
// data.orderSource = 'WECHAT' |
|
|
|
if (data) { |
|
|
|
BaseService.post(api, data).then((res: any) => { |
|
|
|
// 处理空值,将空字符串转换为 null |
|
|
|
const processedData = { ...data }; |
|
|
|
Object.keys(processedData).forEach(key => { |
|
|
|
if (processedData[key] === '' || processedData[key] === undefined) { |
|
|
|
processedData[key] = null; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 将 appid 字段名改为 Appid |
|
|
|
if (processedData.appid !== undefined) { |
|
|
|
processedData.Appid = processedData.appid; |
|
|
|
delete processedData.appid; |
|
|
|
} |
|
|
|
|
|
|
|
BaseService.post(api, processedData).then((res: any) => { |
|
|
|
if (res && res.code === 0) { |
|
|
|
ElMessage.success("操作成功"); |
|
|
|
getList(); |
|
|
@@ -513,7 +598,7 @@ let field = ref({ |
|
|
|
type: 'select', |
|
|
|
listData: TEXT_TYPE, |
|
|
|
hide: false, |
|
|
|
required: false |
|
|
|
required: true |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
@@ -584,7 +669,7 @@ let field = ref({ |
|
|
|
itemType: 'textarea', |
|
|
|
rows: 4, |
|
|
|
placeholder: '请输入文本内容', |
|
|
|
hide: false, |
|
|
|
hide: true, |
|
|
|
required: false |
|
|
|
} |
|
|
|
}, |
|
|
@@ -601,5 +686,24 @@ let field = ref({ |
|
|
|
} |
|
|
|
}] |
|
|
|
}); |
|
|
|
|
|
|
|
let appidField = { |
|
|
|
prop: "appid", |
|
|
|
label: "appId", |
|
|
|
form: { |
|
|
|
formLabelWidth: formLabelWidth, |
|
|
|
type: "input", |
|
|
|
required: true, |
|
|
|
placeholder: "请输入appId", |
|
|
|
hide: false |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 文本内容字段始终必填 |
|
|
|
// field.value.field?.forEach(item => { |
|
|
|
// if (item.prop === 'text' && item.form) { |
|
|
|
// item.form.required = true; |
|
|
|
// } |
|
|
|
// }); |
|
|
|
</script> |
|
|
|
<style lang='scss' scoped></style> |