musicalManager.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <div class='m-container'>
  3. <!-- <h2>声部管理</h2> -->
  4. <div class="m-core">
  5. <!-- <div class='newBand'>添加</div> -->
  6. <!-- 列表 -->
  7. <el-row class="music-title">
  8. <el-col :span="6">
  9. 一级分类
  10. <el-popover placement="right"
  11. width="300"
  12. v-permission="'subject/upset/insert'"
  13. trigger="click">
  14. <el-input v-model.trim="oneTypeName"
  15. size="medium"
  16. style="width: 70%"
  17. autocomplete="off"></el-input>
  18. <el-button style="margin: 0;"
  19. @click="onAddMusic"
  20. type="primary"
  21. size="medium">提交</el-button>
  22. <el-button slot="reference"
  23. type="primary"
  24. round
  25. icon="el-icon-plus">添加</el-button>
  26. </el-popover>
  27. </el-col>
  28. <el-col :span="18">
  29. 二级分类
  30. </el-col>
  31. </el-row>
  32. <el-row v-for="(item, index) in subjectList"
  33. :key="item.id">
  34. <el-col :span="6">
  35. <el-button @click="subjectDelete(item)" v-permission="'subject/upset/del'"
  36. icon="el-icon-delete"
  37. circle></el-button>
  38. <span class="one_name">{{ item.name }}</span>
  39. </el-col>
  40. <el-col :span="18"
  41. class="tow_col">
  42. <el-tag v-for="s in item.subjects"
  43. :key="s.id"
  44. type="info"
  45. effect="dark"
  46. :closable="$helpers.permission('subject/upset/del')"
  47. :disable-transitions="false"
  48. @close="subjectDelete(s)"> {{s.name}}</el-tag>
  49. <span style="display: inline-block;">
  50. <el-input class="input-new-tag"
  51. v-if="item.inputStatus"
  52. v-model.trim="inputValue[index]"
  53. key="tag"
  54. ref="saveTagInput"
  55. >
  56. </el-input>
  57. <el-button v-else
  58. key="tag"
  59. type="primary"
  60. round
  61. v-permission="'subject/upset/insert'"
  62. icon="el-icon-plus"
  63. @click="item.inputStatus = true">添加</el-button>
  64. <el-button v-if="item.inputStatus"
  65. type="info"
  66. round
  67. icon="el-icon-check"
  68. @click="onSave(item, index)">保存</el-button>
  69. </span>
  70. </el-col>
  71. </el-row>
  72. </div>
  73. </div>
  74. </template>
  75. <script>
  76. import pagination from '@/components/Pagination/index'
  77. import { subjectListTree, subjectUpset } from '@/api/specialSetting'
  78. export default {
  79. components: { pagination },
  80. name: 'musicalManager',
  81. data () {
  82. return {
  83. oneTypeName: null, // 添加一级分类名称
  84. subjectList: [],
  85. inputValue: []
  86. }
  87. },
  88. mounted () {
  89. this.getList()
  90. },
  91. methods: {
  92. onAddMusic () {
  93. // 添加一级分类
  94. if (!this.oneTypeName) return
  95. subjectUpset({
  96. parentSubjectId: 0,
  97. tenantId: 1,
  98. name: this.oneTypeName
  99. }).then(res => {
  100. this.messageTips('添加', res)
  101. if (res.code == 200) {
  102. this.oneTypeName = null
  103. }
  104. })
  105. },
  106. onSave (item, index) {
  107. // 添加二级分类
  108. if (!this.inputValue[index]) return
  109. subjectUpset({
  110. parentSubjectId: item.id,
  111. tenantId: 1,
  112. name: this.inputValue[index]
  113. }).then(res => {
  114. this.messageTips('添加', res)
  115. if (res.code == 200) {
  116. this.inputValue[index] = null
  117. }
  118. })
  119. },
  120. subjectDelete (item) { // 删除分类
  121. this.$confirm("是否确认删除分类", "提示", {
  122. confirmButtonText: "确定",
  123. cancelButtonText: "取消",
  124. type: "warning",
  125. })
  126. .then(() => {
  127. subjectUpset({
  128. delFlag: 'YES',
  129. id: item.id
  130. }).then(res => {
  131. this.messageTips('删除', res)
  132. })
  133. })
  134. },
  135. messageTips (title, res) {
  136. if (res.code == 200) {
  137. this.$message.success(title + '成功')
  138. this.getList()
  139. } else {
  140. this.$message.error(res.msg)
  141. }
  142. },
  143. getList () {
  144. subjectListTree({
  145. delFlag: 'NO',
  146. tenantId: 1,
  147. rows: 9999
  148. }).then(res => {
  149. let result = res.data
  150. if (res.code == 200) {
  151. let tempArray = []
  152. result.rows.forEach(item => {
  153. item.inputStatus = false
  154. tempArray.push(item)
  155. })
  156. this.subjectList = tempArray
  157. }
  158. })
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="scss" scoped>
  164. /deep/.el-popover {
  165. .el-form {
  166. display: flex;
  167. }
  168. .el-form-item__content {
  169. margin-left: 0 !important;
  170. }
  171. }
  172. .music-title {
  173. font-size: 14px;
  174. color: #444;
  175. .el-col {
  176. background-color: #edeef0;
  177. padding-left: 36px;
  178. }
  179. /deep/.el-button {
  180. float: right;
  181. margin-top: 10px;
  182. margin-right: 16px;
  183. }
  184. }
  185. .el-row {
  186. margin-bottom: 12px;
  187. .el-col {
  188. line-height: 48px;
  189. }
  190. .el-col-18 {
  191. width: calc(75% - 20px);
  192. margin-left: 20px;
  193. }
  194. .one_name {
  195. padding-left: 10px;
  196. }
  197. .tow_col {
  198. padding-left: 20px;
  199. .el-button--primary {
  200. background: #fff;
  201. border-color: #979797;
  202. color: #777;
  203. &:hover,
  204. &:active,
  205. &:focus {
  206. background: #fff;
  207. border-color: #979797;
  208. color: #777;
  209. }
  210. }
  211. }
  212. .tow_input {
  213. width: 100px;
  214. margin-right: 12px;
  215. }
  216. }
  217. /deep/.el-date-editor.el-input {
  218. width: 100% !important;
  219. }
  220. .el-select {
  221. width: 98% !important;
  222. }
  223. .el-tag + .el-tag {
  224. margin-left: 10px;
  225. }
  226. .button-new-tag {
  227. margin-left: 10px;
  228. height: 32px;
  229. line-height: 30px;
  230. padding-top: 0;
  231. padding-bottom: 0;
  232. }
  233. .input-new-tag {
  234. width: 90px;
  235. // margin-left: 10px;
  236. vertical-align: bottom;
  237. }
  238. .el-tag--dark.el-tag--info {
  239. background-color: #f0f2f5;
  240. border-color: #f0f2f5;
  241. color: #5a5e66;
  242. /deep/.el-tag__close {
  243. background-color: #c0c4cc;
  244. }
  245. }
  246. </style>