|
@@ -19,14 +19,14 @@ import {
|
|
|
NTabs,
|
|
|
useMessage,
|
|
|
} from "naive-ui";
|
|
|
-import { defineComponent, reactive, watch } from "vue";
|
|
|
+import { defineComponent, onMounted, reactive, watch } from "vue";
|
|
|
import { Close } from "@vicons/ionicons5";
|
|
|
import styles from "./index.module.less";
|
|
|
import { getImage } from "/src/pc/home/images";
|
|
|
import { ABC_DATA } from "/src/pc/home/runtime";
|
|
|
import TheIcon from "/src/components/The-icon";
|
|
|
import TheSpeed from "/src/pc/home/component/the-speed";
|
|
|
-import { api_musicSheetCreationSave } from "/src/pc/api";
|
|
|
+import { api_musicSheetCreationSave, api_subjectList } from "/src/pc/api";
|
|
|
export default defineComponent({
|
|
|
name: "TheCreate",
|
|
|
props: {
|
|
@@ -41,32 +41,41 @@ export default defineComponent({
|
|
|
const instruments = [
|
|
|
{
|
|
|
label: "竖笛",
|
|
|
- key: "shudi",
|
|
|
+ key: "CLARINET",
|
|
|
+ id: 4,
|
|
|
icon: getImage("icon_27_0.png"),
|
|
|
},
|
|
|
{
|
|
|
label: "排箫",
|
|
|
- key: "paixiao",
|
|
|
+ key: "PANPIPE",
|
|
|
+ id: 1,
|
|
|
icon: getImage("icon_27_1.png"),
|
|
|
},
|
|
|
{
|
|
|
label: "口风琴",
|
|
|
- key: "koufengqin",
|
|
|
+ key: "HARMONICA",
|
|
|
+ id: 5,
|
|
|
icon: getImage("icon_27_2.png"),
|
|
|
},
|
|
|
{
|
|
|
label: "陶笛",
|
|
|
- key: "taodie",
|
|
|
+ key: "OCARINA",
|
|
|
+ id: 2,
|
|
|
icon: getImage("icon_27_3.png"),
|
|
|
},
|
|
|
{
|
|
|
label: "葫芦丝",
|
|
|
- key: "hulusi",
|
|
|
+ key: "FENUGREEK_SILK",
|
|
|
+ id: 3,
|
|
|
icon: getImage("icon_27_4.png"),
|
|
|
},
|
|
|
];
|
|
|
+ const formsOptions = reactive({
|
|
|
+ subjects: [] as any[],
|
|
|
+ loading: false,
|
|
|
+ });
|
|
|
const froms = reactive({
|
|
|
- instrument: "shudi",
|
|
|
+ subjectId: 4,
|
|
|
key: ABC_DATA.key[0],
|
|
|
meter: ABC_DATA.meter[0],
|
|
|
speed: 80,
|
|
@@ -74,16 +83,40 @@ export default defineComponent({
|
|
|
});
|
|
|
|
|
|
const handleCreate = async () => {
|
|
|
- await api_musicSheetCreationSave({
|
|
|
- creationData: "sd",
|
|
|
- name: "sd",
|
|
|
- creationConfig: "sd",
|
|
|
- subjectId: 1,
|
|
|
- });
|
|
|
- emit('create')
|
|
|
+ formsOptions.loading = true;
|
|
|
+ try {
|
|
|
+ await api_musicSheetCreationSave({
|
|
|
+ creationData: "",
|
|
|
+ name: "",
|
|
|
+ creationConfig: JSON.stringify({
|
|
|
+ key: froms.key.value,
|
|
|
+ meter: froms.meter.value,
|
|
|
+ speed: froms.speed,
|
|
|
+ measure: froms.measure,
|
|
|
+ }),
|
|
|
+ subjectId: 1,
|
|
|
+ });
|
|
|
+ emit("create");
|
|
|
+ } catch (error) {
|
|
|
+ console.log("🚀 ~ error:", error);
|
|
|
+ }
|
|
|
+ formsOptions.loading = false;
|
|
|
+ };
|
|
|
+
|
|
|
+ const getSubjects = async () => {
|
|
|
+ const res = await api_subjectList();
|
|
|
+ formsOptions.subjects = res.data || [];
|
|
|
};
|
|
|
+ onMounted(async () => {
|
|
|
+ getSubjects();
|
|
|
+ });
|
|
|
return () => (
|
|
|
- <NModal autoFocus={false} show={props.show} onUpdate:show={(val) => emit("update:show", val)}>
|
|
|
+ <NModal
|
|
|
+ transformOrigin="center"
|
|
|
+ autoFocus={false}
|
|
|
+ show={props.show}
|
|
|
+ onUpdate:show={(val) => emit("update:show", val)}
|
|
|
+ >
|
|
|
<div class={styles.setbox}>
|
|
|
<div class={styles.head}>
|
|
|
<div>新建乐谱</div>
|
|
@@ -102,8 +135,8 @@ export default defineComponent({
|
|
|
<NSpace style={{ paddingBottom: "45px" }}>
|
|
|
{instruments.map((item) => (
|
|
|
<div
|
|
|
- class={[styles.item, froms.instrument === item.key && styles.itemActive]}
|
|
|
- onClick={() => (froms.instrument = item.key)}
|
|
|
+ class={[styles.item, froms.subjectId === item.id && styles.itemActive]}
|
|
|
+ onClick={() => (froms.subjectId = item.id)}
|
|
|
>
|
|
|
<div class={styles.itemImg}>
|
|
|
<img class={styles.icon} src={item.icon} />
|
|
@@ -204,7 +237,7 @@ export default defineComponent({
|
|
|
<NButton round onClick={() => emit("update:show", false)}>
|
|
|
取消
|
|
|
</NButton>
|
|
|
- <NButton round type="primary" onClick={() => handleCreate()}>
|
|
|
+ <NButton loading={formsOptions.loading} round type="primary" onClick={() => handleCreate()}>
|
|
|
确定
|
|
|
</NButton>
|
|
|
</div>
|