|
@@ -1,7 +1,13 @@
|
|
<template>
|
|
<template>
|
|
<div>
|
|
<div>
|
|
<el-alert title="教材信息" :closable="false" class="alert" type="info" />
|
|
<el-alert title="教材信息" :closable="false" class="alert" type="info" />
|
|
- <el-form :model="form" :inline="true" label-width="120px" class="form">
|
|
|
|
|
|
+ <el-form
|
|
|
|
+ :model="form"
|
|
|
|
+ :inline="true"
|
|
|
|
+ label-width="120px"
|
|
|
|
+ class="form"
|
|
|
|
+ ref="form"
|
|
|
|
+ >
|
|
<el-row>
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-col :span="12">
|
|
<el-form-item
|
|
<el-form-item
|
|
@@ -19,13 +25,17 @@
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="12">
|
|
<el-col :span="12">
|
|
- <el-form-item label="教材分类" prop="organId" :rules="[
|
|
|
|
|
|
+ <el-form-item
|
|
|
|
+ label="适用分部"
|
|
|
|
+ prop="organId"
|
|
|
|
+ :rules="[
|
|
{
|
|
{
|
|
required: true,
|
|
required: true,
|
|
message: '请选择适用分部',
|
|
message: '请选择适用分部',
|
|
trigger: 'change',
|
|
trigger: 'change',
|
|
},
|
|
},
|
|
- ]">
|
|
|
|
|
|
+ ]"
|
|
|
|
+ >
|
|
<select-all
|
|
<select-all
|
|
style="width: 260px"
|
|
style="width: 260px"
|
|
v-model.trim="form.organId"
|
|
v-model.trim="form.organId"
|
|
@@ -48,7 +58,7 @@
|
|
<el-row>
|
|
<el-row>
|
|
<el-form-item
|
|
<el-form-item
|
|
label="教材封面图"
|
|
label="教材封面图"
|
|
- prop="poster"
|
|
|
|
|
|
+ prop="coverImg"
|
|
:rules="[
|
|
:rules="[
|
|
{
|
|
{
|
|
required: true,
|
|
required: true,
|
|
@@ -58,13 +68,15 @@
|
|
]"
|
|
]"
|
|
label-width="120px"
|
|
label-width="120px"
|
|
>
|
|
>
|
|
|
|
+ <!-- v-show="!form.coverImg" -->
|
|
<upload
|
|
<upload
|
|
- v-if="!form.poster"
|
|
|
|
- v-model="form.poster"
|
|
|
|
|
|
+ class="uploadImg"
|
|
|
|
+ v-model="form.coverImg"
|
|
:imageWidthM="210"
|
|
:imageWidthM="210"
|
|
:imageHeightM="268"
|
|
:imageHeightM="268"
|
|
|
|
+ ref="uploadImg"
|
|
></upload>
|
|
></upload>
|
|
- <img v-else :src="form.poster" alt="" width="210px" height="268px" />
|
|
|
|
|
|
+ <!-- <img v-show="form.coverImg" :src="form.coverImg" alt="" width="105px" height="134px" @click="uploadImg"/> -->
|
|
<p style="color: red">
|
|
<p style="color: red">
|
|
请上传210*268像素,大小2M以内,格式为jpg、png、gif图片
|
|
请上传210*268像素,大小2M以内,格式为jpg、png、gif图片
|
|
</p>
|
|
</p>
|
|
@@ -82,12 +94,14 @@
|
|
>添加分类</el-button
|
|
>添加分类</el-button
|
|
>
|
|
>
|
|
<el-tree
|
|
<el-tree
|
|
- :data="form.data"
|
|
|
|
|
|
+ :data="form.sysMusicScoreCategoriesList"
|
|
node-key="index"
|
|
node-key="index"
|
|
default-expand-all
|
|
default-expand-all
|
|
:expand-on-click-node="false"
|
|
:expand-on-click-node="false"
|
|
draggable
|
|
draggable
|
|
accordion
|
|
accordion
|
|
|
|
+ ref="tree"
|
|
|
|
+ :props="treeProps"
|
|
>
|
|
>
|
|
>
|
|
>
|
|
<span class="custom-tree-node" slot-scope="{ node, data }">
|
|
<span class="custom-tree-node" slot-scope="{ node, data }">
|
|
@@ -112,7 +126,9 @@
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
import Upload from "@/components/Upload/index";
|
|
import Upload from "@/components/Upload/index";
|
|
|
|
+import { addsysMusicScore, getSysMusicScoreDetail,resetsysMusicScore } from "../api";
|
|
export default {
|
|
export default {
|
|
|
|
+ props: ["activeRow"],
|
|
components: {
|
|
components: {
|
|
Upload,
|
|
Upload,
|
|
},
|
|
},
|
|
@@ -121,19 +137,39 @@ export default {
|
|
form: {
|
|
form: {
|
|
organId: [],
|
|
organId: [],
|
|
name: null,
|
|
name: null,
|
|
- data: [],
|
|
|
|
|
|
+ coverImg: "",
|
|
|
|
+ sysMusicScoreCategoriesList: [],
|
|
},
|
|
},
|
|
index: 0,
|
|
index: 0,
|
|
|
|
+ treeProps: {
|
|
|
|
+ children: "sysMusicScoreCategoriesList",
|
|
|
|
+ label: "name",
|
|
|
|
+ },
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- mounted() {
|
|
|
|
- this.$store.dispatch("setBranchs");
|
|
|
|
|
|
+ async mounted() {
|
|
|
|
+ await this.$store.dispatch("setBranchs");
|
|
|
|
+ if (this.activeRow?.id) {
|
|
|
|
+ try {
|
|
|
|
+ const res = await getSysMusicScoreDetail({ id: this.activeRow.id });
|
|
|
|
+ this.form.name = res.data.name;
|
|
|
|
+ this.form.organId = res.data.organId.split(",").map((item) => {
|
|
|
|
+ return Number(item);
|
|
|
|
+ });
|
|
|
|
+ this.form.coverImg = res.data.coverImg;
|
|
|
|
+ this.form.sysMusicScoreCategoriesList = this.recursionDate(
|
|
|
|
+ res.data.sysMusicScoreCategoriesList
|
|
|
|
+ );
|
|
|
|
+ } catch (e) {}
|
|
|
|
+ }
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
// 递归遍历数组
|
|
// 递归遍历数组
|
|
recursionDate(arr) {
|
|
recursionDate(arr) {
|
|
|
|
+
|
|
// 这里来了
|
|
// 这里来了
|
|
if (arr.length > 0) {
|
|
if (arr.length > 0) {
|
|
|
|
+
|
|
let newArr = [];
|
|
let newArr = [];
|
|
for (let i = 0; i < arr.length; i++) {
|
|
for (let i = 0; i < arr.length; i++) {
|
|
let obj = {
|
|
let obj = {
|
|
@@ -141,15 +177,23 @@ export default {
|
|
index: arr[i].id,
|
|
index: arr[i].id,
|
|
};
|
|
};
|
|
|
|
|
|
- if (arr[i].sysMenus && arr[i].sysMenus.length > 0) {
|
|
|
|
- obj.children = recursionDate(arr[i].sysMenus);
|
|
|
|
|
|
+ if (
|
|
|
|
+ arr[i].sysMusicScoreCategoriesList &&
|
|
|
|
+ arr[i].sysMusicScoreCategoriesList.length > 0
|
|
|
|
+ ) {
|
|
|
|
+ obj.sysMusicScoreCategoriesList = this.recursionDate(
|
|
|
|
+ arr[i].sysMusicScoreCategoriesList
|
|
|
|
+ );
|
|
}
|
|
}
|
|
|
|
+
|
|
newArr.push(obj);
|
|
newArr.push(obj);
|
|
}
|
|
}
|
|
|
|
+
|
|
return newArr;
|
|
return newArr;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
appendItem(data) {
|
|
appendItem(data) {
|
|
|
|
+ console.log(data);
|
|
this.$prompt("请输入教材名称", "提示", {
|
|
this.$prompt("请输入教材名称", "提示", {
|
|
confirmButtonText: "确定",
|
|
confirmButtonText: "确定",
|
|
cancelButtonText: "取消",
|
|
cancelButtonText: "取消",
|
|
@@ -162,19 +206,19 @@ export default {
|
|
// this.form.data.push({ index: `xxx${this.index}`, label: value });
|
|
// this.form.data.push({ index: `xxx${this.index}`, label: value });
|
|
const newChild = {
|
|
const newChild = {
|
|
index: `xxx${this.index}`,
|
|
index: `xxx${this.index}`,
|
|
- label: value,
|
|
|
|
- children: [],
|
|
|
|
|
|
+ name: value,
|
|
|
|
+ sysMusicScoreCategoriesList: [],
|
|
};
|
|
};
|
|
- if (!data.children) {
|
|
|
|
- this.$set(data, "children", []);
|
|
|
|
|
|
+ if (!data.sysMusicScoreCategoriesList) {
|
|
|
|
+ this.$set(data, "sysMusicScoreCategoriesList", []);
|
|
}
|
|
}
|
|
- data.children.push(newChild);
|
|
|
|
|
|
+ data.sysMusicScoreCategoriesList.push(newChild);
|
|
})
|
|
})
|
|
.catch(() => {});
|
|
.catch(() => {});
|
|
},
|
|
},
|
|
removeItem(node, data) {
|
|
removeItem(node, data) {
|
|
const parent = node.parent;
|
|
const parent = node.parent;
|
|
- const children = parent.data.children || parent.data;
|
|
|
|
|
|
+ const children = parent.data.sysMusicScoreCategoriesList || parent.data;
|
|
const index = children.findIndex((d) => d.id === data.id);
|
|
const index = children.findIndex((d) => d.id === data.id);
|
|
children.splice(index, 1);
|
|
children.splice(index, 1);
|
|
},
|
|
},
|
|
@@ -183,11 +227,12 @@ export default {
|
|
confirmButtonText: "确定",
|
|
confirmButtonText: "确定",
|
|
cancelButtonText: "取消",
|
|
cancelButtonText: "取消",
|
|
closeOnClickModal: false,
|
|
closeOnClickModal: false,
|
|
|
|
+ inputValue: data.name,
|
|
inputPattern: /^.{1,30}$/,
|
|
inputPattern: /^.{1,30}$/,
|
|
inputErrorMessage: "请输入1到15个汉字或字符",
|
|
inputErrorMessage: "请输入1到15个汉字或字符",
|
|
})
|
|
})
|
|
.then(({ value }) => {
|
|
.then(({ value }) => {
|
|
- data.label = value;
|
|
|
|
|
|
+ data.name = value;
|
|
// this.form.data.push({ index: `xxx${this.index}`, label: value });
|
|
// this.form.data.push({ index: `xxx${this.index}`, label: value });
|
|
})
|
|
})
|
|
.catch(() => {});
|
|
.catch(() => {});
|
|
@@ -202,11 +247,44 @@ export default {
|
|
})
|
|
})
|
|
.then(({ value }) => {
|
|
.then(({ value }) => {
|
|
this.index += 1;
|
|
this.index += 1;
|
|
- this.form.data.push({ index: `xxx${this.index}`, label: value });
|
|
|
|
|
|
+ this.form.sysMusicScoreCategoriesList.push({
|
|
|
|
+ index: `xxx${this.index}`,
|
|
|
|
+ name: value,
|
|
|
|
+ });
|
|
})
|
|
})
|
|
.catch(() => {});
|
|
.catch(() => {});
|
|
// this.form.data.push({})
|
|
// this.form.data.push({})
|
|
},
|
|
},
|
|
|
|
+ addSubmit() {
|
|
|
|
+ this.$refs.form.validate(async (flag) => {
|
|
|
|
+ if (flag) {
|
|
|
|
+ let { organId, ...rest } = this.form;
|
|
|
|
+ let obj = {
|
|
|
|
+ ...rest,
|
|
|
|
+ organId: organId.join(","),
|
|
|
|
+ };
|
|
|
|
+ try {
|
|
|
|
+ if( this.activeRow.id){
|
|
|
|
+ obj.id = this.activeRow.id
|
|
|
|
+ const resut = await resetsysMusicScore(obj)
|
|
|
|
+ this.$$message.success('修改成功')
|
|
|
|
+ }else{
|
|
|
|
+ const resut = await addsysMusicScore(obj);
|
|
|
|
+ this.$$message.success('添加成功')
|
|
|
|
+ this.$emit("getList");
|
|
|
|
+ this.$emit("close");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.log(e)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ console.log("提交");
|
|
|
|
+ },
|
|
|
|
+ uploadImg() {
|
|
|
|
+ this.$refs.uploadImg.$refs.upload.submit();
|
|
|
|
+ },
|
|
},
|
|
},
|
|
computed: {},
|
|
computed: {},
|
|
};
|
|
};
|
|
@@ -230,4 +308,10 @@ export default {
|
|
margin-left: 5px;
|
|
margin-left: 5px;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+.uploadImg {
|
|
|
|
+ /deep/.avatar {
|
|
|
|
+ width: 105px;
|
|
|
|
+ height: 134px;
|
|
|
|
+ }
|
|
|
|
+}
|
|
</style>
|
|
</style>
|