jingyuanchao 1 rok pred
rodič
commit
737c00436d

+ 75 - 75
src/components/K-FileUpload/index.vue

@@ -1,13 +1,14 @@
 <template>
   <div class="upload-file">
     <el-upload
-    multiple
-    drag
-    v-if="isShowUploadBtn"
-    :action="uploadFileUrl"
-    :before-upload="handleBeforeUpload"
-    :on-error="uploadedSuccessfully"
-    :on-success="handleUploadSuccess"
+      :disabled="disabled"
+      multiple
+      drag
+      v-if="isShowUploadBtn"
+      :action="uploadFileUrl"
+      :before-upload="handleBeforeUpload"
+      :on-error="uploadedSuccessfully"
+      :on-success="handleUploadSuccess"
       :file-list="fileList"
       :limit="limit"
       :accept="accept"
@@ -23,14 +24,16 @@
       <!-- <el-button size="mini" type="primary">{{ btnName }}</el-button> -->
       <!-- 上传提示 -->
       <div class="el-upload__tip" slot="tip" v-if="showTip">
-        文件<template v-if="fileSize">大小不超过<b style="color: #f56c6c">{{ fileSize }}MB</b></template>
+        文件
+        <template v-if="fileSize">大小不超过<b style="color: #f56c6c">{{ fileSize }}MB</b></template>
         <template v-if="fileType"> 格式为<b style="color: #f56c6c">{{ fileType.join("/") }}</b></template>
         的文件
       </div>
     </el-upload>
 
     <!-- 详情页面显示列表 -->
-    <transition-group v-if="!isShowUploadBtn" class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
+    <transition-group v-if="!isShowUploadBtn" class="upload-file-list el-upload-list el-upload-list--text"
+                      name="el-fade-in-linear" tag="ul">
       <li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file) in fileList">
         <el-link :href="file.url.indexOf('http') > -1? file.url: imageUrl(file.url)" :underline="false" target="_blank">
           <span class="el-icon-document"> {{ file.name }} </span>
@@ -41,8 +44,8 @@
 </template>
 
 <script>
-import { getToken } from "@/utils/auth";
-import { upload } from "@/api/system/public";
+import {getToken} from "@/utils/auth";
+import {upload} from "@/api/system/public";
 import {imageUrl} from "@/utils/ruoyi";
 
 export default {
@@ -57,6 +60,10 @@ export default {
       type: Number,
       default: 5,
     },
+    disabled: {
+      type: Boolean,
+      default: false,
+    },
     // 大小限制(MB)
     fileSize: {
       type: Number,
@@ -65,7 +72,7 @@ export default {
     // 文件类型, 例如['png', 'jpg', 'jpeg']
     fileType: {
       type: Array,
-      default: () => ["pdf", "jpg", "png", "bmp","zip","rar","7z"],
+      default: () => ["pdf", "jpg", "png", "bmp", "zip", "rar", "7z"],
     },
     // 是否显示提示
     isShowTip: {
@@ -91,12 +98,12 @@ export default {
         Authorization: "Bearer " + getToken(),
       },
       fileList: [],
-      fileValueList:[],
+      fileValueList: [],
       accept: this.getAcceptByFileType()//".pdf,.jpg,.png,.bmp",
     };
   },
   watch: {
-    defaultValue:{
+    defaultValue: {
       handler(val) {
         if (val) {
           let temp = 1;
@@ -104,8 +111,7 @@ export default {
           // 首先将值转为数组
           const list = Array.isArray(val) ? val : this.value.split(',');
           console.log("watch fileList", list)
-          if(list.length>this.limit)
-          {
+          if (list.length > this.limit) {
             this.handleExceed();
             return;
           }
@@ -116,20 +122,19 @@ export default {
               let itemObj = JSON.parse(item);
               // console.log("watch fileList itemObj", itemObj)
               if ('name' in itemObj && 'url' in itemObj) {
-                item=itemObj
-              }
-              else {
-                item = { name: item, url: item };
+                item = itemObj
+              } else {
+                item = {name: item, url: item};
               }
             }
             item.uid = item.uid || new Date().getTime() + temp++;
             return item;
           });
-          this.fileValueList=[...this.fileList];
+          this.fileValueList = [...this.fileList];
           this.$emit("input", this.listToTagObj(this.fileValueList));
         } else {
           this.fileList = [];
-          this.fileValueList=[];
+          this.fileValueList = [];
           return [];
         }
       },
@@ -152,11 +157,9 @@ export default {
   methods: {
     imageUrl,
 
-    getAcceptByFileType()
-    {
-      if(this.fileType)
-      {
-        let arr= this.fileType.map(x=> "."+x);
+    getAcceptByFileType() {
+      if (this.fileType) {
+        let arr = this.fileType.map(x => "." + x);
         return arr.join(",");
       }
       return "";
@@ -184,10 +187,9 @@ export default {
         }
       }
 
-      if(this.fileList.findIndex(x=>x.name==file.name)>-1)
-      {
+      if (this.fileList.findIndex(x => x.name == file.name) > -1) {
         this.$modal.msgError(`不能上传相同名称的文件或图片!`);
-          return false;
+        return false;
       }
 
       this.$modal.loading("正在上传文件,请稍候...");
@@ -204,32 +206,31 @@ export default {
       this.$modal.closeLoading()
     },
     // 上传成功回调
-    handleUploadSuccess(res, file,fileList) {
+    handleUploadSuccess(res, file, fileList) {
       console.log("handleUploadSuccess", res, file, fileList);
-      this.fileList=fileList;
+      this.fileList = fileList;
       this.$emit("input", this.listToTagObj(this.fileValueList));
     },
     // 删除文件
     handleDelete(item) {
       if (item && item.status === "success") {
-        console.log("handleDelete index",item)
-      //this.fileList.splice(item, 1);
-      // console.log("handleDelete",item,this.fileValueList)
+        console.log("handleDelete index", item)
+        //this.fileList.splice(item, 1);
+        // console.log("handleDelete",item,this.fileValueList)
 
-      let index = this.fileValueList.findIndex(x=>x.name==item.name);
-      // console.log("handleDelete",index,this.fileValueList)
-      if(index>-1)
-      {
-        this.fileValueList.splice(index, 1);
+        let index = this.fileValueList.findIndex(x => x.name == item.name);
+        // console.log("handleDelete",index,this.fileValueList)
+        if (index > -1) {
+          this.fileValueList.splice(index, 1);
+        }
+        //this.fileValueList.splice(item, 1);
+        console.log("handleDelete deleted", this.fileValueList)
+        this.fileList = this.listToTagObj(this.fileValueList);
+        this.$emit("input", this.listToTagObj(this.fileValueList));
       }
-      //this.fileValueList.splice(item, 1);
-      console.log("handleDelete deleted",this.fileValueList)
-      this.fileList = this.listToTagObj(this.fileValueList);
-      this.$emit("input", this.listToTagObj(this.fileValueList));
-    }
     },
     // 上传失败结束处理 必须调用,否则失败文件也会显示
-    uploadedSuccessfully(err,file,fileList) {
+    uploadedSuccessfully(err, file, fileList) {
     },
     // 获取文件名称
     getFileName(name) {
@@ -250,14 +251,14 @@ export default {
     uploadFile(fileObj) {
       let formData = new FormData();
       formData.append('file', fileObj.file);
-      console.log("this.fileValueList.length",this.fileValueList.length)
-      if (this.fileValueList.length<=this.limit){
+      console.log("this.fileValueList.length", this.fileValueList.length)
+      if (this.fileValueList.length <= this.limit) {
         upload(formData).then(res => {
           /*上传成功*/
           this.$modal.closeLoading();
           //let imgUrl = process.env.VUE_APP_BASE_API + res.data.url;
           let arr = [];
-          arr.push({ name: res.data.realName, url: res.data.url });
+          arr.push({name: res.data.realName, url: res.data.url});
           this.fileValueList = this.fileValueList.concat(arr);
           this.$modal.msgSuccess("上传成功!");
           fileObj.onSuccess();
@@ -281,40 +282,39 @@ export default {
     },
 
     listToTagObj(list) {
-      let tempArry=[];
+      let tempArry = [];
       for (let i in list) {
         // console.log("listToString2 i",i);
-        tempArry.push(JSON.stringify( {url:list[i].url,name:list[i].name}));
+        tempArry.push(JSON.stringify({url: list[i].url, name: list[i].name}));
       }
-      console.log("listToString2",tempArry);
+      console.log("listToString2", tempArry);
       return tempArry;
     },
     onPreview(file) {
-        console.log(file);
-        var name = file.name;
-        let index = this.fileValueList.findIndex(x=>x.name==file.name);
-        this.fileValueList[index]
-        var url = this.fileValueList[index].url;
-        if(process.env.VUE_APP_BASE_API!=='/')
-        {
-          url=process.env.VUE_APP_BASE_API+this.fileValueList[index].url;
-        }
-        // console.log("process.env.VUE_APP_BASE_API",process.env.VUE_APP_BASE_API,process)
+      console.log(file);
+      var name = file.name;
+      let index = this.fileValueList.findIndex(x => x.name == file.name);
+      this.fileValueList[index]
+      var url = this.fileValueList[index].url;
+      if (process.env.VUE_APP_BASE_API !== '/') {
+        url = process.env.VUE_APP_BASE_API + this.fileValueList[index].url;
+      }
+      // console.log("process.env.VUE_APP_BASE_API",process.env.VUE_APP_BASE_API,process)
 
-        // console.log("process.env.VUE_APP_BASE_API url",url)
-        const a = document.createElement("a");
-        a.setAttribute("download", name);
-        a.setAttribute("target", "_blank");
-        a.setAttribute("href", url);
-        a.click();
-      },
-      clearFiles(){
-        if(this.$refs["fileUpload"])
-          this.$refs["fileUpload"].clearFiles();
+      // console.log("process.env.VUE_APP_BASE_API url",url)
+      const a = document.createElement("a");
+      a.setAttribute("download", name);
+      a.setAttribute("target", "_blank");
+      a.setAttribute("href", url);
+      a.click();
+    },
+    clearFiles() {
+      if (this.$refs["fileUpload"])
+        this.$refs["fileUpload"].clearFiles();
 
-        this.fileList = [];
-        this.fileValueList = [];
-      },
+      this.fileList = [];
+      this.fileValueList = [];
+    },
   }
 };
 </script>

+ 12 - 4
src/components/common/textarea.vue

@@ -5,13 +5,15 @@
       :rows="row"
       v-model="pv"
       :maxlength="length"
+      :disabled="disabled"
       :placeholder="placeholder"
     ></el-input>
-    <div class="k-textarea__length">{{pv ? pv.length : 0}} / {{length}}</div>
+    <div class="k-textarea__length">{{ pv ? pv.length : 0 }} / {{ length }}</div>
   </div>
 </template>
 <script>
 import sync from "../utils/computed.sync";
+
 export default {
   data() {
     return {};
@@ -22,20 +24,26 @@ export default {
   watch: {},
   props: {
     value: {},
-    row:{
-      type:Number,
+    disabled: {
+      type: Boolean,
+      default: false,
+    },
+    row: {
+      type: Number,
       default: 5,
     },
     length: {},
     placeholder: {}
   },
   methods: {},
-  mounted() {}
+  mounted() {
+  }
 };
 </script>
 <style lang="scss">
 .k-textarea {
   position: relative;
+
   &__length {
     position: absolute;
     bottom: 0;

+ 3 - 7
src/directive/permission/hasPermi.js

@@ -7,11 +7,11 @@ import store from "@/store";
 
 export default {
   inserted(el, binding, vnode) {
-   
+
     const { value } = binding;
     const all_permission = "*:*:*";
     const permissions = store.getters && store.getters.permissions;
-    
+
     if (value && value instanceof Array && value.length > 0) {
       const permissionFlag = value;
 
@@ -20,15 +20,11 @@ export default {
           all_permission === permission || permissionFlag.includes(permission)
         );
       });
-      console.log(el, binding,'vnode')
-      console.log(hasPermissions,'hasPermissions');
-      
       if (!hasPermissions) {
-        //console.log(el.parentNode,'el')
         el.parentNode && el.parentNode.removeChild(el);
       }
     } else {
       throw new Error(`请设置操作权限标签值`);
     }
   },
-};
+};

+ 31 - 9
src/views/core/drill/plan/index.vue

@@ -301,6 +301,7 @@
                 v-model="form.planCycle"
                 placeholder="请选择任务周期"
                 style="width: 100%"
+                :disabled="tableDisable()"
               >
                 <el-option
                   v-for="dict in dict.type.drill_plan_cycle"
@@ -315,6 +316,7 @@
             <el-form-item label="任务次数" prop="execTimes">
               <template>
                 <el-input-number
+                  :disabled="tableDisable()"
                   style="width: 100%"
                   v-model="form.execTimes"
                   :min="1"
@@ -328,6 +330,7 @@
           <el-col :span="12" v-show="form.planCycle == 0">
             <el-form-item prop="startDate" label="开始日期">
               <el-date-picker
+                :disabled="tableDisable()"
                 style="width: 100%"
                 v-model="form.startDate"
                 @change="startDateChanged"
@@ -342,6 +345,7 @@
           <el-col :span="12" v-show="form.planCycle == 0">
             <el-form-item prop="endDate" label="结束日期">
               <el-date-picker
+                :disabled="tableDisable()"
                 style="width: 100%"
                 v-model="form.endDate"
                 :picker-options="endDatepickerOptions"
@@ -391,6 +395,7 @@
           <el-col :span="12">
             <el-form-item label="机构类型" prop="execOrgType">
               <el-select
+                :disabled="tableDisable()"
                 style="width: 100%"
                 v-model="form.execOrgType"
                 placeholder="请选择机构类型"
@@ -432,6 +437,7 @@
               prop="planExecOrgIdList"
             >
               <org-tree-select
+                :disabled="tableDisable()"
                 v-model="form.planExecOrgIdList"
                 :queryData="form.execOrgType"
                 ref="orgTreeSelect"
@@ -445,7 +451,7 @@
         <el-row>
           <el-col :span="24">
             <el-form-item label="备注" prop="remark">
-              <el-input v-model="form.remark" placeholder="请输入备注"/>
+              <el-input v-model="form.remark" placeholder="请输入备注"  :disabled="tableDisable()"/>
             </el-form-item>
           </el-col>
         </el-row>
@@ -453,6 +459,7 @@
           <el-col :span="12">
             <el-form-item label="上传文件" prop="fileList">
               <K-file-upload
+                :disabled="tableDisable()"
                 ref="upload"
                 :defaultValue="formFileListDefualtValue"
                 v-model="form.fileList"
@@ -660,10 +667,9 @@ export default {
     },
     //所属机构为当前用户登录机构时才显示 “编辑、删除”按钮
     checkCanEdit(row) {
-      // console.log("checkCanEdit",this.$store.getters.orgId,row.belongOrgId)
+       console.log("checkCanEdit",this.$store.getters.orgId,row.belongOrgId)
       return (
-        row.belongOrgId == this.$store.getters.orgId ||
-        row.createOrgId == this.$store.getters.orgId
+        row.belongOrgId == this.$store.getters.orgId
       );
     },
     checkCanDel(row) {
@@ -954,12 +960,25 @@ export default {
     handleRevocation(row) {
       if (row.id != null) {
         let msg = "";
-        if (row.done == 1) {
-          msg =
-            "因存在已完成任务,撤回后下周期起将不再生成任务";
+        //无周期
+        if (row.planCycle == 0) {
+          if (row.done == 1) {
+            msg = '因存在已完成任务,无周期任务不允许撤回,如需删除下发任务请点击"删除"';
+            this.$alert(msg,'系统提示',{
+              confirmButtonText:"确认"
+            })
+            return
+          } else {
+            msg = "因存在不已完成任务,撤回后将删除所有生成任务";
+          }
         } else {
-          msg =
-            "因存在不已完成任务,撤回后将删除所有生成任务";
+          //有周期
+          if (row.done == 1) {
+            msg =
+              "因存在已完成任务,撤回后下周期起将不再生成任务";
+          } else {
+            msg = "因存在不已完成任务,撤回后将删除所有生成任务";
+          }
         }
         this.$modal
           .confirm(msg)
@@ -984,6 +1003,9 @@ export default {
         `plan_${new Date().getTime()}.xlsx`
       );
     },
+    tableDisable(){
+      return this.form.planStatus==1;
+    },
     // showSelectFile() {
     //   this.$refs["DialogSelectFile"].show();
     // },

+ 33 - 10
src/views/core/edu/plan/index.vue

@@ -354,8 +354,10 @@
                 style="width: 100%"
                 v-model="form.planCycle"
                 placeholder="请选择任务周期"
+                :disabled="tableDisable()"
               >
                 <el-option
+
                   v-for="dict in dict.type.edu_plan_cycle"
                   :key="dict.value"
                   :label="dict.label"
@@ -368,6 +370,7 @@
             <el-form-item label="任务次数" prop="execTimes">
               <template>
                 <el-input-number
+                  :disabled="tableDisable()"
                   style="width: 100%"
                   v-model="form.execTimes"
                   :min="1"
@@ -389,6 +392,7 @@
           <el-col :span="12" v-show="form.planCycle == 0">
             <el-form-item prop="startDate" label="开始日期">
               <el-date-picker
+                :disabled="tableDisable()"
                 style="width: 100%"
                 v-model="form.startDate"
                 @change="startDateChanged"
@@ -403,6 +407,7 @@
           <el-col :span="12" v-show="form.planCycle == 0">
             <el-form-item prop="endDate" label="结束日期">
               <el-date-picker
+                :disabled="tableDisable()"
                 style="width: 100%"
                 v-model="form.endDate"
                 :picker-options="endDatepickerOptions"
@@ -435,6 +440,7 @@
                 v-model="form.execOrgType"
                 placeholder="请选择受训机构类型"
                 @change="execOrgTypeChanged()"
+                :disabled="tableDisable()"
               >
                 <el-option
                   v-for="dict in getUserOrgType"
@@ -465,7 +471,7 @@
                 :queryData="form.execOrgType"
                 ref="orgTreeSelect"
                 :enabledCheckOrgTypes="form.execOrgType"
-                :disable="true"
+                :disabled="tableDisable()"
               >
               </org-tree-select>
             </el-form-item>
@@ -481,6 +487,7 @@
                 type="textarea"
                 show-word-limit
                 placeholder="请输入备注"
+                :disabled="tableDisable()"
               />
             </el-form-item>
           </el-col>
@@ -489,6 +496,7 @@
           <el-col :span="12">
             <el-form-item label="上传文件" prop="fileList">
               <K-file-upload
+                :disabled="tableDisable()"
                 ref="upload"
                 :defaultValue="formFileListDefualtValue"
                 v-model="form.fileList"
@@ -497,7 +505,7 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="">
-              <el-button type="primary" @click="showSelectFile"
+              <el-button type="primary" @click="showSelectFile"  v-if="!tableDisable()"
               >选取知识库文件
               </el-button
               >
@@ -678,7 +686,6 @@ export default {
     },
     /** 查询教育培训计划列表 */
     getList() {
-      console.log("12312312312312")
       this.loading = true;
       listPlan(this.queryParams).then((response) => {
         this.planList = response.rows;
@@ -716,6 +723,9 @@ export default {
       }
       return time.getTime() < new Date(startDate).getTime();
     },
+    tableDisable(){
+      return this.form.planStatus==1;
+    },
 
     checkCanPublish(row) {
       //是标准计划且未下发,状态为草稿或停用,且所属机构为当前用户登录机构时才显示 “下发”按钮
@@ -736,8 +746,7 @@ export default {
     //所属机构为当前用户登录机构或等于创建机构时才显示 “编辑、删除”按钮
     checkCanEdit(row) {
       return (
-        row.belongOrgId == this.$store.getters.orgId ||
-        row.createOrgId == this.$store.getters.orgId
+        row.belongOrgId == this.$store.getters.orgId
       );
     },
     checkCanDel(row) {
@@ -1036,13 +1045,27 @@ export default {
     //撤回计划
     handleRevocation(row) {
       let msg = "";
-      if (row.done == 1) {
-        msg =
-          "因存在已完成任务,撤回后下周期起将不再生成任务";
+      //无周期
+      if (row.planCycle == 0) {
+        if (row.done == 1) {
+          msg = '因存在已完成任务,无周期任务不允许撤回,如需删除下发任务请点击"删除"';
+          this.$alert(msg,'系统提示',{
+            confirmButtonText:"确认"
+          })
+          return
+        } else {
+          msg = "因存在不已完成任务,撤回后将删除所有生成任务";
+        }
       } else {
-        msg =
-          "因存在不已完成任务,撤回后将删除所有生成任务";
+        //有周期
+        if (row.done == 1) {
+          msg =
+            "因存在已完成任务,撤回后下周期起将不再生成任务";
+        } else {
+          msg = "因存在不已完成任务,撤回后将删除所有生成任务";
+        }
       }
+
       this.$modal
         .confirm(msg, "提示")
         .then(() => {