zhangjie vor 1 Jahr
Ursprung
Commit
15d6ed0323

+ 15 - 0
src/assets/styles/base.scss

@@ -318,6 +318,21 @@ body {
       padding: 6px 10px;
     }
   }
+
+  // action-column
+  td.action-column {
+    padding-left: 10px;
+    padding-right: 10px;
+    .el-button--text {
+      padding: 0;
+      margin: 0 5px;
+      border: none !important;
+      outline: none !important;
+      &:not(.is-disabled):hover {
+        transform: scale(1.1);
+      }
+    }
+  }
 }
 
 /* list */

+ 4 - 0
src/assets/styles/common-comp.scss

@@ -453,6 +453,10 @@ $--cc-labels-pre: cc-labels;
 
 // drag-table
 .drag-table {
+  th,
+  td {
+    padding: 10px;
+  }
   .after-drop {
     td {
       border-bottom: 2px solid $--color-primary;

+ 17 - 4
src/components/DragTable.vue

@@ -1,12 +1,12 @@
 <template>
-  <table class="table table-tiny drag-table">
+  <table class="table drag-table">
     <colgroup>
-      <col width="20" />
+      <col v-if="dragEnable" width="20" />
       <col v-for="column in columns" :key="column.prop" :width="column.width" />
     </colgroup>
     <thead>
       <tr>
-        <th></th>
+        <th v-if="dragEnable"></th>
         <th v-for="column in columns" :key="column.prop">
           {{ column.label }}
         </th>
@@ -34,13 +34,18 @@
         @dragend.prevent="dragEnd"
       >
         <td
+          v-if="dragEnable"
           class="drag-handle"
           @mousedown.stop="dragHandleMousedown"
           @mouseup.stop="dragHandleMouseup"
         >
           <i class="el-icon-more"></i>
         </td>
-        <td v-for="column in columns" :key="column.prop">
+        <td
+          v-for="column in columns"
+          :key="column.prop"
+          :class="column.className"
+        >
           <slot :name="column.prop" v-bind:row="row">
             {{ row[column.prop] }}
           </slot>
@@ -73,6 +78,10 @@ export default {
       type: String,
       default: "sortNum",
     },
+    dragEnable: {
+      type: Boolean,
+      default: true,
+    },
   },
   data() {
     return {
@@ -116,10 +125,13 @@ export default {
       return this.tableData[pos + offset] || null;
     },
     dragStart(e, row) {
+      if (!this.dragEnable) return;
       this.dragStartPageY = e.pageY;
       this.curDragRow = row;
     },
     dragOver(e) {
+      if (!this.dragEnable) return;
+
       // console.log(e.target);
       this.isDragDown = e.pageY > this.dragStartPageY;
       if (e.target.className.includes("drag-table-tbody")) {
@@ -136,6 +148,7 @@ export default {
       this.curDropRow = this.getSiblingRow(targetKey, 0);
     },
     dragEnd(e) {
+      if (!this.dragEnable) return;
       if (this.curDragRow.id === this.curDropRow.id || !this.curDropRow) return;
       // 往下:target上一个位置
       // 往上:target下一个位置

+ 37 - 23
src/modules/course/components/profession/ProfessionalCourse.vue

@@ -5,27 +5,33 @@
         <p class="tips-info">请根据开设专业选择课程</p>
       </div>
       <div>
-        <el-button type="primary" @click="toAdd">选择课程</el-button>
+        <el-button v-if="canEdit" type="primary" @click="toAdd"
+          >选择课程</el-button
+        >
       </div>
     </div>
 
     <div class="part-box part-box-pad">
-      <drag-table :data="dataList" :columns="columns" @sort-change="sortChange">
+      <drag-table
+        :data="dataList"
+        :columns="columns"
+        :drag-enable="canEdit"
+        @sort-change="sortChange"
+      >
         <template #course="{ row }">
           {{ row.courseName }}({{ row.courseCode }})
         </template>
         <template #action="{ row }">
-          <div class="action-column">
-            <el-button class="btn-danger" type="text" @click="toDelete(row)"
-              >删除</el-button
-            >
-          </div>
+          <el-button class="btn-danger" type="text" @click="toDelete(row)"
+            >删除</el-button
+          >
         </template>
       </drag-table>
     </div>
 
     <!-- AddProfessionalCourse -->
     <add-professional-course
+      v-if="canEdit"
       ref="AddProfessionalCourse"
       :row-data="rowData"
       @modified="getList"
@@ -60,24 +66,32 @@ export default {
   data() {
     return {
       dataList: [],
-      columns: [
-        {
-          label: "序号",
-          prop: "$index",
-          width: 60,
-        },
-        {
-          label: "课程(代码)",
-          prop: "course",
-        },
-        {
-          label: "操作",
-          prop: "action",
-          width: 100,
-        },
-      ],
+      columns: [],
+      canEdit: false,
     };
   },
+  created() {
+    this.canEdit = this.checkPrivilege("link", "canEditCourse");
+    this.columns = [
+      {
+        label: "序号",
+        prop: "$index",
+        width: 60,
+      },
+      {
+        label: "课程(代码)",
+        prop: "course",
+      },
+    ];
+    if (this.canEdit) {
+      this.columns.push({
+        label: "操作",
+        prop: "action",
+        className: "action-column",
+        width: 100,
+      });
+    }
+  },
   mounted() {
     this.getList();
   },

+ 7 - 0
src/modules/course/components/profession/ProfessionalMatrix.vue

@@ -34,6 +34,7 @@
               >
                 <template slot-scope="scope">
                   <el-input-number
+                    v-if="scope.row.canEdit"
                     v-model="scope.row[`${column.name}_${subr}`].value"
                     class="width-50"
                     :min="0"
@@ -45,6 +46,9 @@
                       () => unitChange(scope.row, `${column.name}_${subr}`)
                     "
                   ></el-input-number>
+                  <span v-else>{{
+                    scope.row[`${column.name}_${subr}`].value
+                  }}</span>
                 </template>
               </el-table-column>
             </el-table-column>
@@ -59,6 +63,7 @@
             >
               <template slot-scope="scope">
                 <el-input-number
+                  v-if="scope.row.canEdit"
                   v-model="scope.row[`${column.name}_null`].value"
                   class="width-50"
                   :min="0"
@@ -68,6 +73,7 @@
                   :controls="false"
                   @change="() => unitChange(scope.row, `${column.name}_null`)"
                 ></el-input-number>
+                <span v-else>{{ scope.row[`${column.name}_null`].value }}</span>
               </template>
             </el-table-column>
           </template>
@@ -120,6 +126,7 @@ export default {
         const nitem = {
           courseCode: item.courseCode,
           courseName: item.courseName,
+          canEdit: item.canEdit,
         };
         item.requirements.forEach((requirement) => {
           requirement.subRequirements.forEach((subr) => {

+ 52 - 37
src/modules/course/components/profession/ProfessionalRequirement.vue

@@ -7,40 +7,47 @@
         </p>
       </div>
       <div>
-        <el-button type="primary" @click="toAdd">新增毕业要求</el-button>
+        <el-button v-if="canEdit" type="primary" @click="toAdd"
+          >新增毕业要求</el-button
+        >
       </div>
     </div>
 
     <div class="part-box part-box-pad">
-      <drag-table :data="dataList" :columns="columns" @sort-change="sortChange">
+      <drag-table
+        :data="dataList"
+        :columns="columns"
+        :drag-enable="canEdit"
+        @sort-change="sortChange"
+      >
         <template #action="{ row }">
-          <div class="action-column">
-            <el-button class="btn-primary" type="text" @click="toEditNode(row)"
-              >子节点</el-button
-            >
-            <el-button class="btn-primary" type="text" @click="toEdit(row)"
-              >编辑</el-button
-            >
-            <el-button
-              :disabled="!!row.code"
-              class="btn-danger"
-              type="text"
-              @click="toDelete(row)"
-              >删除</el-button
-            >
-          </div>
+          <el-button class="btn-primary" type="text" @click="toEditNode(row)"
+            >子节点</el-button
+          >
+          <el-button class="btn-primary" type="text" @click="toEdit(row)"
+            >编辑</el-button
+          >
+          <el-button
+            :disabled="!!row.code"
+            class="btn-danger"
+            type="text"
+            @click="toDelete(row)"
+            >删除</el-button
+          >
         </template>
       </drag-table>
     </div>
 
     <!-- ModifyRequirement -->
     <modify-requirement
+      v-if="canEdit"
       ref="ModifyRequirement"
       :instance="curRow"
       @modified="getList"
     ></modify-requirement>
     <!-- ModifyRequirementNode -->
     <modify-requirement-node
+      v-if="canEdit"
       ref="ModifyRequirementNode"
       :instance="curRow"
       @modified="getList"
@@ -78,28 +85,36 @@ export default {
     return {
       dataList: [],
       curRow: {},
-      columns: [
-        {
-          label: "序号",
-          prop: "$index",
-          width: 60,
-        },
-        {
-          label: "毕业要求",
-          prop: "name",
-        },
-        {
-          label: "子节点",
-          prop: "nodeCount",
-        },
-        {
-          label: "操作",
-          prop: "action",
-          width: 160,
-        },
-      ],
+      columns: [],
+      canEdit: false,
     };
   },
+  created() {
+    this.canEdit = this.checkPrivilege("link", "canEditRequirement");
+    this.columns = [
+      {
+        label: "序号",
+        prop: "$index",
+        width: 60,
+      },
+      {
+        label: "毕业要求",
+        prop: "name",
+      },
+      {
+        label: "子节点",
+        prop: "nodeCount",
+      },
+    ];
+    if (this.canEdit) {
+      this.columns.push({
+        label: "操作",
+        prop: "action",
+        className: "action-column",
+        width: 160,
+      });
+    }
+  },
   mounted() {
     this.getList();
   },