|
@@ -0,0 +1,122 @@
|
|
|
+<template>
|
|
|
+ <div id="detail">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="main">
|
|
|
+ <el-col :span="24" class="back">
|
|
|
+ <el-button type="primary" size="mini" @click="back">返回</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="detail">
|
|
|
+ <data-form :data="form" :fields="formFields" :rules="rules" @save="toSave">
|
|
|
+ <template #options="{item}">
|
|
|
+ <template v-if="item.model === 'type'">
|
|
|
+ <el-option v-for="(i, index) in typelist" :key="index" :label="i.name" :value="i.id"></el-option>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </data-form>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import dataForm from '@common/src/components/frame/form.vue';
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: channel } = createNamespacedHelpers('channel');
|
|
|
+const { mapActions: code } = createNamespacedHelpers('code');
|
|
|
+export default {
|
|
|
+ metaInfo() {
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
+ },
|
|
|
+ name: 'detail',
|
|
|
+ props: {},
|
|
|
+ components: {
|
|
|
+ dataForm,
|
|
|
+ },
|
|
|
+ data: function() {
|
|
|
+ return {
|
|
|
+ formFields: [
|
|
|
+ { label: '信息类型', model: 'type', type: 'select' },
|
|
|
+ { label: '标题', model: 'title' },
|
|
|
+ { label: '来源', model: 'origin' },
|
|
|
+ { label: '简介', model: 'desc', type: 'textarea' },
|
|
|
+ ],
|
|
|
+ form: {},
|
|
|
+ rules: {},
|
|
|
+ // 类型
|
|
|
+ typelist: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ async created() {
|
|
|
+ await this.searchOther();
|
|
|
+ await this.search();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...code({ codeQuery: 'query' }),
|
|
|
+ ...channel(['query', 'fetch', 'create', 'update']),
|
|
|
+ async search() {
|
|
|
+ if (this.id) {
|
|
|
+ let res = await this.fetch(this.id);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `form`, res.data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 提交
|
|
|
+ async toSave({ data }) {
|
|
|
+ if (data.id) {
|
|
|
+ let res = await this.update(data);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$message({
|
|
|
+ message: '信息修改成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.back();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data.user_id = this.user.uid;
|
|
|
+ let res = await this.create(data);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$checkRes(res, '创建成功', '创建失败');
|
|
|
+ this.$alert(`房间号:${res.data.room_id}` + `密码:${res.data.passwd.secret};`, '成功', {
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ type: 'success',
|
|
|
+ center: true,
|
|
|
+ callback: action => {
|
|
|
+ this.back();
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 返回
|
|
|
+ back() {
|
|
|
+ this.$router.push({ path: '/channel' });
|
|
|
+ },
|
|
|
+ // 查询类型
|
|
|
+ async searchOther() {
|
|
|
+ let res = await this.codeQuery({ category: '04' });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `typelist`, res.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['user']),
|
|
|
+ id() {
|
|
|
+ return this.$route.query.id;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {},
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.main {
|
|
|
+ .back {
|
|
|
+ text-align: right;
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|