CourseWeightManage.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="course-weight-manage">
  3. <div class="part-box part-box-pad">
  4. <p>说明:</p>
  5. <p>
  6. 1.请在课程目标考核对应的评价方式表格中打√,并录入权重占比及目标分值;
  7. </p>
  8. <p>2.所有课程目标的总目标分值等于100分;</p>
  9. <p>3.各课程目标下评价方式的总权重应等于100%;</p>
  10. <p>4.目标整体权重应等于100%,用于计算课程整体达成度。</p>
  11. </div>
  12. <div class="part-box part-box-pad">
  13. <el-table :data="tableSetData">
  14. <el-table-column
  15. prop="evaluationName"
  16. label="评价方式"
  17. width="140"
  18. fixed="left"
  19. ></el-table-column>
  20. <el-table-column v-for="(target, tindex) in dataList" :key="tindex">
  21. <template slot="header">
  22. <el-row type="flex" align="middle">
  23. <el-col :span="10" :offset="2">
  24. {{ target.courseTargetName }}
  25. </el-col>
  26. <el-col :span="12">
  27. <span style="margin-right: 5px">目标整体权重</span>
  28. <el-input-number
  29. v-model="targetTotalWeight[target.courseTargetId]"
  30. class="width-50"
  31. size="small"
  32. :min="0"
  33. :max="100"
  34. :step="1"
  35. step-strictly
  36. :controls="false"
  37. >
  38. </el-input-number>
  39. <span style="margin-left: 5px">%</span>
  40. </el-col>
  41. </el-row>
  42. </template>
  43. <el-table-column min-width="340">
  44. <template slot="header">
  45. <el-row>
  46. <el-col :span="10" :offset="2"> 权重 </el-col>
  47. <el-col :span="12"> 目标分值 </el-col>
  48. </el-row>
  49. </template>
  50. <template slot-scope="scope">
  51. <el-row type="flex" align="middle">
  52. <el-col :span="2">
  53. <el-checkbox
  54. v-model="scope.row.targets[tindex].used"
  55. @change="usedChange(scope.$index, tindex)"
  56. ></el-checkbox>
  57. </el-col>
  58. <el-col :span="10">
  59. <el-input-number
  60. v-model="scope.row.targets[tindex].weight"
  61. :disabled="!scope.row.targets[tindex].used"
  62. class="width-80"
  63. size="small"
  64. :min="0"
  65. :max="100"
  66. :step="1"
  67. step-strictly
  68. :controls="false"
  69. >
  70. </el-input-number>
  71. <span style="margin-left: 5px">%</span>
  72. </el-col>
  73. <el-col :span="12">
  74. <el-input-number
  75. v-model="scope.row.targets[tindex].targetScore"
  76. :disabled="!scope.row.targets[tindex].used"
  77. class="width-80"
  78. size="small"
  79. :min="0"
  80. :max="1000"
  81. :step="1"
  82. step-strictly
  83. :controls="false"
  84. >
  85. </el-input-number>
  86. </el-col>
  87. </el-row>
  88. </template>
  89. </el-table-column>
  90. </el-table-column>
  91. </el-table>
  92. <div class="text-center" style="margin: 20px 0">
  93. <el-button type="primary" :loading="loading" @click="submit"
  94. >保存</el-button
  95. >
  96. </div>
  97. <el-table
  98. :data="dataList"
  99. :header-cell-style="{ textAlign: 'center' }"
  100. :cell-style="{ textAlign: 'center' }"
  101. >
  102. <el-table-column
  103. prop="courseTargetName"
  104. label="课程目标"
  105. width="140"
  106. ></el-table-column>
  107. <el-table-column
  108. prop="degreeRequirement"
  109. label="支撑毕业要求"
  110. min-width="200"
  111. ></el-table-column>
  112. <el-table-column prop="totalWeight" label="目标整体权重" width="110">
  113. <template slot-scope="scope">{{ scope.row.totalWeight }}%</template>
  114. </el-table-column>
  115. <el-table-column label="考核/评价环节及目标分值">
  116. <el-table-column
  117. v-for="(ename, eindex) in evaluationData"
  118. :key="ename"
  119. :label="ename"
  120. >
  121. <template slot-scope="scope">
  122. {{
  123. scope.row.evaluation[eindex].used
  124. ? scope.row.evaluation[eindex].targetScore
  125. : ""
  126. }}
  127. </template>
  128. </el-table-column>
  129. </el-table-column>
  130. <el-table-column label="目标分值统计" width="120">
  131. <template slot-scope="scope">
  132. {{ getEvaluationSumScore(scope.row.evaluation) }}
  133. </template>
  134. </el-table-column>
  135. </el-table>
  136. </div>
  137. </div>
  138. </template>
  139. <script>
  140. import { courseWeightDetail, courseWeightSave } from "../../api";
  141. import { weightList } from "./targetData";
  142. import { omit, pick } from "lodash";
  143. import { calcSum } from "@/plugins/utils";
  144. export default {
  145. name: "course-weight-manage",
  146. props: {
  147. course: {
  148. type: Object,
  149. default() {
  150. return {};
  151. },
  152. },
  153. },
  154. data() {
  155. return {
  156. dataList: [],
  157. tableSetData: [],
  158. targetTotalWeight: {},
  159. evaluationData: [],
  160. loading: false,
  161. };
  162. },
  163. mounted() {
  164. // this.getList();
  165. this.dataList = weightList;
  166. this.transformData(this.dataList);
  167. },
  168. methods: {
  169. async getList() {
  170. const res = await courseWeightDetail(this.course.courseCode);
  171. this.dataList = res.submitForm || [];
  172. this.transformData(this.dataList);
  173. },
  174. transformData(data) {
  175. if (!data || !data.length) return [];
  176. const evaluationList = [];
  177. const evaluationMap = {};
  178. const targetTotalWeight = {};
  179. data[0].evaluation.forEach((item, index) => {
  180. evaluationMap[item.evaluationName] = index;
  181. });
  182. this.evaluationData = data[0].evaluation.map(
  183. (item) => item.evaluationName
  184. );
  185. data.forEach((target) => {
  186. targetTotalWeight[target.courseTargetId] = target.totalWeight;
  187. const targetData = {
  188. ...omit(target, ["evaluation"]),
  189. totalWeight: target.totalWeight || undefined,
  190. };
  191. target.evaluation.forEach((item) => {
  192. const index = evaluationMap[item.evaluationName];
  193. if (!evaluationList[index]) {
  194. evaluationList[index] = {
  195. evaluationName: item.evaluationName,
  196. targets: [],
  197. };
  198. }
  199. evaluationList[index].targets.push({
  200. ...targetData,
  201. used: item.used,
  202. weight: item.weight || undefined,
  203. targetScore: item.targetScore || undefined,
  204. });
  205. });
  206. });
  207. this.targetTotalWeight = targetTotalWeight;
  208. this.tableSetData = evaluationList;
  209. },
  210. usedChange(rowIndex, tindex) {
  211. const target = this.tableSetData[rowIndex].targets[tindex];
  212. if (!target.used) {
  213. target.weight = undefined;
  214. target.targetScore = undefined;
  215. }
  216. },
  217. getEvaluationSumScore(evaluation) {
  218. return calcSum(
  219. evaluation.map((item) => (item.used ? item.targetScore : 0))
  220. );
  221. },
  222. updateDataList() {
  223. const evaluationData = {};
  224. this.tableSetData.forEach((item) => {
  225. item.targets.forEach((elem) => {
  226. const key = `${item.evaluationName}_${elem.courseTargetId}`;
  227. evaluationData[key] = pick(elem, ["used", "weight", "targetScore"]);
  228. });
  229. });
  230. this.dataList.forEach((target) => {
  231. target.totalWeight = this.targetTotalWeight[target.courseTargetId];
  232. target.evaluation.forEach((item) => {
  233. const key = `${item.evaluationName}_${target.courseTargetId}`;
  234. Object.assign(item, evaluationData[key]);
  235. });
  236. });
  237. },
  238. checkDataList() {
  239. if (!this.dataList.length) return;
  240. // TODO:
  241. return true;
  242. },
  243. async submit() {
  244. if (this.loading) return;
  245. this.updateDataList();
  246. if (!this.checkDataList()) return;
  247. this.loading = true;
  248. const res = await courseWeightSave({
  249. courseCode: this.course.courseCode,
  250. submitForm: this.dataList,
  251. }).catch(() => {});
  252. this.loading = false;
  253. if (!res) return;
  254. this.$message.success("保存成功!");
  255. },
  256. },
  257. };
  258. </script>