Files
dvcp_v2_wxcp_app/src/apps/AppBroadcast/addPlay.vue

522 lines
14 KiB
Vue
Raw Normal View History

2021-11-15 10:29:05 +08:00
<template>
<div class="addPlay">
<div class="content">
<div class="item">
<div class="label">播发内容</div>
2021-12-23 11:27:28 +08:00
<div class="value" @click="nameClick">
2021-12-15 14:37:20 +08:00
<span :class="formData.mediaName == '请选择' ? 'color-999' : ''">{{ formData.mediaName }}</span>
2021-11-15 10:29:05 +08:00
<img src="./img/right-icon.png" alt="">
</div>
</div>
<div class="item">
<div class="label">播放设备</div>
<div class="value" @click="selectClick('showEquipment', equipmentList)">
2021-12-15 14:37:20 +08:00
<span :class="formData.serialName == '请选择' ? 'color-999' : ''">{{ formData.serialName }}</span>
2021-11-15 10:29:05 +08:00
<img src="./img/right-icon.png" alt="">
</div>
</div>
<div class="item">
<div class="label">播发级别</div>
<div class="value" @click="selectClick('showMessageLevel', messageLevelList)">
2021-12-15 14:37:20 +08:00
<span :class="formData.messageLevelName == '请选择' ? 'color-999' : ''">{{ formData.messageLevelName }}</span>
2021-11-15 10:29:05 +08:00
<img src="./img/right-icon.png" alt="">
</div>
</div>
</div>
<div class="radio-content">
<div class="title">播放方式</div>
2021-12-15 14:37:20 +08:00
<div class="item mar-r50" :class="formData.taskType == 0 ? 'active' : ''" @click="formData.taskType = 0">立即播放<img
src="./img/bigHorn-xz.png" alt=""></div>
<div class="item" :class="formData.taskType == 1 ? 'active' : ''" @click="formData.taskType = 1"><img
src="./img/bigHorn-xz.png" alt="">定时播放
</div>
2021-11-15 10:29:05 +08:00
</div>
<div class="content" v-if="formData.taskType != 0">
<div class="item">
<div class="label">定时策略</div>
<div class="value" @click="selectClick('showCyclingType', cyclingTypeList)">
2021-12-15 14:37:20 +08:00
<span :class="formData.cyclingTypeName == '请选择' ? 'color-999' : ''">{{ formData.cyclingTypeName }}</span>
2021-11-15 10:29:05 +08:00
<img src="./img/right-icon.png" alt="">
</div>
</div>
</div>
<div class="radio-content" v-if="formData.taskType != 0 && formData.cyclingType == 2">
<div class="title">播放天数</div>
2021-12-15 14:37:20 +08:00
<div class="mini-item" :class="item.isCheck ? 'mini-active' : ''" v-for="(item, index) in dayList" :key="index"
@click="checkClick(index)">{{ item.label }}
</div>
2021-11-15 10:29:05 +08:00
</div>
<div class="content" v-if="formData.taskType != 0 && formData.cyclingType == 3">
<div class="item">
<div class="label">播放天数</div>
<div class="value">
2021-12-15 14:37:20 +08:00
<u-input type="text" placeholder="请输入" height="18" input-align="right" v-model="formData.broadcastDay"
maxlength="4"/>
2021-11-15 10:29:05 +08:00
</div>
</div>
</div>
<div class="content" v-if="formData.taskType != 0">
<div class="item">
<div class="label">开始日期</div>
<div class="value" @click="timeClick(true, 'showDate')">
2021-12-15 14:37:20 +08:00
<span :class="formData.startDate ? 'color-999' : ''">{{ formData.startDate || '请选择' }}</span>
2021-11-15 10:29:05 +08:00
<img src="./img/right-icon.png" alt="">
</div>
</div>
<div class="item">
<div class="label">开始时间</div>
<div class="value" @click="timeClick(false, 'showSatrt')">
2021-12-15 14:37:20 +08:00
<span :class="formData.startTime ? 'color-999' : ''">{{ formData.startTime || '请选择' }}</span>
2021-11-15 10:29:05 +08:00
<img src="./img/right-icon.png" alt="">
</div>
</div>
<div class="item">
<div class="label">结束时间</div>
<div class="value" @click="timeClick(false, 'showEnd')">
2021-12-15 14:37:20 +08:00
<span :class="formData.endTime ? 'color-999' : ''">{{ formData.endTime || '请选择' }}</span>
2021-11-15 10:29:05 +08:00
<img src="./img/right-icon.png" alt="">
</div>
</div>
</div>
<div class="btn" @click="addConfirm">确认</div>
2021-12-15 14:37:20 +08:00
<u-select v-model="showSelect" :list="selectList" @confirm="confirm" label-name="dictName"
value-name="dictValue"></u-select>
2021-11-15 10:29:05 +08:00
<u-picker v-model="showDateTime" mode="time" :params="params" @confirm="confirm"></u-picker>
2021-12-24 10:02:37 +08:00
2021-11-15 10:29:05 +08:00
</div>
</template>
2021-12-15 14:37:20 +08:00
<script>
2021-11-15 10:29:05 +08:00
export default {
name: "addPlay",
data() {
return {
showSelect: false,
selectList: [],
showMedia: false,
mediaList: [],
showEquipment: false,
equipmentList: [],
showMessageLevel: false,
messageLevelList: [],
showCyclingType: false,
cyclingTypeList: [],
formData: {
mediaId: '',
mediaName: '请选择',
serialNo: '',
serialName: '请选择',
messageLevel: '',
messageLevelName: '请选择',
taskType: '0',
cyclingTypeName: '请选择',
cyclingType: '',
startDate: '',
startTime: '',
endTime: '',
broadcastDay: '',
cyclingDate: ''
},
dayList: [
{
isCheck: false,
value: 1,
label: '每周一'
},
{
isCheck: false,
value: 2,
label: '每周二'
},
{
isCheck: false,
value: 3,
label: '每周三'
},
{
isCheck: false,
value: 4,
label: '每周四'
},
{
isCheck: false,
value: 5,
label: '每周五'
},
{
isCheck: false,
value: 6,
label: '每周六'
},
{
isCheck: false,
value: 7,
label: '每周日'
}
],
showDateTime: false,
showDate: false,
showSatrt: false,
showEnd: false,
params: {
year: true,
month: true,
day: true,
hour: false,
minute: false,
second: false
},
}
},
2021-12-15 14:37:20 +08:00
onLoad() {
2021-11-15 10:29:05 +08:00
uni.$on('choose', e => {
console.log(e)
this.formData.mediaId = e.mediaId
this.formData.mediaName = e.mediaName
})
2021-12-24 15:27:36 +08:00
},
onShow() {
document.title = '音频播放'
2021-11-15 10:29:05 +08:00
},
methods: {
2021-12-23 11:27:28 +08:00
nameClick() {
uni.navigateTo({url: '../AppResourcesManage/AppResourcesManage?isChoose=1'})
},
2021-11-15 10:29:05 +08:00
addConfirm() {
var cyclingDateList = []
this.dayList.map((item) => {
2021-12-15 14:37:20 +08:00
if (item.isCheck) {
2021-11-15 10:29:05 +08:00
cyclingDateList.push(item.value)
}
})
2021-12-15 14:37:20 +08:00
if (!this.formData.mediaId) {
2021-11-15 10:29:05 +08:00
return this.$u.toast('请选择播发内容')
}
2021-12-15 14:37:20 +08:00
if (!this.formData.serialNo) {
2021-11-15 10:29:05 +08:00
return this.$u.toast('请选择播放设备')
}
2021-12-15 14:37:20 +08:00
if (!this.formData.messageLevel) {
2021-11-15 10:29:05 +08:00
return this.$u.toast('播发级别')
}
//播放方式(定时播放)
2021-12-15 14:37:20 +08:00
if (this.formData.taskType != 0 && this.formData.startDate == '请选择') {
2021-11-15 10:29:05 +08:00
return this.$u.toast('请选择开始日期')
}
2021-12-15 14:37:20 +08:00
if (this.formData.taskType != 0 && this.formData.startTime == '请选择') {
2021-11-15 10:29:05 +08:00
return this.$u.toast('请选择开始时间')
}
2021-12-15 14:37:20 +08:00
if (this.formData.taskType != 0 && this.formData.endTime == '请选择') {
2021-11-15 10:29:05 +08:00
return this.$u.toast('请选择结束时间')
}
//播放方式(定时播放)定时策略(时长)
2021-12-15 14:37:20 +08:00
if (this.formData.taskType != 0 && this.formData.cyclingType == 3 && !this.formData.broadcastDay) {
2021-11-15 10:29:05 +08:00
return this.$u.toast('请输入播放天数')
}
//播放方式(定时播放)定时策略(自定义)
2021-12-15 14:37:20 +08:00
if (this.formData.taskType != 0 && this.formData.cyclingType == 2 && !cyclingDateList.length) {
2021-11-15 10:29:05 +08:00
return this.$u.toast('请选择播放天数')
}
2021-12-15 14:37:20 +08:00
if (this.formData.taskType != 0 && this.formData.cyclingType == 2) {
2021-11-15 10:29:05 +08:00
this.formData.cyclingDate = cyclingDateList.join(',')
}
this.formData.coverageType = '4'
this.$http.post(`/app/appzyvideobroadcast/play`, {...this.formData,}).then((res) => {
if (res.code == 0) {
this.$u.toast('提交成功')
setTimeout(() => {
uni.navigateBack()
}, 1000)
}
2021-12-15 14:37:20 +08:00
})
2021-11-15 10:29:05 +08:00
},
confirm(e) {
2021-12-15 14:37:20 +08:00
if (this.showMedia) {
2021-11-15 10:29:05 +08:00
this.formData.mediaId = e[0].value
this.formData.mediaName = e[0].label
}
2021-12-15 14:37:20 +08:00
if (this.showEquipment) {
2021-11-15 10:29:05 +08:00
this.formData.serialNo = e[0].value
this.formData.serialName = e[0].label
}
2021-12-15 14:37:20 +08:00
if (this.showMessageLevel) {
2021-11-15 10:29:05 +08:00
this.formData.messageLevel = e[0].value
this.formData.messageLevelName = e[0].label
}
2021-12-15 14:37:20 +08:00
if (this.showCyclingType) {
2021-11-15 10:29:05 +08:00
this.formData.cyclingType = e[0].value
this.formData.cyclingTypeName = e[0].label
}
2021-12-15 14:37:20 +08:00
if (this.showDate) {
2021-11-15 10:29:05 +08:00
this.formData.startDate = e.year + '-' + e.month + '-' + e.day
}
2021-12-15 14:37:20 +08:00
if (this.showSatrt) {
2021-11-15 10:29:05 +08:00
var startTime = e.hour + ':' + e.minute + ':' + e.second
var myDate = new Date();
2021-12-15 14:37:20 +08:00
var time = myDate.getHours() + ':' + myDate.getMinutes() + ':' + myDate.getSeconds()
2021-11-15 10:29:05 +08:00
if (this.timeToSec(startTime) - this.timeToSec(time) > 0) {
this.formData.startTime = startTime
2021-12-15 14:37:20 +08:00
} else {
2021-11-15 10:29:05 +08:00
this.$u.toast('开始时间要大于当前时间')
}
}
2021-12-15 14:37:20 +08:00
if (this.showEnd) {
2021-11-15 10:29:05 +08:00
var endTime = e.hour + ':' + e.minute + ':' + e.second
console.log(this.timeToSec(endTime), this.timeToSec(this.formData.startTime))
if (this.timeToSec(endTime) - this.timeToSec(this.formData.startTime) > 0) {
this.formData.endTime = endTime
} else {
this.$u.toast('结束时间要大于开始时间')
}
}
this.init()
},
init() {
this.showMedia = false
this.showEquipment = false
this.showMessageLevel = false
this.showCyclingType = false
this.showDate = false
this.showSatrt = false
this.showEnd = false
},
selectClick(showType, list) {
this.showSelect = true
this[showType] = true
this.selectList = list
},
getMediaList() {
this.$http.post(`/app/appdlbresource/list?current=1&size=10000`).then((res) => {
if (res.code == 0) {
this.mediaList = []
2021-12-15 14:37:20 +08:00
if (res.data && res.data.records.length) {
2021-11-15 10:29:05 +08:00
res.data.records.map((item) => {
let info = {
dictName: item.name,
dictValue: item.id
}
this.mediaList.push(info)
})
}
}
})
},
getEquipmentList() {
this.$http.post(`/app/appdlbquipment/getDlbDeviceList?current=1&size=10000&devStatus=5&keyword=`).then((res) => {
if (res.code == 0) {
this.equipmentList = []
2021-12-15 14:37:20 +08:00
if (res.data && res.data.records.length) {
2021-11-15 10:29:05 +08:00
res.data.records.map((item) => {
let info = {
dictName: item.deviceName,
dictValue: item.serialNo
}
this.equipmentList.push(info)
})
}
}
})
},
checkClick(index) {
this.dayList[index].isCheck = !this.dayList[index].isCheck
},
timeClick(showYear, showType) {
this[showType] = true
this.showDateTime = true
2021-12-15 14:37:20 +08:00
if (showYear) {
2021-11-15 10:29:05 +08:00
this.params = {
year: true,
month: true,
day: true,
hour: false,
minute: false,
second: false
}
2021-12-15 14:37:20 +08:00
} else {
2021-11-15 10:29:05 +08:00
this.params = {
year: false,
month: false,
day: false,
hour: true,
minute: true,
second: true
}
}
},
timeToSec(time) {
var s = "";
var hour = time.split(":")[0];
var min = time.split(":")[1];
2021-12-15 14:37:20 +08:00
var second = time.split(":")[2];
2021-11-15 10:29:05 +08:00
s = Number(hour * 3600) + Number(min * 60) + Number(second)
return s;
2021-12-15 14:37:20 +08:00
},
2021-11-15 10:29:05 +08:00
},
created() {
this.$dict.load('dlbMessageUrgency', 'dlbBroadTaskType', 'dlbDyclingType').then(() => {
this.getMediaList()
this.getEquipmentList()
this.messageLevelList = this.$dict.getDict('dlbMessageUrgency')
this.cyclingTypeList = this.$dict.getDict('dlbDyclingType')
})
},
}
</script>
<style lang="scss" scoped>
.addPlay {
padding-bottom: 128px;
2021-12-15 14:37:20 +08:00
.content {
2021-11-15 10:29:05 +08:00
padding-left: 32px;
background-color: #fff;
2021-12-15 14:37:20 +08:00
.item {
2021-11-15 10:29:05 +08:00
width: 100%;
padding: 34px 0;
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
line-height: 44px;
border-bottom: 1px solid #ddd;
display: flex;
color: #333;
justify-content: space-between;
2021-12-15 14:37:20 +08:00
.label {
2021-11-15 10:29:05 +08:00
width: 198px;
font-size: 32px;
}
2021-12-15 14:37:20 +08:00
.value {
2021-11-15 10:29:05 +08:00
display: flex;
align-items: center;
justify-content: flex-end;
font-size: 28px;
flex: 1;
padding-right: 32px;
max-width: calc(100% - 198px);
box-sizing: border-box;
text-align: right;
span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
2021-12-15 14:37:20 +08:00
img {
2021-11-15 10:29:05 +08:00
width: 32px;
height: 32px;
vertical-align: middle;
margin-left: 6px;
}
}
2021-12-15 14:37:20 +08:00
.color-999 {
2021-11-15 10:29:05 +08:00
color: #999;
}
}
}
2021-12-15 14:37:20 +08:00
.radio-content {
2021-11-15 10:29:05 +08:00
padding: 34px 32px 38px;
border-bottom: 1px solid #ddd;
background-color: #fff;
2021-12-15 14:37:20 +08:00
.title {
2021-11-15 10:29:05 +08:00
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333;
line-height: 44px;
margin-bottom: 54px;
2021-12-15 14:37:20 +08:00
span {
2021-11-15 10:29:05 +08:00
font-size: 24px;
font-weight: 400;
}
}
2021-12-15 14:37:20 +08:00
.item {
2021-11-15 10:29:05 +08:00
display: inline-block;
width: 320px;
height: 112px;
line-height: 112px;
text-align: center;
background: #F5F5F5;
border-radius: 4px;
font-size: 30px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333;
2021-12-15 14:37:20 +08:00
img {
2021-11-15 10:29:05 +08:00
display: none;
}
}
2021-12-15 14:37:20 +08:00
.active {
2021-11-15 10:29:05 +08:00
background: #E7F1FE;
color: #1174FE;
position: relative;
2021-12-15 14:37:20 +08:00
img {
2021-11-15 10:29:05 +08:00
display: inline-block;
position: absolute;
bottom: 0;
right: 0;
width: 46px;
height: 46px;
}
}
2021-12-15 14:37:20 +08:00
2021-11-15 10:29:05 +08:00
.mar-r50 {
margin-right: 50px;
}
2021-12-15 14:37:20 +08:00
.mini-item {
2021-11-15 10:29:05 +08:00
display: inline-block;
width: 128px;
height: 72px;
line-height: 72px;
text-align: center;
background: #F9F9F9;
border-radius: 16px;
color: #333;
font-size: 28px;
margin-right: 58px;
margin-bottom: 32px;
}
2021-12-15 14:37:20 +08:00
2021-11-15 10:29:05 +08:00
.mini-item:nth-of-type(5) {
margin-right: 0;
}
2021-12-15 14:37:20 +08:00
.mini-active {
2021-11-15 10:29:05 +08:00
background: #F2F8FE;
border: 1px solid #89B2EE;
box-sizing: border-box;
}
}
2021-12-15 14:37:20 +08:00
.btn {
2021-11-15 10:29:05 +08:00
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 112px;
line-height: 112px;
text-align: center;
background: #3975C6;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
}
}
2021-12-15 14:37:20 +08:00
</style>