music-sheet-gym.tsx 20 KB

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