mcIndex.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <fullscreen :fullscreen.sync="fullscreen" class="container">
  3. <div class="container-box">
  4. <el-row :gutter="20">
  5. <el-col :span="4">
  6. <el-input placeholder="输入关键字进行过滤" v-model="filterText">
  7. </el-input>
  8. <div class="tree-box">
  9. <el-tree
  10. class="filter-tree"
  11. :data="treeData"
  12. node-key="catalog"
  13. :props="defaultProps"
  14. default-expand-all
  15. :filter-node-method="filterNode"
  16. @node-click="nodeClick"
  17. ref="tree"
  18. >
  19. </el-tree>
  20. </div>
  21. </el-col>
  22. <el-col :span="20">
  23. <el-input
  24. v-model="params.knowledgeName"
  25. style="width: 200px"
  26. placeholder="知识标题"
  27. ></el-input>
  28. <el-select
  29. :popper-append-to-body="false"
  30. v-model="params.pubType"
  31. placeholder="发布类型"
  32. clearable
  33. >
  34. <el-option
  35. v-for="item in knowledgeTypeOpation"
  36. :key="item.id"
  37. :label="item.pubType"
  38. :value="item.id"
  39. >
  40. </el-option>
  41. </el-select>
  42. <el-button>查询</el-button>
  43. <el-radio-group v-model="params.knowledgeType" @change="checkType">
  44. <el-radio-button label="a">正常</el-radio-button>
  45. <el-radio-button label="1">已收藏</el-radio-button>
  46. </el-radio-group>
  47. <el-button @click="addKnowledge" style="float: right">添加</el-button>
  48. <el-table border ref="filterTable" :data="tableData" style="width: 100%;margin-top:20px">
  49. <el-table-column prop="title" label="知识标题"> </el-table-column>
  50. <el-table-column prop="address" label="地区"> </el-table-column>
  51. <el-table-column prop="time" label="时间" sortable>
  52. </el-table-column>
  53. <el-table-column prop="point" label="点击量" sortable>
  54. </el-table-column>
  55. <el-table-column prop="address" label="操作">
  56. <template slot-scope="scope">
  57. <el-button
  58. plain
  59. size="mini"
  60. type="primary"
  61. @click="detailes(scope.row)"
  62. >查看</el-button
  63. >
  64. <el-button
  65. plain
  66. size="mini"
  67. type="success"
  68. @click="collection(scope.row)"
  69. >{{ scope.row.collectionDesc }}</el-button
  70. >
  71. <el-button
  72. plain
  73. size="mini"
  74. type="danger"
  75. @click="detailes(scope.row)"
  76. >修改</el-button
  77. >
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. <el-pagination
  82. class="pageBox"
  83. @current-change="currchange"
  84. layout="prev, pager, next"
  85. background
  86. :total="total"
  87. >
  88. </el-pagination>
  89. </el-col>
  90. </el-row>
  91. </div>
  92. <el-dialog
  93. title="增加知识库"
  94. :visible.sync="dialogVisible"
  95. width="45%"
  96. :modal-append-to-body="false"
  97. >
  98. <el-form :model="formData" ref="infolist">
  99. <el-form-item prop="title">
  100. <span>标题</span>
  101. <el-input v-model="formData.knowledgeTitle" placeholder="标题">
  102. </el-input>
  103. </el-form-item>
  104. <el-form-item prop="catalog">
  105. <span>目录</span>
  106. <el-tree
  107. class="filter-tree"
  108. :data="treeData"
  109. node-key="catalog"
  110. :props="defaultProps"
  111. default-expand-all
  112. :filter-node-method="filterNode"
  113. @node-click="nodeClick"
  114. ref="tree"
  115. >
  116. </el-tree>
  117. </el-form-item>
  118. <el-form-item prop="content">
  119. <span>内容</span>
  120. <p-editor-tiny
  121. imgType="upload"
  122. v-model="formData.content"
  123. ></p-editor-tiny>
  124. </el-form-item>
  125. </el-form>
  126. <span slot="footer" class="dialog-footer">
  127. <el-button @click="dialogVisible = false">取 消</el-button>
  128. <el-button type="primary" @click="dialogVisible = false"
  129. >确 定</el-button
  130. >
  131. </span>
  132. </el-dialog>
  133. </fullscreen>
  134. </template>
  135. <script>
  136. export default {
  137. components: {
  138. PEditorTiny: () =>
  139. import(
  140. /* webpackChunkName: "peditor-tiny" */ "../../../components/p-editor-tiny"
  141. ),
  142. },
  143. data() {
  144. return {
  145. total: 0,
  146. pageSize: 1,
  147. formData: {
  148. title: "",
  149. catalog: "",
  150. department: "",
  151. content: "",
  152. },
  153. dialogVisible: false,
  154. fullscreen: false,
  155. params: {
  156. knowledgeType: "a",
  157. knowledgeName: "",
  158. pubType: "",
  159. },
  160. dataSourse: [
  161. {
  162. title: "知识库标题1",
  163. address: "哈尔滨",
  164. time: "2016-05-02",
  165. point: "106",
  166. collection: "1",
  167. collectionDesc: "已收藏",
  168. catalog: "1",
  169. },
  170. {
  171. title: "知识库标题2",
  172. address: "哈尔滨",
  173. time: "2016-05-01",
  174. point: "3",
  175. collection: "0",
  176. collectionDesc: "未收藏",
  177. catalog: "2",
  178. },
  179. {
  180. title: "知识库标题3",
  181. address: "哈尔滨",
  182. time: "2016-04-02",
  183. point: "1",
  184. collection: "1",
  185. collectionDesc: "已收藏",
  186. catalog: "3",
  187. },
  188. {
  189. title: "知识库标题4",
  190. address: "哈尔滨",
  191. time: "2016-03-02",
  192. point: "101",
  193. collection: "0",
  194. collectionDesc: "未收藏",
  195. catalog: "3",
  196. },
  197. ],
  198. tableData: [
  199. {
  200. title: "知识库标题1",
  201. address: "哈尔滨",
  202. time: "2016-05-02",
  203. point: "106",
  204. collection: "1",
  205. collectionDesc: "已收藏",
  206. catalog: "1",
  207. },
  208. {
  209. title: "知识库标题2",
  210. address: "哈尔滨",
  211. time: "2016-05-01",
  212. point: "3",
  213. collection: "0",
  214. collectionDesc: "未收藏",
  215. catalog: "2",
  216. },
  217. {
  218. title: "知识库标题3",
  219. address: "哈尔滨",
  220. time: "2016-04-02",
  221. point: "1",
  222. collection: "1",
  223. collectionDesc: "已收藏",
  224. catalog: "3",
  225. },
  226. {
  227. title: "知识库标题4",
  228. address: "哈尔滨",
  229. time: "2016-03-02",
  230. point: "101",
  231. collection: "0",
  232. collectionDesc: "未收藏",
  233. catalog: "3",
  234. },
  235. ],
  236. filterText: "",
  237. treeData: [],
  238. defaultProps: {
  239. children: "children",
  240. label: "title",
  241. },
  242. knowledgeTypeOpation: [],
  243. };
  244. },
  245. methods: {
  246. // 分页
  247. currchange(v) {
  248. this.pageSize = v;
  249. },
  250. //字典类型
  251. getListype(v) {
  252. this.$http({
  253. url: "/market/mkKnowledgePubMsgType/queryList",
  254. method: "post",
  255. headers: {
  256. "Content-Type": "application/json",
  257. },
  258. data: {
  259. dictCode: "pubType",
  260. },
  261. }).then((res) => {
  262. this.knowledgeTypeOpation = res.data;
  263. });
  264. },
  265. addKnowledge() {
  266. this.$router.push("/addknowledge");
  267. // this.dialogVisible = true;
  268. },
  269. // 查看
  270. detailes(val) {
  271. console.log(val);
  272. },
  273. // 树点击
  274. nodeClick(index, data, node) {
  275. let dataArr = JSON.parse(JSON.stringify(this.dataSourse));
  276. let catalog = data.data.hasOwnProperty("catalog")
  277. ? data.data.catalog
  278. : "";
  279. if (catalog) {
  280. this.tableData = dataArr.filter((item) => {
  281. if (item.catalog == catalog) {
  282. return item;
  283. }
  284. });
  285. } else {
  286. this.tableData = this.dataSourse;
  287. }
  288. },
  289. // 列表筛选
  290. checkType(val) {
  291. if (val != "a") {
  292. this.tableData = this.tableData.filter((item) => {
  293. if (item.collection == val) {
  294. return item;
  295. }
  296. });
  297. } else {
  298. this.tableData = this.dataSourse;
  299. }
  300. },
  301. // 树筛选
  302. filterNode(value, data) {
  303. if (!value) return true;
  304. return data.label.indexOf(value) !== -1;
  305. },
  306. resetDateFilter() {
  307. this.$refs.filterTable.clearFilter("date");
  308. },
  309. clearFilter() {
  310. this.$refs.filterTable.clearFilter();
  311. },
  312. // 列表数据格式化
  313. formatter(row, column) {
  314. return row.address;
  315. },
  316. // 列表筛选
  317. filterTag(value, row) {
  318. return row.tag === value;
  319. },
  320. // 收藏
  321. collection(val) {
  322. if (val.collection == "1") {
  323. val.collection = "0";
  324. val.collectionDesc = "为收藏";
  325. } else {
  326. val.collection = "1";
  327. val.collectionDesc = "已收藏";
  328. }
  329. },
  330. getData() {
  331. this.$http({
  332. url: "/market/mkKnowledgeCatalog/queryList",
  333. method: "post",
  334. headers: {
  335. "Content-Type": "application/json",
  336. },
  337. data: {},
  338. }).then((res) => {
  339. this.treeData = res.data;
  340. });
  341. },
  342. },
  343. mounted() {
  344. this.getListype();
  345. this.getData();
  346. },
  347. watch: {
  348. filterText(val) {
  349. this.$refs.tree.filter(val);
  350. },
  351. },
  352. };
  353. </script>
  354. <style>
  355. .pageBox {
  356. text-align: right;
  357. margin-top: 10px;
  358. }
  359. .tree-box {
  360. height: 400px;
  361. overflow: auto;
  362. border: 1px solid #dcdfe6;
  363. border-top: none;
  364. }
  365. </style>