327 lines
14 KiB
Vue
327 lines
14 KiB
Vue
<!-- eslint-disable vue/valid-v-slot -->
|
|
<template>
|
|
<div class="outer">
|
|
<!-- 按钮 -->
|
|
<div class="buttonBox">
|
|
<el-button @click="addClick()" class="primary" type="primary" size="default"
|
|
style="margin-right: 10px">新增</el-button>
|
|
</div>
|
|
<!-- 表格 -->
|
|
<el-table :data="tableData" border style="width: 100%; margin-top: 25px">
|
|
<el-table-column align="center" prop="id" label="资源位ID" />
|
|
<el-table-column align="center" prop="name" label="活动名称" />
|
|
<el-table-column align="center" prop="url" label="开屏页" width="200">
|
|
<template v-slot="scope">
|
|
<el-image style="width: 100%; height: 100px" :src="scope.row.url" :zoom-rate="1.1"
|
|
:preview-src-list="[scope.row.url]" fit="cover" preview-teleported="true"
|
|
hide-on-click-modal="true" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="center" prop="skipType" label="跳转">
|
|
<template v-slot="scope">
|
|
<span>{{ scope.row.skipType == 1 ? "native" : (scope.row.skipType == 2 ? "H5" : scope.row.skipType == 3
|
|
? "房间" : "") }}</span>
|
|
<br />
|
|
<span>{{ scope.row.skipContent }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="center" prop="USER_LEVEL" label="可见等级" :formatter="ruleJsonFormatter" />
|
|
<el-table-column align="center" prop="PLATFORM" label="生效平台" :formatter="ruleJsonFormatter" />
|
|
<el-table-column align="center" prop="IOS" label="iOS版本号" :formatter="ruleJsonFormatter" />
|
|
<el-table-column align="center" prop="ANDROID" label="安卓版本号" :formatter="ruleJsonFormatter" />
|
|
<el-table-column align="center" prop="NOT_CHANNELS" label="不展示渠道" :formatter="ruleJsonFormatter" />
|
|
<el-table-column align="center" label="操作" width="200">
|
|
<template v-slot="scope">
|
|
<el-button @click="editClick(scope.row)" class="primary" type="primary" size="default">编辑</el-button>
|
|
<el-button @click="delClick(scope.row)" class="danger" type="danger" size="default">删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<!-- 分页 -->
|
|
<el-pagination style="margin-top: 10px" class="paginationClass" v-model:current-page="currentPage"
|
|
v-model:page-size="pageSize" :page-sizes="[10, 20, 30, 40, 50, 100, 200, 300, 400, 500]" :small="small"
|
|
:disabled="disabled" :background="background" layout="sizes, prev, pager, next" :total="totals"
|
|
@size-change="handleSizeChange" @current-change="handleCurrentChange" />
|
|
<!-- 编辑弹窗 -->
|
|
<el-dialog v-model="editDialog" title="开屏配置" width="50%" center>
|
|
<div style="margin-bottom: 25px">
|
|
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">活动名称</span>
|
|
<el-input v-model="resource.name" style="width: 75%" class="input" placeholder="请输入活动名称"></el-input>
|
|
</div>
|
|
<div style="margin-bottom: 25px">
|
|
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">开屏页</span>
|
|
<input type="hidden" class="form-control" name="avatar" v-model="resource.url" />
|
|
<img :src="resource.url" style="width:120px;"/>
|
|
<input type="file" style="width: 26%; display: inline-block;" id="urlFile" name="urlFile"/>
|
|
</div>
|
|
<div style="margin-bottom: 25px">
|
|
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label"></span>
|
|
<button class="btn btn-success col-sm-4" type="button" id="urlUploadBtn">上传</button>
|
|
<span class="btn col-sm-4" id="urlUploadInfo" style="color:red;"></span>
|
|
</div>
|
|
<div style="margin-bottom: 25px;margin-top: 70px;">
|
|
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">跳转位置</span>
|
|
<el-select v-model="resource.skipType" style="width: 75%" placeholder="请选择">
|
|
<el-option v-for="item in options" :key="item.value" :label="item.label"
|
|
:value="item.value"></el-option>
|
|
</el-select>
|
|
</div>
|
|
<div style="margin-bottom: 25px" v-if="resource.skipType == 2 || resource.skipType == 3">
|
|
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">{{ resource.skipType == 2 ? "跳转链接" :
|
|
(resource.skipType == 3 ? "跳转房间" : "") }}</span>
|
|
<el-input v-model="resource.skipContent" style="width: 75%" class="input"
|
|
:placeholder="[resource.skipType == 2 ? '请输入跳转链接' : (resource.skipType == 3 ? '请输入房间ID' : '')]"></el-input>
|
|
</div>
|
|
<div style="margin-bottom: 25px;">
|
|
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">生效时间</span>
|
|
<el-date-picker v-model="resource.startTime" type="datetime" placeholder="选择日期时间">
|
|
</el-date-picker>
|
|
</div>
|
|
<div style="margin-bottom: 25px">
|
|
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">失效时间</span>
|
|
<el-date-picker v-model="resource.endTime" type="datetime" placeholder="选择日期时间">
|
|
</el-date-picker>
|
|
</div>
|
|
<div style="margin-bottom: 25px">
|
|
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">排序</span>
|
|
<el-input v-model="resource.seqNo" style="width: 75%" class="input" placeholder="请输入排序"></el-input>
|
|
</div>
|
|
<div style="margin-bottom: 25px" v-for="(rule, index) in rules" :key="rule" :index="index">
|
|
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">{{ rule.ruleName }}</span>
|
|
<el-input v-model="resource.ruleValue[rule.ruleCode]" style="width: 75%" class="input" :placeholder="rule.description" v-if="rule.ruleKind != 'IN'"></el-input>
|
|
<el-select v-model="resource.ruleValue[rule.ruleCode]" style="width: 75%" placeholder="请选择" v-if="rule.ruleKind == 'IN'">
|
|
<el-option label="全部" :value="''"></el-option>
|
|
<el-option v-for="value in rule.ruleValue.split(',')" :key="value" :label="value" :value="value"></el-option>
|
|
</el-select>
|
|
</div>
|
|
<template #footer>
|
|
<span class="dialog-footer">
|
|
<el-button @click="editDialog = false">取消</el-button>
|
|
<el-button type="primary" @click="editDialogClick()"> 确认 </el-button>
|
|
</span>
|
|
</template>
|
|
</el-dialog>
|
|
<!-- 公共二次确认删除弹窗 -->
|
|
<el-dialog v-model="delDialog" title="提示" width="30%" center>
|
|
<span> {{ delDialogText }}</span>
|
|
<template #footer>
|
|
<span class="dialog-footer">
|
|
<el-button @click="delDialog = false">取消</el-button>
|
|
<el-button type="primary" @click="delClick()"> 确认 </el-button>
|
|
</span>
|
|
</template>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { getResourcePage, delResource, saveResource, effective } from "@/api/resource/resource";
|
|
import { getResourceRuleList } from '@/api/resource/resourceRule';
|
|
import { uploadFile } from '@/api/common/upload';
|
|
|
|
export default {
|
|
name: "SplashView",
|
|
data() {
|
|
return {
|
|
totals: 100, //总页数
|
|
currentPage: 1, //页码
|
|
pageSize: 10, //条数
|
|
delDialog: false,
|
|
delDialogText: "确认要删除资源位吗?",
|
|
editDialog: false,
|
|
options: [
|
|
{
|
|
value: 0,
|
|
label: "无"
|
|
},
|
|
{
|
|
value: 1,
|
|
label: "APP首页"
|
|
},
|
|
{
|
|
value: 2,
|
|
label: "H5"
|
|
},
|
|
{
|
|
value: 3,
|
|
label: "房间内"
|
|
}
|
|
],
|
|
tableData: [], //表单数据存放
|
|
rules: [],
|
|
resource: {
|
|
id: null,
|
|
name: '',
|
|
icon: '',
|
|
skipType: 0,
|
|
skipContent: '',
|
|
url: '',
|
|
startTime: null,
|
|
endTime: null,
|
|
seqNo: 0,
|
|
ruleValue: {}
|
|
},
|
|
imageUrl: '',
|
|
};
|
|
},
|
|
setup() {
|
|
return {};
|
|
},
|
|
created() {
|
|
this.init();
|
|
this.getRule();
|
|
this.getData();
|
|
},
|
|
methods: {
|
|
init() {
|
|
this.$nextTick(function () {
|
|
let $this = this;
|
|
$('#urlUploadBtn').click(function () {
|
|
uploadFile('urlFile').then(res => {
|
|
if (res.path) {
|
|
$this.resource.url = res.path;
|
|
$('#urlUploadInfo').val('上传成功');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
},
|
|
getRule() {
|
|
getResourceRuleList({
|
|
ruleType: 1
|
|
}).then(res => {
|
|
this.rules = res.data;
|
|
});
|
|
},
|
|
ruleJsonFormatter(row, col, cell, index) {
|
|
let value = '';
|
|
let key = col.property;
|
|
let ruleValue = row.ruleValue;
|
|
if (!ruleValue) {
|
|
return value;
|
|
}
|
|
let ruleObj = JSON.parse(ruleValue);
|
|
value = ruleObj[key];
|
|
if (!value) {
|
|
value = '全部';
|
|
}
|
|
if (key == 'IOS') {
|
|
value = ruleObj['IOS_LOW_VERSION'] + '~' + ruleObj['IOS_HIGH_VERSION'];
|
|
} else if (key == 'ANDROID') {
|
|
value = ruleObj['ANDROID_LOW_VERSION'] + '~' + ruleObj['ANDROID_HIGH_VERSION'];
|
|
}
|
|
return value;
|
|
},
|
|
getData() {
|
|
getResourcePage({
|
|
type: 2,
|
|
page: this.currentPage,
|
|
pageSize: this.pageSize,
|
|
}).then(res => {
|
|
let data = res.data;
|
|
this.totals = data.total;
|
|
this.tableData = data.records.map(v => {
|
|
v['enabled'] = (v.isEnabled == 1);
|
|
return v;
|
|
});
|
|
console.log(this.tableData);
|
|
});
|
|
},
|
|
switchClick(id) {
|
|
effective({
|
|
id: id
|
|
}).then(res => {
|
|
this.getData();
|
|
});
|
|
},
|
|
addClick() {
|
|
this.resource.id = null;
|
|
this.resource.name = '';
|
|
this.resource.icon = '';
|
|
this.resource.skipType = 0;
|
|
this.resource.skipContent = '';
|
|
this.resource.url = '';
|
|
this.resource.startTime = null;
|
|
this.resource.endTime = null;
|
|
this.resource.seqNo = 0;
|
|
this.resource.ruleValue = {};
|
|
for (let i = 0, len = this.rules.length; i < len; i++) {
|
|
let rule = this.rules[i];
|
|
this.resource.ruleValue[rule.ruleCode] = '';
|
|
}
|
|
this.editDialog = true;
|
|
},
|
|
editClick(row) {
|
|
this.resource.id = row.id;
|
|
this.resource.name = row.name;
|
|
this.resource.icon = row.icon;
|
|
this.resource.skipType = row.skipType;
|
|
this.resource.skipContent = row.skipContent;
|
|
this.resource.url = row.url;
|
|
this.resource.startTime = row.startTime;
|
|
this.resource.endTime = row.endTime;
|
|
this.resource.seqNo = row.seqNo;
|
|
let ruleValue = row.ruleValue;
|
|
if (ruleValue) {
|
|
let ruleObj = JSON.parse(ruleValue);
|
|
for (let i = 0, len = this.rules.length; i < len; i++) {
|
|
let ruleCode = this.rules[i].ruleCode;
|
|
this.resource.ruleValue[ruleCode] = ruleObj[ruleCode];
|
|
}
|
|
}
|
|
this.editDialog = true;
|
|
},
|
|
editDialogClick() {
|
|
let startTime = this.resource.startTime;
|
|
if (startTime) {
|
|
this.resource.startTime = new Date(startTime).format("yyyy-MM-dd hh:mm:ss");
|
|
}
|
|
let endTime = this.resource.endTime;
|
|
if (endTime) {
|
|
this.resource.endTime = new Date(endTime).format("yyyy-MM-dd hh:mm:ss");
|
|
}
|
|
saveResource({
|
|
id: this.resource.id,
|
|
name: this.resource.name,
|
|
icon: this.resource.icon,
|
|
type: 2,
|
|
skipType: this.resource.skipType,
|
|
skipContent: this.resource.skipContent,
|
|
url: this.resource.url,
|
|
startTime: this.resource.startTime,
|
|
endTime: this.resource.endTime,
|
|
seqNo: this.resource.seqNo,
|
|
ruleValue: JSON.stringify(this.resource.ruleValue)
|
|
}).then(res => {
|
|
this.getData();
|
|
this.editDialog = false;
|
|
});
|
|
},
|
|
delClick(row) {
|
|
delResource({
|
|
id: row.id,
|
|
}).then((res) => {
|
|
this.getData();
|
|
this.delDialog = false;
|
|
});
|
|
},
|
|
// 分页导航
|
|
handleSizeChange(val) {
|
|
this.getData();
|
|
},
|
|
handleCurrentChange(val) {
|
|
this.getData();
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
.outer {
|
|
padding-top: 20px;
|
|
background: #ecf0f5;
|
|
border-top: 3px solid #d2d6de;
|
|
}
|
|
</style>
|