|
@@ -23,6 +23,7 @@
|
|
|
<el-form-item
|
|
|
label="适用分部"
|
|
|
prop="organId"
|
|
|
+ v-if="!activeRow.id"
|
|
|
:rules="[
|
|
|
{
|
|
|
required: true,
|
|
@@ -135,56 +136,34 @@ export default {
|
|
|
this.imageWidthM = 210
|
|
|
this.imageHeightM = 268
|
|
|
// }
|
|
|
- console.log(this.type)
|
|
|
- if(this.type == 'create') { // 添加一级分类或子级
|
|
|
-
|
|
|
- } else if(this.type == 'update') { // 修改分类
|
|
|
- try {
|
|
|
- const res = await getSysMusicScoreDetail({ id: this.activeRow.id });
|
|
|
+ try {
|
|
|
+ const res = await getSysMusicScoreDetail({ id: this.activeRow.id });
|
|
|
+ if(this.type == 'create') { // 添加一级分类或子级
|
|
|
+ this.form.organId = res.data.organId.split(",").map((item) => {
|
|
|
+ return Number(item);
|
|
|
+ });
|
|
|
+ } else if(this.type == 'update') { // 修改分类
|
|
|
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.soundResource = res.data.soundResource;
|
|
|
- this.form.sysMusicScoreCategoriesList =
|
|
|
- this.recursionDate(res.data.sysMusicScoreCategoriesList) || [];
|
|
|
- } catch (e) {}
|
|
|
- }
|
|
|
+ }
|
|
|
+ } catch (e) {}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- // 递归遍历数组
|
|
|
- recursionDate(arr) {
|
|
|
- // 这里来了
|
|
|
- if (arr.length > 0) {
|
|
|
- let newArr = [];
|
|
|
- for (let i = 0; i < arr.length; i++) {
|
|
|
- let obj = {
|
|
|
- ...arr[i],
|
|
|
- index: arr[i].id,
|
|
|
- };
|
|
|
-
|
|
|
- if (
|
|
|
- arr[i].sysMusicScoreCategoriesList &&
|
|
|
- arr[i].sysMusicScoreCategoriesList.length > 0
|
|
|
- ) {
|
|
|
- obj.sysMusicScoreCategoriesList = this.recursionDate(
|
|
|
- arr[i].sysMusicScoreCategoriesList
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- newArr.push(obj);
|
|
|
- }
|
|
|
-
|
|
|
- return newArr;
|
|
|
- }
|
|
|
- },
|
|
|
addSubmit() {
|
|
|
this.$refs.form.validate(async (flag) => {
|
|
|
if (flag) {
|
|
|
let { organId, ...rest } = this.form;
|
|
|
- let parentId = this.activeRow?.id || 0
|
|
|
+ let parentId = 0
|
|
|
+ if(this.type == 'create') {
|
|
|
+ parentId = this.activeRow?.id || 0
|
|
|
+ } else if(this.type == 'update') {
|
|
|
+ parentId = this.activeRow?.parentId || 0
|
|
|
+ }
|
|
|
let obj = {
|
|
|
...rest,
|
|
|
parentId,
|