helpCategory.vue 7.1 KB

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