|
@@ -1,27 +1,183 @@
|
|
<template>
|
|
<template>
|
|
<div id="index">
|
|
<div id="index">
|
|
<el-row>
|
|
<el-row>
|
|
- <el-col :span="24">
|
|
|
|
- <p>视频管理</p>
|
|
|
|
|
|
+ <el-col :span="24" class="video">
|
|
|
|
+ <el-col :span="24" class="leftTop">
|
|
|
|
+ <span>|</span>
|
|
|
|
+ <span>视频管理</span>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24" class="info">
|
|
|
|
+ <span v-if="display == 'list'">
|
|
|
|
+ <el-col :span="24" class="btn">
|
|
|
|
+ <el-button type="primary" size="mini" @click="display = 'detail'">添加信息</el-button>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24" class="list">
|
|
|
|
+ <data-table :fields="fields" :data="list" :total="total" @query="search" :opera="opera" @edit="toEdit" @delete="toDelete"></data-table>
|
|
|
|
+ </el-col>
|
|
|
|
+ </span>
|
|
|
|
+ <span v-else>
|
|
|
|
+ <el-col :span="24" class="btn">
|
|
|
|
+ <el-button type="primary" size="mini" @click="back()">返回</el-button>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24" class="detail">
|
|
|
|
+ <data-form :data="form" :fields="formFields" @save="toSave" :rules="rules">
|
|
|
|
+ <template #custom="{item, form}">
|
|
|
|
+ <template v-if="item.model === 'file_path'">
|
|
|
|
+ <upload
|
|
|
|
+ :limit="1"
|
|
|
|
+ :data="form.file_path"
|
|
|
|
+ type="file_path"
|
|
|
|
+ listType=""
|
|
|
|
+ :url="'/files/filepath/upload'"
|
|
|
|
+ @upload="uploadSuccess"
|
|
|
|
+ @delete="uploadDelete"
|
|
|
|
+ ></upload>
|
|
|
|
+ </template>
|
|
|
|
+ <template v-else-if="item.model === 'start_time'">
|
|
|
|
+ <el-date-picker
|
|
|
|
+ v-model="form.start_time"
|
|
|
|
+ type="datetime"
|
|
|
|
+ placeholder="请选择开始时间"
|
|
|
|
+ format="yyyy-MM-dd HH:mm"
|
|
|
|
+ value-format="yyyy-MM-dd HH:mm"
|
|
|
|
+ >
|
|
|
|
+ </el-date-picker>
|
|
|
|
+ </template>
|
|
|
|
+ <template v-else-if="item.model === 'end_time'">
|
|
|
|
+ <el-date-picker
|
|
|
|
+ v-model="form.end_time"
|
|
|
|
+ type="datetime"
|
|
|
|
+ placeholder="请选择开始时间"
|
|
|
|
+ format="yyyy-MM-dd HH:mm"
|
|
|
|
+ value-format="yyyy-MM-dd HH:mm"
|
|
|
|
+ >
|
|
|
|
+ </el-date-picker>
|
|
|
|
+ </template>
|
|
|
|
+ </template>
|
|
|
|
+ </data-form>
|
|
|
|
+ </el-col>
|
|
|
|
+ </span>
|
|
|
|
+ </el-col>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+import upload from '@/components/uploaddock.vue';
|
|
|
|
+import dataTable from '@/components/data-table.vue';
|
|
|
|
+import dataForm from '@/components/form.vue';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions: channelVideo } = createNamespacedHelpers('channelVideo');
|
|
export default {
|
|
export default {
|
|
metaInfo() {
|
|
metaInfo() {
|
|
return { title: this.$route.meta.title };
|
|
return { title: this.$route.meta.title };
|
|
},
|
|
},
|
|
name: 'index',
|
|
name: 'index',
|
|
props: {},
|
|
props: {},
|
|
- components: {},
|
|
|
|
|
|
+ components: {
|
|
|
|
+ dataTable,
|
|
|
|
+ dataForm,
|
|
|
|
+ upload,
|
|
|
|
+ },
|
|
data: function() {
|
|
data: function() {
|
|
- return {};
|
|
|
|
|
|
+ return {
|
|
|
|
+ display: 'list',
|
|
|
|
+ opera: [
|
|
|
|
+ {
|
|
|
|
+ label: '编辑',
|
|
|
|
+ icon: 'el-icon-edit',
|
|
|
|
+ method: 'edit',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '删除',
|
|
|
|
+ icon: 'el-icon-delete',
|
|
|
|
+ method: 'delete',
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ fields: [
|
|
|
|
+ { label: '标题', prop: 'title' },
|
|
|
|
+ { label: '开始时间', prop: 'start_time' },
|
|
|
|
+ { label: '结束时间', prop: 'end_time' },
|
|
|
|
+ ],
|
|
|
|
+ list: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ // 添加信息
|
|
|
|
+ form: {},
|
|
|
|
+ rules: {},
|
|
|
|
+ formFields: [
|
|
|
|
+ { label: '标题', model: 'title' },
|
|
|
|
+ { label: '开始时间', model: 'start_time', custom: true },
|
|
|
|
+ { label: '结束时间', model: 'end_time', custom: true },
|
|
|
|
+ { label: '视频文件', model: 'file_path', custom: true },
|
|
|
|
+ ],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ async created() {
|
|
|
|
+ await this.search();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ ...channelVideo(['query', 'delete', 'update', 'create']),
|
|
|
|
+ // 查询
|
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
|
+ let res = await this.query({ skip, limit, user_id: this.user.id });
|
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
|
+ },
|
|
|
|
+ // 修改
|
|
|
|
+ toEdit({ data }) {
|
|
|
|
+ this.$set(this, `form`, data);
|
|
|
|
+ this.display = 'detail';
|
|
|
|
+ },
|
|
|
|
+ // 提交
|
|
|
|
+ async toSave({ data }) {
|
|
|
|
+ if (data.id) {
|
|
|
|
+ let res = await this.update(data);
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$checkRes(res, '修改成功', '修改失败');
|
|
|
|
+ this.back();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ data.user_id = this.user.id;
|
|
|
|
+ let res = await this.create(data);
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$checkRes(res, '创建成功', '创建失败');
|
|
|
|
+ this.back();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 删除
|
|
|
|
+ toDelete({ data }) {
|
|
|
|
+ this.$confirm('您确定要删除此信息吗?', '提示', {
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'warning',
|
|
|
|
+ })
|
|
|
|
+ .then(async () => {
|
|
|
|
+ let res = await this.delete(data.id);
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: '删除信息成功',
|
|
|
|
+ type: 'success',
|
|
|
|
+ });
|
|
|
|
+ this.search();
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {});
|
|
|
|
+ },
|
|
|
|
+ // 返回
|
|
|
|
+ back() {
|
|
|
|
+ this.form = {};
|
|
|
|
+ this.display = 'list';
|
|
|
|
+ this.search();
|
|
|
|
+ },
|
|
|
|
+ uploadSuccess({ type, data }) {
|
|
|
|
+ this.$set(this.form, `${type}`, data.uri);
|
|
|
|
+ },
|
|
|
|
+ uploadDelete(index) {
|
|
|
|
+ this.$set(this.form, `file_path`, null);
|
|
|
|
+ },
|
|
},
|
|
},
|
|
- created() {},
|
|
|
|
- methods: {},
|
|
|
|
computed: {
|
|
computed: {
|
|
...mapState(['user']),
|
|
...mapState(['user']),
|
|
},
|
|
},
|
|
@@ -29,4 +185,26 @@ export default {
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
|
|
|
|
-<style lang="less" scoped></style>
|
|
|
|
|
|
+<style lang="less" scoped>
|
|
|
|
+.leftTop {
|
|
|
|
+ font-size: 18px;
|
|
|
|
+ width: 96%;
|
|
|
|
+ height: 41px;
|
|
|
|
+ line-height: 35px;
|
|
|
|
+ border-bottom: 1px solid #e5e5e5;
|
|
|
|
+ position: relative;
|
|
|
|
+ bottom: 1px;
|
|
|
|
+ margin: 10px;
|
|
|
|
+ font-weight: 600;
|
|
|
|
+ color: #22529a;
|
|
|
|
+}
|
|
|
|
+.info {
|
|
|
|
+ margin: 0 40px 15px 10px;
|
|
|
|
+ width: 96%;
|
|
|
|
+ padding: 10px;
|
|
|
|
+ .btn {
|
|
|
|
+ text-align: right;
|
|
|
|
+ margin: 10px 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|