helpCategory.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <!-- <div class="squrt"></div>帮助中心分类 -->
  5. <el-page-header @back="onCancel"
  6. content="帮助中心分类"></el-page-header>
  7. </h2>
  8. <div class="m-core">
  9. <!-- 列表 -->
  10. <el-button style="margin-bottom: 20px;" type="primary" v-permission="'helpCenterCatalog/modify'"
  11. @click="openTypes('create')"icon="el-icon-plus">添加</el-button>
  12. <div class="tableWrap">
  13. <el-table :data="tableList"
  14. :header-cell-style="{background:'#EDEEF0',color:'#444'}"
  15. row-key="id"
  16. :tree-props="{children: 'children', hasChildren: 'hasChildren'}">>
  17. <el-table-column width="120px"
  18. align="center"
  19. prop="id"
  20. label="分类编号"></el-table-column>
  21. <el-table-column align="center"
  22. prop="text"
  23. label="分类名称"></el-table-column>
  24. <el-table-column align="center"
  25. label="操作">
  26. <template slot-scope="scope">
  27. <el-button v-permission="'helpCenterCatalog/modify'"
  28. @click="openTypes('add', scope.row)"
  29. type="text">添加</el-button>
  30. <el-button v-permission="'helpCenterCatalog/modify'"
  31. @click="openTypes('update', scope.row)"
  32. type="text">修改</el-button>
  33. <el-button v-permission="'helpCenterCatalog/delete'"
  34. @click="onTypeDelOpeation(scope.row)"
  35. type="text">删除</el-button>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. <!-- <pagination
  40. :total="pageInfo.total"
  41. :page.sync="pageInfo.page"
  42. :limit.sync="pageInfo.limit"
  43. :page-sizes="pageInfo.page_size"
  44. @pagination="getList"
  45. /> -->
  46. </div>
  47. </div>
  48. <el-dialog :title="formTitle[formActionTitle]"
  49. :visible.sync="typeStatus"
  50. @close="onFormClose('ruleForm')"
  51. width="500px">
  52. <el-form :model="form"
  53. :rules="rules"
  54. ref="ruleForm">
  55. <el-form-item label="分类名称"
  56. prop="text"
  57. :label-width="formLabelWidth">
  58. <el-input v-model.trim="form.text"
  59. autocomplete="off"></el-input>
  60. </el-form-item>
  61. </el-form>
  62. <span slot="footer"
  63. class="dialog-footer">
  64. <el-button @click="typeStatus = false">取 消</el-button>
  65. <el-button type="primary"
  66. @click="onTypeSubmit('ruleForm')">确 定</el-button>
  67. </span>
  68. </el-dialog>
  69. </div>
  70. </template>
  71. <script>
  72. import pagination from "@/components/Pagination/index";
  73. // import store from '@/store'
  74. import {
  75. helpCenterCatalogList,
  76. helpCenterCatalogModify,
  77. helpCenterCatalogDelete
  78. } from "@/api/appTenant";
  79. export default {
  80. components: { pagination },
  81. name: "helpCategory",
  82. data () {
  83. return {
  84. tableList: [],
  85. subjectList: [], // 声部列表
  86. formActionTitle: "create",
  87. formTitle: {
  88. create: "添加帮助中心分类",
  89. add: "添加帮助中心分类",
  90. update: "修改帮助中心分类"
  91. },
  92. typeStatus: false, // 添加教学点
  93. formLabelWidth: "120px",
  94. form: {
  95. text: null, // 训练模块名称
  96. parentId: 0
  97. },
  98. rules: {
  99. text: [{ required: true, message: "请输入类型名称", trigger: "blur" }]
  100. // subjectIds: [{ required: true, message: "请选择声部组合", trigger: "change" }]
  101. },
  102. pageInfo: {
  103. // 分页规则
  104. limit: 10, // 限制显示条数
  105. page: 1, // 当前页
  106. total: 0, // 总条数
  107. page_size: [10, 20, 40, 50] // 选择限制显示条数
  108. }
  109. };
  110. },
  111. mounted () {
  112. this.getList()
  113. },
  114. methods: {
  115. onTypeDelOpeation (row) {
  116. this.$confirm('您是否删除该分类?', '提示', {
  117. confirmButtonText: '确定',
  118. cancelButtonText: '取消',
  119. type: 'warning'
  120. }).then(() => {
  121. helpCenterCatalogDelete({ id: row.id }).then(res => {
  122. this.messageTips('删除', res)
  123. })
  124. }).catch(() => {
  125. })
  126. },
  127. onTypeSubmit (formName) {
  128. // 添加数据
  129. this.$refs[formName].validate(valid => {
  130. if (valid) {
  131. if (this.formActionTitle == "create" || this.formActionTitle == "add") {
  132. if (this.form.id) {
  133. // 判断有没有Id,如果有则删除
  134. delete this.form.id;
  135. }
  136. helpCenterCatalogModify(this.form).then(res => {
  137. this.messageTips("添加", res);
  138. });
  139. } else if (this.formActionTitle == "update") {
  140. helpCenterCatalogModify(this.form).then(res => {
  141. this.messageTips("修改", res);
  142. });
  143. }
  144. } else {
  145. return false;
  146. }
  147. });
  148. },
  149. messageTips (title, res) {
  150. if (res.code == 200) {
  151. this.$message.success(title + "成功");
  152. this.typeStatus = false;
  153. this.getList();
  154. } else {
  155. this.$message.error(res.msg);
  156. }
  157. },
  158. getList () {
  159. // {
  160. // delFlag: 0
  161. // rows: this.pageInfo.limit,
  162. // page: this.pageInfo.page
  163. // }
  164. helpCenterCatalogList({
  165. parentId: 0
  166. }).then(res => {
  167. let result = res.data;
  168. if (res.code == 200) {
  169. this.tableList = this.setTableData(result);
  170. }
  171. });
  172. },
  173. setTableData (result) {
  174. let list = []
  175. list = result.map(res => {
  176. let tempList = {}
  177. tempList = {
  178. id: res.id,
  179. text: res.text,
  180. }
  181. if (res.children && res.children.length > 0) {
  182. tempList.children = this.setTableData(res.children)
  183. }
  184. return tempList
  185. })
  186. return list
  187. },
  188. openTypes (type, row) {
  189. this.typeStatus = true;
  190. this.formActionTitle = type;
  191. if (type == 'create') {
  192. // 添加时,默认添加一级分类
  193. this.form.parentId = 0
  194. } else if (type == "update") {
  195. // 修改的时候赋值
  196. this.form = {
  197. id: row.id,
  198. text: row.text, // 训练模块名称
  199. parentId: 0
  200. };
  201. } else if (type == 'add') {
  202. this.form.parentId = row.id
  203. }
  204. },
  205. onCancel () {
  206. this.$store.dispatch('delVisitedViews', this.$route)
  207. this.$router.push({
  208. path: "/contentManager/helpContent"
  209. });
  210. },
  211. onFormClose (formName) {
  212. // 关闭弹窗重置验证
  213. this.form = {
  214. name: null, // 训练模块名称
  215. subjectIds: []
  216. };
  217. this.$refs[formName].resetFields();
  218. }
  219. }
  220. };
  221. </script>
  222. <style lang="scss" scoped>
  223. ::v-deep .el-date-editor.el-input {
  224. width: 100% !important;
  225. }
  226. ::v-deep .el-select {
  227. width: 100% !important;
  228. }
  229. </style>