123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- <template>
- <fullscreen :fullscreen.sync="fullscreen" class="container">
- <div class="container-box">
- <el-row :gutter="20">
- <el-col :span="4">
- <el-input placeholder="输入关键字进行过滤" v-model="filterText">
- </el-input>
- <div class="tree-box">
- <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>
- </div>
- </el-col>
- <el-col :span="20">
- <el-input
- v-model="params.knowledgeName"
- style="width: 200px"
- placeholder="知识标题"
- ></el-input>
- <el-select
- :popper-append-to-body="false"
- v-model="params.pubType"
- placeholder="发布类型"
- clearable
- >
- <el-option
- v-for="item in knowledgeTypeOpation"
- :key="item.id"
- :label="item.pubType"
- :value="item.id"
- >
- </el-option>
- </el-select>
- <el-button>查询</el-button>
- <el-radio-group v-model="params.knowledgeType" @change="checkType">
- <el-radio-button label="a">正常</el-radio-button>
- <el-radio-button label="1">已收藏</el-radio-button>
- </el-radio-group>
- <el-button @click="addKnowledge" style="float: right">添加</el-button>
- <el-table border ref="filterTable" :data="tableData" style="width: 100%;margin-top:20px">
- <el-table-column prop="title" label="知识标题"> </el-table-column>
- <el-table-column prop="address" label="地区"> </el-table-column>
- <el-table-column prop="time" label="时间" sortable>
- </el-table-column>
- <el-table-column prop="point" label="点击量" sortable>
- </el-table-column>
- <el-table-column prop="address" label="操作">
- <template slot-scope="scope">
- <el-button
- plain
- size="mini"
- type="primary"
- @click="detailes(scope.row)"
- >查看</el-button
- >
- <el-button
- plain
- size="mini"
- type="success"
- @click="collection(scope.row)"
- >{{ scope.row.collectionDesc }}</el-button
- >
- <el-button
- plain
- size="mini"
- type="danger"
- @click="detailes(scope.row)"
- >修改</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- class="pageBox"
- @current-change="currchange"
- layout="prev, pager, next"
- background
- :total="total"
- >
- </el-pagination>
- </el-col>
- </el-row>
- </div>
- <el-dialog
- title="增加知识库"
- :visible.sync="dialogVisible"
- width="45%"
- :modal-append-to-body="false"
- >
- <el-form :model="formData" ref="infolist">
- <el-form-item prop="title">
- <span>标题</span>
- <el-input v-model="formData.knowledgeTitle" placeholder="标题">
- </el-input>
- </el-form-item>
- <el-form-item prop="catalog">
- <span>目录</span>
- <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>
- </el-form-item>
- <el-form-item prop="content">
- <span>内容</span>
- <p-editor-tiny
- imgType="upload"
- v-model="formData.content"
- ></p-editor-tiny>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">取 消</el-button>
- <el-button type="primary" @click="dialogVisible = false"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </fullscreen>
- </template>
- <script>
- export default {
- components: {
- PEditorTiny: () =>
- import(
- /* webpackChunkName: "peditor-tiny" */ "../../../components/p-editor-tiny"
- ),
- },
- data() {
- return {
- total: 0,
- pageSize: 1,
- formData: {
- title: "",
- catalog: "",
- department: "",
- content: "",
- },
- dialogVisible: false,
- fullscreen: false,
- params: {
- knowledgeType: "a",
- knowledgeName: "",
- pubType: "",
- },
- dataSourse: [
- {
- title: "知识库标题1",
- address: "哈尔滨",
- time: "2016-05-02",
- point: "106",
- collection: "1",
- collectionDesc: "已收藏",
- catalog: "1",
- },
- {
- title: "知识库标题2",
- address: "哈尔滨",
- time: "2016-05-01",
- point: "3",
- collection: "0",
- collectionDesc: "未收藏",
- catalog: "2",
- },
- {
- title: "知识库标题3",
- address: "哈尔滨",
- time: "2016-04-02",
- point: "1",
- collection: "1",
- collectionDesc: "已收藏",
- catalog: "3",
- },
- {
- title: "知识库标题4",
- address: "哈尔滨",
- time: "2016-03-02",
- point: "101",
- collection: "0",
- collectionDesc: "未收藏",
- catalog: "3",
- },
- ],
- tableData: [
- {
- title: "知识库标题1",
- address: "哈尔滨",
- time: "2016-05-02",
- point: "106",
- collection: "1",
- collectionDesc: "已收藏",
- catalog: "1",
- },
- {
- title: "知识库标题2",
- address: "哈尔滨",
- time: "2016-05-01",
- point: "3",
- collection: "0",
- collectionDesc: "未收藏",
- catalog: "2",
- },
- {
- title: "知识库标题3",
- address: "哈尔滨",
- time: "2016-04-02",
- point: "1",
- collection: "1",
- collectionDesc: "已收藏",
- catalog: "3",
- },
- {
- title: "知识库标题4",
- address: "哈尔滨",
- time: "2016-03-02",
- point: "101",
- collection: "0",
- collectionDesc: "未收藏",
- catalog: "3",
- },
- ],
- filterText: "",
- treeData: [],
- defaultProps: {
- children: "children",
- label: "title",
- },
- knowledgeTypeOpation: [],
- };
- },
- methods: {
- // 分页
- currchange(v) {
- this.pageSize = v;
- },
- //字典类型
- getListype(v) {
- this.$http({
- url: "/market/mkKnowledgePubMsgType/queryList",
- method: "post",
- headers: {
- "Content-Type": "application/json",
- },
- data: {
- dictCode: "pubType",
- },
- }).then((res) => {
- this.knowledgeTypeOpation = res.data;
- });
- },
- addKnowledge() {
- this.$router.push("/addknowledge");
- // this.dialogVisible = true;
- },
- // 查看
- detailes(val) {
- console.log(val);
- },
- // 树点击
- nodeClick(index, data, node) {
- let dataArr = JSON.parse(JSON.stringify(this.dataSourse));
- let catalog = data.data.hasOwnProperty("catalog")
- ? data.data.catalog
- : "";
- if (catalog) {
- this.tableData = dataArr.filter((item) => {
- if (item.catalog == catalog) {
- return item;
- }
- });
- } else {
- this.tableData = this.dataSourse;
- }
- },
- // 列表筛选
- checkType(val) {
- if (val != "a") {
- this.tableData = this.tableData.filter((item) => {
- if (item.collection == val) {
- return item;
- }
- });
- } else {
- this.tableData = this.dataSourse;
- }
- },
- // 树筛选
- filterNode(value, data) {
- if (!value) return true;
- return data.label.indexOf(value) !== -1;
- },
- resetDateFilter() {
- this.$refs.filterTable.clearFilter("date");
- },
- clearFilter() {
- this.$refs.filterTable.clearFilter();
- },
- // 列表数据格式化
- formatter(row, column) {
- return row.address;
- },
- // 列表筛选
- filterTag(value, row) {
- return row.tag === value;
- },
- // 收藏
- collection(val) {
- if (val.collection == "1") {
- val.collection = "0";
- val.collectionDesc = "为收藏";
- } else {
- val.collection = "1";
- val.collectionDesc = "已收藏";
- }
- },
- getData() {
- this.$http({
- url: "/market/mkKnowledgeCatalog/queryList",
- method: "post",
- headers: {
- "Content-Type": "application/json",
- },
- data: {},
- }).then((res) => {
- this.treeData = res.data;
- });
- },
- },
- mounted() {
- this.getListype();
- this.getData();
- },
- watch: {
- filterText(val) {
- this.$refs.tree.filter(val);
- },
- },
- };
- </script>
- <style>
- .pageBox {
- text-align: right;
- margin-top: 10px;
- }
- .tree-box {
- height: 400px;
- overflow: auto;
- border: 1px solid #dcdfe6;
- border-top: none;
- }
- </style>
|