music-sheet-gym.tsx 23 KB

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