music-sheet-gyt.tsx 23 KB

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