music-sheet-gyt.tsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. import {defineComponent, onMounted, reactive, ref} from 'vue'
  2. import SaveForm from '@components/save-form'
  3. import {DataTableRowKey, NButton, NCascader, NDataTable, NDatePicker, NDescriptions, NDescriptionsItem, NFormItem, NImage, NInput, NModal, NSelect, NSpace, NTag, useDialog, useMessage} from 'naive-ui'
  4. import Pagination from '@components/pagination'
  5. import TheTooltip from '@components/TheTooltip'
  6. import AddMusic from '@views/music-library/project-music-sheet/module/gyt/addMusic'
  7. import {getMapValueByKey, getSelectDataFromObj} from '@/utils/objectUtil'
  8. import {appKey, musicSheetAudioType, musicSheetSourceType, musicSheetType} from '@/utils/constant'
  9. import {
  10. musicSheetApplicationExtendCategoryList,
  11. musicSheetApplicationExtendDel,
  12. musicSheetApplicationExtendStatus,
  13. musicSheetApplicationOwnerList,
  14. musicSheetPageByApplication
  15. } from '@views/music-library/api'
  16. import {musicSheetApplicationExtendSubjectList, sysApplicationPage} from '@views/system-manage/api'
  17. import {filterTimes} from '@/utils/dateUtil'
  18. import {copyText, getOwnerName} from '@views/music-library/musicUtil'
  19. import UpdateMusic from '@views/music-library/project-music-sheet/module/gyt/updateMusic'
  20. import MusicPreView from '@views/music-library/music-sheet/modal/musicPreView'
  21. export default defineComponent({
  22. name: 'project-music-sheet-gyt',
  23. props: {
  24. appKey: {
  25. type: String,
  26. default: 'GYT'
  27. }
  28. },
  29. setup(props) {
  30. const dialog = useDialog()
  31. const message = useMessage()
  32. const state = reactive({
  33. loading: false,
  34. appId: null as any,
  35. pagination: {
  36. page: 1,
  37. rows: 10,
  38. pageTotal: 0
  39. },
  40. searchForm: {
  41. keyword: null,
  42. musicSheetType: null, //曲目类型(SINGLE:单曲 CONCERT:合奏)
  43. subjectId: null, //声部ID
  44. subjectIds: null, //曲目声部ID集合
  45. musicCategoryIds: null, //曲目分类ID
  46. status: null, //曲目状态(0:停用,1:启用)
  47. sourceType: null, //来源类型/作者属性(PLATFORM: 平台; ORG: 机构; PERSON: 个人)
  48. paymentType: null, //收费类型(FREE:免费;VIP:会员;CHARGE:单曲收费)
  49. userId: null, //所属人
  50. musicCategoryId: null, //曲目分类ID
  51. times: null, // 上传时间
  52. audioType: null, //音频类型(HOMEMODE: 自制 COMMON: 普通)
  53. exquisiteFlag: null, //精品标志
  54. topFlag: null, //是否置顶(0:否;1:是)
  55. availableType: null, //可用途径 ORG 机构 PLATFORM 平台
  56. appAuditFlag: null, //是否审核版本
  57. detailFlag: null, //是否查询详情
  58. applicationId: null, //所属人项目ID
  59. extendApplicationId: null //所属人项目ID
  60. },
  61. subjectList: [],
  62. dataList: [] as any[],
  63. musicSheetCategories: [],
  64. showAddDialog: false,
  65. showEditDialog: false,
  66. userIdDisable: true,
  67. userIdData: [] as any,
  68. updateRow: {} as any, // 修改选择的行
  69. applicationId: null, //应用ID
  70. musicPreview: false,
  71. musicScore: null as any,
  72. useProjectData: [] as any // 适用项目行数据
  73. })
  74. onMounted(async () => {
  75. state.loading = true
  76. // 获取应用APP信息
  77. try {
  78. const { data } = await sysApplicationPage({ page: 1, rows: 1, appKey: props.appKey })
  79. const tempList = data.rows || []
  80. if (!tempList || tempList.length == 0) {
  81. state.loading = false
  82. message.error('加载项目信息失败')
  83. return
  84. }
  85. state.appId = tempList[0].id
  86. state.applicationId = tempList[0].id
  87. } catch {}
  88. // 加载声部
  89. try {
  90. // const { data } = await subjectPage({ page: 1, rows: 999 })
  91. // const tempList = data.rows || []
  92. // tempList.forEach((item: any) => {
  93. // item.label = item.name
  94. // item.value = item.id + ''
  95. // })
  96. // state.subjectList = tempList
  97. const { data } = await musicSheetApplicationExtendSubjectList({
  98. applicationId: state.applicationId
  99. })
  100. const tempList = data || []
  101. tempList.forEach((item: any) => {
  102. item.label = item.subjectName
  103. item.value = item.subjectId
  104. })
  105. state.subjectList = tempList
  106. } catch {}
  107. try {
  108. //加载曲目分类列表
  109. const { data } = await musicSheetApplicationExtendCategoryList({
  110. applicationIds: state.appId
  111. })
  112. if (data && data.length > 0) {
  113. state.musicSheetCategories = data[0].musicSheetCategories
  114. }
  115. } catch {}
  116. // 加载表格数据
  117. initUseAppList()
  118. getList()
  119. })
  120. const saveForm = ref()
  121. const onSearch = () => {
  122. saveForm.value?.submit()
  123. }
  124. const onBtnReset = () => {
  125. saveForm.value?.reset()
  126. }
  127. const onSubmit = () => {
  128. state.pagination.page = 1
  129. getList()
  130. }
  131. const initUseAppList = async () => {
  132. try {
  133. const appKeys = Object.keys(appKey)
  134. const { data } = await sysApplicationPage({ page: 1, rows: 999 })
  135. const tempList = data.rows || []
  136. state.useProjectData = []
  137. const filter = tempList.filter((next: any) => {
  138. return appKeys.includes(next.appKey)
  139. })
  140. filter.forEach((item: any) => {
  141. state.useProjectData.push({
  142. ...item,
  143. label: item.appName,
  144. value: item.id
  145. })
  146. })
  147. } catch {}
  148. }
  149. const updateUserIdData = async (sourceType: any) => {
  150. if (!state.searchForm.extendApplicationId) {
  151. return
  152. }
  153. state.userIdData = []
  154. state.searchForm.userId = null
  155. if (sourceType && sourceType !== 'PLATFORM') {
  156. const { data } = await musicSheetApplicationOwnerList({
  157. page: 1,
  158. rows: 9999,
  159. sourceType: sourceType,
  160. applicationId: state.searchForm.extendApplicationId
  161. })
  162. const temp = data.rows || []
  163. temp.forEach((next: any) => {
  164. state.userIdData.push({
  165. ...next,
  166. label: sourceType === 'PERSON' ? next.userName : next.organizationRole,
  167. value: sourceType === 'PERSON' ? next.userId : next.organizationRoleId
  168. })
  169. })
  170. }
  171. }
  172. const checkedRowKeysRef = ref<DataTableRowKey[]>([])
  173. const handleCheck = (rowKeys: DataTableRowKey[]) => {
  174. checkedRowKeysRef.value = rowKeys
  175. }
  176. const getList = async () => {
  177. try {
  178. state.loading = true
  179. const sourceType = state.searchForm.sourceType
  180. const { data } = await musicSheetPageByApplication({
  181. ...state.pagination,
  182. ...state.searchForm,
  183. userId: sourceType && sourceType === 'PERSON' ? state.searchForm.userId : null,
  184. organizationRoleId: sourceType && sourceType === 'ORG' ? state.searchForm.userId : null,
  185. ...filterTimes(state.searchForm.times, ['startTime', 'endTime']),
  186. applicationId: state.applicationId
  187. })
  188. state.pagination.pageTotal = Number(data.total)
  189. state.dataList = data.rows || []
  190. } catch {}
  191. state.loading = false
  192. }
  193. const onChangeStatus = (row: any) => {
  194. const statusStr = row.status ? '停用' : '启用'
  195. dialog.warning({
  196. title: '提示',
  197. content: `是否${statusStr}?`,
  198. positiveText: '确定',
  199. negativeText: '取消',
  200. onPositiveClick: async () => {
  201. try {
  202. await musicSheetApplicationExtendStatus({
  203. ids: row.applicationExtendId,
  204. status: !row.status
  205. })
  206. getList()
  207. message.success(`${statusStr}成功`)
  208. } catch {}
  209. }
  210. })
  211. }
  212. const onBatchChangeStatus = (status: boolean) => {
  213. const length = checkedRowKeysRef.value.length
  214. if (length == 0) {
  215. message.warning('未选择数据')
  216. }
  217. const statusStr = !status ? '停用' : '启用'
  218. dialog.warning({
  219. title: '提示',
  220. content: `是否${statusStr}` + length + `条数据?`,
  221. positiveText: '确定',
  222. negativeText: '取消',
  223. onPositiveClick: async () => {
  224. try {
  225. await musicSheetApplicationExtendStatus({
  226. ids: checkedRowKeysRef.value.join(','),
  227. status: status
  228. })
  229. getList()
  230. message.success(`${statusStr}成功`)
  231. } catch {}
  232. }
  233. })
  234. }
  235. const onRmove = (row: any): void => {
  236. dialog.warning({
  237. title: '提示',
  238. content: `删除曲目,是否继续?`,
  239. positiveText: '确定',
  240. negativeText: '取消',
  241. onPositiveClick: async () => {
  242. try {
  243. await musicSheetApplicationExtendDel(row.applicationExtendId)
  244. getList()
  245. message.success('删除成功')
  246. } catch {}
  247. }
  248. })
  249. }
  250. const columns = (): any => {
  251. return [
  252. {
  253. type: 'selection'
  254. },
  255. {
  256. title: '曲目名称',
  257. key: 'id',
  258. render: (row: any) => (
  259. <>
  260. <NDescriptions labelPlacement="left" column={1}>
  261. <NDescriptionsItem label="曲目名称">
  262. <TheTooltip content={row.name} />{' '}
  263. </NDescriptionsItem>
  264. <NDescriptionsItem label="曲目编号">
  265. <div
  266. onDblclick={() => {
  267. copyText(message, row.id)
  268. }}
  269. >
  270. <TheTooltip content={row.id} />
  271. </div>
  272. </NDescriptionsItem>
  273. </NDescriptions>
  274. </>
  275. )
  276. },
  277. {
  278. title: '封面图',
  279. key: 'musicCover',
  280. render(row: any): JSX.Element {
  281. return <NImage width={60} height={60} src={row.musicCover} />
  282. }
  283. },
  284. // {
  285. // title: '可用声部',
  286. // key: 'subjectNames',
  287. // render: (row: any) => {
  288. // return <TheTooltip content={row.subjectNames}/>
  289. // }
  290. // },
  291. {
  292. title: '曲目信息',
  293. key: 'musicSheetCategoriesName',
  294. render: (row: any) => (
  295. <>
  296. <NDescriptions labelPlacement="left" column={1}>
  297. <NDescriptionsItem label="曲目来源">
  298. {getMapValueByKey(row.sourceType, new Map(Object.entries(musicSheetSourceType)))}
  299. </NDescriptionsItem>
  300. <NDescriptionsItem label="多声轨渲染">
  301. {getMapValueByKey(row.musicSheetType, new Map(Object.entries(musicSheetType)))}
  302. </NDescriptionsItem>
  303. <NDescriptionsItem label="所属人">
  304. <TheTooltip content={getOwnerName(row.musicSheetExtend, row.sourceType)} />
  305. </NDescriptionsItem>
  306. <NDescriptionsItem label="可用声部">
  307. <TheTooltip content={row.subjectNames} />
  308. </NDescriptionsItem>
  309. </NDescriptions>
  310. </>
  311. )
  312. },
  313. {
  314. title: '伴奏类型',
  315. key: 'audioType',
  316. render: (row: any) => {
  317. return (
  318. <div>
  319. {getMapValueByKey(row.audioType, new Map(Object.entries(musicSheetAudioType)))}
  320. </div>
  321. )
  322. }
  323. },
  324. {
  325. title: '曲目分类',
  326. key: 'musicSheetCategoryName'
  327. },
  328. // {
  329. // title: '可用途径',
  330. // key: 'availableType',
  331. // render: (row: any) => {
  332. // return <div>{getMapValueByKey(row.availableType, new Map(Object.entries(musicSheetAvailableType)))}</div>
  333. // }
  334. // },
  335. // {
  336. // title: '收费方式',
  337. // key: 'paymentType',
  338. // render: (row: any) => {
  339. // return (
  340. // <div>
  341. // {getMapValueByKey(row.paymentType, new Map(Object.entries(musicSheetPaymentType)))}
  342. // </div>
  343. // )
  344. // }
  345. // },
  346. {
  347. title: '上传人',
  348. minWidth: '150px',
  349. key: 'composer',
  350. render(row: any) {
  351. return (
  352. <NDescriptions labelPlacement="left" column={1}>
  353. <NDescriptionsItem label="上传人">{row.createByName}</NDescriptionsItem>
  354. <NDescriptionsItem label="上传时间">{row.createTime}</NDescriptionsItem>
  355. </NDescriptions>
  356. )
  357. }
  358. },
  359. {
  360. title: '状态',
  361. key: 'status',
  362. render(row: any) {
  363. return (
  364. <NTag type={row.status ? 'primary' : 'default'}>{row.status ? '启用' : '停用'}</NTag>
  365. )
  366. }
  367. },
  368. {
  369. title: '操作',
  370. key: 'operation',
  371. fixed: 'right',
  372. render(row: any) {
  373. return (
  374. <NSpace>
  375. <NButton
  376. type="primary"
  377. size="small"
  378. text
  379. onClick={() => {
  380. state.musicPreview = true
  381. state.musicScore = row
  382. }}
  383. >
  384. 预览
  385. </NButton>
  386. <NButton
  387. type="primary"
  388. size="small"
  389. text
  390. v-auth="musicSheetApplicationExtend/status1751235279221424130"
  391. onClick={() => onChangeStatus(row)}
  392. >
  393. {row.status ? '停用' : '启用'}
  394. </NButton>
  395. <NButton
  396. type="primary"
  397. size="small"
  398. text
  399. v-auth="musicSheetApplicationExtend/update1751235625503162370"
  400. onClick={() => {
  401. state.showEditDialog = true
  402. state.updateRow = row
  403. }}
  404. >
  405. 修改
  406. </NButton>
  407. <NButton
  408. type="primary"
  409. size="small"
  410. text
  411. disabled={!!row.status}
  412. onClick={() => onRmove(row)}
  413. v-auth="musicSheetApplicationExtend/del1770708605081792513"
  414. >
  415. 删除
  416. </NButton>
  417. </NSpace>
  418. )
  419. }
  420. }
  421. ]
  422. }
  423. return () => {
  424. return (
  425. <div class="system-menu-container">
  426. <SaveForm
  427. ref={saveForm}
  428. model={state.searchForm}
  429. onSubmit={onSubmit}
  430. saveKey="music-sheet-gyt"
  431. onSetModel={(val: any) => (state.searchForm = val)}
  432. >
  433. <NFormItem label="关键词" path="keyword">
  434. <NInput
  435. placeholder="请输入曲目名称/编号"
  436. v-model:value={state.searchForm.keyword}
  437. clearable
  438. />
  439. </NFormItem>
  440. <NFormItem label="曲目来源" path="sourceType">
  441. <NSelect
  442. placeholder="请选择曲目来源"
  443. v-model:value={state.searchForm.sourceType}
  444. options={getSelectDataFromObj(musicSheetSourceType)}
  445. onUpdateValue={async (value: any) => {
  446. state.userIdData = []
  447. state.searchForm.userId = null
  448. if (value && value !== 'PLATFORM') {
  449. await updateUserIdData(value)
  450. state.userIdDisable = !state.searchForm.extendApplicationId
  451. } else {
  452. state.userIdDisable = true
  453. }
  454. }}
  455. clearable
  456. />
  457. </NFormItem>
  458. <NFormItem label="所属项目" path="applicationId">
  459. <NSelect
  460. placeholder="请选择所属项目"
  461. v-model:value={state.searchForm.extendApplicationId}
  462. options={state.useProjectData}
  463. clearable
  464. onUpdateValue={async (value: any) => {
  465. state.searchForm.extendApplicationId = value
  466. if (value) {
  467. await updateUserIdData(state.searchForm.sourceType)
  468. state.userIdDisable = !(
  469. state.searchForm.sourceType && state.searchForm.sourceType !== 'PLATFORM'
  470. )
  471. } else {
  472. state.searchForm.userId = null
  473. state.userIdDisable = true
  474. state.userIdData = []
  475. }
  476. }}
  477. />
  478. </NFormItem>
  479. <NFormItem label="所属人" path="userId">
  480. <NSelect
  481. filterable
  482. placeholder="请选择所属人"
  483. disabled={state.userIdDisable}
  484. v-model:value={state.searchForm.userId}
  485. options={state.userIdData}
  486. clearable
  487. ></NSelect>
  488. </NFormItem>
  489. <NFormItem label="多声轨渲染" path="subjectType">
  490. <NSelect
  491. placeholder="请选多声轨渲染"
  492. v-model:value={state.searchForm.musicSheetType}
  493. options={getSelectDataFromObj(musicSheetType)}
  494. clearable
  495. />
  496. </NFormItem>
  497. <NFormItem label="伴奏类型" path="audioType">
  498. <NSelect
  499. placeholder="请选择伴奏类型"
  500. v-model:value={state.searchForm.audioType}
  501. options={getSelectDataFromObj(musicSheetAudioType)}
  502. clearable
  503. />
  504. </NFormItem>
  505. <NFormItem label="可用声部" path="subjectId">
  506. <NSelect
  507. placeholder="请选择可用声部"
  508. v-model:value={state.searchForm.subjectId}
  509. options={state.subjectList}
  510. clearable
  511. filterable
  512. />
  513. </NFormItem>
  514. <NFormItem label="曲目分类" path="musicCategoryId">
  515. <NCascader
  516. valueField="id"
  517. labelField="name"
  518. children-field="children"
  519. placeholder="请选择曲目分类"
  520. v-model:value={state.searchForm.musicCategoryId}
  521. options={state.musicSheetCategories}
  522. clearable
  523. filterable
  524. />
  525. </NFormItem>
  526. {/*<NFormItem*/}
  527. {/* label="可用途径"*/}
  528. {/* path="availableType"*/}
  529. {/*>*/}
  530. {/* <NSelect*/}
  531. {/* placeholder="请选择可用途径"*/}
  532. {/* v-model:value={state.searchForm.availableType}*/}
  533. {/* options={getSelectDataFromObj(musicSheetAvailableType)}*/}
  534. {/* clearable*/}
  535. {/* >*/}
  536. {/* </NSelect>*/}
  537. {/*</NFormItem>*/}
  538. {/*<NFormItem label="收费方式" path="paymentType">*/}
  539. {/* <NSelect*/}
  540. {/* placeholder="请选择收费方式"*/}
  541. {/* v-model:value={state.searchForm.paymentType}*/}
  542. {/* options={getSelectDataFromObj(musicSheetPaymentType)}*/}
  543. {/* clearable*/}
  544. {/* ></NSelect>*/}
  545. {/*</NFormItem>*/}
  546. <NFormItem label="状态" path="status">
  547. <NSelect
  548. v-model:value={state.searchForm.status}
  549. placeholder="请选择状态"
  550. options={
  551. [
  552. {
  553. label: '启用',
  554. value: true
  555. },
  556. {
  557. label: '停用',
  558. value: false
  559. }
  560. ] as any
  561. }
  562. clearable
  563. />
  564. </NFormItem>
  565. <NFormItem label="上传时间" path="authorFrom">
  566. <NDatePicker
  567. v-model:value={state.searchForm.times}
  568. type="daterange"
  569. clearable
  570. value-format="yyyy.MM.dd"
  571. startPlaceholder="开始时间"
  572. endPlaceholder="结束时间"
  573. />
  574. </NFormItem>
  575. <NFormItem>
  576. <NSpace>
  577. <NButton type="primary" onClick={onSearch}>
  578. 搜索
  579. </NButton>
  580. <NButton type="default" onClick={onBtnReset}>
  581. 重置
  582. </NButton>
  583. </NSpace>
  584. </NFormItem>
  585. </SaveForm>
  586. <div class={['section-container']}>
  587. <NSpace style={{ paddingBottom: '12px' }}>
  588. <NButton
  589. type="primary"
  590. v-auth="musicSheetApplicationExtend/saveBatch1751234383880126466"
  591. onClick={() => {
  592. state.showAddDialog = true
  593. }}
  594. >
  595. 添加曲目
  596. </NButton>
  597. <NButton
  598. disabled={checkedRowKeysRef.value.length == 0}
  599. v-auth="musicSheetApplicationExtend/status1751235279221424130"
  600. onClick={() => {
  601. onBatchChangeStatus(false)
  602. }}
  603. >
  604. 批量停用
  605. </NButton>
  606. <NButton
  607. disabled={checkedRowKeysRef.value.length == 0}
  608. v-auth="musicSheetApplicationExtend/status1751235279221424130"
  609. onClick={() => {
  610. onBatchChangeStatus(true)
  611. }}
  612. >
  613. 批量启用
  614. </NButton>
  615. </NSpace>
  616. <NDataTable
  617. loading={state.loading}
  618. columns={columns()}
  619. data={state.dataList}
  620. rowKey={(row: any) => row.applicationExtendId}
  621. onUpdateCheckedRowKeys={handleCheck}
  622. scrollX={'1200'}
  623. ></NDataTable>
  624. <Pagination
  625. v-model:page={state.pagination.page}
  626. v-model:pageSize={state.pagination.rows}
  627. v-model:pageTotal={state.pagination.pageTotal}
  628. onList={getList}
  629. sync
  630. saveKey="music-sheet-gyt"
  631. ></Pagination>
  632. </div>
  633. <NModal
  634. v-model:show={state.showAddDialog}
  635. preset="dialog"
  636. showIcon={false}
  637. title={'添加曲目'}
  638. style={{ width: '1300px' }}
  639. >
  640. <AddMusic
  641. onClose={() => (state.showAddDialog = false)}
  642. onGetList={() => {
  643. state.pagination.page = 1
  644. getList()
  645. }}
  646. subjectList={state.subjectList}
  647. appId={state.appId}
  648. musicSheetCategories={state.musicSheetCategories}
  649. />
  650. </NModal>
  651. <NModal
  652. v-model:show={state.showEditDialog}
  653. preset="dialog"
  654. showIcon={false}
  655. title={'修改曲目'}
  656. style={{ width: '500px' }}
  657. >
  658. <UpdateMusic
  659. onClose={() => (state.showEditDialog = false)}
  660. onGetList={() => {
  661. state.pagination.page = 1
  662. getList()
  663. }}
  664. rowData={state.updateRow}
  665. appId={state.appId}
  666. musicSheetCategories={state.musicSheetCategories}
  667. />
  668. </NModal>
  669. <NModal
  670. blockScroll={true}
  671. v-model:show={state.musicPreview}
  672. preset="dialog"
  673. showIcon={false}
  674. title={'曲目预览'}
  675. style={{ width: 'auto' }}
  676. >
  677. <MusicPreView item={state.musicScore} />
  678. </NModal>
  679. </div>
  680. )
  681. }
  682. }
  683. })