瀏覽代碼

基础信息修改

duy 2 月之前
父節點
當前提交
fa2d2f6da3
共有 3 個文件被更改,包括 56 次插入20 次删除
  1. 5 1
      src/api/ruleManage/fileRule.js
  2. 2 0
      src/views/codeRule/ConditionsSet.vue
  3. 49 19
      src/views/codeRule/ruleManage.vue

+ 5 - 1
src/api/ruleManage/fileRule.js

@@ -20,7 +20,11 @@ export const add = (data) => {
     return request({
         url: '/api/blade-business/PrivateStandard/add',
         method: 'post',
-        data
+    
+        data,
+         headers: {
+        'Content-Type': 'multipart/form-data'
+        },
     });
 }
 export const edit = (data) => {

+ 2 - 0
src/views/codeRule/ConditionsSet.vue

@@ -365,6 +365,8 @@ export default {
     },
           //保存条件
       saveCondition() {
+        console.log(this.paramList,'this.paramList');
+        
       let resArr = this.paramList.map(item => {
         // 收集所有 codeValue 的 value,不需要额外的数组包装
         const rightIds = item.codeList.reduce((acc, codeItem) => {

+ 49 - 19
src/views/codeRule/ruleManage.vue

@@ -362,7 +362,7 @@
             <el-date-picker
             style="width: 100%;"
               format="yyyy 年 MM 月 dd 日"
-              value-format="yyyy 年 MM 月 dd 日"
+              value-format="yyyy-MM-dd"
               v-model="fileForm.issueDate"
               type="date"
               placeholder="选择日期">
@@ -371,7 +371,7 @@
           <el-form-item label="实施日期" >
             <el-date-picker
                format="yyyy 年 MM 月 dd 日"
-              value-format="yyyy 年 MM 月 dd 日"
+              value-format="yyyy-MM-dd"
             style="width: 100%;"
               v-model="fileForm.actualizeDate"
               type="date"
@@ -478,7 +478,10 @@ import { getStore, setStore } from "@/util/store";
         manageLoad: false,
         addFileDialogVisible:false,
         addFileRuleLoad:false,
-        fileForm:{},
+        fileForm:{
+          standardFileUrl: [], // 用于展示的文件列表
+          files: [] // 存储实际的文件对象
+        },
         fileRuleForm:{
           name: [
             { required: true, message: '请输入规范名称', trigger: 'blur' }
@@ -733,31 +736,58 @@ import { getStore, setStore } from "@/util/store";
          this.addFileDialogVisible = true;
          },
          
-        uploadImportData(file){
-            let formData = new FormData()
-            formData.append('file', file.raw);
-            let pictureList =[]
-            pictureList.push(file.name)
-            this.fileForm.standardFileUrl=pictureList.map(item=>{
-                 return {
-                    name: item,
-                    url: item,
-                    raw:file.raw
-                }
-            }) 
-        },
+     uploadImportData(file) {
+          // 验证文件类型
+       
+
+          // 将文件对象存入 files 数组
+          if (!this.fileForm.files) {
+            this.fileForm.files = [];
+          }
+          this.fileForm.files.push(file.raw);
+
+          // 更新显示的文件列表
+          this.fileForm.standardFileUrl = this.fileForm.files.map(file => ({
+            name: file.name,
+          }));
+      },
         async addFileRoleForm(){
           const isValid = await this.$refs.fileFormRef.validate()
           if (!isValid) {
             this.$message.error('请填写完整的规范信息');
             return;
           }
-          add({
-            ...this.fileForm,
+          const formData = new FormData();
+          // 添加基本信息
+          let objData={
+            name: this.fileForm.name,
+            issueDate: this.fileForm.issueDate,
+            actualizeDate: this.fileForm.actualizeDate,
             type: 2,
             privateId: this.treeId,
             parentId: this.ruleItem.id,
-          }).then((res) => {
+          }
+          let data = JSON.stringify(objData);
+          formData.append('data', new Blob([JSON.stringify(objData)], {
+              type: 'application/json'
+            }));
+
+        // 添加文件
+        if (this.fileForm.files && this.fileForm.files.length > 0) {
+          this.fileForm.files.forEach(file => {
+            formData.append('files', file);
+          });
+        }
+                // add({
+          //   ...this.fileForm,
+          //   type: 2,
+          //   privateId: this.treeId,
+          //   parentId: this.ruleItem.id,
+          // })
+          console.log(formData,'formData');
+          
+           add(formData)
+          .then((res) => {
             if(res.data.code==200){
                 this.$message.success(res.data.msg)