12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145 |
- import { defineComponent, h, onMounted, reactive, ref } from 'vue'
- import SaveForm from '@components/save-form'
- import {
- DataTableColumns,
- DataTableRowKey,
- NButton,
- NDataTable,
- NFormItem,
- NIcon,
- NImage,
- NInput,
- NInputNumber,
- NSelect,
- NSpace,
- NStep,
- NSteps,
- useDialog,
- useMessage
- } from 'naive-ui'
- import Pagination from '@components/pagination'
- import { getMapValueByKey, getSelectDataFromObj } from '@/utils/objectUtil'
- import {
- appKey,
- musicSheetAvailableType,
- musicSheetPaymentType,
- musicSheetSourceType,
- musicSheetType
- } from '@/utils/constant'
- import {musicSheetApplicationExtendSaveBatch, musicSheetApplicationExtendTagList, musicSheetApplicationOwnerList, musicSheetPage} from '@views/music-library/api'
- import deepClone from '@/utils/deep.clone'
- import { getOwnerName } from '@views/music-library/musicUtil'
- import TheTooltip from "@components/TheTooltip";
- import {sysApplicationPage} from "@views/menu-manage/api";
- export default defineComponent({
- name: 'klx-addMusic',
- props: {
- appId: {
- type: String,
- required: true
- },
- subjectList: {
- type: Array,
- default: () => []
- },
- musicSheetTagList: {
- type: Array,
- default: () => []
- }
- },
- emits: ['close', 'getList'],
- setup(props, { slots, attrs, emit }) {
- const dialogs = useDialog()
- const message = useMessage()
- const state = reactive({
- loading: false,
- pagination: {
- page: 1,
- rows: 5,
- pageTotal: 0
- },
- stepPagination: {
- page: 1,
- rows: 5,
- pageTotal: 0
- },
- searchForm: {
- keyword: null,
- musicSheetType: null,
- subjectId: null,
- sourceType: null,
- composer : null,
- userId : null,
- applicationId : null,
- },
- subjectList: [] as any,
- showAdd: false,
- currentStep: 1,
- dataList: [],
- selectRowData: [] as any, // 选择的数据列表
- musicSheetCategories: [] as any,
- musicSheetTagList: [] as any,
- useProjectData: [] as any, // 适用项目行数据
- userIdDisable: true,
- userIdData: [] as any,
- globalMusicTagIds: [] as any, //曲目标签
- globalPaymentType: null as any, //收费方式
- globalMusicPrice: null as any, //曲目价格
- globalAvailableType: null as any, //可用途径
- globalTopFlag: null as any, //是否置顶
- globalExquisiteFlag: null as any, //精品乐谱
- globalStartSortNum: null as any // 排序起始值
- })
- onMounted(async () => {
- state.searchForm.keyword = null
- state.searchForm.musicSheetType = null
- state.searchForm.subjectId = null
- state.searchForm.sourceType = null
- state.searchForm.composer = null
- state.searchForm.userId = null
- state.searchForm.applicationId = null
- state.loading = true
- state.subjectList = props.subjectList
- // state.musicSheetTagList = props.musicSheetTagList
- // 加载曲目标签
- try {
- const {data} = await musicSheetApplicationExtendTagList({applicationId: props.appId})
- if (data && data.length > 0) {
- data.forEach((item: any) => {
- state.musicSheetTagList.push({
- ...item,
- label: item.name,
- value: item.id
- })
- })
- }
- } catch (err) {
- }
- await initUseAppList()
- await getList()
- })
- const initUseAppList = async () => {
- try {
- const appKeys = Object.keys(appKey)
- const { data } = await sysApplicationPage({ page: 1, rows: 999 })
- const tempList = data.rows || []
- state.useProjectData = []
- const filter = tempList.filter((next: any) => {
- return appKeys.includes(next.appKey)
- })
- filter.forEach((item: any) => {
- state.useProjectData.push({
- ...item,
- label: item.appName,
- value: item.id
- })
- })
- } catch {}
- }
- const getList = async () => {
- try {
- state.loading = true
- const search = {
- ...state.searchForm,
- userId: (state.searchForm.sourceType && state.searchForm.sourceType == 'PERSON') ? state.searchForm.userId : null,
- organizationRoleId: (state.searchForm.sourceType && state.searchForm.sourceType == 'ORG') ? state.searchForm.userId : null,
- }
- const { data } = await musicSheetPage({
- ...state.pagination,
- ...search,
- addAppId: props.appId
- })
- state.pagination.pageTotal = Number(data.total)
- state.dataList = data.rows || []
- } catch {}
- state.loading = false
- }
- const saveForm = ref()
- const onSearch = () => {
- saveForm.value?.submit()
- }
- const onBtnReset = () => {
- saveForm.value?.reset()
- }
- const onSubmit = () => {
- state.pagination.page = 1
- getList()
- }
- const updateUserIdData = async (sourceType: any) => {
- if (!state.searchForm.applicationId) {
- return
- }
- state.userIdData = []
- state.searchForm.userId = null
- if (sourceType && sourceType !== 'PLATFORM') {
- const { data } = await musicSheetApplicationOwnerList({
- page: 1,
- rows: 9999,
- sourceType: sourceType,
- applicationId: state.searchForm.applicationId
- })
- const temp = data.rows || []
- temp.forEach((next: any) => {
- state.userIdData.push({
- ...next,
- label: sourceType === 'PERSON' ? next.userName : next.organizationRole,
- value: sourceType === 'PERSON' ? next.userId : next.organizationRoleId
- })
- })
- }
- }
- const onSave = async () => {
- if (state.selectRowData.length == 0) {
- message.error('未选择曲目')
- return
- }
- const params = [] as any[]
- for (let i = 0; i < state.selectRowData.length; i++) {
- const item = state.selectRowData[i]
- if (!item.musicTagIds || item.musicTagIds.length == 0) {
- message.error('曲目标签不能为空')
- return
- }
- if (!item.paymentType) {
- message.error('收费方式不能为空')
- return
- }
- if (!item.paymentType.includes('CHARGE')) {
- item.musicPrice = 0
- } else {
- if (item.musicPrice === null || item.musicPrice === undefined || item.musicPrice==='') {
- message.error('曲目价格不能为空')
- return
- }
- }
- if (!item.availableType) {
- message.error('可用途径不能为空')
- return
- }
- if (typeof item.topFlag !== 'boolean') {
- message.error('是否置顶不能为空')
- return
- }
- if (typeof item.exquisiteFlag !== 'boolean') {
- message.error('是否精品不能为空')
- return
- }
- if (item.sortNo === null || item.sortNo === undefined || item.sortNo === '') {
- message.error('排序号不能为空')
- return
- }
- params.push({
- ...item,
- musicSheetId: item.id,
- applicationId: props.appId,
- paymentType: item.paymentType.join(','),
- musicTagIds: item.musicTagIds.join(','),
- id: null
- })
- }
- const res = (await musicSheetApplicationExtendSaveBatch(params)) as any
- if (res && res.code == '200') {
- message.success(`添加成功`)
- emit('getList')
- emit('close')
- }
- }
- const columnsField = [
- {
- type: 'selection'
- },
- {
- title: '曲目编号',
- key: 'id'
- },
- {
- title: '封面图',
- key: 'titleImg',
- render(row: any) {
- return <NImage width={40} height={40} src={row.musicCover} />
- }
- },
- {
- title: '可用声部',
- key: 'subjectNames',
- render: (row: any) => {
- return <TheTooltip content={row.subjectNames}/>
- }
- },
- {
- title: '曲目名称',
- key: 'name'
- },
- {
- title: '音乐人',
- key: 'composer'
- },
- {
- title: '多声轨渲染',
- key: 'musicSheetType',
- render: (row: any) => {
- return (
- <div>
- {getMapValueByKey(row.musicSheetType, new Map(Object.entries(musicSheetType)))}
- </div>
- )
- }
- },
- {
- title: '曲目来源',
- key: 'sourceType',
- render(row: any) {
- return getMapValueByKey(row.sourceType, new Map(Object.entries(musicSheetSourceType)))
- }
- },
- {
- title: '所属人',
- key: 'userName',
- render: (row: any) => {
- return <TheTooltip content={getOwnerName(row.musicSheetExtend, row.sourceType)} />
- }
- }
- ]
- const columns = (): any => {
- return columnsField
- }
- const stepColumns = (): DataTableColumns => {
- const field = deepClone(columnsField)
- field.splice(0, 1)
- field.push({
- title(column: any) {
- return (
- <NSpace>
- 曲目标签
- <NButton
- type="primary"
- size="small"
- text
- onClick={() => {
- dialogs.create({
- title: '请选择曲目标签',
- showIcon: false,
- content: () => {
- return h(
- 'div',
- {
- class: 'flex flex-col justify-center items-center text-14px'
- },
- [
- h(NSelect, {
- onUpdateValue(v) {
- state.globalMusicTagIds = v
- },
- multiple: true,
- clearable: true,
- options: state.musicSheetTagList
- })
- ]
- )
- },
- positiveText: '确定',
- negativeText: '取消',
- onPositiveClick: () => {
- for (let i = 0; i < state.selectRowData.length; i++) {
- const item = state.selectRowData[i]
- item.musicTagIds = state.globalMusicTagIds
- }
- }
- })
- }}
- >
- <NIcon size={15} style="padding-left: 5px;margin-top:4px">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
- <path d="M2 26h28v2H2z" fill="currentColor"></path>
- <path
- d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
- fill="currentColor"
- ></path>
- </svg>
- </NIcon>
- </NButton>
- </NSpace>
- )
- },
- key: 'musicTagIds',
- width:'180px',
- render: (row: any) => {
- // })
- return (
- <NSelect
- placeholder="请选择曲目标签"
- value={row.musicTagIds}
- options={state.musicSheetTagList}
- clearable
- multiple
- maxTagCount={1}
- onUpdateValue={(value) => {
- row['musicTagIds'] = value
- }}
- />
- )
- }
- })
- field.push({
- title(column: any) {
- return (
- <NSpace>
- 收费方式
- <NButton
- type="primary"
- size="small"
- text
- onClick={() => {
- dialogs.create({
- title: '请选择收费方式',
- showIcon: false,
- content: () => {
- return h(
- 'div',
- {
- class: 'flex flex-col justify-center items-center text-14px'
- },
- [
- h(NSelect, {
- value: state.globalPaymentType,
- onUpdateValue(v) {
- state.globalPaymentType = v
- const free = 'FREE'
- if (state.globalPaymentType[state.globalPaymentType.length - 1] == free) {
- state.globalPaymentType = [free]
- return
- }
- if (state.globalPaymentType.length > 1 && state.globalPaymentType.includes(free)) {
- state.globalPaymentType.splice(state.globalPaymentType.indexOf(free), 1)
- }
- },
- multiple: true,
- clearable: true,
- options: getSelectDataFromObj(musicSheetPaymentType)
- }
- )
- ]
- )
- },
- positiveText: '确定',
- negativeText: '取消',
- onPositiveClick: () => {
- for (let i = 0; i < state.selectRowData.length; i++) {
- const item = state.selectRowData[i]
- item.paymentType = state.globalPaymentType
- if (!state.globalPaymentType.includes("CHARGE")) {
- item.musicPrice = 0
- item.musicPriceDisable = true
- }
- }
- }
- })
- }}
- >
- <NIcon size={15} style="padding-left: 5px;margin-top:4px">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
- <path d="M2 26h28v2H2z" fill="currentColor"></path>
- <path
- d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
- fill="currentColor"
- ></path>
- </svg>
- </NIcon>
- </NButton>
- </NSpace>
- )
- },
- key: 'paymentType',
- width:'180px',
- render: (row: any) => {
- return (
- <NSelect
- placeholder="请选择收费方式"
- value={row.paymentType as []}
- options={getSelectDataFromObj(musicSheetPaymentType)}
- clearable
- multiple
- maxTagCount={1}
- onUpdate:value={(value) => {
- row.paymentType = value
- const free = 'FREE'
- if (row.paymentType[row.paymentType.length - 1] == free) {
- row.paymentType = [free]
- } else if (row.paymentType.length > 1 && row.paymentType.includes(free)) {
- row.paymentType.splice(row.paymentType.indexOf(free), 1)
- }
- if (!row.paymentType.includes("CHARGE")) {
- row.musicPrice = 0
- }
- }}
- />
- )
- }
- })
- field.push({
- title(column: any) {
- return (
- <NSpace>
- 曲目价格
- <NButton
- type="primary"
- size="small"
- text
- onClick={() => {
- dialogs.create({
- title: '请输入曲目价格',
- showIcon: false,
- content: () => {
- return h(
- 'div',
- {
- class: 'flex flex-col justify-center items-center text-14px'
- },
- [
- // icon
- h(NInputNumber, {
- onUpdateValue(v) {
- state.globalMusicPrice = v
- },
- min: 0,
- max: 9999
- })
- ]
- )
- },
- positiveText: '确定',
- negativeText: '取消',
- onPositiveClick: () => {
- if (state.globalMusicPrice) {
- for (let i = 0; i < state.selectRowData.length; i++) {
- const item = state.selectRowData[i]
- if (item.paymentType.includes("CHARGE")) { // 只修改包含单曲收费,则价格为0
- item.musicPrice = state.globalMusicPrice
- }
- }
- }
- }
- })
- }}
- >
- <NIcon size={15} style="padding-left: 5px;margin-top:4px">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
- <path d="M2 26h28v2H2z" fill="currentColor"></path>
- <path
- d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
- fill="currentColor"
- ></path>
- </svg>
- </NIcon>
- </NButton>
- </NSpace>
- )
- },
- key: 'musicPrice',
- render: (row: any) => {
- return h(NInputNumber, {
- value: row.musicPrice,
- min: 0,
- max: 9999,
- disabled: !row.paymentType?.includes('CHARGE'),
- onUpdateValue(value: any) {
- row['musicPrice'] = value
- }
- })
- }
- })
- field.push({
- title(column: any) {
- return (
- <NSpace>
- 可用途径
- <NButton
- type="primary"
- size="small"
- text
- onClick={() => {
- dialogs.create({
- title: '请选择可用途径',
- showIcon: false,
- content: () => {
- return h(
- 'div',
- {
- class: 'flex flex-col justify-center items-center text-14px'
- },
- [
- // icon
- h(NSelect, {
- onUpdateValue(v) {
- state.globalAvailableType = v
- },
- clearable: true,
- options: getSelectDataFromObj(musicSheetAvailableType)
- })
- ]
- )
- },
- positiveText: '确定',
- negativeText: '取消',
- onPositiveClick: () => {
- for (let i = 0; i < state.selectRowData.length; i++) {
- const item = state.selectRowData[i]
- item.availableType = state.globalAvailableType
- }
- }
- })
- }}
- >
- <NIcon size={15} style="padding-left: 5px;margin-top:4px">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
- <path d="M2 26h28v2H2z" fill="currentColor"></path>
- <path
- d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
- fill="currentColor"
- ></path>
- </svg>
- </NIcon>
- </NButton>
- </NSpace>
- )
- },
- key: 'availableType',
- render: (row: any) => {
- return (
- <NSelect
- placeholder="请选择可用途径"
- value={row.availableType}
- options={getSelectDataFromObj(musicSheetAvailableType)}
- onUpdateValue={(value) => {
- row['availableType'] = value
- }}
- clearable
- />
- )
- }
- })
- field.push({
- title(column: any) {
- return (
- <NSpace>
- 是否置顶
- <NButton
- type="primary"
- size="small"
- text
- onClick={() => {
- dialogs.create({
- title: '请选择是否置顶',
- showIcon: false,
- content: () => {
- return h(
- 'div',
- {
- class: 'flex flex-col justify-center items-center text-14px'
- },
- [
- // icon
- h(NSelect, {
- onUpdateValue(v) {
- state.globalTopFlag = v
- },
- options: [
- {
- label: '是',
- value: true
- },
- {
- label: '否',
- value: false
- }
- ] as any
- })
- ]
- )
- },
- positiveText: '确定',
- negativeText: '取消',
- onPositiveClick: () => {
- for (let i = 0; i < state.selectRowData.length; i++) {
- const item = state.selectRowData[i]
- item.topFlag = state.globalTopFlag
- }
- }
- })
- }}
- >
- <NIcon size={15} style="padding-left: 5px;margin-top:4px">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
- <path d="M2 26h28v2H2z" fill="currentColor"></path>
- <path
- d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
- fill="currentColor"
- ></path>
- </svg>
- </NIcon>
- </NButton>
- </NSpace>
- )
- },
- key: 'topFlag',
- render: (row: any) => {
- return (
- <NSelect
- placeholder="请选择是否置顶"
- value={row.topFlag}
- options={
- [
- {
- label: '是',
- value: true
- },
- {
- label: '否',
- value: false
- }
- ] as any
- }
- clearable
- onUpdateValue={(value) => {
- row['topFlag'] = value
- }}
- />
- )
- }
- })
- field.push({
- title(column: any) {
- return (
- <NSpace>
- 是否精品
- <NButton
- type="primary"
- size="small"
- text
- onClick={() => {
- dialogs.create({
- title: '请选择是否精品',
- showIcon: false,
- content: () => {
- return h(
- 'div',
- {
- class: 'flex flex-col justify-center items-center text-14px'
- },
- [
- // icon
- h(NSelect, {
- onUpdateValue(v) {
- state.globalExquisiteFlag = v
- },
- options: [
- {
- label: '是',
- value: true
- },
- {
- label: '否',
- value: false
- }
- ] as any
- })
- ]
- )
- },
- positiveText: '确定',
- negativeText: '取消',
- onPositiveClick: () => {
- for (let i = 0; i < state.selectRowData.length; i++) {
- const item = state.selectRowData[i]
- item.exquisiteFlag = state.globalExquisiteFlag
- }
- }
- })
- }}
- >
- <NIcon size={15} style="padding-left: 5px;margin-top:4px">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
- <path d="M2 26h28v2H2z" fill="currentColor"></path>
- <path
- d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
- fill="currentColor"
- ></path>
- </svg>
- </NIcon>
- </NButton>
- </NSpace>
- )
- },
- key: 'exquisiteFlag',
- render: (row: any) => {
- return (
- <NSelect
- placeholder="请选择是否精品"
- value={row.exquisiteFlag}
- onUpdateValue={(value) => {
- row['exquisiteFlag'] = value
- }}
- options={
- [
- {
- label: '是',
- value: true
- },
- {
- label: '否',
- value: false
- }
- ] as any
- }
- clearable
- />
- )
- }
- })
- field.push({
- title(column: any) {
- return (
- <NSpace>
- 排序
- <NButton
- type="primary"
- size="small"
- text
- onClick={() => {
- dialogs.create({
- title: '请输入排序起始值',
- showIcon: false,
- content: () => {
- return h(
- 'div',
- {
- class: 'flex flex-col justify-center items-center text-14px'
- },
- [
- // icon
- h(NInputNumber, {
- onUpdateValue(v) {
- state.globalStartSortNum = v
- },
- min: 0,
- max: 9999
- })
- ]
- )
- },
- positiveText: '确定',
- negativeText: '取消',
- onPositiveClick: () => {
- for (let i = 0; i < state.selectRowData.length; i++) {
- const item = state.selectRowData[i]
- item.sortNo = state.globalStartSortNum + i
- }
- }
- })
- }}
- >
- <NIcon size={15} style="padding-left: 5px;margin-top:4px">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
- <path d="M2 26h28v2H2z" fill="currentColor"></path>
- <path
- d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z"
- fill="currentColor"
- ></path>
- </svg>
- </NIcon>
- </NButton>
- </NSpace>
- )
- },
- key: 'sortNo',
- fixed: 'right',
- width: 150,
- render: (row: any) => {
- return h(NInputNumber, {
- value: row.sortNo,
- min: 0,
- max: 9999,
- onUpdateValue(value: any) {
- row.sortNo = value
- }
- })
- }
- })
- field.push({
- title: '操作',
- key: 'operation',
- fixed: 'right',
- render(row: any) {
- return (
- <NSpace>
- <NButton
- type="primary"
- size="small"
- text
- //v-auth="musicSheet/update1602302618558099458"
- onClick={() => {
- dialogs.warning({
- title: '提示',
- content: `是否删除该数据?`,
- positiveText: '确定',
- negativeText: '取消',
- onPositiveClick: async () => {
- try {
- const index = state.selectRowData.findIndex((item: any) => {
- if (item.id == row.id) {
- return true
- }
- })
- if (index > -1) {
- state.selectRowData.splice(index, 1)
- }
- const index1 = checkedRowKeysRef.value.findIndex((item: any) => {
- if (item == row.id) {
- return true
- }
- })
- if (index1 > -1) {
- checkedRowKeysRef.value.splice(index, 1)
- }
- } catch {}
- }
- })
- }}
- >
- 移除
- </NButton>
- </NSpace>
- )
- }
- })
- return field
- }
- const checkedRowKeysRef = ref<DataTableRowKey[]>([])
- const handleCheck = (rowKeys: DataTableRowKey[]) => {
- checkedRowKeysRef.value = rowKeys
- // 添加行更新值
- state.dataList.forEach((next: any) => {
- if (checkedRowKeysRef.value.includes(next.id)) {
- const find = state.selectRowData.find((row: any) => {
- return row.id === next.id
- })
- if (!find) {
- state.selectRowData.push({
- ...next,
- paymentType: [] as any,
- musicPriceDisable: false // 默认可以编辑曲目价格
- })
- }
- }
- })
- // 去掉行更新值
- state.selectRowData = state.selectRowData.filter((next: any) => {
- return checkedRowKeysRef.value.includes(next.id)
- })
- }
- return () => {
- return (
- <div class="system-menu-container">
- <NSpace vertical size="medium">
- <NSteps
- current={state.currentStep}
- // onUpdateCurrent={()=>{
- // state.currentStep = val
- // }}
- style={'margin-bottom: 10px;margin-top: 10px'}
- >
- <NStep title="选择曲目" description=""></NStep>
- <NStep title="设置曲目信息" description=""></NStep>
- </NSteps>
- </NSpace>
- {state.currentStep === 1 && (
- <div class="system-menu-container">
- <SaveForm
- ref={saveForm}
- model={state.searchForm}
- onSubmit={onSubmit}
- saveKey="klx-addMusic"
- onSetModel={(val: any) => (state.searchForm = val)}
- >
- <NFormItem label="关键词" path="keyword">
- <NInput
- v-model:value={state.searchForm.keyword}
- placeholder="请输入曲目名称/编号"
- clearable
- />
- </NFormItem>
- <NFormItem label="多声轨渲染" path="musicSheetType">
- <NSelect
- placeholder="请选择多声轨渲染"
- v-model:value={state.searchForm.musicSheetType}
- options={getSelectDataFromObj(musicSheetType)}
- clearable
- />
- </NFormItem>
- <NFormItem label="可用声部" path="musicSubject">
- <NSelect
- placeholder="请选择可用声部"
- v-model:value={state.searchForm.subjectId}
- options={state.subjectList}
- clearable
- />
- </NFormItem>
- <NFormItem label="音乐人" path="composer">
- <NInput
- placeholder="请选择音乐人"
- v-model:value={state.searchForm.composer}
- clearable
- />
- </NFormItem>
- <NFormItem label="曲目来源" path="sourceType">
- <NSelect
- placeholder="请选择曲目来源"
- v-model:value={state.searchForm.sourceType}
- options={getSelectDataFromObj(musicSheetSourceType)}
- onUpdateValue={async (value: any) => {
- state.userIdData = []
- state.searchForm.userId = null
- if (value && value !== 'PLATFORM') {
- await updateUserIdData(value)
- state.userIdDisable = false
- } else {
- state.userIdDisable = true
- }
- }}
- clearable
- />
- </NFormItem>
- <NFormItem label="所属项目" path="applicationId">
- <NSelect
- placeholder="请选择所属项目"
- v-model:value={state.searchForm.applicationId}
- options={state.useProjectData}
- clearable
- onUpdateValue={async (value: any) => {
- state.searchForm.applicationId = value
- if (value) {
- await updateUserIdData(state.searchForm.sourceType)
- state.userIdDisable = !(
- state.searchForm.sourceType && state.searchForm.sourceType !== 'PLATFORM'
- )
- } else {
- state.searchForm.userId = null
- state.userIdDisable = true
- state.userIdData = []
- }
- }}
- />
- </NFormItem>
- <NFormItem label="所属人" path="author">
- <NSelect
- filterable
- placeholder="请选择所属人"
- disabled={state.userIdDisable || (!state.searchForm.applicationId && !state.searchForm.sourceType)}
- v-model:value={state.searchForm.userId}
- options={state.userIdData}
- clearable
- ></NSelect>
- </NFormItem>
- <NFormItem>
- <NSpace>
- <NButton type="primary" onClick={onSearch}>
- 搜索
- </NButton>
- <NButton type="default" onClick={onBtnReset}>
- 重置
- </NButton>
- </NSpace>
- </NFormItem>
- </SaveForm>
- <p style={{ paddingBottom: '12px' }}>
- 你选择了<span style={'color:red;padding:0 8px'}>{state.selectRowData.length}</span>
- 条曲目
- </p>
- <NDataTable
- loading={state.loading}
- columns={columns()}
- data={state.dataList}
- rowKey={(row: any) => row.id}
- onUpdateCheckedRowKeys={handleCheck}
- ></NDataTable>
- <Pagination
- v-model:page={state.pagination.page}
- v-model:pageSize={state.pagination.rows}
- v-model:pageTotal={state.pagination.pageTotal}
- onList={getList}
- sync
- saveKey="klx-addMusic"
- ></Pagination>
- </div>
- )}
- {state.currentStep === 2 && (
- <div class="system-menu-container" style={'margin-top: 15px;'}>
- <NDataTable
- loading={state.loading}
- columns={stepColumns()}
- data={state.selectRowData}
- rowKey={(row: any) => row.id}
- maxHeight={500}
- scrollX={2000}
- ></NDataTable>
- </div>
- )}
- <NSpace justify="end" style={'margin-top:10px'}>
- <NButton
- type="default"
- onClick={() => {
- if (state.currentStep > 1) {
- state.currentStep = state.currentStep - 1
- } else {
- emit('close')
- }
- }}
- >
- {state.currentStep === 1 ? '取消' : '上一步'}
- </NButton>
- <NButton
- type="primary"
- onClick={() => {
- if (state.currentStep < 2) {
- if (state.selectRowData.length == 0) {
- message.warning('请选择曲目')
- return
- }
- state.currentStep = state.currentStep + 1
- } else {
- onSave()
- }
- }}
- // loading={btnLoading.value}
- // disabled={btnLoading.value}
- >
- {state.currentStep === 2 ? '确定' : '下一步'}
- </NButton>
- </NSpace>
- </div>
- )
- }
- }
- })
|