globalSubjects.vue 6.8 KB

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