helpCategory.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. mounted () {
  113. this.getList()
  114. },
  115. methods: {
  116. onTypeDelOpeation (row) {
  117. this.$confirm('您是否删除该分类?', '提示', {
  118. confirmButtonText: '确定',
  119. cancelButtonText: '取消',
  120. type: 'warning'
  121. }).then(() => {
  122. helpCenterCatalogDelete({ id: row.id }).then(res => {
  123. this.messageTips('删除', res)
  124. })
  125. }).catch(() => {
  126. })
  127. },
  128. onTypeSubmit (formName) {
  129. // 添加数据
  130. this.$refs[formName].validate(valid => {
  131. if (valid) {
  132. if (this.formActionTitle == "create" || this.formActionTitle == "add") {
  133. if (this.form.id) {
  134. // 判断有没有Id,如果有则删除
  135. delete this.form.id;
  136. }
  137. helpCenterCatalogModify(this.form).then(res => {
  138. this.messageTips("添加", res);
  139. });
  140. } else if (this.formActionTitle == "update") {
  141. helpCenterCatalogModify(this.form).then(res => {
  142. this.messageTips("修改", res);
  143. });
  144. }
  145. } else {
  146. return false;
  147. }
  148. });
  149. },
  150. messageTips (title, res) {
  151. if (res.code == 200) {
  152. this.$message.success(title + "成功");
  153. this.typeStatus = false;
  154. this.getList();
  155. } else {
  156. this.$message.error(res.msg);
  157. }
  158. },
  159. getList () {
  160. // {
  161. // delFlag: 0
  162. // rows: this.pageInfo.limit,
  163. // page: this.pageInfo.page
  164. // }
  165. helpCenterCatalogList({
  166. parentId: 0
  167. }).then(res => {
  168. let result = res.data;
  169. if (res.code == 200) {
  170. this.tableList = this.setTableData(result);
  171. }
  172. });
  173. },
  174. setTableData (result) {
  175. let list = []
  176. list = result.map(res => {
  177. let tempList = {}
  178. tempList = {
  179. id: res.id,
  180. text: res.text,
  181. }
  182. if (res.children && res.children.length > 0) {
  183. tempList.children = this.setTableData(res.children)
  184. }
  185. return tempList
  186. })
  187. return list
  188. },
  189. openTypes (type, row) {
  190. this.typeStatus = true;
  191. this.formActionTitle = type;
  192. if (type == 'create') {
  193. // 添加时,默认添加一级分类
  194. this.form.parentId = 0
  195. } else if (type == "update") {
  196. // 修改的时候赋值
  197. this.form = {
  198. id: row.id,
  199. text: row.text, // 作业模块名称
  200. parentId: 0
  201. };
  202. } else if (type == 'add') {
  203. this.form.parentId = row.id
  204. }
  205. },
  206. onCancel () {
  207. this.$store.dispatch('delVisitedViews', this.$route)
  208. this.$router.push({
  209. path: "/insideSetting/helpContent"
  210. });
  211. },
  212. onFormClose (formName) {
  213. // 关闭弹窗重置验证
  214. this.form = {
  215. name: null, // 作业模块名称
  216. subjectIds: []
  217. };
  218. this.$refs[formName].resetFields();
  219. }
  220. }
  221. };
  222. </script>
  223. <style lang="scss" scoped>
  224. .el-button--primary {
  225. background: #14928a;
  226. border-color: #14928a;
  227. color: #fff;
  228. &:hover,
  229. &:active,
  230. &:focus {
  231. background: #14928a;
  232. border-color: #14928a;
  233. color: #fff;
  234. }
  235. }
  236. /deep/.el-date-editor.el-input {
  237. width: 100% !important;
  238. }
  239. /deep/.el-select {
  240. width: 100% !important;
  241. }
  242. </style>