music-sheet-gym.tsx 23 KB

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