musicalManager.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. trigger="click">
  13. <el-input v-model.trim="oneTypeName"
  14. size="medium"
  15. style="width: 73%"
  16. autocomplete="off"></el-input>
  17. <el-button style="margin: 0;"
  18. @click="onAddMusic"
  19. type="primary"
  20. size="medium">提交</el-button>
  21. <el-button slot="reference"
  22. type="primary"
  23. size="mini"
  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)"
  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
  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. size="small">
  56. </el-input>
  57. <el-button v-else
  58. key="tag"
  59. type="primary"
  60. size="mini"
  61. round
  62. icon="el-icon-plus"
  63. @click="item.inputStatus = true">添加</el-button>
  64. <el-button v-if="item.inputStatus"
  65. type="info"
  66. size="mini"
  67. round
  68. icon="el-icon-check"
  69. @click="onSave(item, index)">保存</el-button>
  70. </span>
  71. </el-col>
  72. </el-row>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import pagination from '@/components/Pagination/index'
  78. import { subjectListTree, subjectUpset } from '@/api/specialSetting'
  79. export default {
  80. components: { pagination },
  81. name: 'musicalManager',
  82. data () {
  83. return {
  84. oneTypeName: null, // 添加一级分类名称
  85. subjectList: [],
  86. inputValue: []
  87. }
  88. },
  89. mounted () {
  90. this.getList()
  91. },
  92. methods: {
  93. onAddMusic () {
  94. // 添加一级分类
  95. if (!this.oneTypeName) return
  96. subjectUpset({
  97. parentSubjectId: 0,
  98. tenantId: 1,
  99. name: this.oneTypeName
  100. }).then(res => {
  101. this.messageTips('添加', res)
  102. if (res.code == 200) {
  103. this.oneTypeName = null
  104. }
  105. })
  106. },
  107. onSave (item, index) {
  108. // 添加二级分类
  109. if (!this.inputValue[index]) return
  110. subjectUpset({
  111. parentSubjectId: item.id,
  112. tenantId: 1,
  113. name: this.inputValue[index]
  114. }).then(res => {
  115. this.messageTips('添加', res)
  116. if (res.code == 200) {
  117. this.inputValue[index] = null
  118. }
  119. })
  120. },
  121. subjectDelete (item) { // 删除分类
  122. subjectUpset({
  123. delFlag: 'YES',
  124. id: item.id
  125. }).then(res => {
  126. this.messageTips('删除', res)
  127. })
  128. },
  129. messageTips (title, res) {
  130. if (res.code == 200) {
  131. this.$message.success(title + '成功')
  132. this.getList()
  133. } else {
  134. this.$message.error(res.msg)
  135. }
  136. },
  137. getList () {
  138. subjectListTree({
  139. delFlag: 0,
  140. tenantId: 1,
  141. rows: 9999
  142. }).then(res => {
  143. let result = res.data
  144. if (res.code == 200) {
  145. let tempArray = []
  146. result.rows.forEach(item => {
  147. item.inputStatus = false
  148. tempArray.push(item)
  149. })
  150. this.subjectList = tempArray
  151. }
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. /deep/.el-popover {
  159. .el-form {
  160. display: flex;
  161. }
  162. .el-form-item__content {
  163. margin-left: 0 !important;
  164. }
  165. }
  166. .music-title {
  167. font-size: 14px;
  168. color: #444;
  169. .el-col {
  170. background-color: #edeef0;
  171. padding-left: 36px;
  172. }
  173. /deep/.el-button {
  174. float: right;
  175. margin-top: 10px;
  176. margin-right: 16px;
  177. }
  178. }
  179. .el-row {
  180. margin-bottom: 12px;
  181. .el-col {
  182. line-height: 48px;
  183. }
  184. .el-col-18 {
  185. width: calc(75% - 20px);
  186. margin-left: 20px;
  187. }
  188. .one_name {
  189. padding-left: 10px;
  190. }
  191. .tow_col {
  192. padding-left: 20px;
  193. .el-button--primary {
  194. background: #fff;
  195. border-color: #979797;
  196. color: #777;
  197. &:hover,
  198. &:active,
  199. &:focus {
  200. background: #fff;
  201. border-color: #979797;
  202. color: #777;
  203. }
  204. }
  205. }
  206. .tow_input {
  207. width: 100px;
  208. margin-right: 12px;
  209. }
  210. }
  211. .el-button--primary {
  212. background: #14928a;
  213. border-color: #14928a;
  214. color: #fff;
  215. &:hover,
  216. &:active,
  217. &:focus {
  218. background: #14928a;
  219. border-color: #14928a;
  220. color: #fff;
  221. }
  222. }
  223. /deep/.el-date-editor.el-input {
  224. width: 100% !important;
  225. }
  226. .el-select {
  227. width: 98% !important;
  228. }
  229. .el-tag + .el-tag {
  230. margin-left: 10px;
  231. }
  232. .button-new-tag {
  233. margin-left: 10px;
  234. height: 32px;
  235. line-height: 30px;
  236. padding-top: 0;
  237. padding-bottom: 0;
  238. }
  239. .input-new-tag {
  240. width: 90px;
  241. // margin-left: 10px;
  242. vertical-align: bottom;
  243. }
  244. .el-tag--dark.el-tag--info {
  245. background-color: #f0f2f5;
  246. border-color: #f0f2f5;
  247. color: #5a5e66;
  248. /deep/.el-tag__close {
  249. background-color: #c0c4cc;
  250. }
  251. }
  252. </style>