|
|
@ -50,7 +50,6 @@ |
|
|
</div> |
|
|
</div> |
|
|
<transition name="tab-slide" mode="out-in"> |
|
|
<transition name="tab-slide" mode="out-in"> |
|
|
<div :key="activeTab" class="content-area"> |
|
|
<div :key="activeTab" class="content-area"> |
|
|
<div v-if="currentScreenItem"> |
|
|
|
|
|
<!-- {{ currentScreenItem.name }}(ID: {{ currentScreenItem.id }})内容 - 这里是第{{ activeTab + 1 }}个大屏的详细配置 --> |
|
|
<!-- {{ currentScreenItem.name }}(ID: {{ currentScreenItem.id }})内容 - 这里是第{{ activeTab + 1 }}个大屏的详细配置 --> |
|
|
<div> |
|
|
<div> |
|
|
<div class="screen-content-title"> |
|
|
<div class="screen-content-title"> |
|
|
@ -136,7 +135,7 @@ |
|
|
class="edit-readonly" |
|
|
class="edit-readonly" |
|
|
@dblclick="handleDblClick('openForm', 'open_lib_http')" |
|
|
@dblclick="handleDblClick('openForm', 'open_lib_http')" |
|
|
> |
|
|
> |
|
|
{{ openForm.open_lib_http || '' }} |
|
|
|
|
|
|
|
|
{{ openForm.open_lib_http }} |
|
|
</span> |
|
|
</span> |
|
|
<el-input |
|
|
<el-input |
|
|
v-else |
|
|
v-else |
|
|
@ -152,7 +151,7 @@ |
|
|
class="edit-readonly" |
|
|
class="edit-readonly" |
|
|
@dblclick="handleDblClick('openForm', 'open_lib_appId')" |
|
|
@dblclick="handleDblClick('openForm', 'open_lib_appId')" |
|
|
> |
|
|
> |
|
|
{{ openForm.open_lib_appId || '' }} |
|
|
|
|
|
|
|
|
{{ openForm.open_lib_appId }} |
|
|
</span> |
|
|
</span> |
|
|
<el-input |
|
|
<el-input |
|
|
v-else |
|
|
v-else |
|
|
@ -168,7 +167,7 @@ |
|
|
class="edit-readonly" |
|
|
class="edit-readonly" |
|
|
@dblclick="handleDblClick('openForm', 'open_lib_secret')" |
|
|
@dblclick="handleDblClick('openForm', 'open_lib_secret')" |
|
|
> |
|
|
> |
|
|
{{ openForm.open_lib_secret || '' }} |
|
|
|
|
|
|
|
|
{{ openForm.open_lib_secret }} |
|
|
</span> |
|
|
</span> |
|
|
<el-input |
|
|
<el-input |
|
|
v-else |
|
|
v-else |
|
|
@ -193,7 +192,7 @@ |
|
|
class="edit-readonly" |
|
|
class="edit-readonly" |
|
|
@dblclick="handleDblClick('hotForm', 'hot_search_http')" |
|
|
@dblclick="handleDblClick('hotForm', 'hot_search_http')" |
|
|
> |
|
|
> |
|
|
{{ hotForm.hot_search_http || '' }} |
|
|
|
|
|
|
|
|
{{ hotForm.hot_search_http }} |
|
|
</span> |
|
|
</span> |
|
|
<el-input |
|
|
<el-input |
|
|
v-else |
|
|
v-else |
|
|
@ -218,7 +217,7 @@ |
|
|
class="edit-readonly" |
|
|
class="edit-readonly" |
|
|
@dblclick="handleDblClick('vxForm', 'vx_appID')" |
|
|
@dblclick="handleDblClick('vxForm', 'vx_appID')" |
|
|
> |
|
|
> |
|
|
{{ vxForm.vx_appID || '' }} |
|
|
|
|
|
|
|
|
{{ vxForm.vx_appID }} |
|
|
</span> |
|
|
</span> |
|
|
<el-input |
|
|
<el-input |
|
|
v-else |
|
|
v-else |
|
|
@ -234,7 +233,7 @@ |
|
|
class="edit-readonly" |
|
|
class="edit-readonly" |
|
|
@dblclick="handleDblClick('vxForm', 'vx_AppSecret')" |
|
|
@dblclick="handleDblClick('vxForm', 'vx_AppSecret')" |
|
|
> |
|
|
> |
|
|
{{ vxForm.vx_AppSecret || '' }} |
|
|
|
|
|
|
|
|
{{ vxForm.vx_AppSecret }} |
|
|
</span> |
|
|
</span> |
|
|
<el-input |
|
|
<el-input |
|
|
v-else |
|
|
v-else |
|
|
@ -248,34 +247,14 @@ |
|
|
</div> |
|
|
</div> |
|
|
<div class="config-remarks">双击输入框可进行编辑。图书馆公众号AppID、AppSecrect 仅用于“总览屏”显示公众号粉丝数量。</div> |
|
|
<div class="config-remarks">双击输入框可进行编辑。图书馆公众号AppID、AppSecrect 仅用于“总览屏”显示公众号粉丝数量。</div> |
|
|
</div> |
|
|
</div> |
|
|
<div v-if="currentScreenItem.id === 1 || currentScreenItem.id === 4" class="config-item"> |
|
|
|
|
|
<div class="config-item-main"> |
|
|
|
|
|
<span class="data-title">二维码</span> |
|
|
|
|
|
<div class="upload-item" style="margin-bottom: 20px;"> |
|
|
|
|
|
<p>公众号二维码</p> |
|
|
|
|
|
<div style="display: flex; justify-content: flex-start;"> |
|
|
|
|
|
<img style="display: block; height: 120px; margin-right: 15px;" src="@/assets/images/cover-bg.png" alt=""> |
|
|
|
|
|
<div class="upload-img-input"> |
|
|
|
|
|
<!-- @change="changeAiFile" --> |
|
|
|
|
|
<input ref="fileInput" type="file" multiple> |
|
|
|
|
|
<div class="upload-libImg"><i class="iconfont icon-shangchuan2" /><span>点击上传</span></div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="config-remarks">双击可上传图片。二维码用于“总览屏”、“媒体屏”,在任意分屏编辑均可生效!</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
<bookRecommend v-if="currentScreenItem.id === 1" ref="bookRecommendRef" /> |
|
|
|
|
|
<areaSetting v-if="currentScreenItem.id === 2" ref="areaSettingRef" /> |
|
|
|
|
|
|
|
|
<wecharQrCode v-if="currentScreenItem.id === 1 || currentScreenItem.id === 4" ref="wecharQrCodeRef" :qr-code-url="wecharQrCodeUrl" @triggerInit="initScreenSetting" @ready="onWechatQrCodeReady" /> |
|
|
|
|
|
<bookRecommend v-if="currentScreenItem.id === 1" ref="bookRecommendRef" @ready="initScreenBookRecommend" /> |
|
|
|
|
|
<areaSetting v-if="currentScreenItem.id === 2" ref="areaSettingRef" :map-data="mapData" @triggerInit="initScreenSetting" @ready="initScreenBranch" /> |
|
|
<mediaSetting v-if="currentScreenItem.id === 4" ref="mediaSettingRef" /> |
|
|
<mediaSetting v-if="currentScreenItem.id === 4" ref="mediaSettingRef" /> |
|
|
<advSetting v-if="currentScreenItem.id === 5" ref="advSettingRef" /> |
|
|
|
|
|
|
|
|
<advSetting v-if="currentScreenItem.id === 5" ref="advSettingRef" :welcome-play="welcomePlay" @triggerInit="initScreenSetting" /> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div v-else> |
|
|
|
|
|
请选择一个大屏进行配置 |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</transition> |
|
|
</transition> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
@ -284,6 +263,7 @@ |
|
|
import { FetchInitScreenSetting, FetchEditScreenSetting } from '@/api/digitalScreen/index' |
|
|
import { FetchInitScreenSetting, FetchEditScreenSetting } from '@/api/digitalScreen/index' |
|
|
import Sortable from 'sortablejs' |
|
|
import Sortable from 'sortablejs' |
|
|
import previewSetting from './module/previewSetting' |
|
|
import previewSetting from './module/previewSetting' |
|
|
|
|
|
import wecharQrCode from './module/wecharQrCode' |
|
|
import bookRecommend from './module/bookRecommend' |
|
|
import bookRecommend from './module/bookRecommend' |
|
|
import areaSetting from './module/areaSetting' |
|
|
import areaSetting from './module/areaSetting' |
|
|
import mediaSetting from './module/mediaSetting' |
|
|
import mediaSetting from './module/mediaSetting' |
|
|
@ -293,6 +273,7 @@ export default { |
|
|
name: 'DigitalScreen', |
|
|
name: 'DigitalScreen', |
|
|
components: { |
|
|
components: { |
|
|
previewSetting, |
|
|
previewSetting, |
|
|
|
|
|
wecharQrCode, |
|
|
bookRecommend, |
|
|
bookRecommend, |
|
|
areaSetting, |
|
|
areaSetting, |
|
|
mediaSetting, |
|
|
mediaSetting, |
|
|
@ -306,11 +287,11 @@ export default { |
|
|
originalTitle: '', |
|
|
originalTitle: '', |
|
|
activeTab: 0, |
|
|
activeTab: 0, |
|
|
screenItems: [ |
|
|
screenItems: [ |
|
|
{ id: 1, time: '5', name: '总览屏', enabled: true, editing: false, originalTime: '5' }, |
|
|
|
|
|
{ id: 2, time: '5', name: '区域屏', enabled: true, editing: false, originalTime: '5' }, |
|
|
|
|
|
{ id: 3, time: '5', name: '统计屏', enabled: true, editing: false, originalTime: '5' }, |
|
|
|
|
|
{ id: 4, time: '5', name: '媒体屏', enabled: true, editing: false, originalTime: '5' }, |
|
|
|
|
|
{ id: 5, time: '5', name: '欢迎屏', enabled: true, editing: false, originalTime: '5' } |
|
|
|
|
|
|
|
|
{ id: 1, time: '5', name: '总览屏', enabled: true, editing: false, originalTime: '5', code: 'show1' }, |
|
|
|
|
|
{ id: 2, time: '5', name: '区域屏', enabled: true, editing: false, originalTime: '5', code: 'show2' }, |
|
|
|
|
|
{ id: 3, time: '5', name: '统计屏', enabled: true, editing: false, originalTime: '5', code: 'show3' }, |
|
|
|
|
|
{ id: 4, time: '5', name: '媒体屏', enabled: true, editing: false, originalTime: '5', code: 'show4' }, |
|
|
|
|
|
{ id: 5, time: '5', name: '欢迎屏', enabled: true, editing: false, originalTime: '5', code: 'show5' } |
|
|
], |
|
|
], |
|
|
editingLock: false, |
|
|
editingLock: false, |
|
|
prevActiveTab: 0, |
|
|
prevActiveTab: 0, |
|
|
@ -339,7 +320,9 @@ export default { |
|
|
vx_appID: null, |
|
|
vx_appID: null, |
|
|
vx_AppSecret: null |
|
|
vx_AppSecret: null |
|
|
}, |
|
|
}, |
|
|
vxImageUrl: '', |
|
|
|
|
|
|
|
|
wecharQrCodeUrl: null, |
|
|
|
|
|
mapData: null, |
|
|
|
|
|
welcomePlay: null, |
|
|
editStatus: { |
|
|
editStatus: { |
|
|
openForm: { |
|
|
openForm: { |
|
|
open_lib_http: false, |
|
|
open_lib_http: false, |
|
|
@ -361,7 +344,6 @@ export default { |
|
|
yesterday_visit: null, |
|
|
yesterday_visit: null, |
|
|
this_month_visit: null, |
|
|
this_month_visit: null, |
|
|
last_month_visit: null, |
|
|
last_month_visit: null, |
|
|
// 新增:复选框绑定的属性(必须提前声明) |
|
|
|
|
|
visit_base_checked: false, // 对应“本年到馆”的“直接显示” |
|
|
visit_base_checked: false, // 对应“本年到馆”的“直接显示” |
|
|
today_visit_checked: false, // 对应“今日到馆”的“直接显示” |
|
|
today_visit_checked: false, // 对应“今日到馆”的“直接显示” |
|
|
yesterday_visit_checked: false, // 对应“昨日到馆”的“直接显示” |
|
|
yesterday_visit_checked: false, // 对应“昨日到馆”的“直接显示” |
|
|
@ -370,6 +352,7 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
originalValues: { |
|
|
originalValues: { |
|
|
|
|
|
title: '', |
|
|
openForm: {}, |
|
|
openForm: {}, |
|
|
hotForm: {}, |
|
|
hotForm: {}, |
|
|
vxForm: {}, |
|
|
vxForm: {}, |
|
|
@ -404,10 +387,10 @@ export default { |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
this.initTitle() |
|
|
this.initTitle() |
|
|
this.initScreenSetting() |
|
|
|
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
this.$nextTick(() => { |
|
|
this.$nextTick(() => { |
|
|
|
|
|
this.initScreenSetting() |
|
|
this.draggableScreen() |
|
|
this.draggableScreen() |
|
|
if (this.$refs.bookRecommendRef) { |
|
|
if (this.$refs.bookRecommendRef) { |
|
|
this.$refs.bookRecommendRef.updateBookSwiper() |
|
|
this.$refs.bookRecommendRef.updateBookSwiper() |
|
|
@ -415,152 +398,126 @@ export default { |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
// checked(val) { |
|
|
|
|
|
// // 1. 先同步更新数据 |
|
|
|
|
|
// this.librarySettingForm.visit_base_checked = val |
|
|
|
|
|
// console.log('数据已更新:', this.librarySettingForm.visit_base_checked) |
|
|
|
|
|
|
|
|
|
|
|
// // 2. 强制触发DOM更新 |
|
|
|
|
|
// this.$nextTick(() => { |
|
|
|
|
|
// // 这里可以写需要依赖最新DOM的逻辑(可选) |
|
|
|
|
|
// console.log('DOM已同步更新') |
|
|
|
|
|
// }) |
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
|
initScreenBranch() { |
|
|
|
|
|
this.$refs.areaSettingRef.initScreenBranch() |
|
|
|
|
|
}, |
|
|
|
|
|
initScreenBookRecommend() { |
|
|
|
|
|
this.$refs.bookRecommendRef.initScreenBookRecommend() |
|
|
|
|
|
}, |
|
|
|
|
|
onWechatQrCodeReady() { |
|
|
|
|
|
this.$refs.wecharQrCodeRef.reloadImage() |
|
|
|
|
|
}, |
|
|
// 初始化智慧大屏基本数据 |
|
|
// 初始化智慧大屏基本数据 |
|
|
initScreenSetting() { |
|
|
initScreenSetting() { |
|
|
FetchInitScreenSetting().then(res => { |
|
|
FetchInitScreenSetting().then(res => { |
|
|
console.log('初始化', res) |
|
|
|
|
|
// 遍历接口返回的所有数据 |
|
|
|
|
|
|
|
|
const showScreenItem = Object.values(res).find(item => item.code === 'show_screen') |
|
|
|
|
|
if (showScreenItem) { |
|
|
|
|
|
// 处理显示状态(context) |
|
|
|
|
|
if (showScreenItem.context) { |
|
|
|
|
|
const enabledIds = showScreenItem.context.split(',').map(Number) |
|
|
|
|
|
this.screenItems.forEach(item => { |
|
|
|
|
|
item.enabled = enabledIds.includes(item.id) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理显示顺序(remarks) |
|
|
|
|
|
if (showScreenItem.remarks) { |
|
|
|
|
|
const orderIds = showScreenItem.remarks.split(',').map(Number) |
|
|
|
|
|
// 按照remarks指定的顺序重新排列screenItems |
|
|
|
|
|
this.screenItems.sort((a, b) => { |
|
|
|
|
|
return orderIds.indexOf(a.id) - orderIds.indexOf(b.id) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Object.values(res).forEach(item => { |
|
|
Object.values(res).forEach(item => { |
|
|
const { code, context } = item |
|
|
const { code, context } = item |
|
|
// 根据code匹配对应表单字段并赋值 |
|
|
|
|
|
switch (code) { |
|
|
|
|
|
// 到馆统计相关 |
|
|
|
|
|
case 'arrival_library_setting': |
|
|
|
|
|
|
|
|
// 处理标题 |
|
|
|
|
|
if (code === 'screen_title') { |
|
|
|
|
|
this.screen_title = context |
|
|
|
|
|
this.originalTitle = this.screen_title |
|
|
|
|
|
this.originalValues.title = this.screen_title |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理到馆统计相关 |
|
|
|
|
|
if (code === 'arrival_library_setting') { |
|
|
this.arrival_library_setting = context |
|
|
this.arrival_library_setting = context |
|
|
break |
|
|
|
|
|
case 'visit_base': |
|
|
|
|
|
this.librarySettingForm.visit_base = context |
|
|
|
|
|
break |
|
|
|
|
|
case 'last_year_visit_base': |
|
|
|
|
|
this.librarySettingForm.last_year_visit_base = context |
|
|
|
|
|
break |
|
|
|
|
|
case 'today_visit': |
|
|
|
|
|
this.librarySettingForm.today_visit = context |
|
|
|
|
|
break |
|
|
|
|
|
case 'yesterday_visit': |
|
|
|
|
|
this.librarySettingForm.yesterday_visit = context |
|
|
|
|
|
break |
|
|
|
|
|
case 'this_month_visit': |
|
|
|
|
|
this.librarySettingForm.this_month_visit = context |
|
|
|
|
|
break |
|
|
|
|
|
case 'last_month_visit': |
|
|
|
|
|
this.librarySettingForm.last_month_visit = context |
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
// 图创接口相关 |
|
|
|
|
|
case 'open_lib_http': |
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理各个屏幕的显示时间(show1-show5) |
|
|
|
|
|
if (code.startsWith('show') && !isNaN(parseInt(code.replace('show', '')))) { |
|
|
|
|
|
const screenId = parseInt(code.replace('show', '')) |
|
|
|
|
|
const screenItem = this.screenItems.find(item => item.id === screenId) |
|
|
|
|
|
if (screenItem) { |
|
|
|
|
|
screenItem.time = context || '5' // 默认5秒 |
|
|
|
|
|
screenItem.originalTime = screenItem.time // 同步originalTime |
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理到馆统计表单字段 |
|
|
|
|
|
if (['visit_base', 'last_year_visit_base', 'today_visit', 'yesterday_visit', 'this_month_visit', 'last_month_visit'].includes(code)) { |
|
|
|
|
|
this.$set(this.librarySettingForm, code, context) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理图创接口相关 |
|
|
|
|
|
if (code === 'open_lib_http') { |
|
|
this.openForm.open_lib_http = context |
|
|
this.openForm.open_lib_http = context |
|
|
break |
|
|
|
|
|
case 'open_lib_appId': |
|
|
|
|
|
|
|
|
} else if (code === 'open_lib_appId') { |
|
|
this.openForm.open_lib_appId = context |
|
|
this.openForm.open_lib_appId = context |
|
|
break |
|
|
|
|
|
case 'open_lib_secret': |
|
|
|
|
|
|
|
|
} else if (code === 'open_lib_secret') { |
|
|
this.openForm.open_lib_secret = context |
|
|
this.openForm.open_lib_secret = context |
|
|
break |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 热门搜索相关 |
|
|
|
|
|
case 'hot_search_http': |
|
|
|
|
|
|
|
|
// 处理热门搜索相关 |
|
|
|
|
|
if (code === 'hot_search_http') { |
|
|
this.hotForm.hot_search_http = context |
|
|
this.hotForm.hot_search_http = context |
|
|
break |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 微信绑定相关 |
|
|
|
|
|
case 'vx_appID': |
|
|
|
|
|
|
|
|
// 处理微信绑定相关 |
|
|
|
|
|
if (code === 'vx_appID') { |
|
|
this.vxForm.vx_appID = context |
|
|
this.vxForm.vx_appID = context |
|
|
break |
|
|
|
|
|
case 'vx_AppSecret': |
|
|
|
|
|
|
|
|
} else if (code === 'vx_AppSecret') { |
|
|
this.vxForm.vx_AppSecret = context |
|
|
this.vxForm.vx_AppSecret = context |
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
// 公众号二维码(如有需要可处理) |
|
|
|
|
|
case 'wechar_qr_code': |
|
|
|
|
|
this.vxImageUrl = context // 假设用于展示二维码图片 |
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
// 大屏显示时长相关(show1-show5对应5个大屏的时长) |
|
|
|
|
|
case 'show1': |
|
|
|
|
|
if (this.screenItems[0]) this.screenItems[0].time = context |
|
|
|
|
|
break |
|
|
|
|
|
case 'show2': |
|
|
|
|
|
if (this.screenItems[1]) this.screenItems[1].time = context |
|
|
|
|
|
break |
|
|
|
|
|
case 'show3': |
|
|
|
|
|
if (this.screenItems[2]) this.screenItems[2].time = context |
|
|
|
|
|
break |
|
|
|
|
|
case 'show4': |
|
|
|
|
|
if (this.screenItems[3]) this.screenItems[3].time = context |
|
|
|
|
|
break |
|
|
|
|
|
case 'show5': |
|
|
|
|
|
if (this.screenItems[4]) this.screenItems[4].time = context |
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
// 大屏启用状态(show_screen格式为"1,2,3,4",表示启用的大屏ID) |
|
|
|
|
|
case 'show_screen': |
|
|
|
|
|
if (context) { |
|
|
|
|
|
const enabledIds = context.split(',').map(Number) |
|
|
|
|
|
this.screenItems.forEach(item => { |
|
|
|
|
|
item.enabled = enabledIds.includes(item.id) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
} |
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理公众号二维码 |
|
|
|
|
|
if (code === 'wechar_qr_code') { |
|
|
|
|
|
this.wecharQrCodeUrl = context |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (code === 'map_data') { |
|
|
|
|
|
this.mapData = context |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (code === 'welcome_play') { |
|
|
|
|
|
this.welcomePlay = context |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
// 在initScreenSetting方法中,替换原处理逻辑 |
|
|
|
|
|
|
|
|
|
|
|
// 例如在初始化数据时(initScreenSetting中),替换直接赋值为this.$set |
|
|
|
|
|
Object.values(res).forEach(item => { |
|
|
Object.values(res).forEach(item => { |
|
|
const { code, context, remarks } = item |
|
|
const { code, context, remarks } = item |
|
|
if (['visit_base', 'today_visit', 'yesterday_visit', 'this_month_visit', 'last_month_visit'].includes(code)) { |
|
|
if (['visit_base', 'today_visit', 'yesterday_visit', 'this_month_visit', 'last_month_visit'].includes(code)) { |
|
|
// 用$set更新基础属性 |
|
|
|
|
|
this.$set(this.librarySettingForm, code, context) |
|
|
this.$set(this.librarySettingForm, code, context) |
|
|
// 用$set更新复选框属性(关键) |
|
|
|
|
|
this.$set(this.librarySettingForm, `${code}_checked`, remarks === '1') |
|
|
this.$set(this.librarySettingForm, `${code}_checked`, remarks === '1') |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}).catch(() => { |
|
|
}).catch(() => { |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
handleTabClick(index) { |
|
|
|
|
|
// 如果是双击事件,则不执行Tab切换 |
|
|
|
|
|
if (this.isDoubleClick) { |
|
|
|
|
|
this.isDoubleClick = false |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
this.prevActiveTab = this.activeTab // 记录当前激活的标签 |
|
|
|
|
|
this.activeTab = index |
|
|
|
|
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
if (this.currentScreenItem && this.currentScreenItem.id === 5) { |
|
|
|
|
|
if (this.$refs.advSettingRef) { |
|
|
|
|
|
this.$refs.advSettingRef.updateSwiper() |
|
|
|
|
|
} |
|
|
|
|
|
} else if (this.currentScreenItem && this.currentScreenItem.id === 1) { |
|
|
|
|
|
if (this.$refs.bookRecommendRef) { |
|
|
|
|
|
this.$refs.bookRecommendRef.updateBookSwiper() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 大屏标题 |
|
|
initTitle() { |
|
|
initTitle() { |
|
|
this.screen_title = '默认大屏标题' |
|
|
|
|
|
|
|
|
this.screen_title = '' // 默认空字符串 |
|
|
this.originalTitle = this.screen_title |
|
|
this.originalTitle = this.screen_title |
|
|
|
|
|
this.originalValues.title = this.screen_title |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
handleTitleDblClick() { |
|
|
handleTitleDblClick() { |
|
|
this.isEditable = true |
|
|
this.isEditable = true |
|
|
this.originalTitle = this.screen_title |
|
|
this.originalTitle = this.screen_title |
|
|
|
|
|
this.originalValues.title = this.screen_title |
|
|
this.$nextTick(() => { |
|
|
this.$nextTick(() => { |
|
|
const titleInput = this.$refs.titleInput |
|
|
const titleInput = this.$refs.titleInput |
|
|
if (titleInput) { |
|
|
if (titleInput) { |
|
|
@ -570,49 +527,184 @@ export default { |
|
|
}, |
|
|
}, |
|
|
handleTitleBlur() { |
|
|
handleTitleBlur() { |
|
|
this.isEditable = false |
|
|
this.isEditable = false |
|
|
if (this.screen_title !== this.originalTitle) { |
|
|
|
|
|
this.updateTitle() |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
updateTitle() { |
|
|
|
|
|
if (this.screen_title.length > 17) { |
|
|
if (this.screen_title.length > 17) { |
|
|
this.$message.warning('标题不能超过17个字,请修改!') |
|
|
this.$message.warning('标题不能超过17个字,请修改!') |
|
|
this.screen_title = this.originalTitle |
|
|
this.screen_title = this.originalTitle |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
console.log('更新标题接口调用,新标题:', this.screen_title) |
|
|
|
|
|
this.originalTitle = this.screen_title |
|
|
|
|
|
this.$message.success('标题更新成功!') |
|
|
|
|
|
|
|
|
if (this.screen_title !== this.originalTitle) { |
|
|
|
|
|
this.saveEdit('title', 'screen_title') |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
// 大屏是否启用 |
|
|
|
|
|
|
|
|
handleTabClick(index) { |
|
|
|
|
|
// 如果是双击事件,则不执行Tab切换 |
|
|
|
|
|
if (this.isDoubleClick) { |
|
|
|
|
|
this.isDoubleClick = false |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
this.prevActiveTab = this.activeTab |
|
|
|
|
|
this.activeTab = index |
|
|
|
|
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
if (this.currentScreenItem && this.currentScreenItem.id === 1) { |
|
|
|
|
|
if (this.$refs.bookRecommendRef) { |
|
|
|
|
|
this.$refs.bookRecommendRef.updateBookSwiper() |
|
|
|
|
|
} |
|
|
|
|
|
} else if (this.currentScreenItem && this.currentScreenItem.id === 5) { |
|
|
|
|
|
if (this.$refs.advSettingRef) { |
|
|
|
|
|
this.$refs.advSettingRef.updateSwiper() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
// handleTabClick(index) { |
|
|
|
|
|
// if (this.isDoubleClick) { |
|
|
|
|
|
// this.isDoubleClick = false |
|
|
|
|
|
// return |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// const prevTab = this.activeTab |
|
|
|
|
|
// this.activeTab = index |
|
|
|
|
|
|
|
|
|
|
|
// if (prevTab === index) { |
|
|
|
|
|
// return |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// this.$nextTick(() => { |
|
|
|
|
|
// const currentId = this.currentScreenItem?.id |
|
|
|
|
|
// if (!currentId) return |
|
|
|
|
|
// switch (currentId) { |
|
|
|
|
|
// case 1: |
|
|
|
|
|
// this.handleScreen1() |
|
|
|
|
|
// break |
|
|
|
|
|
// case 4: |
|
|
|
|
|
// this.handleScreen4() |
|
|
|
|
|
// break |
|
|
|
|
|
// case 5: |
|
|
|
|
|
// this.handleScreen5() |
|
|
|
|
|
// break |
|
|
|
|
|
// } |
|
|
|
|
|
// }) |
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
|
|
|
|
// // 处理ID=1的屏幕(总览屏) |
|
|
|
|
|
// handleScreen1() { |
|
|
|
|
|
// if (this.$refs.bookRecommendRef) { |
|
|
|
|
|
// this.$refs.bookRecommendRef.updateBookSwiper() |
|
|
|
|
|
// } else { |
|
|
|
|
|
// console.warn('bookRecommend组件未渲染(ID=1屏幕)') |
|
|
|
|
|
// } |
|
|
|
|
|
// this.refreshWechatQrCode() |
|
|
|
|
|
// }, |
|
|
|
|
|
// // 处理ID=1的屏幕 |
|
|
|
|
|
// handleScreen4() { |
|
|
|
|
|
// this.refreshWechatQrCode() |
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
|
|
|
|
// // 处理ID=5的屏幕(欢迎屏) |
|
|
|
|
|
// handleScreen5() { |
|
|
|
|
|
// if (this.$refs.advSettingRef) { |
|
|
|
|
|
// this.$refs.advSettingRef.updateSwiper() |
|
|
|
|
|
// } else { |
|
|
|
|
|
// console.warn('advSetting组件未渲染(ID=5屏幕)') |
|
|
|
|
|
// } |
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
|
|
|
|
// refreshWechatQrCode() { |
|
|
|
|
|
// if (this.$refs.wecharQrCodeRef) { |
|
|
|
|
|
// this.$refs.wecharQrCodeRef.reloadImage() |
|
|
|
|
|
// } else { |
|
|
|
|
|
// console.log('wecharQrCode组件尚未渲染或无需渲染') |
|
|
|
|
|
// } |
|
|
|
|
|
// }, |
|
|
|
|
|
// 大屏是否启用 - 修改后也需要提交show_screen |
|
|
toggleScreenStatus(index) { |
|
|
toggleScreenStatus(index) { |
|
|
|
|
|
const currentEnabledCount = this.enabledCount |
|
|
|
|
|
|
|
|
|
|
|
if (this.screenItems[index].enabled && currentEnabledCount <= 1) { |
|
|
|
|
|
this.$message.warning('至少需要启用一个大屏') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 正常切换状态 |
|
|
this.screenItems[index].enabled = !this.screenItems[index].enabled |
|
|
this.screenItems[index].enabled = !this.screenItems[index].enabled |
|
|
const statusText = this.screenItems[index].enabled ? '启用' : '停用' |
|
|
const statusText = this.screenItems[index].enabled ? '启用' : '停用' |
|
|
this.$message.info(`大屏${index + 1}已${statusText}`) |
|
|
|
|
|
|
|
|
this.$message.info(`大屏${index + 1}-即${this.screenItems[index].name}已${statusText}`) |
|
|
|
|
|
|
|
|
|
|
|
this.submitScreenOrderAndStatus() |
|
|
}, |
|
|
}, |
|
|
// 大屏拖拽排序 |
|
|
// 大屏拖拽排序 |
|
|
draggableScreen() { |
|
|
draggableScreen() { |
|
|
const tbody = document.querySelector('.config-screen') |
|
|
|
|
|
|
|
|
const container = document.querySelector('.config-screen') |
|
|
const that = this |
|
|
const that = this |
|
|
Sortable.create(tbody, { |
|
|
|
|
|
|
|
|
let originalOrder = [...this.screenItems.map(item => item.id)] |
|
|
|
|
|
Sortable.create(container, { |
|
|
draggable: '.config-screen-item', |
|
|
draggable: '.config-screen-item', |
|
|
|
|
|
animation: 150, |
|
|
|
|
|
onStart() { |
|
|
|
|
|
originalOrder = [...that.screenItems.map(item => item.id)] |
|
|
|
|
|
}, |
|
|
onEnd({ newIndex, oldIndex }) { |
|
|
onEnd({ newIndex, oldIndex }) { |
|
|
if (newIndex === oldIndex) return |
|
|
if (newIndex === oldIndex) return |
|
|
|
|
|
|
|
|
const activeItemId = that.screenItems[that.activeTab].id |
|
|
const activeItemId = that.screenItems[that.activeTab].id |
|
|
// 执行元素移动操作 |
|
|
// 执行元素移动操作 |
|
|
const movedItem = that.screenItems.splice(oldIndex, 1)[0] |
|
|
const movedItem = that.screenItems.splice(oldIndex, 1)[0] |
|
|
that.screenItems.splice(newIndex, 0, movedItem) |
|
|
that.screenItems.splice(newIndex, 0, movedItem) |
|
|
|
|
|
|
|
|
// 查找原激活项在新数组中的索引 |
|
|
// 查找原激活项在新数组中的索引 |
|
|
const newActiveIndex = that.screenItems.findIndex(item => item.id === activeItemId) |
|
|
const newActiveIndex = that.screenItems.findIndex(item => item.id === activeItemId) |
|
|
// 更新激活的Tab索引 |
|
|
|
|
|
if (newActiveIndex !== -1) { |
|
|
if (newActiveIndex !== -1) { |
|
|
that.activeTab = newActiveIndex |
|
|
that.activeTab = newActiveIndex |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 检查顺序是否真的发生了变化 |
|
|
|
|
|
const newOrder = [...that.screenItems.map(item => item.id)] |
|
|
|
|
|
if (!that.arraysEqual(originalOrder, newOrder)) { |
|
|
|
|
|
// 顺序变化,提交show_screen数据 |
|
|
|
|
|
that.submitScreenOrderAndStatus() |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 辅助方法:判断两个数组是否相等 |
|
|
|
|
|
arraysEqual(arr1, arr2) { |
|
|
|
|
|
if (arr1.length !== arr2.length) return false |
|
|
|
|
|
for (let i = 0; i < arr1.length; i++) { |
|
|
|
|
|
if (arr1[i] !== arr2[i]) return false |
|
|
|
|
|
} |
|
|
|
|
|
return true |
|
|
|
|
|
}, |
|
|
|
|
|
// 提交屏幕顺序和状态到show_screen |
|
|
|
|
|
submitScreenOrderAndStatus() { |
|
|
|
|
|
// 1. 收集显示的屏幕ID(enabled为true的) |
|
|
|
|
|
const enabledIds = this.screenItems |
|
|
|
|
|
.filter(item => item.enabled) |
|
|
|
|
|
.map(item => item.id) |
|
|
|
|
|
.join(',') |
|
|
|
|
|
|
|
|
|
|
|
// 2. 收集所有屏幕的顺序(无论是否启用) |
|
|
|
|
|
const orderIds = this.screenItems |
|
|
|
|
|
.map(item => item.id) |
|
|
|
|
|
.join(',') |
|
|
|
|
|
|
|
|
|
|
|
// 3. 调用saveEdit提交,使用specialFields表单类型 |
|
|
|
|
|
const formName = 'specialFields' |
|
|
|
|
|
const field = 'show_screen' |
|
|
|
|
|
|
|
|
|
|
|
// 记录原始值用于可能的回滚 |
|
|
|
|
|
if (!this.originalValues[formName]) { |
|
|
|
|
|
this.originalValues[formName] = {} |
|
|
|
|
|
} |
|
|
|
|
|
this.originalValues[formName][field] = { |
|
|
|
|
|
context: enabledIds, |
|
|
|
|
|
remarks: orderIds |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 调用saveEdit提交 |
|
|
|
|
|
this.saveEdit(formName, field) |
|
|
|
|
|
}, |
|
|
// 大屏展示时间操作 |
|
|
// 大屏展示时间操作 |
|
|
handleTimeClick(event) { |
|
|
handleTimeClick(event) { |
|
|
// 阻止事件冒泡 |
|
|
// 阻止事件冒泡 |
|
|
@ -657,40 +749,47 @@ export default { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
handleTimeBlur(item) { |
|
|
handleTimeBlur(item) { |
|
|
|
|
|
// 验证时长有效性 |
|
|
if (item.time === '' || isNaN(item.time) || parseInt(item.time) <= 0) { |
|
|
if (item.time === '' || isNaN(item.time) || parseInt(item.time) <= 0) { |
|
|
this.$message.warning('播放时长必须为大于0的数字') |
|
|
this.$message.warning('播放时长必须为大于0的数字') |
|
|
item.time = item.originalTime |
|
|
item.time = item.originalTime |
|
|
} else { |
|
|
} else { |
|
|
if (item.time !== item.originalTime) { |
|
|
|
|
|
|
|
|
// 转换为整数字符串(避免出现小数) |
|
|
item.time = parseInt(item.time).toString() |
|
|
item.time = parseInt(item.time).toString() |
|
|
this.updateScreenTime(item) |
|
|
|
|
|
|
|
|
// 只有当值发生变化时才提交 |
|
|
|
|
|
if (item.time !== item.originalTime) { |
|
|
|
|
|
this.submitScreenTime(item) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
item.editing = false |
|
|
item.editing = false |
|
|
}, |
|
|
}, |
|
|
updateScreenTime(item) { |
|
|
|
|
|
console.log(`更新大屏${item.id}播放时长为${item.time}秒`) |
|
|
|
|
|
this.$message.success(`大屏${item.id}播放时长已更新`) |
|
|
|
|
|
|
|
|
// 提交屏幕时长到对应show1-show5 |
|
|
|
|
|
submitScreenTime(item) { |
|
|
|
|
|
// 使用specialFields表单类型 |
|
|
|
|
|
const formName = 'specialFields' |
|
|
|
|
|
const field = item.code |
|
|
|
|
|
|
|
|
|
|
|
// 记录原始值用于可能的回滚 |
|
|
|
|
|
if (!this.originalValues[formName]) { |
|
|
|
|
|
this.originalValues[formName] = {} |
|
|
|
|
|
} |
|
|
|
|
|
this.originalValues[formName][field] = item.originalTime |
|
|
|
|
|
|
|
|
|
|
|
// 调用saveEdit提交 |
|
|
|
|
|
this.saveEdit(formName, field) |
|
|
}, |
|
|
}, |
|
|
// 双击进入编辑模式 |
|
|
|
|
|
|
|
|
// 其他表单编辑框 |
|
|
handleDblClick(formName, field) { |
|
|
handleDblClick(formName, field) { |
|
|
// 记录原始值(用于恢复) |
|
|
|
|
|
this.originalValues[formName][field] = this[formName][field] |
|
|
this.originalValues[formName][field] = this[formName][field] |
|
|
// 开启编辑状态 |
|
|
|
|
|
this.editStatus[formName][field] = true |
|
|
this.editStatus[formName][field] = true |
|
|
// 聚焦输入框 |
|
|
|
|
|
this.$nextTick(() => { |
|
|
this.$nextTick(() => { |
|
|
const input = this.$refs[`${formName}${field}`] |
|
|
const input = this.$refs[`${formName}${field}`] |
|
|
if (input) input.focus() |
|
|
if (input) input.focus() |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 失焦/回车保存编辑 |
|
|
|
|
|
handleBlur(formName, field) { |
|
|
handleBlur(formName, field) { |
|
|
// 关闭编辑状态 |
|
|
|
|
|
this.editStatus[formName][field] = false |
|
|
this.editStatus[formName][field] = false |
|
|
// 对比新值与原始值,有变化则执行保存逻辑 |
|
|
|
|
|
if (this[formName][field] !== this.originalValues[formName][field]) { |
|
|
if (this[formName][field] !== this.originalValues[formName][field]) { |
|
|
this.saveEdit(formName, field) |
|
|
this.saveEdit(formName, field) |
|
|
} |
|
|
} |
|
|
@ -700,87 +799,137 @@ export default { |
|
|
const virtualFormName = 'specialFields' |
|
|
const virtualFormName = 'specialFields' |
|
|
const field = 'arrival_library_setting' |
|
|
const field = 'arrival_library_setting' |
|
|
|
|
|
|
|
|
// 初始化原始值(如果尚未初始化) |
|
|
|
|
|
if (this.originalValues[virtualFormName] === undefined) { |
|
|
|
|
|
|
|
|
// 初始化原始值(仅首次) |
|
|
|
|
|
if (!this.originalValues[virtualFormName]) { |
|
|
this.originalValues[virtualFormName] = {} |
|
|
this.originalValues[virtualFormName] = {} |
|
|
} |
|
|
} |
|
|
if (this.originalValues[virtualFormName][field] === undefined) { |
|
|
if (this.originalValues[virtualFormName][field] === undefined) { |
|
|
this.originalValues[virtualFormName][field] = this.arrival_library_setting |
|
|
this.originalValues[virtualFormName][field] = this.arrival_library_setting |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 调用现有的 saveEdit 方法处理保存逻辑 |
|
|
|
|
|
this.saveEdit(virtualFormName, field) |
|
|
this.saveEdit(virtualFormName, field) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 保持原有的 saveEdit 方法不变 |
|
|
|
|
|
|
|
|
handleCheckboxChange(field, checked) { |
|
|
|
|
|
this.$set(this.librarySettingForm, `${field}_checked`, checked) |
|
|
|
|
|
this.saveEdit('librarySettingForm', field) |
|
|
|
|
|
}, |
|
|
saveEdit(formName, field) { |
|
|
saveEdit(formName, field) { |
|
|
const value = this[formName === 'specialFields' ? field : `${formName}.${field}`] |
|
|
|
|
|
console.log(`保存${formName}.${field}:`, value) |
|
|
|
|
|
|
|
|
let code = field |
|
|
|
|
|
let context |
|
|
|
|
|
let remarks = '' |
|
|
|
|
|
|
|
|
// 对于单选框组,0/1/2/3等值都是有效的,不需要验证非空 |
|
|
|
|
|
if (formName !== 'specialFields' && !value) { |
|
|
|
|
|
this.$message.warning(`${this.getFieldLabel(formName, field)}不能为空`) |
|
|
|
|
|
this[formName][field] = this.originalValues[formName][field] |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
// 处理标题特殊情况 |
|
|
|
|
|
if (formName === 'title') { |
|
|
|
|
|
code = 'screen_title' |
|
|
|
|
|
context = this.screen_title |
|
|
|
|
|
} else if (formName === 'specialFields' && field === 'show_screen') { |
|
|
|
|
|
// 处理show_screen特殊情况 |
|
|
|
|
|
context = this.originalValues[formName][field].context |
|
|
|
|
|
remarks = this.originalValues[formName][field].remarks |
|
|
|
|
|
} else if (formName === 'specialFields' && field.startsWith('show')) { |
|
|
|
|
|
// 处理show1-show5时长提交 |
|
|
|
|
|
// 从screenItems中找到对应的屏幕获取time |
|
|
|
|
|
const screenItem = this.screenItems.find(item => item.code === field) |
|
|
|
|
|
context = screenItem ? screenItem.time : '5' // 默认5秒 |
|
|
|
|
|
} else if (formName === 'specialFields') { |
|
|
|
|
|
// 处理其他特殊字段(如arrival_library_setting) |
|
|
|
|
|
context = this[field] |
|
|
|
|
|
} else { |
|
|
|
|
|
// 处理普通表单字段 |
|
|
|
|
|
context = this[formName][field] |
|
|
|
|
|
if (formName === 'librarySettingForm') { |
|
|
|
|
|
remarks = this[formName][`${field}_checked`] ? '1' : '0' |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 定义“空值”(排除0,允许0作为有效值) |
|
|
|
|
|
const isEmpty = value === '' || value === null || value === undefined |
|
|
|
|
|
|
|
|
|
|
|
// 非空验证(图书馆字段允许0,但不允许空) |
|
|
|
|
|
if (formName === 'librarySettingForm' && isEmpty) { |
|
|
|
|
|
|
|
|
// 2. 校验必填项和特殊规则 |
|
|
|
|
|
// 对于show_screen,至少需要启用一个屏幕 |
|
|
|
|
|
if (formName === 'specialFields' && field === 'show_screen') { |
|
|
|
|
|
if (!context) { |
|
|
|
|
|
this.$message.warning('至少需要启用一个大屏') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
} else if (formName === 'specialFields' && field.startsWith('show')) { |
|
|
|
|
|
// 对于show1-show5,校验时长有效性 |
|
|
|
|
|
if (!context || isNaN(context) || parseInt(context) <= 0) { |
|
|
|
|
|
this.$message.warning('播放时长必须为大于0的数字') |
|
|
|
|
|
this.rollbackValue(formName, field) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
} else if (!context && context !== 0) { |
|
|
|
|
|
// 其他字段的非空校验 |
|
|
this.$message.warning(`${this.getFieldLabel(formName, field)}不能为空`) |
|
|
this.$message.warning(`${this.getFieldLabel(formName, field)}不能为空`) |
|
|
this[formName][field] = this.originalValues[formName][field] |
|
|
|
|
|
|
|
|
this.rollbackValue(formName, field) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 图书馆表单的处理(关键) |
|
|
|
|
|
const checkBoxField = `${field}_checked` // 关联的复选框字段 |
|
|
|
|
|
const isChecked = this[formName][checkBoxField] // 复选框状态 |
|
|
|
|
|
|
|
|
// 3. 构建提交参数 |
|
|
|
|
|
const submitParam = { code, context, remarks } |
|
|
|
|
|
|
|
|
// 构造提交参数(核心:处理remarks) |
|
|
|
|
|
const param = { |
|
|
|
|
|
code: field, |
|
|
|
|
|
context: value, |
|
|
|
|
|
remarks: isChecked ? '1' : '0' // 同步复选框状态 |
|
|
|
|
|
|
|
|
// 4. 调用接口保存 |
|
|
|
|
|
FetchEditScreenSetting(submitParam) |
|
|
|
|
|
.then(() => { |
|
|
|
|
|
this.$message.success(`${this.getFieldLabel(formName, field)}更新成功`) |
|
|
|
|
|
// 更新原始值为新值 |
|
|
|
|
|
if (formName === 'title') { |
|
|
|
|
|
this.originalTitle = this.screen_title |
|
|
|
|
|
this.originalValues.title = this.screen_title |
|
|
|
|
|
} else if (formName === 'specialFields' && field.startsWith('show') && field !== 'show_screen') { |
|
|
|
|
|
// 更新屏幕的originalTime |
|
|
|
|
|
const screenItem = this.screenItems.find(item => item.code === field) |
|
|
|
|
|
if (screenItem) { |
|
|
|
|
|
screenItem.originalTime = context |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (formName === 'librarySettingForm') { |
|
|
|
|
|
const checkBoxField = `${field}_checked` |
|
|
|
|
|
param.remarks = this[formName][checkBoxField] ? '1' : '0' |
|
|
|
|
|
|
|
|
this.originalValues[formName][field] = context |
|
|
|
|
|
} else if (formName !== 'specialFields' || field !== 'show_screen') { |
|
|
|
|
|
this.originalValues[formName][field] = context |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 提交保存 |
|
|
|
|
|
FetchEditScreenSetting(param).then(res => { |
|
|
|
|
|
this.$message.success(`${this.getFieldLabel(formName, field)}更新成功`) |
|
|
|
|
|
}).catch(() => { |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
.catch(() => { |
|
|
this.$message.error(`${this.getFieldLabel(formName, field)}更新失败`) |
|
|
this.$message.error(`${this.getFieldLabel(formName, field)}更新失败`) |
|
|
this[formName][field] = this.originalValues[formName][field] |
|
|
|
|
|
|
|
|
this.rollbackValue(formName, field) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 复选框状态变化时的处理函数 |
|
|
|
|
|
handleCheckboxChange(code, checked) { |
|
|
|
|
|
this.$set(this.librarySettingForm, `${code}_checked`, checked) |
|
|
|
|
|
this.saveCheckboxStatus(code, checked) |
|
|
|
|
|
}, |
|
|
|
|
|
saveCheckboxStatus(code, checked) { |
|
|
|
|
|
const param = { |
|
|
|
|
|
code: code, // 关联的基础字段(如visit_base) |
|
|
|
|
|
context: this.librarySettingForm[code], // 基础字段的值 |
|
|
|
|
|
remarks: checked ? '1' : '0' // 转为后端需要的'1'/'0' |
|
|
|
|
|
|
|
|
// 新增:回滚值的通用方法 |
|
|
|
|
|
rollbackValue(formName, field) { |
|
|
|
|
|
if (this.originalValues[formName]?.[field] !== undefined) { |
|
|
|
|
|
if (formName === 'title') { |
|
|
|
|
|
this.screen_title = this.originalValues[formName][field] |
|
|
|
|
|
} else if (formName === 'specialFields' && field.startsWith('show') && field !== 'show_screen') { |
|
|
|
|
|
// 回滚屏幕时长 |
|
|
|
|
|
const screenItem = this.screenItems.find(item => item.code === field) |
|
|
|
|
|
if (screenItem) { |
|
|
|
|
|
screenItem.time = this.originalValues[formName][field] |
|
|
|
|
|
screenItem.originalTime = this.originalValues[formName][field] |
|
|
|
|
|
} |
|
|
|
|
|
} else if (formName === 'specialFields') { |
|
|
|
|
|
this[field] = this.originalValues[formName][field] |
|
|
|
|
|
} else { |
|
|
|
|
|
this[formName][field] = this.originalValues[formName][field] |
|
|
|
|
|
// 回滚复选框状态 |
|
|
|
|
|
if (formName === 'librarySettingForm') { |
|
|
|
|
|
const originalChecked = this.originalValues[formName][`${field}_checked`] |
|
|
|
|
|
if (originalChecked !== undefined) { |
|
|
|
|
|
this[formName][`${field}_checked`] = originalChecked |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
FetchEditScreenSetting(param).then(res => { |
|
|
|
|
|
this.$message.success(`"${this.getFieldLabel('librarySettingForm', code)}"的直接显示状态已更新`) |
|
|
|
|
|
}).catch(() => { |
|
|
|
|
|
this.$message.error('状态更新失败') |
|
|
|
|
|
// 失败时回滚状态 |
|
|
|
|
|
this.$set(this.librarySettingForm, `${code}_checked`, !checked) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
}, |
|
|
// 获取字段显示名称(用于提示信息) |
|
|
|
|
|
getFieldLabel(formName, field) { |
|
|
getFieldLabel(formName, field) { |
|
|
const labels = { |
|
|
const labels = { |
|
|
|
|
|
title: { |
|
|
|
|
|
screen_title: '大屏标题' |
|
|
|
|
|
}, |
|
|
|
|
|
specialFields: { |
|
|
|
|
|
arrival_library_setting: '到馆统计设置', |
|
|
|
|
|
show_screen: '大屏显示设置', |
|
|
|
|
|
show1: '总览屏播放时长', |
|
|
|
|
|
show2: '区域屏播放时长', |
|
|
|
|
|
show3: '统计屏播放时长', |
|
|
|
|
|
show4: '媒体屏播放时长', |
|
|
|
|
|
show5: '欢迎屏播放时长' |
|
|
|
|
|
}, |
|
|
openForm: { |
|
|
openForm: { |
|
|
open_lib_http: 'OpenLib地址', |
|
|
open_lib_http: 'OpenLib地址', |
|
|
open_lib_appId: 'AppId', |
|
|
open_lib_appId: 'AppId', |
|
|
@ -800,9 +949,6 @@ export default { |
|
|
yesterday_visit: '昨日到馆', |
|
|
yesterday_visit: '昨日到馆', |
|
|
this_month_visit: '本月到馆', |
|
|
this_month_visit: '本月到馆', |
|
|
last_month_visit: '上月到馆' |
|
|
last_month_visit: '上月到馆' |
|
|
}, |
|
|
|
|
|
specialFields: { |
|
|
|
|
|
arrival_library_setting: '到馆统计设置' |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return labels[formName][field] || field |
|
|
return labels[formName][field] || field |
|
|
@ -935,7 +1081,7 @@ export default { |
|
|
|
|
|
|
|
|
// 内容区域样式 + 过渡动画 |
|
|
// 内容区域样式 + 过渡动画 |
|
|
.content-area { |
|
|
.content-area { |
|
|
height: 520px; |
|
|
|
|
|
|
|
|
height: 510px; |
|
|
border-radius: 4px; |
|
|
border-radius: 4px; |
|
|
width: 100%; |
|
|
width: 100%; |
|
|
overflow-y: scroll; |
|
|
overflow-y: scroll; |
|
|
|