|
@@ -1,177 +1,172 @@
|
|
|
-<template>
|
|
|
- <div id="aPw">
|
|
|
- <el-row>
|
|
|
- <el-col :span="24">
|
|
|
- <el-col :span="24" class="leftTop"> <span>|</span> <span>图文管理</span> </el-col>
|
|
|
- <el-col :span="24" class="info">
|
|
|
- <el-col :span="24" class="top">
|
|
|
- <el-button type="primary" size="mini" @click="dialog = true">添加信息</el-button>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" class="list">
|
|
|
- <data-table :fields="fields" :opera="opera" :data="list" :total="total" @edit="toEdit" @delete="toDelete" @query="search"></data-table>
|
|
|
- </el-col>
|
|
|
- </el-col>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-dialog title="信息管理" :visible.sync="dialog" @closed="handleClose" width="50%" :append-to-body="true">
|
|
|
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
|
- <el-form-item label="信息内容" prop="content">
|
|
|
- <el-input v-model="form.content" type="textarea" placeholder="请输入信息内容"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="图片" prop="url">
|
|
|
- <uploadArray
|
|
|
- :limit="6"
|
|
|
- :data="form.url"
|
|
|
- :uploadBtn="true"
|
|
|
- type="url"
|
|
|
- :url="`/files/image/upload`"
|
|
|
- @upload="uploadSuccess"
|
|
|
- @delete="uploadDelete"
|
|
|
- ></uploadArray>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="视频文件" prop="file_path">
|
|
|
- <upload
|
|
|
- :limit="1"
|
|
|
- :data="form.file_path"
|
|
|
- type="file_path"
|
|
|
- listType=""
|
|
|
- :url="'/files/imgpath/upload'"
|
|
|
- @upload="uploadSuccess"
|
|
|
- @delete="uploadDelete"
|
|
|
- ></upload>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <el-button type="primary" @click="save">保存</el-button>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- </el-dialog>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script>
|
|
|
-const _ = require('lodash');
|
|
|
-import dataTable from '@common/src/components/frame/filter-page-table.vue';
|
|
|
-import upload from '@common/src/components/frame/upload.vue';
|
|
|
-import uploadArray from '@common/src/components/upload/uploadArray.vue';
|
|
|
-import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
-const { mapActions: dockPw } = createNamespacedHelpers('dockPw');
|
|
|
-export default {
|
|
|
- name: 'aPw',
|
|
|
- props: {},
|
|
|
- components: { dataTable, upload, uploadArray },
|
|
|
- data: function() {
|
|
|
- return {
|
|
|
- opera: [
|
|
|
- {
|
|
|
- label: '修改',
|
|
|
- icon: 'el-icon-edit',
|
|
|
- method: 'edit',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '删除',
|
|
|
- icon: 'el-icon-delete',
|
|
|
- method: 'delete',
|
|
|
- },
|
|
|
- ],
|
|
|
- fields: [
|
|
|
- { label: '信息内容', prop: 'content' },
|
|
|
- { label: '发布时间', prop: 'create_time' },
|
|
|
- ],
|
|
|
- list: [],
|
|
|
- total: 0,
|
|
|
- dialog: false,
|
|
|
- form: { url: [] },
|
|
|
- rules: {},
|
|
|
- };
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.search();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- ...dockPw(['query', 'fetch', 'update', 'delete', 'create']),
|
|
|
- async search({ skip = 0, limit = 10 } = {}) {
|
|
|
- const res = await this.query({ dock_id: this.user.id, skip, limit });
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- this.$set(this, `list`, res.data);
|
|
|
- this.$set(this, `total`, res.total);
|
|
|
- }
|
|
|
- },
|
|
|
- // 修改
|
|
|
- toEdit({ data }) {
|
|
|
- this.$set(this, `form`, data);
|
|
|
- this.dialog = true;
|
|
|
- },
|
|
|
- // 保存
|
|
|
- async save() {
|
|
|
- let data = _.cloneDeep(this.form);
|
|
|
- if (data.id) {
|
|
|
- let res = await this.update(data);
|
|
|
- if (this.$checkRes(res, '信息修改成功', res.errmsg || '信息修改失败')) this.handleClose();
|
|
|
- } else {
|
|
|
- data.dock_id = this.user.id;
|
|
|
- let res = await this.create(data);
|
|
|
- if (this.$checkRes(res, '信息添加成功', res.errmsg || '信息添加失败')) this.handleClose();
|
|
|
- }
|
|
|
- },
|
|
|
- // 删除
|
|
|
- async toDelete({ data }) {
|
|
|
- let res = await this.delete(data.id);
|
|
|
- if (this.$checkRes(res, '信息删除成功', res.errmsg || '信息删除失败')) this.search();
|
|
|
- },
|
|
|
- // 取消
|
|
|
- handleClose() {
|
|
|
- this.form = { url: [] };
|
|
|
- this.dialog = false;
|
|
|
- this.search();
|
|
|
- },
|
|
|
- uploadSuccess({ type, data }) {
|
|
|
- let arr = _.get(this.form, type);
|
|
|
- if (_.isArray(arr)) {
|
|
|
- let datas = { name: data.name, url: data.uri };
|
|
|
- this.form[type].push({ name: data.name, url: data.uri });
|
|
|
- } else {
|
|
|
- this.$set(this.form, `${type}`, data.uri);
|
|
|
- }
|
|
|
- },
|
|
|
- uploadDelete(data) {
|
|
|
- if (_.isObject(data)) this.$set(this.form, data.type, null);
|
|
|
- else this.form.url.splice(data, 1);
|
|
|
- this.$message({
|
|
|
- message: '删除成功',
|
|
|
- type: 'success',
|
|
|
- });
|
|
|
- },
|
|
|
- },
|
|
|
- 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 38px 0 10px;
|
|
|
- .top {
|
|
|
- text-align: right;
|
|
|
- padding: 10px 0;
|
|
|
- }
|
|
|
-}
|
|
|
-</style>
|
|
|
+<template>
|
|
|
+ <div id="aPw">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-col :span="24" class="leftTop"> <span>|</span> <span>图文管理</span> </el-col>
|
|
|
+ <el-col :span="24" class="info">
|
|
|
+ <el-row type="flex" justify="end" style="padding:10px">
|
|
|
+ <el-col :span="2">
|
|
|
+ <el-button type="primary" size="mini" @click="toAdd()">添加</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <data-table :fields="fields" :opera="opera" :data="list" :usePage="false" @delete="toDelete" @edit="toAdd"></data-table>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-dialog title="图文信息" :visible.sync="dialog" width="40%">
|
|
|
+ <el-form ref="form" :model="form" label-width="80px" class="form">
|
|
|
+ <el-form-item label="信息内容">
|
|
|
+ <el-input v-model="form.content" type="textarea" placeholder="请输入信息内容"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="图片">
|
|
|
+ <upload
|
|
|
+ :limit="1"
|
|
|
+ :data="form.img_url"
|
|
|
+ type="img_url"
|
|
|
+ listType=""
|
|
|
+ :url="'/files/live/dock_imgtxt/upload'"
|
|
|
+ @upload="uploadSuccess"
|
|
|
+ @delete="uploadDelete"
|
|
|
+ ></upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="视频">
|
|
|
+ <upload
|
|
|
+ :limit="1"
|
|
|
+ :data="form.file_url"
|
|
|
+ type="file_url"
|
|
|
+ listType=""
|
|
|
+ :url="'/files/live/dock_imgtxt/upload'"
|
|
|
+ @upload="uploadSuccess"
|
|
|
+ @delete="uploadDelete"
|
|
|
+ ></upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="vSubmit">保存</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import dataTable from '@common/src/components/frame/filter-page-table.vue';
|
|
|
+import upload from '@common/src/components/frame/upload.vue';
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: dockImgtxt } = createNamespacedHelpers('dockImgtxt');
|
|
|
+export default {
|
|
|
+ name: 'aPw',
|
|
|
+ props: {},
|
|
|
+ components: { dataTable, upload },
|
|
|
+ data: function() {
|
|
|
+ return {
|
|
|
+ dialog: false,
|
|
|
+ list: [],
|
|
|
+ opera: [
|
|
|
+ {
|
|
|
+ label: '编辑',
|
|
|
+ method: 'edit',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '删除',
|
|
|
+ type: 'danger',
|
|
|
+ method: 'delete',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ fields: [{ label: '信息', prop: 'content', model: 'content' }],
|
|
|
+ form: {},
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...dockImgtxt(['query', 'create', 'update', 'delete']),
|
|
|
+ async search() {
|
|
|
+ const res = await this.query({ dock_id: this.user._id });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async vSubmit() {
|
|
|
+ let dup = _.cloneDeep(this.form);
|
|
|
+ let res;
|
|
|
+ if (!dup.id) {
|
|
|
+ dup.user_id = this.user.user_id;
|
|
|
+ dup.dock_id = this.user._id;
|
|
|
+ res = await this.create(dup);
|
|
|
+ } else {
|
|
|
+ res = await this.update(dup);
|
|
|
+ }
|
|
|
+ if (this.$checkRes(res, '保存成功', res.errmsg || '保存失败')) {
|
|
|
+ this.search();
|
|
|
+ this.dialog = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async toDelete({ data }) {
|
|
|
+ const { _id } = data;
|
|
|
+ const res = await this.delete(_id);
|
|
|
+ if (this.$checkRes(res, '删除成功', res.errmsg || '删除失败')) {
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ toAdd({ data = {} } = {}) {
|
|
|
+ this.dialog = true;
|
|
|
+ this.$set(this, `form`, data);
|
|
|
+ },
|
|
|
+ uploadSuccess({ type, data }) {
|
|
|
+ const { uri } = data;
|
|
|
+ this.$set(this.form, type, uri);
|
|
|
+ },
|
|
|
+ uploadDelete({ file, type }) {
|
|
|
+ delete this.form[type];
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['user']),
|
|
|
+ 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 38px 0 10px;
|
|
|
+}
|
|
|
+/deep/.el-dialog__body {
|
|
|
+ height: 350px;
|
|
|
+ overflow: hidden;
|
|
|
+ padding: 20px;
|
|
|
+}
|
|
|
+.table {
|
|
|
+ height: 328px;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+/deep/.el-table td {
|
|
|
+ padding: 5px 0;
|
|
|
+}
|
|
|
+/deep/.el-table th {
|
|
|
+ padding: 5px 0;
|
|
|
+}
|
|
|
+.page {
|
|
|
+ text-align: center;
|
|
|
+ padding: 10px 0;
|
|
|
+}
|
|
|
+</style>
|