globalSubjects.vue 9.2 KB

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