|
@@ -1,6 +1,32 @@
|
|
<template>
|
|
<template>
|
|
<div>
|
|
<div>
|
|
<el-form :model="musicForm" label-width="110px" ref="form">
|
|
<el-form :model="musicForm" label-width="110px" ref="form">
|
|
|
|
+ <el-form-item label="选择学员" prop="studentId" v-if="this.chioseStudent" :rules="[
|
|
|
|
+ { required: true, message: '请选择学员', trigger: 'blur' },
|
|
|
|
+ ]">
|
|
|
|
+ <el-select
|
|
|
|
+ style="width: 400px !important"
|
|
|
|
+ v-model.trim="musicForm.studentId"
|
|
|
|
+ clearable
|
|
|
|
+ placeholder="请选择"
|
|
|
|
+ remote
|
|
|
|
+ filterable
|
|
|
|
+ :remote-method="remoteMethod"
|
|
|
|
+ :loading="remoteLoading"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in studentList"
|
|
|
|
+ :key="item.userId"
|
|
|
|
+ :label="item.username"
|
|
|
|
+ :value="item.userId"
|
|
|
|
+ >
|
|
|
|
+ <span style="float: left">{{ item.username }}</span>
|
|
|
|
+ <span style="float: right; color: #8492a6; font-size: 13px">{{
|
|
|
|
+ item.userId
|
|
|
|
+ }}</span>
|
|
|
|
+ </el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
<el-form-item
|
|
<el-form-item
|
|
label="乐器分类"
|
|
label="乐器分类"
|
|
prop="goodsCategoryId"
|
|
prop="goodsCategoryId"
|
|
@@ -92,10 +118,12 @@
|
|
<script>
|
|
<script>
|
|
import { goodsQuery } from "@/api/businessManager";
|
|
import { goodsQuery } from "@/api/businessManager";
|
|
import { addStudentInstrument, updateStudentInstrument } from "@/api/buildTeam";
|
|
import { addStudentInstrument, updateStudentInstrument } from "@/api/buildTeam";
|
|
|
|
+import { getToken, getTenantId } from "@/utils/auth";
|
|
import { getTimes } from "@/utils";
|
|
import { getTimes } from "@/utils";
|
|
-import dayjs from 'dayjs'
|
|
|
|
|
|
+import axios from "axios";
|
|
|
|
+import dayjs from "dayjs";
|
|
export default {
|
|
export default {
|
|
- props: ["categoryList", "operationData", "operationStatus"],
|
|
|
|
|
|
+ props: ["categoryList", "operationData", "operationStatus", "chioseStudent"],
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
musicForm: {
|
|
musicForm: {
|
|
@@ -108,30 +136,32 @@ export default {
|
|
pickerOptions: {
|
|
pickerOptions: {
|
|
firstDayOfWeek: 1,
|
|
firstDayOfWeek: 1,
|
|
disabledDate(time) {
|
|
disabledDate(time) {
|
|
- let times = dayjs(dayjs().format('YYYY-MM-DD')).valueOf()
|
|
|
|
|
|
+ let times = dayjs(dayjs().format("YYYY-MM-DD")).valueOf();
|
|
return times > time.getTime();
|
|
return times > time.getTime();
|
|
},
|
|
},
|
|
},
|
|
},
|
|
typeList: this.categoryList,
|
|
typeList: this.categoryList,
|
|
musicList: [],
|
|
musicList: [],
|
|
|
|
+ remoteLoading: false,
|
|
|
|
+ studentList: [],
|
|
};
|
|
};
|
|
},
|
|
},
|
|
async mounted() {
|
|
async mounted() {
|
|
- console.log(this.operationData)
|
|
|
|
- let operationData = this.operationData
|
|
|
|
- if(operationData) {
|
|
|
|
- let musicForm = this.musicForm
|
|
|
|
- musicForm.goodsCategoryId = operationData.goodsCategoryId
|
|
|
|
- if(operationData.goodsCategoryId) {
|
|
|
|
- await this.changeCategory(operationData.goodsCategoryId)
|
|
|
|
|
|
+ console.log(this.operationData);
|
|
|
|
+ let operationData = this.operationData;
|
|
|
|
+ if (operationData) {
|
|
|
|
+ let musicForm = this.musicForm;
|
|
|
|
+ musicForm.goodsCategoryId = operationData.goodsCategoryId;
|
|
|
|
+ if (operationData.goodsCategoryId) {
|
|
|
|
+ await this.changeCategory(operationData.goodsCategoryId);
|
|
}
|
|
}
|
|
- musicForm.goodsId = operationData.goodsId
|
|
|
|
- musicForm.goodsName = operationData.goodsName
|
|
|
|
- musicForm.status = operationData.status + ''
|
|
|
|
- musicForm.date = operationData.endTime || null
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- musicForm.id = operationData.id
|
|
|
|
|
|
+ musicForm.studentId = operationData.studentId;
|
|
|
|
+ musicForm.goodsId = operationData.goodsId;
|
|
|
|
+ musicForm.goodsName = operationData.goodsName;
|
|
|
|
+ musicForm.status = operationData.status + "";
|
|
|
|
+ musicForm.date = operationData.endTime || null;
|
|
|
|
+ musicForm.id = operationData.id;
|
|
|
|
+ this.remoteMethod(musicForm.studentId);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -139,7 +169,11 @@ export default {
|
|
this.musicForm.goodsName = "";
|
|
this.musicForm.goodsName = "";
|
|
this.musicForm.goodsId = null;
|
|
this.musicForm.goodsId = null;
|
|
if (val) {
|
|
if (val) {
|
|
- goodsQuery({ goodsCategoryId: val, rows: 99999, type: 'INSTRUMENT' }).then((res) => {
|
|
|
|
|
|
+ goodsQuery({
|
|
|
|
+ goodsCategoryId: val,
|
|
|
|
+ rows: 99999,
|
|
|
|
+ type: "INSTRUMENT",
|
|
|
|
+ }).then((res) => {
|
|
if (res.code == 200 && res.data) {
|
|
if (res.code == 200 && res.data) {
|
|
this.musicList = res.data.rows;
|
|
this.musicList = res.data.rows;
|
|
}
|
|
}
|
|
@@ -153,37 +187,89 @@ export default {
|
|
const { date, status, ...rest } = this.musicForm;
|
|
const { date, status, ...rest } = this.musicForm;
|
|
let obj = {
|
|
let obj = {
|
|
...rest,
|
|
...rest,
|
|
- status
|
|
|
|
|
|
+ status,
|
|
};
|
|
};
|
|
// 是否有乐保
|
|
// 是否有乐保
|
|
- if(status == 1) {
|
|
|
|
- if(this.operationData && this.operationData.startTime) {
|
|
|
|
- obj.startTime = this.operationData.startTime
|
|
|
|
|
|
+ if (status == 1) {
|
|
|
|
+ if (this.operationData && this.operationData.startTime) {
|
|
|
|
+ obj.startTime = this.operationData.startTime;
|
|
} else {
|
|
} else {
|
|
- obj.startTime = dayjs().format('YYYY-MM-DD HH:mm') + ':00'
|
|
|
|
|
|
+ obj.startTime = dayjs().format("YYYY-MM-DD HH:mm") + ":00";
|
|
}
|
|
}
|
|
- obj.endTime = date
|
|
|
|
|
|
+ obj.endTime = date;
|
|
} else {
|
|
} else {
|
|
- obj.startTime = ''
|
|
|
|
- obj.endTime = ''
|
|
|
|
|
|
+ obj.startTime = "";
|
|
|
|
+ obj.endTime = "";
|
|
}
|
|
}
|
|
- if(this.operationStatus == 'create') {
|
|
|
|
|
|
+ if (this.operationStatus == "create") {
|
|
const res = await addStudentInstrument(obj);
|
|
const res = await addStudentInstrument(obj);
|
|
- this.$message.success('添加成功')
|
|
|
|
- } else if(this.operationStatus == 'update') {
|
|
|
|
|
|
+ this.$message.success("添加成功");
|
|
|
|
+ } else if (this.operationStatus == "update") {
|
|
const res = await updateStudentInstrument(obj);
|
|
const res = await updateStudentInstrument(obj);
|
|
- this.$message.success('修改成功')
|
|
|
|
|
|
+ this.$message.success("修改成功");
|
|
}
|
|
}
|
|
- this.$emit('close')
|
|
|
|
- this.$emit('getList')
|
|
|
|
|
|
+ this.$emit("close");
|
|
|
|
+ this.$emit("getList");
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.log(e);
|
|
console.log(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ remoteMethod(query) {
|
|
|
|
+ if (query !== "") {
|
|
|
|
+ this.remoteLoading = true;
|
|
|
|
+ // 发请求搜索
|
|
|
|
+ const url = "/api-web/studentManage/queryStudentList";
|
|
|
|
+ const options = {
|
|
|
|
+ method: "post",
|
|
|
|
+ headers: {
|
|
|
|
+ Authorization: getToken(),
|
|
|
|
+ tenantId: getTenantId(),
|
|
|
|
+ },
|
|
|
|
+ data: {
|
|
|
|
+ rows: 999999,
|
|
|
|
+ search: query,
|
|
|
|
+ },
|
|
|
|
+ url,
|
|
|
|
+ };
|
|
|
|
+ this.remoteLoading = true;
|
|
|
|
+ // this.studentList = []
|
|
|
|
+ axios(options).then((res) => {
|
|
|
|
+ this.remoteLoading = false;
|
|
|
|
+ let result = res.data;
|
|
|
|
+ if (result.code == 200) {
|
|
|
|
+ // Array.prototype.splice.apply(this.studentList, result.data.rows);
|
|
|
|
+ if (result.data.rows && result.data.rows.length > 0) {
|
|
|
|
+ result.data.rows.forEach((item) => {
|
|
|
|
+ this.studentList.unshift(item);
|
|
|
|
+ });
|
|
|
|
+ this.studentList = this.deweight(this.studentList, "userId");
|
|
|
|
+ }
|
|
|
|
+ // this.studentList = this.studentList.concat(result.data.rows);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 制定属性去重
|
|
|
|
+ deweight(arr, key) {
|
|
|
|
+ let res = [];
|
|
|
|
+ arr.forEach((item) => {
|
|
|
|
+ let list = [];
|
|
|
|
+ res.forEach((resitem) => {
|
|
|
|
+ list.push(resitem[key]);
|
|
|
|
+ });
|
|
|
|
+ if (list.indexOf(item[key]) === -1) {
|
|
|
|
+ res.push(item);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return res;
|
|
|
|
+ },
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
|
+ .width100 {
|
|
|
|
+ width: 100%!important;
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|