Jelajahi Sumber

公司基本信息接口测试,读取图片接口测试

Bella 2 tahun lalu
induk
melakukan
b0da1dcf78

+ 22 - 17
src/api/data/basicInfo.js

@@ -2,11 +2,10 @@ import { get, post, put } from "@/utils/requestMethod";
 
 /**
  * 获取公司基本信息
- * @param {*} company_id
  * @returns
  */
-const getCompanyBasicInfo = (company_id) => {
-  return get(`/data/company?company_id=${company_id}`);
+const getCompanyBasicInfo = () => {
+  return get(`/data/company`);
 };
 
 /**
@@ -16,17 +15,24 @@ const getCompanyBasicInfo = (company_id) => {
  */
 const editCompanyBasicInfo = (options) => {
   let params = new FormData();
-  params.append("company_id", options.company_id);
-  options.management_unit !== "" &&
+  options.management_unit &&
+    options.management_unit !== "" &&
     params.append("management_unit", options.management_unit);
-  options.custodian_unit !== "" &&
+  options.custodian_unit &&
+    options.custodian_unit !== "" &&
     params.append("custodian_unit", options.custodian_unit);
-  options.introduction !== "" &&
+  options.introduction &&
+    options.introduction !== "" &&
     params.append("introduction", options.introduction);
-  options.contact_person !== "" &&
+  options.contact_person &&
+    options.contact_person !== "" &&
     params.append("contact_person", options.contact_person);
-  options.contact_information !== "" &&
+  options.contact_information &&
+    options.contact_information !== "" &&
     params.append("contact_information", options.contact_information);
+  options.picture &&
+    options.picture !== "" &&
+    params.append("picture", options.picture);
   return put("/data/company", params);
 };
 
@@ -44,14 +50,6 @@ const getBuildingList = () => {
   return get(`/data/building_list`);
 };
 
-
-
-
-
-
-
-
-
 /**
  * 获取底层系统
  * @param {*} page
@@ -71,3 +69,10 @@ const addUnderlyingSystem = (picture) => {
   let params = new FormData();
   return post(`/data/underlying_system`, params);
 };
+
+export {
+  addUnderlyingSystem,
+  getCompanyBasicInfo,
+  editCompanyBasicInfo,
+  getBuildingList,
+};

+ 1 - 1
src/main.js

@@ -25,7 +25,7 @@ router.beforeEach((to, from, next) => {
   if (to.path === '/login') {
     next();
   } else {
-    if (to.meta.requireAuth && !sessionStorage.getItem('Authorization')) {
+    if (to.meta.requireAuth && !localStorage.getItem('Authorization')) {
       next({ path: '/login' });
     } else {
       next();

+ 1 - 1
src/store/modules/user.js

@@ -30,7 +30,7 @@ const user = {
                 login({ username: username.trim(), password: password }).then(res => {
                     const { data } = res;
                     commit('SET_TOKEN', data.data);
-                    sessionStorage.setItem('Authorization',data.data);
+                    localStorage.setItem('Authorization',data.data);
                     resolve(data);
                 }).catch(error => {
                     console.log('登陆失败');

+ 121 - 54
src/views/dataManagement/basicInfo/corporationInfo.vue

@@ -7,33 +7,40 @@
           placeholder="请输入单位名称"
         ></el-input>
       </el-form-item>
-      <el-form-item style="width: 350px" label="托管单位:">
-        <el-tag
-          :key="tag.id"
-          v-for="tag in dynamicTags"
-          closable
-          :disable-transitions="false"
-          @close="handleClose(tag)"
+      <el-form-item style="width: 1000px" label="托管单位:">
+        <div
+          class="hostunit"
+          style="width: 1000px; height: auto; overflow: auto; display: flex"
         >
-          {{ tag.name }}
-        </el-tag>
-        <el-input
-          class="input-new-tag"
-          v-if="inputVisible"
-          v-model="newHostInputValue"
-          ref="saveTagInput"
-          size="small"
-          @keyup.enter.native="handleInputConfirm"
-          @blur="handleInputConfirm"
-        >
-        </el-input>
-        <el-button v-else class="button-new-tag" size="small" @click="showInput"
-          >+ New Tag</el-button
-        >
-        <!-- <el-input
-          v-model="form.hostUnit"
-          placeholder="请输入单位名称"
-        ></el-input> -->
+          <el-tag
+            :key="tag.id"
+            v-for="tag in dynamicTags"
+            closable
+            :disable-transitions="false"
+            @close="handleClose(tag)"
+          >
+            {{ tag.name }}
+          </el-tag>
+          <input
+            type="text"
+            placeholder="请输入单位名称"
+            class="input-new-tag"
+            v-show="inputVisible"
+            v-model="inputValue"
+            ref="saveTagInput"
+            size="small"
+            @keyup.enter="handleInputConfirm"
+            @blur="handleInputConfirm"
+          />
+
+          <el-button
+            v-show="!inputVisible"
+            class="button-new-tag"
+            size="small"
+            @click="showInput"
+            >+ New Tag</el-button
+          >
+        </div>
       </el-form-item>
       <el-form-item style="width: 350px" label="公司简介:">
         <el-input v-model="form.profile" placeholder=""></el-input>
@@ -46,9 +53,10 @@
       </el-form-item>
       <el-form-item style="width: 500px" label="上传图片:">
         <el-upload
-          action="#"
+          action=""
+          :http-request="uploadSectionFile"
           list-type="picture-card"
-          :auto-upload="false"
+          :before-upload="beforeAvatarUpload"
           :file-list="fileList"
         >
           <i slot="default" class="el-icon-plus"></i>
@@ -96,10 +104,15 @@
 
 <script>
 import publicFunc from "@/utils/publicFunc";
+import {
+  getCompanyBasicInfo,
+  editCompanyBasicInfo,
+} from "@/api/data/basicInfo";
 export default {
   data() {
     return {
       fileList: [],
+      currentFile: "",
       dynamicTags: [
         {
           id: 1,
@@ -127,14 +140,34 @@ export default {
         profile: "",
         contact_person: "",
         contact_num: "",
+        pictureList: [],
       },
       action: "", //上传地址
-      newHostInputValue: "",
+      inputValue: "",
       inputVisible: false,
     };
   },
+  mounted() {
+    this.displayCompanyInfo();
+  },
 
   methods: {
+    displayCompanyInfo() {
+      getCompanyBasicInfo().then((res) => {
+        if (res.data.code === 0) {
+          // contact_information: "123456"
+          // contact_person: "张三"
+          // custodian_unit: "北京电信规划院"
+          // introduction: "中讯邮电咨询设计院有限公司"
+          // management_unit: "中讯邮电咨询设计院有限公司"
+          let obj = res.data.data;
+          this.form.manageUnit = obj.management_unit;
+          this.form.profile = obj.introduction;
+          this.form.contact_num = obj.contact_information;
+          this.form.contact_person = obj.contact_person;
+        }
+      });
+    },
     handleRemove(file) {
       console.log(file);
       console.log(this.fileList);
@@ -154,15 +187,15 @@ export default {
       });
     },
     handleInputConfirm() {
-      let newHostInputValue = this.newHostInputValue;
-      if (newHostInputValue) {
+      let inputValue = this.inputValue;
+      if (inputValue) {
         this.dynamicTags.push({
           id: Math.random() * 100,
-          name: newHostInputValue,
+          name: inputValue,
         });
       }
       this.inputVisible = false;
-      this.newHostInputValue = "";
+      this.inputValue = "";
     },
     showInput() {
       this.inputVisible = true;
@@ -170,13 +203,38 @@ export default {
         this.$refs.saveTagInput.$refs.input.focus();
       });
     },
+    beforeAvatarUpload(response, file, fileList) {
+      console.log(response);
+      return true;
+    },
+    uploadSectionFile(params) {
+      debugger;
+      console.log(params);
+      let picture = params.file;
+      this.currentFile = params.file;
+      this.form.pictureList.push(picture);
+    },
     resetEvent() {
-      this.form.manageUnit = "";
-      this.form.profile = "";
-      this.form.contact_person = "";
-      this.form.contact_num = "";
+      this.displayCompanyInfo();
+    },
+    submitEvent() {
+      let options = {
+        management_unit: this.form.manageUnit,
+        custodian_unit: JSON.stringify(this.dynamicTags),
+        introduction: this.form.profile,
+        contact_person: this.form.contact_person,
+        contact_information: this.form.contact_num,
+        picture: this.form.pictureList,
+      };
+      debugger;
+      editCompanyBasicInfo(options).then((res) => {
+        if (res.data.code === 0) {
+          setTimeout(() => {
+            this.displayCompanyInfo();
+          }, 500);
+        }
+      });
     },
-    submitEvent() {},
   },
 };
 </script>
@@ -193,22 +251,31 @@ export default {
       padding-top: 20px;
       margin-inline: 20px;
       margin-bottom: 0;
-    }
-
-    .el-tag + .el-tag {
-      margin-left: 10px;
-    }
-    .button-new-tag {
-      margin-left: 10px;
-      height: 32px;
-      line-height: 30px;
-      padding-top: 0;
-      padding-bottom: 0;
-    }
-    .input-new-tag {
-      width: 100px;
-      margin-left: 10px;
-      vertical-align: bottom;
+      .hostunit {
+        width: 800px;
+        height: auto;
+        overflow: auto;
+        display: flex;
+        .el-tag + .el-tag {
+          margin-left: 10px;
+        }
+        .button-new-tag {
+          margin-left: 10px;
+          height: 32px;
+          line-height: 30px;
+          padding-top: 0;
+          padding-bottom: 0;
+        }
+        input {
+          width: 150px;
+          margin-left: 10px;
+          border-radius: 4px;
+          &:focus {
+            outline: none;
+            border-radius: 4px;
+          }
+        }
+      }
     }
 
     /deep/.el-form-item__label {