|
@@ -1,183 +1,191 @@
|
|
-<template>
|
|
|
|
- <div id="aRoadShow">
|
|
|
|
- <el-row>
|
|
|
|
- <el-col :span="24">
|
|
|
|
- <el-col :span="24" class="leftTop"> <span>|</span> <span>项目路演</span> </el-col>
|
|
|
|
- <el-col :span="24" class="info">
|
|
|
|
- <template v-if="view == 'list'">
|
|
|
|
- <el-col :span="24" class="add">
|
|
|
|
- <el-button type="primary" size="mini" @click="view = 'detail'">添加信息</el-button>
|
|
|
|
- </el-col>
|
|
|
|
- <el-col :span="24" class="list">
|
|
|
|
- <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit" @delete="toDelete"></data-table>
|
|
|
|
- </el-col>
|
|
|
|
- </template>
|
|
|
|
- <template v-else>
|
|
|
|
- <el-col :span="24">
|
|
|
|
- <el-col :span="24" class="back">
|
|
|
|
- <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
|
|
|
|
- </el-col>
|
|
|
|
- <el-col :span="24">
|
|
|
|
- <data-form :fields="fields" v-model="form" @save="toSave">
|
|
|
|
- <template #custom="{item, form}">
|
|
|
|
- <template v-if="item.model === 'picture'">
|
|
|
|
- <upload
|
|
|
|
- :limit="1"
|
|
|
|
- :data="form.picture"
|
|
|
|
- type="picture"
|
|
|
|
- :url="'/files/imgpath/upload'"
|
|
|
|
- @upload="uploadSuccess"
|
|
|
|
- @delete="uploadDelete"
|
|
|
|
- ></upload>
|
|
|
|
- </template>
|
|
|
|
- <template v-if="item.model === 'filepath'">
|
|
|
|
- <upload
|
|
|
|
- :limit="1"
|
|
|
|
- :data="form.filepath"
|
|
|
|
- type="filepath"
|
|
|
|
- listType=""
|
|
|
|
- :url="'/files/imgpath/upload'"
|
|
|
|
- @upload="uploadSuccess"
|
|
|
|
- @delete="uploadDelete"
|
|
|
|
- ></upload>
|
|
|
|
- </template>
|
|
|
|
- </template>
|
|
|
|
- </data-form>
|
|
|
|
- </el-col>
|
|
|
|
- </el-col>
|
|
|
|
- </template>
|
|
|
|
- </el-col>
|
|
|
|
- </el-col>
|
|
|
|
- </el-row>
|
|
|
|
- </div>
|
|
|
|
-</template>
|
|
|
|
-
|
|
|
|
-<script>
|
|
|
|
-import dataTable from '@common/src/components/frame/filter-page-table.vue';
|
|
|
|
-import dataForm from '@common/src/components/frame/vform.vue';
|
|
|
|
-import upload from '@common/src/components/frame/upload.vue';
|
|
|
|
-import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
-const { mapActions: roadShow } = createNamespacedHelpers('roadShow');
|
|
|
|
-export default {
|
|
|
|
- name: 'aRoadShow',
|
|
|
|
- props: {},
|
|
|
|
- components: { dataTable, dataForm, upload },
|
|
|
|
- data: function() {
|
|
|
|
- return {
|
|
|
|
- view: 'list',
|
|
|
|
- opera: [
|
|
|
|
- {
|
|
|
|
- label: '编辑',
|
|
|
|
- method: 'edit',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '删除',
|
|
|
|
- type: 'danger',
|
|
|
|
- method: 'delete',
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- fields: [
|
|
|
|
- { label: '信息标题', prop: 'title', model: 'title', filter: true },
|
|
|
|
- { label: '来源', prop: 'origin', model: 'origin' },
|
|
|
|
- { label: '图片', model: 'picture', custom: true, notable: true },
|
|
|
|
- { label: '视频', model: 'filepath', custom: true, notable: true },
|
|
|
|
- { label: '发布时间', prop: 'publish_time', model: 'publish_time', type: 'date' },
|
|
|
|
- { label: '简介', prop: 'brief', model: 'brief', type: 'textarea' },
|
|
|
|
- ],
|
|
|
|
- list: [],
|
|
|
|
- total: 0,
|
|
|
|
- form: {},
|
|
|
|
- };
|
|
|
|
- },
|
|
|
|
- created() {
|
|
|
|
- this.search();
|
|
|
|
- },
|
|
|
|
- methods: {
|
|
|
|
- ...roadShow(['query', 'create', 'update', 'delete']),
|
|
|
|
- async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
|
- const res = await this.query({ skip, limit, dock_id: this.user.id, ...info });
|
|
|
|
- if (this.$checkRes(res)) {
|
|
|
|
- this.$set(this, `list`, res.data);
|
|
|
|
- this.$set(this, `total`, res.total);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- async toSave() {
|
|
|
|
- const dup = _.cloneDeep(this.form);
|
|
|
|
- let res;
|
|
|
|
- if (dup._id) {
|
|
|
|
- res = await this.update(dup);
|
|
|
|
- } else {
|
|
|
|
- dup.dock_id = this.user.id;
|
|
|
|
- res = await this.create(dup);
|
|
|
|
- }
|
|
|
|
- if (this.$checkRes(res, '嘉宾访谈保存成功', res.errmsg || '嘉宾访谈保存失败')) {
|
|
|
|
- this.search();
|
|
|
|
- this.toBack();
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- toEdit({ data }) {
|
|
|
|
- this.view = 'detail';
|
|
|
|
- this.$set(this, `form`, data);
|
|
|
|
- },
|
|
|
|
- toDelete({ data }) {
|
|
|
|
- this.$confirm('您确定要删除此用户吗?', '提示', {
|
|
|
|
- confirmButtonText: '确定',
|
|
|
|
- cancelButtonText: '取消',
|
|
|
|
- type: 'warning',
|
|
|
|
- })
|
|
|
|
- .then(async () => {
|
|
|
|
- const res = await this.delete(data._id);
|
|
|
|
- if (this.$checkRes(res, '嘉宾访谈删除成功', res.errmsg || '嘉宾访谈删除失败')) {
|
|
|
|
- this.search();
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- .catch(() => {});
|
|
|
|
- },
|
|
|
|
- toBack() {
|
|
|
|
- this.view = 'list';
|
|
|
|
- this.form = {};
|
|
|
|
- },
|
|
|
|
- uploadSuccess({ type, data }) {
|
|
|
|
- this.$set(this.form, `${type}`, data.uri);
|
|
|
|
- },
|
|
|
|
- uploadDelete({ type }) {
|
|
|
|
- this.$set(this.form, type, null);
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- computed: {
|
|
|
|
- ...mapState(['user', 'menuParams']),
|
|
|
|
- pageTitle() {
|
|
|
|
- return `${this.$route.meta.title}`;
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- metaInfo() {
|
|
|
|
- return { title: this.$route.meta.title };
|
|
|
|
- },
|
|
|
|
-};
|
|
|
|
-</script>
|
|
|
|
-
|
|
|
|
-<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 {
|
|
|
|
- padding: 0 40px 0 10px;
|
|
|
|
- .add {
|
|
|
|
- text-align: right;
|
|
|
|
- padding: 10px 0;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-.back {
|
|
|
|
- text-align: right;
|
|
|
|
- padding: 10px 0;
|
|
|
|
-}
|
|
|
|
-</style>
|
|
|
|
|
|
+<template>
|
|
|
|
+ <div id="aRoadShow">
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <el-col :span="24" class="leftTop"> <span>|</span> <span>项目路演</span> </el-col>
|
|
|
|
+ <el-col :span="24" class="info">
|
|
|
|
+ <template v-if="view == 'list'">
|
|
|
|
+ <el-col :span="24" class="add">
|
|
|
|
+ <el-button type="primary" size="mini" @click="view = 'detail'">添加信息</el-button>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24" class="list">
|
|
|
|
+ <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit" @delete="toDelete"></data-table>
|
|
|
|
+ </el-col>
|
|
|
|
+ </template>
|
|
|
|
+ <template v-else>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <el-col :span="24" class="back">
|
|
|
|
+ <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <data-form :fields="fieldsForm" v-model="form" @save="toSave">
|
|
|
|
+ <template #custom="{item, form}">
|
|
|
|
+ <template v-if="item.model === 'picture'">
|
|
|
|
+ <upload
|
|
|
|
+ :limit="1"
|
|
|
|
+ :data="form.picture"
|
|
|
|
+ type="picture"
|
|
|
|
+ :url="'/files/imgpath/upload'"
|
|
|
|
+ @upload="uploadSuccess"
|
|
|
|
+ @delete="uploadDelete"
|
|
|
|
+ ></upload>
|
|
|
|
+ </template>
|
|
|
|
+ <template v-if="item.model === 'filepath'">
|
|
|
|
+ <upload
|
|
|
|
+ :limit="1"
|
|
|
|
+ :data="form.filepath"
|
|
|
|
+ type="filepath"
|
|
|
|
+ listType=""
|
|
|
|
+ :url="'/files/imgpath/upload'"
|
|
|
|
+ @upload="uploadSuccess"
|
|
|
|
+ @delete="uploadDelete"
|
|
|
|
+ ></upload>
|
|
|
|
+ </template>
|
|
|
|
+ </template>
|
|
|
|
+ </data-form>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-col>
|
|
|
|
+ </template>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import dataTable from '@common/src/components/frame/filter-page-table.vue';
|
|
|
|
+import dataForm from '@common/src/components/frame/vform.vue';
|
|
|
|
+import upload from '@common/src/components/frame/upload.vue';
|
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions: roadShow } = createNamespacedHelpers('roadShow');
|
|
|
|
+export default {
|
|
|
|
+ name: 'aRoadShow',
|
|
|
|
+ props: {},
|
|
|
|
+ components: { dataTable, dataForm, upload },
|
|
|
|
+ data: function() {
|
|
|
|
+ return {
|
|
|
|
+ view: 'list',
|
|
|
|
+ opera: [
|
|
|
|
+ {
|
|
|
|
+ label: '编辑',
|
|
|
|
+ method: 'edit',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '删除',
|
|
|
|
+ type: 'danger',
|
|
|
|
+ method: 'delete',
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ fields: [
|
|
|
|
+ { label: '信息标题', prop: 'title', model: 'title' },
|
|
|
|
+ { label: '来源', prop: 'origin', model: 'origin' },
|
|
|
|
+ { label: '图片', model: 'picture', custom: true, notable: true },
|
|
|
|
+ { label: '视频', model: 'filepath', custom: true, notable: true },
|
|
|
|
+ { label: '发布时间', prop: 'publish_time', model: 'publish_time', type: 'date' },
|
|
|
|
+ { label: '简介', prop: 'brief', model: 'brief', type: 'textarea' },
|
|
|
|
+ ],
|
|
|
|
+ fieldsForm: [
|
|
|
|
+ { label: '信息标题', model: 'title' },
|
|
|
|
+ { label: '来源', model: 'origin' },
|
|
|
|
+ { label: '简介', model: 'brief', type: 'textarea' },
|
|
|
|
+ { label: '发布时间', model: 'publish_time', type: 'date' },
|
|
|
|
+ { label: '图片', model: 'picture', custom: true },
|
|
|
|
+ { label: '视频', model: 'filepath', custom: true },
|
|
|
|
+ ],
|
|
|
|
+ list: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ form: {},
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.search();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ ...roadShow(['query', 'create', 'update', 'delete']),
|
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
|
+ const res = await this.query({ skip, limit, dock_id: this.user.id, ...info });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ async toSave() {
|
|
|
|
+ const dup = _.cloneDeep(this.form);
|
|
|
|
+ let res;
|
|
|
|
+ if (dup._id) {
|
|
|
|
+ res = await this.update(dup);
|
|
|
|
+ } else {
|
|
|
|
+ dup.dock_id = this.user.id;
|
|
|
|
+ res = await this.create(dup);
|
|
|
|
+ }
|
|
|
|
+ if (this.$checkRes(res, '嘉宾访谈保存成功', res.errmsg || '嘉宾访谈保存失败')) {
|
|
|
|
+ this.search();
|
|
|
|
+ this.toBack();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ toEdit({ data }) {
|
|
|
|
+ this.view = 'detail';
|
|
|
|
+ this.$set(this, `form`, data);
|
|
|
|
+ },
|
|
|
|
+ toDelete({ data }) {
|
|
|
|
+ this.$confirm('您确定要删除此用户吗?', '提示', {
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'warning',
|
|
|
|
+ })
|
|
|
|
+ .then(async () => {
|
|
|
|
+ const res = await this.delete(data._id);
|
|
|
|
+ if (this.$checkRes(res, '嘉宾访谈删除成功', res.errmsg || '嘉宾访谈删除失败')) {
|
|
|
|
+ this.search();
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {});
|
|
|
|
+ },
|
|
|
|
+ toBack() {
|
|
|
|
+ this.view = 'list';
|
|
|
|
+ this.form = {};
|
|
|
|
+ },
|
|
|
|
+ uploadSuccess({ type, data }) {
|
|
|
|
+ this.$set(this.form, `${type}`, data.uri);
|
|
|
|
+ },
|
|
|
|
+ uploadDelete({ type }) {
|
|
|
|
+ this.$set(this.form, type, null);
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapState(['user', 'menuParams']),
|
|
|
|
+ pageTitle() {
|
|
|
|
+ return `${this.$route.meta.title}`;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ metaInfo() {
|
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<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 {
|
|
|
|
+ padding: 0 40px 0 10px;
|
|
|
|
+ .add {
|
|
|
|
+ text-align: right;
|
|
|
|
+ padding: 10px 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+.back {
|
|
|
|
+ text-align: right;
|
|
|
|
+ padding: 10px 0;
|
|
|
|
+}
|
|
|
|
+</style>
|