ProfessionalRequirement.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="professional-requirement">
  3. <div class="box-justify part-box part-box-pad">
  4. <div>
  5. <p class="tips-info">
  6. 如果采用线下阅卷,请先导入试卷结构后再按模版导入期末成绩
  7. </p>
  8. </div>
  9. <div>
  10. <el-button v-if="canEdit" type="primary" @click="toAdd"
  11. >新增毕业要求</el-button
  12. >
  13. </div>
  14. </div>
  15. <div class="part-box part-box-pad">
  16. <drag-table
  17. :data="dataList"
  18. :columns="columns"
  19. :drag-enable="canEdit"
  20. @sort-change="sortChange"
  21. >
  22. <template #action="{ row }">
  23. <el-button class="btn-primary" type="text" @click="toEditNode(row)"
  24. >子节点</el-button
  25. >
  26. <el-button class="btn-primary" type="text" @click="toEdit(row)"
  27. >编辑</el-button
  28. >
  29. <el-button
  30. :disabled="!!row.code"
  31. class="btn-danger"
  32. type="text"
  33. @click="toDelete(row)"
  34. >删除</el-button
  35. >
  36. </template>
  37. </drag-table>
  38. </div>
  39. <!-- ModifyRequirement -->
  40. <modify-requirement
  41. v-if="canEdit"
  42. ref="ModifyRequirement"
  43. :instance="curRow"
  44. @modified="getList"
  45. ></modify-requirement>
  46. <!-- ModifyRequirementNode -->
  47. <modify-requirement-node
  48. v-if="canEdit"
  49. ref="ModifyRequirementNode"
  50. :instance="curRow"
  51. @modified="getList"
  52. ></modify-requirement-node>
  53. </div>
  54. </template>
  55. <script>
  56. import {
  57. professionalRequirementListPage,
  58. professionalRequirementRemove,
  59. professionalRequirementSort,
  60. } from "../../api";
  61. import ModifyRequirement from "./ModifyRequirement.vue";
  62. import ModifyRequirementNode from "./ModifyRequirementNode.vue";
  63. import DragTable from "@/components/DragTable.vue";
  64. export default {
  65. name: "professional-requirement",
  66. components: {
  67. ModifyRequirement,
  68. ModifyRequirementNode,
  69. DragTable,
  70. },
  71. props: {
  72. rowData: {
  73. type: Object,
  74. default() {
  75. return {};
  76. },
  77. },
  78. },
  79. data() {
  80. return {
  81. dataList: [],
  82. curRow: {},
  83. columns: [],
  84. canEdit: false,
  85. };
  86. },
  87. created() {
  88. this.canEdit = this.checkPrivilege("link", "canEditRequirement");
  89. this.columns = [
  90. {
  91. label: "序号",
  92. prop: "$index",
  93. width: 60,
  94. },
  95. {
  96. label: "毕业要求",
  97. prop: "name",
  98. },
  99. {
  100. label: "子节点",
  101. prop: "nodeCount",
  102. },
  103. ];
  104. if (this.canEdit) {
  105. this.columns.push({
  106. label: "操作",
  107. prop: "action",
  108. className: "action-column",
  109. width: 160,
  110. });
  111. }
  112. },
  113. mounted() {
  114. this.getList();
  115. },
  116. methods: {
  117. async getList() {
  118. const data = await professionalRequirementListPage({
  119. professionalId: this.rowData.id,
  120. });
  121. this.dataList = data || [];
  122. },
  123. async sortChange(data) {
  124. const res = await professionalRequirementSort(
  125. data.map((item) => {
  126. return { id: item.id, sortNum: item.sortNum };
  127. })
  128. ).catch(() => {});
  129. if (!res) {
  130. await this.getList();
  131. }
  132. },
  133. toAdd() {
  134. this.curRow = { professionalId: this.rowData.id };
  135. this.$refs.ModifyRequirement.open();
  136. },
  137. toEdit(row) {
  138. this.curRow = { ...row, professionalId: this.rowData.id };
  139. this.$refs.ModifyRequirement.open();
  140. },
  141. toEditNode(row) {
  142. this.curRow = { ...row, professionalId: this.rowData.id };
  143. this.$refs.ModifyRequirementNode.open();
  144. },
  145. toDelete(row) {
  146. if (row.code) return;
  147. this.$confirm(`确定要删除毕业要求【${row.name}】吗?`, "提示", {
  148. type: "warning",
  149. })
  150. .then(async () => {
  151. await professionalRequirementRemove(row.id);
  152. this.$message.success("删除成功!");
  153. this.getList();
  154. })
  155. .catch(() => {});
  156. },
  157. },
  158. };
  159. </script>