ProfessionalMatrix.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="professional-matrix">
  3. <div class="box-justify part-box part-box-pad">
  4. <div>
  5. <p class="tips-info">{{ rowData.name }}毕业要求支撑矩阵管理</p>
  6. </div>
  7. <div>
  8. <el-button type="success" :loading="loading" @click="toDownload"
  9. >下载</el-button
  10. >
  11. </div>
  12. </div>
  13. <div class="part-box part-box-pad">
  14. <el-table :data="dataList" border>
  15. <el-table-column label="课程名称" min-width="200" fixed="left">
  16. <template slot-scope="scope">
  17. {{ scope.row.courseName }}
  18. </template>
  19. </el-table-column>
  20. <el-table-column label="毕业要求" align="center">
  21. <el-table-column
  22. v-for="(column, cindex) in columns"
  23. :key="cindex"
  24. :label="column.name"
  25. align="center"
  26. >
  27. <template v-if="hasSubRequirements">
  28. <el-table-column
  29. v-for="subr in column.subRequirements"
  30. :key="subr"
  31. :label="subr === 'null' ? '' : subr"
  32. align="center"
  33. >
  34. <template slot-scope="scope">
  35. <el-input-number
  36. v-model="scope.row[`${column.name}_${subr}`].value"
  37. class="width-50"
  38. :min="0"
  39. :max="1"
  40. :step="0.01"
  41. step-strictly
  42. :controls="false"
  43. @change="
  44. (val) =>
  45. unitChange(scope.row[`${column.name}_${subr}`].id, val)
  46. "
  47. ></el-input-number>
  48. </template>
  49. </el-table-column>
  50. </template>
  51. <template v-else>
  52. <template slot-scope="scope">
  53. <el-input-number
  54. v-model="scope.row[`${column.name}_null`].value"
  55. class="width-50"
  56. :min="0"
  57. :max="1"
  58. :step="0.01"
  59. step-strictly
  60. :controls="false"
  61. @change="
  62. (val) =>
  63. unitChange(scope.row[`${column.name}_null`].id, val)
  64. "
  65. ></el-input-number>
  66. </template>
  67. </template>
  68. </el-table-column>
  69. </el-table-column>
  70. </el-table>
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. import {
  76. professionalMatrixDetail,
  77. professionalMatrixSave,
  78. professionalMatrixDownload,
  79. } from "../../api";
  80. import { downloadByApi } from "@/plugins/download";
  81. export default {
  82. name: "professional-matrix",
  83. props: {
  84. rowData: {
  85. type: Object,
  86. default() {
  87. return {};
  88. },
  89. },
  90. },
  91. data() {
  92. return {
  93. dataList: [],
  94. columns: [],
  95. hasSubRequirements: false,
  96. loading: false,
  97. };
  98. },
  99. mounted() {
  100. this.getList();
  101. },
  102. methods: {
  103. async getList() {
  104. const res = await professionalMatrixDetail({
  105. professionalId: this.rowData.id,
  106. });
  107. const tableData = res || [];
  108. this.dataList = tableData.map((item, index) => {
  109. if (!index) this.parseColumns(item.requirements);
  110. const nitem = {
  111. courseCode: item.courseCode,
  112. courseName: item.courseName,
  113. };
  114. item.requirements.forEach((requirement) => {
  115. requirement.subRequirements.forEach((subr) => {
  116. nitem[`${requirement.name}_${subr.name + ""}`] = {
  117. id: subr.id,
  118. value: subr.content || undefined,
  119. };
  120. });
  121. });
  122. return nitem;
  123. });
  124. },
  125. parseColumns(requirements) {
  126. this.hasSubRequirements = requirements.some(
  127. (item) => item.subRequirements[0].name !== null
  128. );
  129. if (!this.hasSubRequirements) {
  130. this.columns = requirements.map((item) => {
  131. return { name: item.name };
  132. });
  133. return;
  134. }
  135. this.columns = requirements.map((item) => {
  136. return {
  137. name: item.name,
  138. subRequirements: item.subRequirements.map((subr) => subr.name + ""),
  139. };
  140. });
  141. },
  142. async unitChange(id, val) {
  143. await professionalMatrixSave({
  144. id,
  145. content: val,
  146. });
  147. },
  148. async toDownload(row) {
  149. if (this.loading) return;
  150. this.loading = true;
  151. const res = await downloadByApi(() => {
  152. return professionalMatrixDownload(this.rowData.id);
  153. }, "").catch((e) => {
  154. this.$message.error(e || "下载失败,请重新尝试!");
  155. });
  156. this.loading = false;
  157. if (!res) return;
  158. this.$message.success("下载成功!");
  159. },
  160. },
  161. };
  162. </script>