Przeglądaj źródła

Merge branch 'master' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-fm into test

yusheng 1 rok temu
rodzic
commit
1cdb6da7f2

+ 2 - 2
src/api/doc-manage/index.js

@@ -427,8 +427,8 @@ export async function updateLcyStatus(data) {
   return Promise.reject(new Error(res.data.message));
 }
 // 编码方案
-export async function listCode() {
-  const res = await request.get(`/main/business_code_category/listCode/WD0001`);
+export async function listCode(code) {
+  const res = await request.get(`/main/business_code_category/listCode/${code||'WD0001'}`);
   if (res.data.code == 0) {
     return res.data.data;
   }

+ 23 - 7
src/views/doc/components/browse.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="browse">
+  <div class="browse" v-loading="loading">
     <span class="fullscreen" v-if="fileType == 1" @click="showEditFlag = true">
       <i class="el-icon-full-screen"></i>
       全屏
@@ -10,6 +10,8 @@
       style="height: calc(70vh - 280px); margin-top: 30px"
       frameborder="0"
       allowfullscreen="true"
+      ref="Iframe"
+      v-show="isShow"
     ></iframe>
     <ele-modal
       :visible.sync="showEditFlag"
@@ -38,18 +40,31 @@
       return {
         fileType: 1,
         fileUrl: '',
-        showEditFlag: false
+        showEditFlag: false,
+        loading: false,
+        isShow: false
       };
     },
 
     methods: {
       setFileUrl(row) {
+        this.loading = true;
         this.fileUrl = '';
-        setTimeout(() => {
-          let file = row.storagePath[0];
-          let fileNames = file.storePath.split('/');
-          let url =window.location.origin +'/api/main/file/getFile?objectName=' +file.storePath +'&fullfilename=' +fileNames[fileNames.length - 1];
-          this.fileUrl = '/kkfile/onlinePreview?url=' + btoa(url);
+        this.isShow = false;
+        let file = row.storagePath[0];
+        let fileNames = file.storePath.split('/');
+        let url =
+          window.location.origin +
+          '/api/main/file/getFile?objectName=' +
+          file.storePath +
+          '&fullfilename=' +
+          fileNames[fileNames.length - 1];
+        this.fileUrl = '/kkfile/onlinePreview?url=' + btoa(url);
+        this.$nextTick(() => {
+          this.$refs.Iframe.onload = () => {
+            this.loading = false;
+            this.isShow = true;
+          };
         });
       }
     }
@@ -58,6 +73,7 @@
 <style scoped lang="scss">
   .browse {
     position: relative;
+    min-height: 200px;
     .fullscreen {
       position: absolute;
       top: 10px;

+ 185 - 174
src/views/doc/components/file-edit.vue

@@ -77,6 +77,8 @@
               style="width: 100%"
               v-model="form.directoryId"
               :options="folderList"
+              ref="cascaderRef"
+              @change="cascaderChange"
               :props="{
                 value: 'id',
                 label: 'name',
@@ -141,199 +143,208 @@
 </template>
 
 <script>
-import {
-  fileSaveAPI,
-  fileUpdateAPI,
-  fileGetByIdAPI,
-  fileVersion,
-  listCode
-} from '@/api/doc-manage';
-import FileUpload from '@/components/upload/fileUpload1.vue';
-import { setFolderList } from '../util.js';
-import GetCode from './getCode.vue';
-import doc_template from './template/doc_template.vue';
-import { secretLevelList } from '@/enum/dict';
-import {
-
-  getCode
-} from '@/api/businessCode';
-export default {
-  components: { FileUpload, GetCode, doc_template },
-  props: {
-    // 上级id
-    parentId: [Number, String],
-    lcyStatus: '',
-    fileType: ''
-  },
-  data() {
-    const defaultForm = {
-      name: '', //名称
-      type: '', //类型
-      sizeUnit: '', //大小,
-      unit: '', //单位
-      remark: '', //备注
-      status: '', //状态
-      storagePathId: '',
-      directoryId: '',
-      storagePath: [],
-      id: '',
-      secretLevel: 1
-    };
-    return {
-      rules: {
-        name: [{ required: true, message: '请输入', trigger: 'blur' }],
-        code: [{ required: true, message: '请输入', trigger: 'blur' }],
-        directoryId: [{ required: true, message: '请选择', trigger: 'blur' }],
-        storagePath: [{ required: true, message: '请选择', trigger: 'blur' }]
-      },
-      templateVisible: false,
-      folderList: [],
-      defaultForm,
-      code: '',
-      // 表单数据
-      form: { ...defaultForm },
-
-      // 提交状态
-      loading: false,
-      showEditFlag: false,
-      title: '',
-      type: '',
-      secretLevelList
-    };
-  },
-  computed: {
-    // 是否开启响应式布局
-    styleResponsive() {
-      return this.$store.state.theme.styleResponsive;
-    }
-  },
-  created() {},
-  methods: {
-    async open(type, row, folderList) {
-      this.title = type === 'edit' ? '编辑' : '新增';
-      this.showEditFlag = true;
-      this.type = type;
-      if (type == 'add') {
-        this.form.directoryId = this.parentId;
-        const options = await listCode();
-        if (options.length > 0) {
-          this.success(await getCode(options[0].id))
-          // this.form.code=await getCode(options[0].id)
-        }
-      } else {
-        this.form = await fileGetByIdAPI(row.id);
-        this.form.type = this.form.type + '';
-      }
-      this.folderList = JSON.parse(JSON.stringify(folderList));
-      setFolderList(this.folderList); //权限过滤
-    },
-    getCodeOpen() {
-      this.$refs.getCode.open();
-    },
-    fileChange(file) {
-      console.log(file, 'file');
-      this.form.name = file.name.replace(/\.[^/.]+$/, '');
+  import {
+    fileSaveAPI,
+    fileUpdateAPI,
+    fileGetByIdAPI,
+    fileVersion,
+    listCode
+  } from '@/api/doc-manage';
+  import FileUpload from '@/components/upload/fileUpload1.vue';
+  import { setFolderList } from '../util.js';
+  import GetCode from './getCode.vue';
+  import doc_template from './template/doc_template.vue';
+  import { secretLevelList } from '@/enum/dict';
+  import { getCode } from '@/api/businessCode';
+  export default {
+    components: { FileUpload, GetCode, doc_template },
+    props: {
+      // 上级id
+      parentId: [Number, String],
+      lcyStatus: '',
+      fileType: ''
     },
-    success(code) {
-      this.code = code;
-      this.$nextTick(() => {
-        this.$set(this.form, 'code', code);
-      });
-    },
-    docTemplateOpen() {
-      this.templateVisible = true;
+    data() {
+      const defaultForm = {
+        name: '', //名称
+        type: '', //类型
+        sizeUnit: '', //大小,
+        unit: '', //单位
+        remark: '', //备注
+        status: '', //状态
+        storagePathId: '',
+        directoryId: '',
+        storagePath: [],
+        id: '',
+        secretLevel: 1
+      };
+      return {
+        rules: {
+          name: [{ required: true, message: '请输入', trigger: 'blur' }],
+          code: [{ required: true, message: '请输入', trigger: 'blur' }],
+          directoryId: [{ required: true, message: '请选择', trigger: 'blur' }],
+          storagePath: [{ required: true, message: '请选择', trigger: 'blur' }]
+        },
+        templateVisible: false,
+        folderList: [],
+        defaultForm,
+        code: '',
+        // 表单数据
+        form: { ...defaultForm },
+
+        // 提交状态
+        loading: false,
+        showEditFlag: false,
+        title: '',
+        type: '',
+        secretLevelList,
+        nodeDataCode:''
+      };
     },
-    addTemplate() {
-      const list = this.$refs.tableRef.getTableList();
-      if (list.length == 0 || list.length > 1) {
-        this.$message.error('请选择一个文档模板');
-        return;
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
       }
-      this.form.storagePath = list[0].storagePath;
-      this.form.type = list[0].type + '';
-      this.fileChange(list[0].storagePath[0]);
-      this.templateVisible = false;
     },
-    /* 保存编辑 */
-    save() {
-      let issue_ = false;
-      this.$refs.form.validate(async (valid) => {
-        if (!valid) {
-          return false;
+    created() {},
+    methods: {
+      async open(type, row, folderList) {
+        this.title = type === 'edit' ? '编辑' : '新增';
+        this.showEditFlag = true;
+        this.type = type;
+        this.folderList = JSON.parse(JSON.stringify(folderList));
+        setFolderList(this.folderList); //权限过滤
+        if (type == 'add') {
+          this.form.directoryId = this.parentId;
+          await this.getCode();
+        } else {
+          this.form = await fileGetByIdAPI(row.id);
+          this.form.type = this.form.type + '';
         }
+      },
 
-        const data = {
-          ...this.form,
-          fileType: this.fileType
-        };
-        if (this.type != 'edit') {
-          delete data.id;
-        } else {
-          data.checkOutTime = null;
-          issue_ = await this.issue();
+      getCodeOpen() {
+        this.$refs.getCode.open(this.nodeDataCode);
+      },
+      async getCode() {
+        let nodeData = {};
+        await this.$nextTick(() => {
+          nodeData = this.$refs.cascaderRef.getCheckedNodes();
+        });
+        this.nodeDataCode=nodeData[0]?.data?.code
+        const options = await listCode(nodeData[0]?.data?.code);
+        if (options.length > 0) {
+          this.success(await getCode(options[0].id));
         }
-        data.lcyStatus = this.lcyStatus;
-        // console.log(issue_, 'issue_');
-        // return;
-        this.loading = true;
-        let API = this.type == 'edit' ? fileUpdateAPI : fileSaveAPI;
-        API(data)
-          .then(async (msg) => {
-            this.loading = false;
-            if (issue_) {
-              await fileVersion({ id: data.id });
-            }
-            this.cancel();
-            this.$emit('done');
+      },
+      fileChange(file) {
+        console.log(file, 'file');
+        this.form.name = file.name.replace(/\.[^/.]+$/, '');
+      },
+      cascaderChange() {
+        this.getCode();
+      },
+      success(code) {
+        this.code = code;
+        this.$nextTick(() => {
+          this.$set(this.form, 'code', code);
+        });
+      },
+      docTemplateOpen() {
+        this.templateVisible = true;
+      },
+      addTemplate() {
+        const list = this.$refs.tableRef.getTableList();
+        if (list.length == 0 || list.length > 1) {
+          this.$message.error('请选择一个文档模板');
+          return;
+        }
+        this.form.storagePath = list[0].storagePath;
+        this.form.type = list[0].type + '';
+        this.fileChange(list[0].storagePath[0]);
+        this.templateVisible = false;
+      },
+      /* 保存编辑 */
+      save() {
+        let issue_ = false;
+        this.$refs.form.validate(async (valid) => {
+          if (!valid) {
+            return false;
+          }
+
+          const data = {
+            ...this.form,
+            fileType: this.fileType
+          };
+          if (this.type != 'edit') {
+            delete data.id;
+          } else {
+            data.checkOutTime = null;
+            issue_ = await this.issue();
+          }
+          data.lcyStatus = this.lcyStatus;
+          // console.log(issue_, 'issue_');
+          // return;
+          this.loading = true;
+          let API = this.type == 'edit' ? fileUpdateAPI : fileSaveAPI;
+          API(data)
+            .then(async (msg) => {
+              this.loading = false;
+              if (issue_) {
+                await fileVersion({ id: data.id });
+              }
+              this.cancel();
+              this.$emit('done');
+            })
+            .catch((e) => {
+              this.loading = false;
+            });
+        });
+      },
+      async issue() {
+        return this.$confirm('是否发布新版本', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        })
+          .then(() => {
+            return true;
           })
-          .catch((e) => {
-            this.loading = false;
+          .catch(() => {
+            return false;
           });
-      });
-    },
-    async issue() {
-      return this.$confirm('是否发布新版本', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      })
-        .then(() => {
-          return true;
-        })
-        .catch(() => {
-          return false;
-        });
-    },
-    cancel() {
-      this.form = { ...this.defaultForm };
-      this.$refs.form.clearValidate();
-      this.showEditFlag = false;
+      },
+      cancel() {
+        this.form = { ...this.defaultForm };
+        this.$refs.form.clearValidate();
+        this.showEditFlag = false;
+      }
     }
-  }
-};
+  };
 </script>
 <style scoped lang="scss">
-.aaa {
-  width: 100%;
-
-  ::v-deep .upload-demo {
+  .aaa {
     width: 100%;
 
-    .el-upload--text {
+    ::v-deep .upload-demo {
       width: 100%;
 
-      button {
+      .el-upload--text {
         width: 100%;
-        background: #ffffff;
-        border: 1px solid #dbdbdb;
-        border-radius: 5px;
+
+        button {
+          width: 100%;
+          background: #ffffff;
+          border: 1px solid #dbdbdb;
+          border-radius: 5px;
+        }
       }
-    }
 
-    .el-upload-list {
-      transform: translate(10px, -39px);
-      position: absolute;
+      .el-upload-list {
+        transform: translate(10px, -39px);
+        position: absolute;
+      }
     }
   }
-}
 </style>

+ 5 - 3
src/views/doc/components/getCode.vue

@@ -84,7 +84,7 @@ export default {
         code: '',
         type1: ''
       },
-
+      nodeDataCode:'',
       showEditFlag: false
     };
   },
@@ -99,8 +99,9 @@ export default {
   },
   created() {},
   methods: {
-    async open() {
+    async open(nodeDataCode) {
       this.list = await selectTreeList();
+      this.nodeDataCode=nodeDataCode
       this.setTree(this.list);
       this.showEditFlag = true;
     },
@@ -118,7 +119,8 @@ export default {
       let data = await listParentId({
         pageNum: 1,
         size: 100,
-        parentId: val
+        parentId: val,
+        code:this.nodeDataCode
       });
       this.options = data.list.filter((item) => item.type == 2);
       this.form.type1 = '';