|
@@ -12,28 +12,13 @@
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
<el-dialog :title="mydata.dialogInfo.title" :visible.sync="mydata.dialogInfo.dialogVisible" :width="mydata.dialogInfo.width">
|
|
<el-dialog :title="mydata.dialogInfo.title" :visible.sync="mydata.dialogInfo.dialogVisible" :width="mydata.dialogInfo.width">
|
|
- <dynamicForm ref="dynamicForm" v-if="mydata.formFiled && mydata.dialogInfo.dialogVisible" @switchtChange="switchtChange" :filed="mydata.formFiled" :data="mydata.formData" :selectFileList="mydata.selectFileList" @selectFileQuery="selectFileQuery" @save="formSave">
|
|
|
|
- <template v-slot:ext="{ formdata }">
|
|
|
|
- <el-form-item label="选择栏目" v-if="formdata['meta.islink'] == '0'">
|
|
|
|
- <el-select v-model="formdata['meta.catalog']" @change="getarticle">
|
|
|
|
- <el-option v-for="(item, i) in mydata.catalog" :key="`option${i}`" :label="item.name" :value="String(item.alias)"></el-option>
|
|
|
|
- </el-select>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item label="选择文章" v-if="formdata['meta.islink'] == '0'">
|
|
|
|
- <FilterList @articleSelect="articleSelect" v-if="!formdata['meta.id'] || formdata['meta.id'] == ''" :operation="mydata.articleOperation" :useBtn="false" :filter="false" :filed="mydata.articleFileds" :tableData="mydata.articleList" :total="mydata.articleTotal" @query="getarticle"></FilterList>
|
|
|
|
- <span v-else>
|
|
|
|
- {{ formdata['meta.articleTitle'] }}
|
|
|
|
- <el-button type="primary" size="mini" @click="resetArticle">选择</el-button>
|
|
|
|
- </span>
|
|
|
|
- </el-form-item>
|
|
|
|
- </template>
|
|
|
|
|
|
+ <dynamicForm ref="dynamicForm" v-if="mydata.formFiled && mydata.dialogInfo.dialogVisible" :filed="mydata.formFiled" :data="mydata.formData" :selectFileList="mydata.selectFileList" @save="formSave">
|
|
</dynamicForm>
|
|
</dynamicForm>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
- import { openFiles } from "@/api/files/upload";
|
|
|
|
import { cmsQuery } from "@/api/cms/index";
|
|
import { cmsQuery } from "@/api/cms/index";
|
|
import { journalAdd, journalUpdate, journalDel, journalQuery, journalFetch } from "@/api/journal/index";
|
|
import { journalAdd, journalUpdate, journalDel, journalQuery, journalFetch } from "@/api/journal/index";
|
|
export default {
|
|
export default {
|
|
@@ -80,39 +65,11 @@
|
|
async created() {
|
|
async created() {
|
|
this.models = require(`./config.js`);
|
|
this.models = require(`./config.js`);
|
|
this.$data.mydata = { ...this.$data.mydata, ...this.models.default }
|
|
this.$data.mydata = { ...this.$data.mydata, ...this.models.default }
|
|
- if (this.mydata.type == 'page') {
|
|
|
|
- await this.query();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ console.log(this.$data.mydata, 'this.$data.mydata');
|
|
|
|
+
|
|
await this.getCatalog();
|
|
await this.getCatalog();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- // 选择文章
|
|
|
|
- resetArticle() {
|
|
|
|
- this.$refs.dynamicForm.setForm('meta.id', '')
|
|
|
|
- this.$refs.dynamicForm.setForm('meta.articleTitle', '')
|
|
|
|
- this.getarticle();
|
|
|
|
- },
|
|
|
|
- // 文章选择
|
|
|
|
- articleSelect(e) {
|
|
|
|
- this.$refs.dynamicForm.setForm('meta.type', 'article')
|
|
|
|
- this.$refs.dynamicForm.setForm('meta.id', e.postId)
|
|
|
|
- this.$refs.dynamicForm.setForm('meta.articleTitle', e.title)
|
|
|
|
- },
|
|
|
|
- // 查询文章
|
|
|
|
- async getarticle(e) {
|
|
|
|
- const res = await cmsQuery({ ...e, pageNum: e?.pageNum ?? 1, pageSize: e?.pageSize ?? 10 }, 'article', this.$refs.dynamicForm.formdata['meta.catalog']);
|
|
|
|
- console.log(res, 'res');
|
|
|
|
- if (res.code == 200) {
|
|
|
|
- this.$set(this.mydata, 'articleList', res.rows)
|
|
|
|
- this.$set(this.mydata, 'articleTotal', res.total)
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- // 所有栏目查询
|
|
|
|
- async getCatalogs() {
|
|
|
|
- const res = await cmsQuery({ paging: false }, this.$route.query.taxonomy ?? 'catalog');
|
|
|
|
- if (res.code == 200) this.mydata.catalog = res.rows;
|
|
|
|
- },
|
|
|
|
// 查询分类栏目
|
|
// 查询分类栏目
|
|
async getCatalog() {
|
|
async getCatalog() {
|
|
this.mydata.loading = true;
|
|
this.mydata.loading = true;
|
|
@@ -128,7 +85,7 @@
|
|
// 列表查询
|
|
// 列表查询
|
|
async query(e) {
|
|
async query(e) {
|
|
this.mydata.loading = true;
|
|
this.mydata.loading = true;
|
|
- const res = await journalQuery({ pageNum: 1, pageSize: 10, paging: this.mydata.pagination, ...e }, this.mydata.type, this.mydata.alias);
|
|
|
|
|
|
+ const res = await journalQuery({ termId: this.mydata.termId, pageNum: 1, pageSize: 10, paging: this.mydata.pagination, ...e }, this.mydata.type, this.mydata.alias);
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
this.$set(this.mydata, 'tableData', res.rows)
|
|
this.$set(this.mydata, 'tableData', res.rows)
|
|
this.$set(this.mydata, 'total', res.total)
|
|
this.$set(this.mydata, 'total', res.total)
|
|
@@ -137,9 +94,8 @@
|
|
},
|
|
},
|
|
// 列表添加
|
|
// 列表添加
|
|
async itemadd(e) {
|
|
async itemadd(e) {
|
|
- // await this.selectFileQuery();
|
|
|
|
this.mydata.formData = {};
|
|
this.mydata.formData = {};
|
|
- this.mydata.formData.parentId = e[`${this.mydata.classify}Id`];
|
|
|
|
|
|
+ this.mydata.formData.parentId = e.id;
|
|
const dict = this.dict.type.term_type.find(j => j.value == this.mydata.type);
|
|
const dict = this.dict.type.term_type.find(j => j.value == this.mydata.type);
|
|
this.mydata.dialogInfo.title = `添加${dict?.label}`;
|
|
this.mydata.dialogInfo.title = `添加${dict?.label}`;
|
|
this.mydata.dialogInfo.dialogVisible = true;
|
|
this.mydata.dialogInfo.dialogVisible = true;
|
|
@@ -147,26 +103,22 @@
|
|
// 列表修改
|
|
// 列表修改
|
|
async listEdit(e) {
|
|
async listEdit(e) {
|
|
this.mydata.loading = true;
|
|
this.mydata.loading = true;
|
|
- // await this.selectFileQuery();
|
|
|
|
- const res = await journalFetch('_' + e[`${this.mydata.classify}Id`], this.mydata.type);
|
|
|
|
|
|
+ const res = await journalFetch(e.id);
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
- const urls = res.data.attachments.map(e => e.url)
|
|
|
|
- this.mydata.formData = { ...res.data, url: res.data.image, topStatus: String(res.data.topStatus), urls: String(urls) };
|
|
|
|
|
|
+ this.mydata.formData = { ...res.data };
|
|
for (const key in this.mydata.formData.meta) {
|
|
for (const key in this.mydata.formData.meta) {
|
|
this.mydata.formData[`meta.${key}`] = this.mydata.formData.meta[key]
|
|
this.mydata.formData[`meta.${key}`] = this.mydata.formData.meta[key]
|
|
}
|
|
}
|
|
const dict = this.dict.type.term_type.find(j => j.value == this.mydata.type);
|
|
const dict = this.dict.type.term_type.find(j => j.value == this.mydata.type);
|
|
this.mydata.dialogInfo.title = `修改${dict.label}`;
|
|
this.mydata.dialogInfo.title = `修改${dict.label}`;
|
|
this.mydata.dialogInfo.dialogVisible = true;
|
|
this.mydata.dialogInfo.dialogVisible = true;
|
|
- // if (this.mydata.formData['meta.islink'] && this.mydata.formData['meta.islink'] == '0') this.switchtChange({ formdata: this.mydata.formData });
|
|
|
|
}
|
|
}
|
|
this.mydata.loading = false;
|
|
this.mydata.loading = false;
|
|
},
|
|
},
|
|
// 列表删除
|
|
// 列表删除
|
|
async listDel(e) {
|
|
async listDel(e) {
|
|
this.mydata.loading = true;
|
|
this.mydata.loading = true;
|
|
- const id = e[`${this.mydata.classify}Id`]
|
|
|
|
- const res = await journalDel(this.mydata.type, id);
|
|
|
|
|
|
+ const res = await journalDel(e.id);
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
this.$modal.msgSuccess('删除成功');
|
|
this.$modal.msgSuccess('删除成功');
|
|
this.query();
|
|
this.query();
|
|
@@ -175,7 +127,6 @@
|
|
},
|
|
},
|
|
// 添加
|
|
// 添加
|
|
async add() {
|
|
async add() {
|
|
- // await this.selectFileQuery();
|
|
|
|
this.mydata.formData = {};
|
|
this.mydata.formData = {};
|
|
const dict = this.dict.type.term_type.find(j => j.value == this.mydata.type);
|
|
const dict = this.dict.type.term_type.find(j => j.value == this.mydata.type);
|
|
this.mydata.dialogInfo.title = `添加${dict.label}`;
|
|
this.mydata.dialogInfo.title = `添加${dict.label}`;
|
|
@@ -183,14 +134,15 @@
|
|
},
|
|
},
|
|
// 表单保存
|
|
// 表单保存
|
|
async formSave(e) {
|
|
async formSave(e) {
|
|
|
|
+ e.termId = this.mydata.termId;
|
|
this.mydata.loading = true;
|
|
this.mydata.loading = true;
|
|
let res;
|
|
let res;
|
|
// 修改
|
|
// 修改
|
|
- if(e[`${this.mydata.classify}Id`]) res = await journalUpdate(e, this.mydata.type);
|
|
|
|
|
|
+ if(e.id) res = await journalUpdate(e);
|
|
// 新增
|
|
// 新增
|
|
- if(!e[`${this.mydata.classify}Id`]) res = await journalAdd({ ...e, contentType: this.mydata.type, catalogIds: this.mydata.termId ? [this.mydata.termId] : [] }, this.mydata.type);
|
|
|
|
|
|
+ if(!e.id) res = await journalAdd(e);
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
- this.$modal.msgSuccess(`${e[`${this.mydata.classify}Id`] ? '修改' : '新增'}成功`);
|
|
|
|
|
|
+ this.$modal.msgSuccess(`${e.id ? '修改' : '新增'}成功`);
|
|
this.mydata.dialogInfo.dialogVisible = false;
|
|
this.mydata.dialogInfo.dialogVisible = false;
|
|
this.query();
|
|
this.query();
|
|
}
|
|
}
|
|
@@ -211,45 +163,6 @@
|
|
this.mydata.termId = e.termId;
|
|
this.mydata.termId = e.termId;
|
|
this.query();
|
|
this.query();
|
|
},
|
|
},
|
|
- // 文件选择
|
|
|
|
- async selectFileQuery(e) {
|
|
|
|
- const res = await openFiles({ path: e ?? '/' });
|
|
|
|
- this.mydata.selectFileList = res.data;
|
|
|
|
- },
|
|
|
|
- switchtChange(e) {
|
|
|
|
- console.log(e)
|
|
|
|
- if (!e.formdata['meta.islink'] || (e.item && e.item.name !== 'meta.islink')) return;
|
|
|
|
- if (e.formdata['meta.islink'] == 0) {
|
|
|
|
- this.mydata.formFiled.splice(2, 7, ...[
|
|
|
|
- { label: "置顶", name: "topStatus", formater: 'switch', activeValue: '1', inactiveValue: '0' },
|
|
|
|
- { label: "隐藏/显示", name: "visible", formater: 'switch', activeValue: '1', inactiveValue: '0' },
|
|
|
|
- ])
|
|
|
|
- this.getCatalogs();
|
|
|
|
- if (this.$refs.dynamicForm) {
|
|
|
|
- this.$refs.dynamicForm.resetForm();
|
|
|
|
- this.$refs.dynamicForm.setForm('meta.islink', e.formdata['meta.islink']);
|
|
|
|
- this.$set(this.mydata, 'articleList', [])
|
|
|
|
- this.$set(this.mydata, 'articleTotal', 0)
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- this.$refs.dynamicForm.resetForm();
|
|
|
|
- this.mydata.formFiled.push(
|
|
|
|
- { label: "标题", name: "title" },
|
|
|
|
- { label: "摘要", name: "summary" },
|
|
|
|
-
|
|
|
|
- { label: "状态", name: "status", formater: "dict:essay_type" },
|
|
|
|
- { label: "备注", name: "remark", placeholder: "输入备注", formater: "textarea" },
|
|
|
|
- { label: "内容", name: "content", formater: 'editor' },
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- if (this.$refs.dynamicForm) {
|
|
|
|
- this.$refs.dynamicForm.setForm('topStatus', e.formdata['topStatus']);
|
|
|
|
- this.$refs.dynamicForm.setForm('visible', e.formdata['visible']);
|
|
|
|
- this.$refs.dynamicForm.setForm('image', e.formdata['image']);
|
|
|
|
- this.$refs.dynamicForm.setForm('postId', e.formdata['postId']);
|
|
|
|
- this.$refs.dynamicForm.setFileds()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|