musicalManagerOut.vue 6.4 KB

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