auditionForm.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div>
  3. <el-form :model="auditionForm" ref="auditionForm" >
  4. <el-form-item
  5. label="分部"
  6. prop="organId"
  7. :label-width="formLabelWidth"
  8. :rules="[{ required: true, message: '请选择分部', trigger: 'blur' }]"
  9. >
  10. <el-select
  11. style="width: 100% !important"
  12. class="multiple"
  13. v-model.trim="auditionForm.organId"
  14. filterable
  15. clearable
  16. placeholder="请选择分部"
  17. >
  18. <el-option
  19. v-for="(item, index) in organList"
  20. :key="index"
  21. :label="item.name"
  22. :value="item.id"
  23. ></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item
  27. label="课程时长"
  28. prop="courseType"
  29. :label-width="formLabelWidth"
  30. :rules="[
  31. { required: true, message: '请选择课程时长', trigger: 'blur' },
  32. ]"
  33. >
  34. <el-select
  35. style="width: 100% !important"
  36. class="multiple"
  37. v-model.trim="auditionForm.courseType"
  38. filterable
  39. clearable
  40. placeholder="课程时长"
  41. >
  42. <el-option
  43. v-for="(item, index) in courseType"
  44. :key="index"
  45. :label="item.label"
  46. :value="item.value"
  47. ></el-option>
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item
  51. label="课程单价"
  52. prop="courseType"
  53. :label-width="formLabelWidth"
  54. :rules="[
  55. { required: true, message: '请选择课程单价', trigger: 'blur' },
  56. ]"
  57. >
  58. <el-input clearable placeholder="课程单价" type="number" v-model="courseType" maxlength="9" />
  59. </el-form-item>
  60. </el-form>
  61. </div>
  62. </template>
  63. <script>
  64. import { resetOrganizationCourseDurationSettings,addOrganizationCourseDurationSettings } from "@/api/specialSetting";
  65. export default {
  66. props: ["activeRow", "organList", "courseType"],
  67. data() {
  68. return {
  69. auditionForm: {
  70. organId: "",
  71. courseType: "",
  72. timer: [],
  73. id: "",
  74. },
  75. inputVisible: false,
  76. formLabelWidth: "80px",
  77. dynamicTags: [],
  78. inputValue: "",
  79. };
  80. },
  81. mounted() {
  82. if (this.activeRow) {
  83. this.auditionForm.organId = this.activeRow.organId;
  84. this.auditionForm.timer = this.activeRow.duration.split(",");
  85. this.dynamicTags = this.activeRow.duration.split(",");
  86. this.auditionForm.courseType = this.activeRow.courseType;
  87. this.auditionForm.id = this.activeRow.id;
  88. }
  89. },
  90. methods: {
  91. async submitInfo(str) {
  92. console.log(str);
  93. this.$refs.auditionForm.validate(async (_) => {
  94. if (_) {
  95. if (str == "update") {
  96. try {
  97. const res = await resetOrganizationCourseDurationSettings({
  98. organId: this.auditionForm.organId,
  99. duration: this.dynamicTags.join(","),
  100. courseType: this.auditionForm.courseType,
  101. id: this.auditionForm.id,
  102. });
  103. this.$message.success("修改成功");
  104. this.$emit('close')
  105. } catch {}
  106. }else if(str == "create"){
  107. try {
  108. const res = await addOrganizationCourseDurationSettings({
  109. organId: this.auditionForm.organId,
  110. duration: this.dynamicTags.join(","),
  111. courseType: this.auditionForm.courseType,
  112. });
  113. this.$message.success("新建成功");
  114. this.$emit('close')
  115. } catch {}
  116. }
  117. }
  118. });
  119. },
  120. },
  121. watch: {
  122. dynamicTags(val) {
  123. this.auditionForm.timer = val;
  124. },
  125. },
  126. };
  127. </script>
  128. <style lang="scss" scoped>
  129. .courseMask {
  130. .el-tag.el-tag--info {
  131. margin-right: 4px;
  132. }
  133. }
  134. </style>