wangxyi 2 месяцев назад
Родитель
Сommit
debc03c67b
1 измененных файлов: 123 добавлений и 30 удалений
  1. 123
    30
      src/views/onlineBusinessHall/onlineOperation/carouselManagement/index.vue

+ 123
- 30
src/views/onlineBusinessHall/onlineOperation/carouselManagement/index.vue Просмотреть файл

@@ -102,11 +102,46 @@ function swiperIdHandleBeforeChange(row) {
}

let type = 'type' //类型
let hyperLink = 'hyperLink' //使用有效期
let hyperLink = 'hyperLink' //超链接
let path = 'path' //路由
let triggerType = 'triggerType' //触发类型
let routeUrl = 'routeUrl' //路由地址
let text = 'text' //文本内容
let textType = 'textType' //文本类型

//选择组件变化监听
function customSelectorSelection(value, title) {
if (title == type) {
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('textType', false, false)
} else if (value === 'NATIVE_ROUTE') {
// 本地路由:routeUrl必填,hyperLink、text、textType不显示
updateFieldVisibility('hyperLink', false, false)
updateFieldVisibility('routeUrl', true, true)
updateFieldVisibility('text', false, false)
updateFieldVisibility('textType', false, false)
} else if (value === 'TEXT') {
// 文本:text、textType必填,hyperLink、routeUrl不显示
updateFieldVisibility('hyperLink', false, false)
updateFieldVisibility('routeUrl', false, false)
updateFieldVisibility('text', true, true)
updateFieldVisibility('textType', true, true)
} else if (value === 'THIRD_PARTY_MINI') {
// 第三方小程序:routeUrl必填,hyperLink、text、textType不显示
updateFieldVisibility('hyperLink', false, false)
updateFieldVisibility('routeUrl', true, true)
updateFieldVisibility('text', false, false)
updateFieldVisibility('textType', false, false)
}
} else if (title == type) {
changeFile(true)
let item = {}
if (value == '1') {
@@ -175,6 +210,46 @@ function customSelectorSelection(value, title) {
}
}

// 更新字段显示/隐藏和必填状态
function updateFieldVisibility(fieldName: string, show: boolean, required: boolean) {
field.value.field.forEach((item: any) => {
if (item.prop === fieldName && item.form) {
item.form.hide = !show
item.form.required = required
}
})
}

// 清空相关字段值
function clearRelatedFields(triggerTypeValue: string) {
if (crudRef.value && crudRef.value.dialogForm) {
if (triggerTypeValue === 'THIRD_PARTY_LINK') {
crudRef.value.dialogForm.routeUrl = ''
crudRef.value.dialogForm.text = ''
crudRef.value.dialogForm.textType = ''
} else if (triggerTypeValue === 'NATIVE_ROUTE') {
crudRef.value.dialogForm.hyperLink = ''
crudRef.value.dialogForm.text = ''
crudRef.value.dialogForm.textType = ''
} else if (triggerTypeValue === 'TEXT') {
crudRef.value.dialogForm.hyperLink = ''
crudRef.value.dialogForm.routeUrl = ''
} else if (triggerTypeValue === 'THIRD_PARTY_MINI') {
crudRef.value.dialogForm.hyperLink = ''
crudRef.value.dialogForm.text = ''
crudRef.value.dialogForm.textType = ''
}
}
}

// 重置字段显示状态为默认
function resetFieldVisibility() {
updateFieldVisibility('hyperLink', false, false)
updateFieldVisibility('routeUrl', false, false)
updateFieldVisibility('text', false, false)
updateFieldVisibility('textType', false, false)
}

// 路由地址字段
function changeFile(b: boolean) {
field.value.field.forEach((item: any) => {
@@ -198,11 +273,19 @@ function handleEdit(idx: any, row: any) {
changeFile(true)
}
customSelectorSelection(row.type, 'type')
// 根据触发类型设置字段显示状态
if (row.triggerType) {
customSelectorSelection(row.triggerType, 'triggerType')
}
}
// 新增
function handleAdd() {
typeOption.value = "add"
changeFile(true)
// 重置所有字段为默认显示状态
resetFieldVisibility()
}

// 删除按钮
@@ -223,6 +306,8 @@ function handleDelete(idx: any, row: any) {
function cancel() {
crudRef.value.reset();
crudRef.value.dialogFormVisible = false;
// 重置字段显示状态
resetFieldVisibility();
}
//分页
function handleCurrentChange(val: number) {
@@ -248,8 +333,6 @@ function submit(data: any) {
api = '/managew/api/operation/flash/add'
}
// data.orderSource = 'WECHAT'
data.miniAppid="123456"
data.routeUrl="123456"
if (data) {
BaseService.post(api, data).then((res: any) => {
if (res && res.code === 0) {
@@ -378,7 +461,7 @@ let field = ref({
}
}, {
prop: "flashType",
label: "类型",
label: "快讯",
listData: FLASH_TYPE,
form: {
index: 2,
@@ -388,24 +471,39 @@ let field = ref({
listData: FLASH_TYPE,
}
}, {
prop: "triggerType",
label: "触发类型",
form: {
index: 8,
formLabelWidth: formLabelWidth,
type: 'select',
required: true,
listData: TRIGGER_TYPE,
}
},
{
prop: "hyperLink",
label: "超链接",
form: {
index: 4,
formLabelWidth: formLabelWidth,
type: 'input'
type: 'input',
hide: false,
required: false
}
},
{
prop: "routeUrl",
label: "路由地址",
form: {
index: 5,
formLabelWidth: formLabelWidth,
type: 'input',
hide: false,
required: false,
placeholder: '请输入路由地址'
}
},
// {
// prop: "speedUrl",
// label: "路由地址",
// form: {
// hideEdit: true,
// // required: true,
// formLabelWidth: formLabelWidth,
// type: 'input'
// }
// },
{
prop: "textType",
label: "文本类型",
@@ -413,7 +511,9 @@ let field = ref({
form: {
formLabelWidth: formLabelWidth,
type: 'select',
listData: TEXT_TYPE
listData: TEXT_TYPE,
hide: false,
required: false
}
},
{
@@ -444,7 +544,8 @@ let field = ref({
label: "排序",
form: {
formLabelWidth: formLabelWidth,
type: 'input'
type: 'input',
required: true
}
},
// {
@@ -482,20 +583,12 @@ let field = ref({
type: 'input',
itemType: 'textarea',
rows: 4,
placeholder: '请输入文本内容'
placeholder: '请输入文本内容',
hide: false,
required: false
}
},
{
prop: "triggerType",
label: "触发类型",
form: {
index: 8,
formLabelWidth: formLabelWidth,
type: 'select',
required: true,
listData: TRIGGER_TYPE,
}
}
],
dialogArray: [{
prop: "routing",

Загрузка…
Отмена
Сохранить