123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- <template>
- <fullscreen class="mc-container">
- <div class="container-box">
- <h2>新增知识库</h2>
- <el-row :gutter="20" style="margin-top: 15px">
- <el-col :span="24"
- ><el-form
- :model="formData"
- :rules="rules"
- ref="ruleForm"
- label-width="50px"
- class="demo-ruleForm"
- >
- <el-col :span="10">
- <el-form-item label="标题" prop="title">
- <el-input
- v-model="formData.title"
- placeholder="请输入标题"
- ></el-input>
- </el-form-item>
- <el-form-item prop="pubType" label="类型">
- <el-select
- style="width: 100%"
- :popper-append-to-body="false"
- v-model="formData.pubType"
- placeholder="发布类型"
- clearable
- >
- <el-option
- v-for="item in knowledgeType"
- :key="item.id"
- :label="item.pubType"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="目录" prop="catalogDesc">
- <div style="display: flex">
- <el-input
- v-model="formData.catalogDesc"
- readonly
- placeholder="请选择目录"
- ></el-input>
- <el-button @click="selectCatalogs">选择</el-button>
- </div>
- </el-form-item>
- <el-form-item label="附件" prop="catalog">
- <myUpload
- @uploadBack="uploadBack"
- :fileInfo="fileInfo"
- :fileList="fileInfo.fileList"
- >
- </myUpload>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="submitForm('ruleForm')"
- >立即创建</el-button
- >
- <el-button @click="resetForm('ruleForm')">取消</el-button>
- </el-form-item>
- </el-col>
- <el-col :span="14">
- <el-form-item label="内容" prop="content">
- <p-editor-tiny
- imgType="upload"
- v-model="formData.content"
- ></p-editor-tiny
- ></el-form-item>
- </el-col> </el-form
- ></el-col>
- </el-row>
- </div>
- <el-dialog
- title="目录树"
- :visible.sync="catalogDialogVisible"
- width="45%"
- :modal-append-to-body="false"
- >
- <el-tree
- class="filter-tree"
- :data="treeData"
- node-key="catalog"
- :props="defaultProps"
- default-expand-all
- :filter-node-method="filterNode"
- @node-click="nodeClick"
- ref="tree"
- >
- </el-tree>
- <span slot="footer" class="dialog-footer">
- <el-button @click="clearCatalog">取 消</el-button>
- <el-button type="primary" @click="trueCatalog">确 定</el-button>
- </span>
- </el-dialog>
- </fullscreen>
- </template><script>
- import myUpload from "../../../components/upload";
- export default {
- data() {
- return {
- catalogDialogVisible: false,
- departmentDialogVisible: false,
- formData: {
- title: "",
- catalog: "",
- catalogDesc: "",
- content: "",
- pubType: "",
- },
- rules: {
- title: [{ required: true, message: "请输入标题", trigger: "blur" }],
- catalogDesc: [
- { required: true, message: "请选择目录", trigger: "change" },
- ],
- pubType: [{ required: true, message: "请选择类型", trigger: "change" }],
- content: [
- {
- required: true,
- message: "请输入内容",
- trigger: "change",
- },
- ],
- },
- filterText: "",
- treeData: [],
- defaultProps: {
- children: "children",
- label: "title",
- },
- knowledgeType: [],
- fileInfo: {
- limit: 5,
- url: "/market/cknowledgenetatt/upload",
- fileList: [],
- },
- };
- },
- components: {
- PEditorTiny: () =>
- import(
- /* webpackChunkName: "peditor-tiny" */ "../../../components/p-editor-tiny"
- ),
- myUpload,
- },
- methods: {
- uploadBack(v) {
- this.attList = v;
- },
- // 选择完目录清空
- clearCatalog() {
- this.formData.catalogDesc = "";
- this.formData.catalog = "";
- this.catalogDialogVisible = false;
- },
- // 选择完目录确认
- trueCatalog() {
- this.catalogDialogVisible = false;
- },
- // 选择目录弹出
- selectCatalogs() {
- this.catalogDialogVisible = true;
- },
- // 选择部门弹出
- selectDepartment() {
- this.departmentDialogVisible = true;
- },
- //字典类型
- getListype(v) {
- this.$http({
- url: "/market/mkKnowledgePubMsgType/queryList",
- method: "post",
- headers: {
- "Content-Type": "application/json",
- },
- data: {
- dictCode: "pubType",
- },
- }).then((res) => {
- this.knowledgeType = res.data;
- });
- },
- // 树筛选
- filterNode(value, data) {
- if (!value) return true;
- return data.label.indexOf(value) !== -1;
- },
- async submitForm(formName) {
- let valid = await this.$refs[formName].validate().catch((err) => err);
- if (valid) {
- alert("submit!");
- } else {
- console.log("error submit!!");
- return false;
- }
- }, // 树点击
- nodeClick(index, data, node) {
- this.formData.catalogDesc = data.data.title;
- this.formData.catalog = data.data.id;
- },
- resetForm(formName) {
- this.$refs[formName].resetFields();
- },
- getData() {
- this.$http({
- url: "/market/mkKnowledgeCatalog/queryList",
- method: "post",
- headers: {
- "Content-Type": "application/json",
- },
- data: {},
- }).then((res) => {
- this.treeData = res.data;
- });
- },
- },
- mounted() {
- this.getData();
- this.getListype();
- },
- watch: {
- filterText(val) {
- this.$refs.tree.filter(val);
- },
- },
- };
- </script>
- <style>
- .mc-container {
- margin: 15px;
- background: #fff;
- border-radius: 5px;
- height: calc(100vh - 150px);
- margin-bottom: 0;
- }
- .mc-container .container-box {
- width: 100%;
- height: 100%;
- max-height: 96vh;
- margin-top: 20px;
- padding: 0 20px 0 20px;
- overflow-x: hidden !important;
- padding-top: 20px;
- }
- .tinymce-editor {
- height: 300px;
- }
- .mc-container .el-upload{
- width:100%
- }
- .mc-container .el-upload-dragger{
- width: 100%;
- }
- </style>
|