yusheng 1 سال پیش
والد
کامیت
808918a3f3
3فایلهای تغییر یافته به همراه192 افزوده شده و 179 حذف شده
  1. 2 2
      src/api/doc-manage/index.js
  2. 185 174
      src/views/doc/components/file-edit.vue
  3. 5 3
      src/views/doc/components/getCode.vue

+ 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));
   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) {
   if (res.data.code == 0) {
     return res.data.data;
     return res.data.data;
   }
   }

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

@@ -77,6 +77,8 @@
               style="width: 100%"
               style="width: 100%"
               v-model="form.directoryId"
               v-model="form.directoryId"
               :options="folderList"
               :options="folderList"
+              ref="cascaderRef"
+              @change="cascaderChange"
               :props="{
               :props="{
                 value: 'id',
                 value: 'id',
                 label: 'name',
                 label: 'name',
@@ -141,199 +143,208 @@
 </template>
 </template>
 
 
 <script>
 <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>
 </script>
 <style scoped lang="scss">
 <style scoped lang="scss">
-.aaa {
-  width: 100%;
-
-  ::v-deep .upload-demo {
+  .aaa {
     width: 100%;
     width: 100%;
 
 
-    .el-upload--text {
+    ::v-deep .upload-demo {
       width: 100%;
       width: 100%;
 
 
-      button {
+      .el-upload--text {
         width: 100%;
         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>
 </style>

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

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