subjectCategroyList.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 声部分类管理
  7. </h2>
  8. <div class="m-core">
  9. <auth auths="subject/upset/insertCate" style="padding-bottom: 20px">
  10. <el-button @click="addCategory" type="primary">添加</el-button>
  11. </auth>
  12. <!-- <save-form
  13. :inline="true"
  14. :model="searchForm"
  15. @submit="search"
  16. @reset="onReSet"
  17. >
  18. <el-form-item>
  19. <el-input
  20. v-model.trim="searchForm.search"
  21. clearable
  22. @keyup.enter.native="search"
  23. placeholder="请输入乐团编号"
  24. ></el-input>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-input
  28. v-model.trim="searchForm.search"
  29. @keyup.enter.native="search"
  30. placeholder="请输入乐团编号"
  31. ></el-input>
  32. </el-form-item>
  33. <el-form-item>
  34. <el-button native-type="submit" type="primary">搜索</el-button>
  35. <el-button native-type="reset" type="danger">重置</el-button>
  36. </el-form-item> -->
  37. <!-- </save-form> -->
  38. <div class="tableWrap">
  39. <el-table
  40. style="width: 100%"
  41. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  42. :data="tableList"
  43. >
  44. <el-table-column
  45. align="center"
  46. prop="id"
  47. label="分类编号"
  48. ></el-table-column>
  49. <el-table-column
  50. align="center"
  51. prop="name"
  52. label="分类名称"
  53. ></el-table-column>
  54. <el-table-column align="center" prop="name" label="操作">
  55. <template slot-scope="scope">
  56. <div>
  57. <!-- v-permission="'subject/upset/del' -->
  58. <auth auths="subject/upset/resetCate">
  59. <el-button type="text" @click="resetSubjectCategory(scope.row)"
  60. >修改</el-button
  61. >
  62. </auth>
  63. <auth auths="subject/upset/delCate">
  64. <el-button type="text" @click="removeSubjectCategory(scope.row)"
  65. >删除</el-button
  66. >
  67. </auth>
  68. </div>
  69. </template>
  70. </el-table-column>
  71. <!-- <el-table-column align="center" prop="name" label="分类图片">
  72. <template slot-scope="scope">
  73. <el-image
  74. v-if="scope.row.img"
  75. style="width: 60px; height: 60px"
  76. fit="cover"
  77. :src="scope.row.img.split(',')[0]"
  78. :previewSrcList="scope.row.img.split(',')"
  79. >
  80. </el-image>
  81. </template>
  82. </el-table-column> -->
  83. </el-table>
  84. <pagination
  85. :total.sync="rules.total"
  86. :page.sync="rules.page"
  87. :limit.sync="rules.limit"
  88. :page-sizes="rules.page_size"
  89. @pagination="getList"
  90. />
  91. </div>
  92. </div>
  93. <el-dialog
  94. title="修改分类"
  95. :visible.sync="categoryVisible"
  96. width="500px"
  97. v-if="categoryVisible"
  98. >
  99. <el-form :model="form" :inline="true" ref="form">
  100. <el-form-item
  101. prop="name"
  102. label="分类名称"
  103. :rules="{
  104. required: true,
  105. message: '请输入分类名称',
  106. trigger: 'change,blur',
  107. }"
  108. >
  109. <el-input v-model="form.name"></el-input>
  110. </el-form-item>
  111. </el-form>
  112. <span slot="footer" class="dialog-footer">
  113. <el-button @click="categoryVisible = false">取 消</el-button>
  114. <el-button type="primary" @click="submitReset">确 定</el-button>
  115. </span>
  116. </el-dialog>
  117. </div>
  118. </template>
  119. <script>
  120. import axios from "axios";
  121. import { getToken } from "@/utils/auth";
  122. import pagination from "@/components/Pagination/index";
  123. import load from "@/utils/loading";
  124. import { subjectListTree,subjectUpset } from "@/api/specialSetting";
  125. export default {
  126. components: { pagination },
  127. data() {
  128. return {
  129. searchForm: {
  130. search: null,
  131. },
  132. form: {
  133. name: null,
  134. id: null,
  135. },
  136. tableList: [],
  137. organList: [],
  138. rules: {
  139. // 分页规则
  140. limit: 10, // 限制显示条数
  141. page: 1, // 当前页
  142. total: 0, // 总条数
  143. page_size: [10, 20, 40, 50], // 选择限制显示条数
  144. },
  145. categoryVisible: false,
  146. };
  147. },
  148. //生命周期 - 创建完成(可以访问当前this实例)
  149. created() {},
  150. //生命周期 - 挂载完成(可以访问DOM元素)
  151. mounted() {
  152. // 获取分部
  153. this.init();
  154. },
  155. methods: {
  156. init() {
  157. this.getList();
  158. },
  159. getList() {
  160. subjectListTree({
  161. delFlag: "NO",
  162. tenantId: 1,
  163. rows: this.rules.limit,
  164. page: this.rules.page,
  165. }).then((res) => {
  166. if (res.code == 200) {
  167. this.tableList = res.data.rows;
  168. this.rules.total = res.data.total;
  169. }
  170. });
  171. },
  172. search() {
  173. this.rules.page = 1;
  174. this.getList();
  175. },
  176. onReSet() {},
  177. resetSubjectCategory(row) {
  178. console.log(row);
  179. this.form.name = row.name;
  180. this.form.id = row.id;
  181. this.categoryVisible = true;
  182. },
  183. removeSubjectCategory(row) {
  184. this.$confirm("是否确认删除分类", "提示", {
  185. confirmButtonText: "确定",
  186. cancelButtonText: "取消",
  187. type: "warning",
  188. }).then(() => {
  189. subjectUpset({
  190. delFlag: "YES",
  191. id: row.id,
  192. }).then((res) => {
  193. this.messageTips("删除", res);
  194. this.search()
  195. });
  196. });
  197. },
  198. messageTips(title, res) {
  199. if (res.code == 200) {
  200. this.$message.success(title + "成功");
  201. } else {
  202. this.$message.error(res.msg);
  203. }
  204. },
  205. submitReset() {
  206. this.$refs.form.validate((valid) => {
  207. if (valid) {
  208. subjectUpset({
  209. parentSubjectId: 0,
  210. tenantId: 1,
  211. name: this.form.name,
  212. id:this.form.id
  213. }).then((res) => {
  214. if (res.code == 200) {
  215. this.messageTips("修改", res);
  216. this.categoryVisible = false;
  217. this.getList()
  218. }
  219. });
  220. }
  221. });
  222. },
  223. addCategory(){
  224. this.form.id = null;
  225. this.form.name = null;
  226. this.categoryVisible = true;
  227. }
  228. },
  229. };
  230. </script>
  231. <style lang='scss' scoped>
  232. </style>