music-sheet-gyt.tsx 20 KB

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