music-sheet-klx.tsx 21 KB

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