resetInfo.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div>
  3. <el-form :model="form" label-width="80px" :inline="true" ref='form'>
  4. <el-form-item label="学员姓名">
  5. <div style="width: 180px">{{ detail.userName }}</div>
  6. </el-form-item>
  7. <el-form-item label="联系电话">
  8. <div>{{ detail.mobileNo }}</div>
  9. </el-form-item>
  10. <br />
  11. <el-form-item prop="subjectId" label="声部" :rules="[{required: true, message: '请选择声部'}]">
  12. <el-select
  13. v-model.trim="form.subjectId"
  14. filterable
  15. clearable
  16. placeholder="请选择声部"
  17. @change="changeSound"
  18. >
  19. <el-option
  20. v-for="(item, i) in soundList"
  21. :key="i"
  22. :label="item.text"
  23. :value="item.value"
  24. ></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item prop="instrumentsId" label="品牌型号" >
  28. <el-select
  29. v-model.trim="form.instrumentsId"
  30. filterable
  31. clearable
  32. placeholder="请选择品牌型号"
  33. >
  34. <el-option
  35. v-for="(item, index) in branchList"
  36. :key="index"
  37. :label="item.name"
  38. :value="item.id"
  39. ></el-option>
  40. </el-select>
  41. </el-form-item>
  42. </el-form>
  43. </div>
  44. </template>
  45. <script>
  46. import { getInstrumentSoundList,updateInstrumentActivity } from "../api";
  47. const soundList = [
  48. { text: "长笛", value: 2 },
  49. { text: "单簧管", value: 4 },
  50. { text: "萨克斯", value: 5 },
  51. { text: "小号", value: 12 },
  52. { text: "圆号", value: 13 },
  53. { text: "长号", value: 14 },
  54. { text: "上低音号", value: 15 },
  55. { text: "大号", value: 17 },
  56. { text: "打击乐", value: 23 },
  57. ];
  58. export default {
  59. props: ["detail"],
  60. data() {
  61. return {
  62. form: {
  63. id:this.detail.id,
  64. subjectId: "",
  65. instrumentsId: "",
  66. },
  67. branchList: [],
  68. soundList
  69. };
  70. },
  71. async mounted() {
  72. await this.$store.dispatch("setSubjects");
  73. this.changeSound(this.detail.subjectId);
  74. this.form.subjectId = this.detail.subjectId;
  75. this.form.instrumentsId = this.detail.instrumentsId;
  76. },
  77. methods: {
  78. async changeSound(val) {
  79. this.form.instrumentsId = "";
  80. if (val) {
  81. try {
  82. const res = await getInstrumentSoundList({
  83. subjectId: val,
  84. page: 1,
  85. rows: 999,
  86. });
  87. this.branchList = res.data.rows.map((item) => {
  88. return {
  89. name: item.brand + item.specification,
  90. id: item.id,
  91. };
  92. });
  93. } catch (e) {
  94. console.log(e);
  95. }
  96. }
  97. },
  98. submited(){
  99. this.$refs.form.validate( async flag=>{
  100. if(flag){
  101. try{
  102. const res = updateInstrumentActivity({...this.form})
  103. this.$message.success('修改成功')
  104. this.$emit('close')
  105. this.$emit('getList')
  106. }catch(e){
  107. console.log(e)
  108. }
  109. }
  110. })
  111. // updateInstrumentActivity
  112. },
  113. },
  114. };
  115. </script>