addMusic.tsx 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950
  1. import { defineComponent, h, onMounted, reactive, ref } from 'vue'
  2. import SaveForm from '@components/save-form'
  3. import {
  4. DataTableColumns,
  5. DataTableRowKey,
  6. NButton,
  7. NCascader,
  8. NDataTable,
  9. NFormItem,
  10. NIcon,
  11. NImage,
  12. NInput,
  13. NInputNumber,
  14. NSelect,
  15. NSpace,
  16. NStep,
  17. NSteps,
  18. useDialog,
  19. useMessage
  20. } from 'naive-ui'
  21. import Pagination from '@components/pagination'
  22. import { getMapValueByKey, getSelectDataFromObj } from '@/utils/objectUtil'
  23. import {appKey, musicSheetAvailableType, musicSheetSourceType, musicSheetType, scoreType} from '@/utils/constant'
  24. import {musicSheetApplicationExtendCategoryList, musicSheetApplicationExtendSaveBatch, musicSheetApplicationOwnerList, musicSheetPage} from '@views/music-library/api'
  25. import deepClone from '@/utils/deep.clone'
  26. import { getOwnerName } from '@views/music-library/musicUtil'
  27. import TheTooltip from "@components/TheTooltip";
  28. import {sysApplicationPage} from "@views/menu-manage/api";
  29. export default defineComponent({
  30. name: 'gyt-addMusic',
  31. props: {
  32. appId: {
  33. type: String,
  34. required: true
  35. },
  36. subjectList: {
  37. type: Array,
  38. default: () => []
  39. },
  40. musicSheetCategories: {
  41. type: Array,
  42. default: () => []
  43. }
  44. },
  45. emits: ['close', 'getList'],
  46. setup(props, { slots, attrs, emit }) {
  47. const dialogs = useDialog()
  48. const message = useMessage()
  49. const state = reactive({
  50. loading: false,
  51. pagination: {
  52. page: 1,
  53. rows: 5,
  54. pageTotal: 0
  55. },
  56. stepPagination: {
  57. page: 1,
  58. rows: 5,
  59. pageTotal: 0
  60. },
  61. searchForm: {
  62. keyword: null,
  63. musicSheetType: null,
  64. subjectId: null,
  65. sourceType: null,
  66. composer : null,
  67. userId : null,
  68. applicationId : null,
  69. },
  70. subjectList: [] as any,
  71. showAdd: false,
  72. currentStep: 1,
  73. dataList: [],
  74. selectRowData: [] as any, // 选择的数据列表
  75. musicSheetCategories: [] as any,
  76. startSortNum: null as any, // 排序起始值
  77. projectMusicCategoryId: null as any, // 曲目分类ID
  78. isConvertibleScore: null as any,//是否支持转简谱
  79. scoreType: null as any,//默认谱面
  80. useProjectData: [] as any, // 适用项目行数据
  81. userIdDisable: true,
  82. userIdData: [] as any,
  83. globalAvailableType : null as any,
  84. })
  85. onMounted(async () => {
  86. state.searchForm.keyword = null
  87. state.searchForm.musicSheetType = null
  88. state.searchForm.subjectId = null
  89. state.searchForm.sourceType = null
  90. state.searchForm.composer = null
  91. state.searchForm.userId = null
  92. state.searchForm.applicationId = null
  93. state.loading = true
  94. state.subjectList = props.subjectList
  95. // state.musicSheetCategories = props.musicSheetCategories
  96. //加载曲目分类列表
  97. try {
  98. const {data} = await musicSheetApplicationExtendCategoryList({
  99. applicationIds: props.appId,
  100. enable: true
  101. })
  102. if (data && data.length > 0) {
  103. state.musicSheetCategories = data[0].musicSheetCategories
  104. }
  105. } catch {
  106. }
  107. await initUseAppList()
  108. await getList()
  109. })
  110. const initUseAppList = async () => {
  111. try {
  112. const appKeys = Object.keys(appKey)
  113. const { data } = await sysApplicationPage({ page: 1, rows: 999 })
  114. const tempList = data.rows || []
  115. state.useProjectData = []
  116. const filter = tempList.filter((next: any) => {
  117. return appKeys.includes(next.appKey)
  118. })
  119. filter.forEach((item: any) => {
  120. state.useProjectData.push({
  121. ...item,
  122. label: item.appName,
  123. value: item.id
  124. })
  125. })
  126. } catch {}
  127. }
  128. const getList = async () => {
  129. try {
  130. state.loading = true
  131. const search = {
  132. ...state.searchForm,
  133. userId: (state.searchForm.sourceType && state.searchForm.sourceType == 'PERSON') ? state.searchForm.userId : null,
  134. organizationRoleId: (state.searchForm.sourceType && state.searchForm.sourceType == 'ORG') ? state.searchForm.userId : null,
  135. }
  136. const { data } = await musicSheetPage({
  137. ...state.pagination,
  138. ...search,
  139. addAppId: props.appId
  140. })
  141. state.pagination.pageTotal = Number(data.total)
  142. state.dataList = data.rows || []
  143. } catch {}
  144. state.loading = false
  145. }
  146. const saveForm = ref()
  147. const onSearch = () => {
  148. saveForm.value?.submit()
  149. }
  150. const onBtnReset = () => {
  151. saveForm.value?.reset()
  152. }
  153. const onSubmit = () => {
  154. state.pagination.page = 1
  155. getList()
  156. }
  157. const updateUserIdData = async (sourceType: any) => {
  158. if (!state.searchForm.applicationId) {
  159. return
  160. }
  161. state.userIdData = []
  162. state.searchForm.userId = null
  163. if (sourceType && sourceType !== 'PLATFORM') {
  164. const { data } = await musicSheetApplicationOwnerList({
  165. page: 1,
  166. rows: 9999,
  167. sourceType: sourceType,
  168. applicationId: state.searchForm.applicationId
  169. })
  170. const temp = data.rows || []
  171. temp.forEach((next: any) => {
  172. state.userIdData.push({
  173. ...next,
  174. label: sourceType === 'PERSON' ? next.userName : next.organizationRole,
  175. value: sourceType === 'PERSON' ? next.userId : next.organizationRoleId
  176. })
  177. })
  178. }
  179. }
  180. const onSave = async () => {
  181. if (state.selectRowData.length == 0) {
  182. message.error('未选择曲目')
  183. return
  184. }
  185. const params = [] as any[]
  186. for (let i = 0; i < state.selectRowData.length; i++) {
  187. const item = state.selectRowData[i]
  188. if (!item.availableType) {
  189. message.error('可用途径不能为空')
  190. return
  191. }
  192. if (!item.projectMusicCategoryId) {
  193. message.error('曲目分类不能为空')
  194. return
  195. }
  196. if (item.scoreType == null) {
  197. message.error('默认谱面不能为空')
  198. return
  199. }
  200. if (item.isConvertibleScore == null) {
  201. message.error('是否支持转谱不能为空')
  202. return
  203. }
  204. if (item.sortNo === null || item.sortNo === undefined || item.sortNo === '') {
  205. message.error('排序号不能为空')
  206. return
  207. }
  208. params.push({
  209. ...item,
  210. musicSheetId: item.id,
  211. musicSheetCategoryId: item.projectMusicCategoryId,
  212. availableType: item.availableType,
  213. applicationId: props.appId,
  214. id: null
  215. })
  216. }
  217. const res = (await musicSheetApplicationExtendSaveBatch(params)) as any
  218. if (res && res.code == '200') {
  219. message.success(`添加成功`)
  220. emit('getList')
  221. emit('close')
  222. }
  223. }
  224. const columnsField = [
  225. {
  226. type: 'selection'
  227. },
  228. {
  229. title: '曲目编号',
  230. key: 'id'
  231. },
  232. {
  233. title: '封面图',
  234. key: 'titleImg',
  235. render(row: any) {
  236. return <NImage width={40} height={40} src={row.musicCover} />
  237. }
  238. },
  239. {
  240. title: '可用声部',
  241. key: 'subjectNames',
  242. render: (row: any) => {
  243. return <TheTooltip content={row.subjectNames}/>
  244. }
  245. },
  246. {
  247. title: '曲目名称',
  248. key: 'name'
  249. },
  250. {
  251. title: '音乐人',
  252. key: 'composer'
  253. },
  254. {
  255. title: '多声轨渲染',
  256. key: 'musicSheetType',
  257. render: (row: any) => {
  258. return (
  259. <div>
  260. {getMapValueByKey(row.musicSheetType, new Map(Object.entries(musicSheetType)))}
  261. </div>
  262. )
  263. }
  264. },
  265. {
  266. title: '曲目来源',
  267. key: 'sourceType',
  268. render(row: any) {
  269. return getMapValueByKey(row.sourceType, new Map(Object.entries(musicSheetSourceType)))
  270. }
  271. },
  272. {
  273. title: '所属人',
  274. key: 'userName',
  275. render: (row: any) => {
  276. return <TheTooltip content={getOwnerName(row.musicSheetExtend, row.sourceType)} />
  277. }
  278. }
  279. ]
  280. const columns = (): any => {
  281. return columnsField
  282. }
  283. const stepColumns = (): DataTableColumns => {
  284. const field = deepClone(columnsField)
  285. field.splice(0, 1)
  286. field.push({
  287. title(column: any) {
  288. return (
  289. <NSpace>
  290. 可用途径
  291. <NButton
  292. type="primary"
  293. size="small"
  294. text
  295. onClick={() => {
  296. dialogs.create({
  297. title: '请选择可用途径',
  298. showIcon: false,
  299. content: () => {
  300. return h(
  301. 'div',
  302. {
  303. class: 'flex flex-col justify-center items-center text-14px'
  304. },
  305. [
  306. // icon
  307. h(NSelect, {
  308. onUpdateValue(v) {
  309. state.globalAvailableType = v
  310. },
  311. clearable: true,
  312. options: [
  313. {
  314. label: '学校',
  315. value: 'ORG'
  316. },
  317. {
  318. label: '平台',
  319. value: 'PLATFORM'
  320. },
  321. ]
  322. })
  323. ]
  324. )
  325. },
  326. positiveText: '确定',
  327. negativeText: '取消',
  328. onPositiveClick: () => {
  329. for (let i = 0; i < state.selectRowData.length; i++) {
  330. const item = state.selectRowData[i]
  331. item.availableType = state.globalAvailableType
  332. }
  333. }
  334. })
  335. }}
  336. >
  337. <NIcon size={15} style="padding-left: 5px;margin-top:4px">
  338. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
  339. <path d="M2 26h28v2H2z" fill="currentColor"></path>
  340. <path
  341. d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
  342. fill="currentColor"
  343. ></path>
  344. </svg>
  345. </NIcon>
  346. </NButton>
  347. </NSpace>
  348. )
  349. },
  350. key: 'availableType',
  351. render: (row: any) => {
  352. return (
  353. <NSelect
  354. placeholder="请选择可用途径"
  355. value={row.availableType}
  356. options={[
  357. {
  358. label: '学校',
  359. value: 'ORG'
  360. },
  361. {
  362. label: '平台',
  363. value: 'PLATFORM'
  364. },
  365. ]}
  366. onUpdateValue={(value) => {
  367. row['availableType'] = value
  368. }}
  369. clearable
  370. />
  371. )
  372. }
  373. })
  374. field.push({
  375. title(column: any) {
  376. return (
  377. <NSpace>
  378. 曲目分类
  379. <NButton
  380. type="primary"
  381. size="small"
  382. text
  383. onClick={() => {
  384. dialogs.create({
  385. title: '请选择曲目分类',
  386. showIcon: false,
  387. content: () => {
  388. return h(
  389. 'div',
  390. {
  391. class: 'flex flex-col justify-center items-center text-14px'
  392. },
  393. [
  394. // icon
  395. h(NCascader, {
  396. onUpdateValue(v) {
  397. state.projectMusicCategoryId = v
  398. },
  399. valueField: 'id',
  400. labelField: 'name',
  401. childrenField: 'children',
  402. placeholderField: '请选择曲目分类',
  403. filterable: true,
  404. options: state.musicSheetCategories
  405. })
  406. ]
  407. )
  408. },
  409. positiveText: '确定',
  410. negativeText: '取消',
  411. onPositiveClick: () => {
  412. for (let i = 0; i < state.selectRowData.length; i++) {
  413. const item = state.selectRowData[i]
  414. item.projectMusicCategoryId = state.projectMusicCategoryId
  415. }
  416. }
  417. })
  418. }}
  419. >
  420. <NIcon size={15} style="padding-left: 5px;margin-top:4px">
  421. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
  422. <path d="M2 26h28v2H2z" fill="currentColor"></path>
  423. <path
  424. d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
  425. fill="currentColor"
  426. ></path>
  427. </svg>
  428. </NIcon>
  429. </NButton>
  430. </NSpace>
  431. )
  432. },
  433. key: 'projectMusicCategoryId',
  434. width: 200,
  435. render: (row: any) => {
  436. // })
  437. return (
  438. <NCascader
  439. valueField="id"
  440. labelField="name"
  441. children-field="children"
  442. placeholder="请选择曲目分类"
  443. value={row.projectMusicCategoryId}
  444. options={state.musicSheetCategories}
  445. onUpdateValue={(value: any) => {
  446. row.projectMusicCategoryId = value
  447. }}
  448. filterable
  449. clearable
  450. />
  451. )
  452. }
  453. })
  454. field.push({
  455. title(column: any) {
  456. return (
  457. <NSpace>
  458. 默认谱面
  459. <NButton
  460. type="primary"
  461. size="small"
  462. text
  463. onClick={() => {
  464. dialogs.create({
  465. title: '请选择默认谱面',
  466. showIcon: false,
  467. content: () => {
  468. return h(
  469. 'div',
  470. {
  471. class: 'flex flex-col justify-center items-center text-14px'
  472. },
  473. [
  474. // icon
  475. h(NSelect, {
  476. onUpdateValue(v) {
  477. state.scoreType = v
  478. },
  479. options: getSelectDataFromObj(scoreType)
  480. })
  481. ]
  482. )
  483. },
  484. positiveText: '确定',
  485. negativeText: '取消',
  486. onPositiveClick: () => {
  487. for (let i = 0; i < state.selectRowData.length; i++) {
  488. const item = state.selectRowData[i]
  489. item.scoreType = state.scoreType
  490. }
  491. }
  492. })
  493. }}
  494. >
  495. <NIcon size={15} style="padding-left: 5px;margin-top:4px">
  496. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
  497. <path d="M2 26h28v2H2z" fill="currentColor"></path>
  498. <path
  499. d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
  500. fill="currentColor"
  501. ></path>
  502. </svg>
  503. </NIcon>
  504. </NButton>
  505. </NSpace>
  506. )
  507. },
  508. key: 'scoreType',
  509. width: 200,
  510. render: (row: any) => {
  511. // })
  512. return (
  513. <NSelect
  514. placeholder="请选择默认谱面"
  515. value={row.scoreType}
  516. options={getSelectDataFromObj(scoreType)}
  517. onUpdateValue={(value: any) => {
  518. row.scoreType = value
  519. }}
  520. clearable
  521. />
  522. )
  523. }
  524. })
  525. field.push({
  526. title(column: any) {
  527. return (
  528. <NSpace>
  529. 是否支持转谱
  530. <NButton
  531. type="primary"
  532. size="small"
  533. text
  534. onClick={() => {
  535. dialogs.create({
  536. title: '是否支持转谱',
  537. showIcon: false,
  538. content: () => {
  539. return h(
  540. 'div',
  541. {
  542. class: 'flex flex-col justify-center items-center text-14px'
  543. },
  544. [
  545. // icon
  546. h(NSelect, {
  547. onUpdateValue(v) {
  548. state.isConvertibleScore = v
  549. },
  550. options: [
  551. {
  552. label: '是',
  553. value: true
  554. },
  555. {
  556. label: '否',
  557. value: false
  558. }] as any
  559. })
  560. ]
  561. )
  562. },
  563. positiveText: '确定',
  564. negativeText: '取消',
  565. onPositiveClick: () => {
  566. for (let i = 0; i < state.selectRowData.length; i++) {
  567. const item = state.selectRowData[i]
  568. item.isConvertibleScore = state.isConvertibleScore
  569. }
  570. }
  571. })
  572. }}
  573. >
  574. <NIcon size={15} style="padding-left: 5px;margin-top:4px">
  575. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
  576. <path d="M2 26h28v2H2z" fill="currentColor"></path>
  577. <path
  578. d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
  579. fill="currentColor"
  580. ></path>
  581. </svg>
  582. </NIcon>
  583. </NButton>
  584. </NSpace>
  585. )
  586. },
  587. key: 'isConvertibleScore',
  588. width: 200,
  589. render: (row: any) => {
  590. // })
  591. return (
  592. <NSelect
  593. value={row.isConvertibleScore}
  594. options={[
  595. {
  596. label: '是',
  597. value: true
  598. },
  599. {
  600. label: '否',
  601. value: false
  602. } as any
  603. ]}
  604. onUpdateValue={(value: any) => {
  605. row.isConvertibleScore = value
  606. }}
  607. filterable
  608. clearable
  609. />
  610. )
  611. }
  612. })
  613. field.push({
  614. title(column: any) {
  615. return (
  616. <NSpace>
  617. 排序
  618. <NButton
  619. type="primary"
  620. size="small"
  621. text
  622. onClick={() => {
  623. dialogs.create({
  624. title: '请输入排序起始值',
  625. showIcon: false,
  626. content: () => {
  627. return h(
  628. 'div',
  629. {
  630. class: 'flex flex-col justify-center items-center text-14px'
  631. },
  632. [
  633. // icon
  634. h(NInputNumber, {
  635. onUpdateValue(v) {
  636. state.startSortNum = v
  637. },
  638. min: 0,
  639. max: 9999
  640. })
  641. ]
  642. )
  643. },
  644. positiveText: '确定',
  645. negativeText: '取消',
  646. onPositiveClick: () => {
  647. if (state.startSortNum) {
  648. for (let i = 0; i < state.selectRowData.length; i++) {
  649. const item = state.selectRowData[i]
  650. item.sortNo = state.startSortNum + i
  651. }
  652. }
  653. }
  654. })
  655. }}
  656. >
  657. <NIcon size={15} style="padding-left: 5px;margin-top:4px">
  658. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
  659. <path d="M2 26h28v2H2z" fill="currentColor"></path>
  660. <path
  661. d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
  662. fill="currentColor"
  663. ></path>
  664. </svg>
  665. </NIcon>
  666. </NButton>
  667. </NSpace>
  668. )
  669. },
  670. key: 'sortNo',
  671. width: 150,
  672. render: (row: any) => {
  673. return h(NInputNumber, {
  674. value: row.sortNo,
  675. min: 0,
  676. max: 9999,
  677. onUpdateValue(value: any) {
  678. row.sortNo = value
  679. }
  680. })
  681. }
  682. })
  683. field.push({
  684. title: '操作',
  685. key: 'operation',
  686. fixed: 'right',
  687. render(row: any) {
  688. return (
  689. <NSpace>
  690. <NButton
  691. type="primary"
  692. size="small"
  693. text
  694. //v-auth="musicSheet/update1602302618558099458"
  695. onClick={() => {
  696. dialogs.warning({
  697. title: '提示',
  698. content: `是否删除该数据?`,
  699. positiveText: '确定',
  700. negativeText: '取消',
  701. onPositiveClick: async () => {
  702. try {
  703. const index = state.selectRowData.findIndex((item: any) => {
  704. if (item.id == row.id) {
  705. return true
  706. }
  707. })
  708. if (index > -1) {
  709. state.selectRowData.splice(index, 1)
  710. }
  711. const index1 = checkedRowKeysRef.value.findIndex((item: any) => {
  712. if (item == row.id) {
  713. return true
  714. }
  715. })
  716. if (index1 > -1) {
  717. checkedRowKeysRef.value.splice(index, 1)
  718. }
  719. } catch {}
  720. }
  721. })
  722. }}
  723. >
  724. 移除
  725. </NButton>
  726. </NSpace>
  727. )
  728. }
  729. })
  730. return field
  731. }
  732. const checkedRowKeysRef = ref<DataTableRowKey[]>([])
  733. const handleCheck = (rowKeys: DataTableRowKey[]) => {
  734. checkedRowKeysRef.value = rowKeys
  735. // 添加行更新值
  736. state.dataList.forEach((next: any) => {
  737. if (checkedRowKeysRef.value.includes(next.id)) {
  738. const find = state.selectRowData.find((row: any) => {
  739. return row.id === next.id
  740. })
  741. if (!find) {
  742. state.selectRowData.push(next)
  743. }
  744. }
  745. })
  746. // 去掉行更新值
  747. state.selectRowData = state.selectRowData.filter((next: any) => {
  748. return checkedRowKeysRef.value.includes(next.id)
  749. })
  750. }
  751. return () => {
  752. return (
  753. <div class="system-menu-container">
  754. <NSpace vertical size="medium">
  755. <NSteps
  756. current={state.currentStep}
  757. // onUpdateCurrent={()=>{
  758. // state.currentStep = val
  759. // }}
  760. style={'margin-bottom: 10px;margin-top: 10px'}
  761. >
  762. <NStep title="选择曲目" description=""></NStep>
  763. <NStep title="设置曲目信息" description=""></NStep>
  764. </NSteps>
  765. </NSpace>
  766. {state.currentStep === 1 && (
  767. <div class="system-menu-container">
  768. <SaveForm
  769. ref={saveForm}
  770. model={state.searchForm}
  771. onSubmit={onSubmit}
  772. // saveKey="cooleshow-edu-addMusic"
  773. onSetModel={(val: any) => (state.searchForm = val)}
  774. >
  775. <NFormItem label="关键词" path="keyword">
  776. <NInput
  777. v-model:value={state.searchForm.keyword}
  778. placeholder="请输入曲目名称/编号"
  779. clearable
  780. />
  781. </NFormItem>
  782. <NFormItem label="多声轨渲染" path="musicSheetType">
  783. <NSelect
  784. placeholder="请选择多声轨渲染"
  785. v-model:value={state.searchForm.musicSheetType}
  786. options={getSelectDataFromObj(musicSheetType)}
  787. clearable
  788. />
  789. </NFormItem>
  790. <NFormItem label="可用声部" path="musicSubject">
  791. <NSelect
  792. placeholder="请选择可用声部"
  793. v-model:value={state.searchForm.subjectId}
  794. options={state.subjectList}
  795. clearable
  796. />
  797. </NFormItem>
  798. <NFormItem label="音乐人" path="composer">
  799. <NInput
  800. placeholder="请选择音乐人"
  801. v-model:value={state.searchForm.composer}
  802. clearable
  803. />
  804. </NFormItem>
  805. <NFormItem label="曲目来源" path="sourceType">
  806. <NSelect
  807. placeholder="请选择曲目来源"
  808. v-model:value={state.searchForm.sourceType}
  809. options={getSelectDataFromObj(musicSheetSourceType)}
  810. onUpdateValue={async (value: any) => {
  811. state.userIdData = []
  812. state.searchForm.userId = null
  813. if (value && value !== 'PLATFORM') {
  814. await updateUserIdData(value)
  815. state.userIdDisable = false
  816. } else {
  817. state.userIdDisable = true
  818. }
  819. }}
  820. clearable
  821. />
  822. </NFormItem>
  823. <NFormItem label="所属项目" path="applicationId">
  824. <NSelect
  825. placeholder="请选择所属项目"
  826. v-model:value={state.searchForm.applicationId}
  827. options={state.useProjectData}
  828. clearable
  829. onUpdateValue={async (value: any) => {
  830. state.searchForm.applicationId = value
  831. if (value) {
  832. await updateUserIdData(state.searchForm.sourceType)
  833. state.userIdDisable = !(
  834. state.searchForm.sourceType && state.searchForm.sourceType !== 'PLATFORM'
  835. )
  836. } else {
  837. state.searchForm.userId = null
  838. state.userIdDisable = true
  839. state.userIdData = []
  840. }
  841. }}
  842. />
  843. </NFormItem>
  844. <NFormItem label="所属人" path="author">
  845. <NSelect
  846. filterable
  847. placeholder="请选择所属人"
  848. disabled={state.userIdDisable || (!state.searchForm.applicationId && !state.searchForm.sourceType)}
  849. v-model:value={state.searchForm.userId}
  850. options={state.userIdData}
  851. clearable
  852. ></NSelect>
  853. </NFormItem>
  854. <NFormItem>
  855. <NSpace>
  856. <NButton type="primary" onClick={onSearch}>
  857. 搜索
  858. </NButton>
  859. <NButton type="default" onClick={onBtnReset}>
  860. 重置
  861. </NButton>
  862. </NSpace>
  863. </NFormItem>
  864. </SaveForm>
  865. <p style={{ paddingBottom: '12px' }}>
  866. 你选择了<span style={'color:red;padding:0 8px'}>{state.selectRowData.length}</span>
  867. 条曲目
  868. </p>
  869. <NDataTable
  870. loading={state.loading}
  871. columns={columns()}
  872. data={state.dataList}
  873. rowKey={(row: any) => row.id}
  874. onUpdateCheckedRowKeys={handleCheck}
  875. ></NDataTable>
  876. <Pagination
  877. v-model:page={state.pagination.page}
  878. v-model:pageSize={state.pagination.rows}
  879. v-model:pageTotal={state.pagination.pageTotal}
  880. onList={getList}
  881. sync
  882. // saveKey="cooleshow-edu-addMusic"
  883. ></Pagination>
  884. </div>
  885. )}
  886. {state.currentStep === 2 && (
  887. <div class="system-menu-container" style={'margin-top: 15px;'}>
  888. <NDataTable
  889. loading={state.loading}
  890. columns={stepColumns()}
  891. data={state.selectRowData}
  892. rowKey={(row: any) => row.id}
  893. maxHeight={500}
  894. scrollX={2000}
  895. ></NDataTable>
  896. </div>
  897. )}
  898. <NSpace justify="end" style={'margin-top:10px'}>
  899. <NButton
  900. type="default"
  901. onClick={() => {
  902. if (state.currentStep > 1) {
  903. state.currentStep = state.currentStep - 1
  904. } else {
  905. emit('close')
  906. }
  907. }}
  908. >
  909. {state.currentStep === 1 ? '取消' : '上一步'}
  910. </NButton>
  911. <NButton
  912. type="primary"
  913. onClick={() => {
  914. if (state.currentStep < 2) {
  915. if (state.selectRowData.length == 0) {
  916. message.warning('请选择曲目')
  917. return
  918. }
  919. state.currentStep = state.currentStep + 1
  920. } else {
  921. onSave()
  922. }
  923. }}
  924. // loading={btnLoading.value}
  925. // disabled={btnLoading.value}
  926. >
  927. {state.currentStep === 2 ? '确定' : '下一步'}
  928. </NButton>
  929. </NSpace>
  930. </div>
  931. )
  932. }
  933. }
  934. })