music-sheet-kt.tsx 23 KB

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