music-sheet-gym.tsx 23 KB

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