123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- import {defineComponent, onMounted, reactive, ref} from "vue";
- import {NButton, NCascader, NForm, NFormItem, NInputNumber, NSelect, NSpace, useMessage} from "naive-ui";
- import {musicSheetApplicationExtendCategoryApplicationExtendInfo, musicSheetApplicationExtendUpdate} from "@views/music-library/api";
- import {getSelectDataFromObj} from "@/utils/objectUtil";
- import {scoreType} from "@/utils/constant";
- import {formatTree} from "@views/music-library/musicUtil";
- export default defineComponent({
- name: 'project-music-cooleshow-edu-updateMusic',
- props: {
- appId: {
- type: String,
- required: true
- },
- rowData: {
- type: Object,
- required: true
- },
- musicSheetCategories: {
- type: Array,
- default: () => []
- }
- },
- emits: ['close', 'getList'],
- setup(props, {slots, attrs, emit}) {
- const message = useMessage()
- const btnLoading = ref(false)
- const forms = reactive({
- musicSheetCategoryId: null as any,
- sortNo: null as any,
- availableType: null as any,
- isConvertibleScore: null as any,//是否支持转简谱
- status: false, // 是否启用
- scoreType: null as any,//默认谱面
- })
- const formsRef = ref()
- const state = reactive({
- rowData: null as any,
- musicSheetCategories: [] as any,
- })
- onMounted(async () => {
- state.rowData = props.rowData
- formatTree(props.musicSheetCategories)
- state.musicSheetCategories = props.musicSheetCategories
- const {data} = await musicSheetApplicationExtendCategoryApplicationExtendInfo({musicSheetId: state.rowData.id, applicationId: props.appId}) as any
- if (!data) {
- message.error("加载应用失败")
- return
- }
- forms.musicSheetCategoryId = data[0].musicSheetCategoryId
- forms.sortNo = data[0].sortNo
- forms.availableType = data[0].availableType
- forms.isConvertibleScore = data[0].isConvertibleScore
- forms.scoreType = data[0].scoreType
- forms.status = data[0].clientStatus
- })
- const onSubmit = async () => {
- formsRef.value.validate(async (error: any) => {
- if (error) return false
- btnLoading.value = true
- try {
- const res = await musicSheetApplicationExtendUpdate(
- {
- ...forms,
- musicSheetId: state.rowData.id,
- applicationId: props.appId
- }
- ) as any;
- if (res && res.code === 200) {
- emit('close')
- emit('getList')
- }
- } catch (error) {
- }
- btnLoading.value = false
- })
- }
- return () => {
- return (
- <div style="background: #fff; padding-top: 12px">
- <NForm
- ref={formsRef}
- labelPlacement="top"
- model={forms}
- label-placement="left"
- label-width="auto"
- >
- <NFormItem
- label="曲目分类"
- path="musicSheetCategoryId"
- rule={[
- {
- required: true,
- message: '请选择曲目分类'
- }
- ]}
- >
- <NCascader
- valueField="id"
- labelField="name"
- children-field="children"
- placeholder="请选择曲目分类"
- disabledField={'disabled'}
- value={forms.musicSheetCategoryId}
- options={state.musicSheetCategories}
- onUpdateValue={(value: any) => {
- forms.musicSheetCategoryId = value
- }}
- clearable
- />
- </NFormItem>
- <NFormItem
- label="可用途径"
- path="availableType"
- rule={[
- {
- required: true,
- message: '请选择可用途径'
- }
- ]}
- >
- <NSelect
- placeholder="请选择可用途径"
- options={[
- {
- label: '学校',
- value: 'ORG'
- },
- {
- label: '平台',
- value: 'PLATFORM'
- },
- ]}
- v-model:value={forms.availableType}
- clearable
- />
- </NFormItem>
- <NFormItem
- label="默认谱面"
- path="scoreType"
- rule={[
- {
- required: true,
- message: '请选择默认谱面'
- }
- ]}
- >
- <NSelect
- v-model:value={forms.scoreType}
- placeholder="请选择默认谱面"
- options={getSelectDataFromObj(scoreType)}
- clearable
- />
- </NFormItem>
- <NFormItem
- label="支持转谱"
- path="isConvertibleScore"
- rule={[
- {
- required: true,
- message: '请选择是否支持转谱',
- trigger: ['input', 'blur'],
- type: 'boolean'
- }
- ]}
- >
- <NSelect
- v-model:value={forms.isConvertibleScore}
- options={
- [
- {
- label: '是',
- value: true
- },
- {
- label: '否',
- value: false
- }
- ] as any
- }
- placeholder="请选择是否支持转谱"
- onUpdateValue={async (value: any) => {
- if (!value) {
- //如果不支持,修改默认谱面
- // forms.scoreType = 'STAVE'
- }
- }}
- clearable
- ></NSelect>
- </NFormItem>
- <NFormItem
- label="是否启用"
- path="status"
- rule={[
- {
- required: true,
- message: '请选择是否启用'
- }
- ]}
- >
- <NSelect
- placeholder="请选择是否启用"
- options={[
- {
- label: '是',
- value: true
- },
- {
- label: '否',
- value: false
- }
- ] as any}
- v-model:value={forms.status}
- clearable
- />
- </NFormItem>
- <NFormItem
- label="排序值"
- path="sortNo"
- >
- <NInputNumber
- v-model:value={forms.sortNo}
- placeholder="请输入排序值"
- clearable
- min={0}
- max={9999}
- style={{width: '100%'}}
- />
- </NFormItem>
- </NForm>
- <NSpace justify="end">
- <NButton onClick={() => emit('close')}>取消</NButton>
- <NButton type="primary" onClick={onSubmit}
- loading={btnLoading.value}
- disabled={btnLoading.value}
- >
- 保存
- </NButton>
- </NSpace>
- </div>
- )
- }
- }
- })
|