globalSubjects.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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 prop="search">
  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 prop="parentSubjectId">
  24. <el-select
  25. v-model="searchForm.parentSubjectId"
  26. placeholder="选择声部分类"
  27. prop="parentSubjectId"
  28. clearable
  29. filterable
  30. >
  31. <el-option
  32. v-for="item in fatherList"
  33. :key="item.id"
  34. :label="item.name"
  35. :value="item.id"
  36. >
  37. </el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button native-type="submit" type="primary">搜索</el-button>
  42. <el-button native-type="reset" type="danger">重置</el-button>
  43. </el-form-item>
  44. </save-form>
  45. <auth auths="subject/upset/insert" style="margin-bottom: 20px">
  46. <el-button @click="addCategory" type="primary">添加</el-button>
  47. </auth>
  48. <div class="tableWrap">
  49. <el-table
  50. style="width: 100%"
  51. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  52. :data="tableList"
  53. >
  54. <el-table-column
  55. align="center"
  56. prop="id"
  57. label="编号"
  58. ></el-table-column>
  59. <el-table-column
  60. align="center"
  61. prop="name"
  62. label="声部名称"
  63. ></el-table-column>
  64. <el-table-column
  65. align="center"
  66. prop="parentSubjectName"
  67. label="所属分类"
  68. ></el-table-column>
  69. <el-table-column align="center" prop="name" label="声部图片">
  70. <template slot-scope="scope">
  71. <el-image
  72. v-if="scope.row.img"
  73. style="width: 60px; height: 60px"
  74. fit="cover"
  75. :src="scope.row.img.split(',')[0]"
  76. :previewSrcList="scope.row.img.split(',')"
  77. >
  78. </el-image>
  79. </template>
  80. </el-table-column>
  81. <el-table-column align="center" prop="name" label="操作">
  82. <template slot-scope="scope">
  83. <div>
  84. <!-- v-permission="'subject/upset/del' -->
  85. <auth auths="subject/upset/reset">
  86. <el-button
  87. type="text"
  88. @click="resetSubjectCategory(scope.row)"
  89. >修改</el-button
  90. >
  91. </auth>
  92. <auth auths="subject/upset/del">
  93. <el-button
  94. type="text"
  95. @click="removeSubjectCategory(scope.row)"
  96. >删除</el-button
  97. >
  98. </auth>
  99. </div>
  100. </template>
  101. </el-table-column>
  102. </el-table>
  103. <pagination
  104. :total.sync="rules.total"
  105. :page.sync="rules.page"
  106. :limit.sync="rules.limit"
  107. :page-sizes="rules.page_size"
  108. @pagination="getList"
  109. />
  110. </div>
  111. </div>
  112. <el-dialog
  113. title="修改分类"
  114. :visible.sync="categoryVisible"
  115. width="500px"
  116. v-if="categoryVisible"
  117. >
  118. <el-form :model="form" :inline="true" ref="form">
  119. <el-form-item prop="parentSubjectId" label="所属分类" :rules="[{ required: true, message: '请选择声部分类' }]">
  120. <el-select
  121. v-model="form.parentSubjectId"
  122. placeholder="请选择所属分类"
  123. prop="parentSubjectId"
  124. style="width:365px!important"
  125. clearable
  126. filterable
  127. >
  128. <el-option
  129. v-for="item in fatherList"
  130. :key="item.id"
  131. :label="item.name"
  132. :value="item.id"
  133. >
  134. </el-option>
  135. </el-select>
  136. </el-form-item>
  137. <el-form-item
  138. prop="name"
  139. label="声部名称"
  140. :rules="{
  141. required: true,
  142. message: '请输入声部名称',
  143. trigger: 'change,blur',
  144. }"
  145. >
  146. <el-input v-model="form.name" placeholder="请输入声部名称" style="width:365px!important"></el-input>
  147. </el-form-item>
  148. <el-form-item
  149. label="声部图片"
  150. prop="img"
  151. :rules="[{ required: true, message: '请上传声部图片' }]"
  152. >
  153. <!-- v-if="!addDisabled" -->
  154. <!-- <upload
  155. v-model="form.img"
  156. :imageWidthM="260"
  157. :imageHeightM="260"
  158. ></upload> -->
  159. <!-- <img v-else :src="form.img" alt="" width="120px" height="120px" /> -->
  160. <image-cropper :options="cropperOptions" :imgSize="2" :imageUrl="form.img" @crop-upload-success="cropSuccess" />
  161. <p style="color: red" >
  162. 仅支持图片格式:JPG、PNG、GIF, 大小2M以内;
  163. </p>
  164. </el-form-item>
  165. </el-form>
  166. <span slot="footer" class="dialog-footer">
  167. <el-button @click="categoryVisible = false">取 消</el-button>
  168. <el-button type="primary" @click="submitReset">确 定</el-button>
  169. </span>
  170. </el-dialog>
  171. </div>
  172. </template>
  173. <script>
  174. import pagination from "@/components/Pagination/index";
  175. import ImageCropper from '@/components/ImageCropper'
  176. import {
  177. subjectListTree,
  178. subjectUpset,
  179. subSubjectList,
  180. } from "@/api/specialSetting";
  181. export default {
  182. components: { pagination, ImageCropper },
  183. data() {
  184. return {
  185. searchForm: {
  186. search: null,
  187. parentSubjectId: null,
  188. },
  189. form: {
  190. name: null,
  191. id: null,
  192. img:null,
  193. parentSubjectId:null
  194. },
  195. tableList: [],
  196. organList: [],
  197. rules: {
  198. // 分页规则
  199. limit: 10, // 限制显示条数
  200. page: 1, // 当前页
  201. total: 0, // 总条数
  202. page_size: [10, 20, 40, 50], // 选择限制显示条数
  203. },
  204. categoryVisible: false,
  205. fatherList: [],
  206. cropperOptions: {
  207. autoCrop: true, //是否默认生成截图框
  208. autoCropWidth: 260, //默认生成截图框宽度
  209. autoCropHeight: 260, //默认生成截图框高度
  210. fixedBox: true, //是否固定截图框大小 不允许改变
  211. previewsCircle: false, //预览图是否是圆形
  212. title: '声部图片', //模态框上显示的标题
  213. },
  214. };
  215. },
  216. //生命周期 - 创建完成(可以访问当前this实例)
  217. created() {},
  218. //生命周期 - 挂载完成(可以访问DOM元素)
  219. mounted() {
  220. // 获取分部
  221. this.init();
  222. },
  223. methods: {
  224. init() {
  225. this.getList();
  226. this.getFatherList();
  227. },
  228. getFatherList() {
  229. subjectListTree({
  230. delFlag: "NO",
  231. rows: 9999,
  232. page: 1,
  233. }).then((res) => {
  234. if (res.code == 200) {
  235. this.fatherList = res.data.rows;
  236. }
  237. });
  238. },
  239. getList() {
  240. subSubjectList({ ...this.searchForm,page:this.rules.page,rows:this.rules.limit }).then((res) => {
  241. this.tableList = res.data.rows;
  242. this.rules.total = res.data.total
  243. });
  244. },
  245. search() {
  246. this.rules.page = 1;
  247. this.getList();
  248. },
  249. onReSet() {
  250. this.$nextTick(() => {
  251. this.search();
  252. });
  253. },
  254. resetSubjectCategory(row) {
  255. this.form.name = row.name;
  256. this.form.id = row.id;
  257. this.form.parentSubjectId = row.parentSubjectId;
  258. this.form.img = row.img;
  259. this.categoryVisible = true;
  260. },
  261. removeSubjectCategory(row) {
  262. this.$confirm("是否确认删除声部", "提示", {
  263. confirmButtonText: "确定",
  264. cancelButtonText: "取消",
  265. type: "warning",
  266. }).then(() => {
  267. subjectUpset({
  268. delFlag: "YES",
  269. id: row.id,
  270. }).then((res) => {
  271. this.messageTips("删除", res);
  272. this.search();
  273. });
  274. });
  275. },
  276. messageTips(title, res) {
  277. if (res.code == 200) {
  278. this.$message.success(title + "成功");
  279. } else {
  280. this.$message.error(res.msg);
  281. }
  282. },
  283. submitReset() {
  284. this.$refs.form.validate((valid) => {
  285. if (valid) {
  286. subjectUpset({
  287. tenantId: 1,
  288. ...this.form
  289. }).then((res) => {
  290. if (res.code == 200) {
  291. this.messageTips("修改", res);
  292. this.categoryVisible = false;
  293. this.getList();
  294. }
  295. });
  296. }
  297. });
  298. },
  299. addCategory() {
  300. this.form.id = null;
  301. this.form.name = null;
  302. this.form.parentSubjectId = null;
  303. this.form.img = null;
  304. this.categoryVisible = true;
  305. },
  306. //上传图片成功
  307. cropSuccess(data) {
  308. this.form.img = data.data.url;
  309. },
  310. },
  311. };
  312. </script>
  313. <style lang='scss' scoped>
  314. </style>