瀏覽代碼

老师端回访图片

1
mo 2 年之前
父節點
當前提交
08539d2d5f
共有 2 個文件被更改,包括 249 次插入50 次删除
  1. 14 7
      package-lock.json
  2. 235 43
      src/views/visitManager/addVisit.vue

+ 14 - 7
package-lock.json

@@ -18699,7 +18699,8 @@
           "resolved": "https://registry.npmmirror.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz",
           "integrity": "sha512-ZFztHzVRdGLAzJmpUT9LNFLe1YiVOEylcaNpEutM26PVTCtOD919IMfD01CgbRouB42Dd9atjx1HseC15DgOZA==",
           "dev": true,
-          "optional": true
+          "optional": true,
+          "requires": {}
         },
         "ansi-regex": {
           "version": "3.0.1",
@@ -19148,7 +19149,8 @@
       "version": "1.1.2",
       "resolved": "https://registry.npmmirror.com/@vue/preload-webpack-plugin/-/preload-webpack-plugin-1.1.2.tgz",
       "integrity": "sha512-LIZMuJk38pk9U9Ur4YzHjlIyMuxPlACdBIHH9/nGYVTsaGKOSnSuELiE8vS9wa+dJpIYspYUOqk+L1Q4pgHQHQ==",
-      "dev": true
+      "dev": true,
+      "requires": {}
     },
     "@vue/web-component-wrapper": {
       "version": "1.3.0",
@@ -19363,7 +19365,8 @@
       "version": "5.3.2",
       "resolved": "https://registry.npmmirror.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
       "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
-      "dev": true
+      "dev": true,
+      "requires": {}
     },
     "acorn-walk": {
       "version": "6.2.0",
@@ -19393,13 +19396,15 @@
       "version": "1.0.1",
       "resolved": "https://registry.npmmirror.com/ajv-errors/-/ajv-errors-1.0.1.tgz",
       "integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==",
-      "dev": true
+      "dev": true,
+      "requires": {}
     },
     "ajv-keywords": {
       "version": "3.5.2",
       "resolved": "https://registry.npmmirror.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
       "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
-      "dev": true
+      "dev": true,
+      "requires": {}
     },
     "alphanum-sort": {
       "version": "1.0.2",
@@ -26656,7 +26661,8 @@
     "postcss-prefix-selector": {
       "version": "1.16.0",
       "resolved": "https://registry.npmmirror.com/postcss-prefix-selector/-/postcss-prefix-selector-1.16.0.tgz",
-      "integrity": "sha512-rdVMIi7Q4B0XbXqNUEI+Z4E+pueiu/CS5E6vRCQommzdQ/sgsS4dK42U7GX8oJR+TJOtT+Qv3GkNo6iijUMp3Q=="
+      "integrity": "sha512-rdVMIi7Q4B0XbXqNUEI+Z4E+pueiu/CS5E6vRCQommzdQ/sgsS4dK42U7GX8oJR+TJOtT+Qv3GkNo6iijUMp3Q==",
+      "requires": {}
     },
     "postcss-reduce-initial": {
       "version": "4.0.3",
@@ -29993,7 +29999,8 @@
     "vuex": {
       "version": "3.6.2",
       "resolved": "https://registry.npmmirror.com/vuex/-/vuex-3.6.2.tgz",
-      "integrity": "sha512-ETW44IqCgBpVomy520DT5jf8n0zoCac+sxWnn+hMe/CzaSejb/eVw2YToiXYX+Ex/AuHHia28vWTq4goAexFbw=="
+      "integrity": "sha512-ETW44IqCgBpVomy520DT5jf8n0zoCac+sxWnn+hMe/CzaSejb/eVw2YToiXYX+Ex/AuHHia28vWTq4goAexFbw==",
+      "requires": {}
     },
     "watchpack": {
       "version": "1.7.5",

+ 235 - 43
src/views/visitManager/addVisit.vue

@@ -21,7 +21,16 @@
         placeholder="请选择"
       >
         <template #right-icon>
-          <a v-if="studentPhone" @click.stop="() => {}" class="phone_section" :href="'tel:' + studentPhone"><img src="../../assets/images/icon_phone.png" class="iconPhone" alt=""></a>
+          <a
+            v-if="studentPhone"
+            @click.stop="() => {}"
+            class="phone_section"
+            :href="'tel:' + studentPhone"
+            ><img
+              src="../../assets/images/icon_phone.png"
+              class="iconPhone"
+              alt=""
+          /></a>
         </template>
       </van-field>
       <van-field
@@ -85,6 +94,22 @@
         placeholder="请选择"
       />
     </van-cell-group>
+    <van-cell-group>
+      <div class="visiWrap">
+        <p>回访图片</p>
+        <!--    :before-delete="beforDelete" -->
+        <van-uploader
+          v-model="uploader"
+          :before-read="beforeRead"
+          :after-read="afterRead"
+          :disabled="id ? true : false"
+          :deletable="!id ? true : false"
+          accept="image/*"
+          multiple
+          :max-count="5"
+        />
+      </div>
+    </van-cell-group>
 
     <div class="button-group" v-if="!id">
       <van-button type="primary" @click="onSubmit" round size="large"
@@ -199,10 +224,12 @@ import {
   queryStudentsWithTeacher,
   visitAdd,
   visitGetInfo,
-  queryUserById
+  queryUserById,
 } from "@/api/teacher";
 import { queryUserInfo } from "@/api/app";
+import { policy } from "@/views/massMessage/api";
 import setLoading from "@/utils/loading";
+import axios from "axios";
 export default {
   name: "addVisit",
   components: {
@@ -219,6 +246,7 @@ export default {
       beforeId: query.beforeId, // 如果有beforeId的时候说明是从待回访列表进来的
       inside: query.inside || 0,
       visitFlag: Number(query.visitFlag) || 0,
+      uploader: [],
       dataForm: {
         // 时间下拉框
         status: false,
@@ -231,7 +259,12 @@ export default {
         headerStatus: true, // 头部是否展示
         studentStatus: false, // 上课学生状态
       },
-      typeList: [{ name: "课程推荐" }, { name: "常规回访" }, { name: "云教练" }, { name: "其它" }],
+      typeList: [
+        { name: "课程推荐" },
+        { name: "常规回访" },
+        { name: "云教练" },
+        { name: "其它" },
+      ],
       visit: {
         status: false,
         type: null,
@@ -243,11 +276,18 @@ export default {
       form: {
         teacherId: null,
         studentId: query.userId || query.studentId || query.beforeId || null,
-        type: query.userId ? '云教练' : query.beforeId ? '常规回访' : null,
-        purpose:  query.userId ? '体验回访' : query.beforeId ? '教学内容未达标' : null,
+        type: query.userId ? "云教练" : query.beforeId ? "常规回访" : null,
+        purpose: query.userId
+          ? "体验回访"
+          : query.beforeId
+          ? "教学内容未达标"
+          : null,
         overview: "",
         feedback: "",
-        visitTime: query.userId || query.id || query.beforeId ? dayjs().format("YYYY年MM月DD日") : null,
+        visitTime:
+          query.userId || query.id || query.beforeId
+            ? dayjs().format("YYYY年MM月DD日")
+            : null,
         visiterType: "TEACHER",
       },
       loading: false,
@@ -264,6 +304,15 @@ export default {
       clickStatus: false,
       dataList: [],
       searchIcon: require("@/assets/images/search.png"),
+      ossUploadUrl: "https://ks3-cn-beijing.ksyuncs.com/daya",
+      dataObj: {
+        policy: "",
+        signature: "",
+        key: "",
+        KSSAccessKeyId: "",
+        acl: "public-read",
+        name: "",
+      },
     };
   },
   mounted() {
@@ -275,7 +324,7 @@ export default {
     if (browser().android || browser().iPhone) {
       this.statusList.headerStatus = false;
     }
-    document.title = this.name || '新增回访记录';
+    document.title = this.name || "新增回访记录";
     this.__init();
   },
   methods: {
@@ -305,17 +354,22 @@ export default {
           form.feedback = tempData.feedback;
           form.visitTime = dayjs(tempData.visitTime).format("YYYY年MM月DD日");
           form.visiterType = tempData.visiterType;
+          let attrList = tempData.attachments.split(",");
+          this.uploader = attrList.map((item) => {
+            return { url: item };
+          });
+          // console.log(this.uploader);
         } else {
           this.$toast(res.msg);
         }
       }
       let userId = this.userId || this.studentId || this.beforeId;
-      if(userId) {
-        await queryUserById({ userId }).then(res => {
-          let result = res.data
-          this.studentPhone = result.phone
-          this.studentName = result.username
-        })
+      if (userId) {
+        await queryUserById({ userId }).then((res) => {
+          let result = res.data;
+          this.studentPhone = result.phone;
+          this.studentName = result.username;
+        });
       }
     },
     async onSubmit() {
@@ -346,14 +400,18 @@ export default {
       setLoading(true);
       // let visitTime = this.form.visitTime.replace(/[^\d]/g,'/');
       // let someDate = new Date(visitTime)
-      let visitTime = dayjs(this.dataForm.currentDate).format("YYYY-MM-DD")
+      let visitTime = dayjs(this.dataForm.currentDate).format("YYYY-MM-DD");
+      let attachmentsList = this.uploader.map((item) => {
+        return item.url;
+      });
       let params = {
         ...form,
-        visitTime
-      }
+        visitTime,
+        attachments: attachmentsList.join(","),
+      };
       // 待回访时要传的参数
-      if(this.beforeId) {
-        params.objectId = this.$route.query.objectId
+      if (this.beforeId) {
+        params.objectId = this.$route.query.objectId;
       }
       let res = await visitAdd({ ...params });
       let result = res.data;
@@ -361,26 +419,26 @@ export default {
       if (result.code == 200) {
         this.$toast("添加成功");
         setTimeout(() => {
-          if(this.inside) {
-            this.onAppBack()
-          } else if(this.userId) {
-            let { visitFlag ,...query } = this.$route.query
-            visitFlag = 0
+          if (this.inside) {
+            this.onAppBack();
+          } else if (this.userId) {
+            let { visitFlag, ...query } = this.$route.query;
+            visitFlag = 0;
             this.$router.replace({
-              path: '/trainDetail',
+              path: "/trainDetail",
               query: {
                 ...query,
-                visitFlag
-              }
+                visitFlag,
+              },
             });
-          } else if(this.beforeId) {
-            let { ...query } = this.$route.query
+          } else if (this.beforeId) {
+            let { ...query } = this.$route.query;
             this.$router.replace({
-              path: '/visitList',
+              path: "/visitList",
               query: {
                 userId: this.beforeId,
-                ...query
-              }
+                ...query,
+              },
             });
           } else {
             this.$router.replace("visitList");
@@ -421,9 +479,13 @@ export default {
         } else if (form.type == "课程推荐") {
           visit.data = [{ name: "新课推荐" }, { name: "续费提醒" }];
         } else if (form.type == "常规回访") {
-          visit.data = [{ name: "课后及作业回访" }, { name: "练习及乐团表现" }, { name: "教学内容未达标" },];
-        } else if(form.type == '云教练') {
-          visit.data = [{ name: "体验回访" }]
+          visit.data = [
+            { name: "课后及作业回访" },
+            { name: "练习及乐团表现" },
+            { name: "教学内容未达标" },
+          ];
+        } else if (form.type == "云教练") {
+          visit.data = [{ name: "体验回访" }];
         } else {
           this.$toast("请选择回访类型");
           return;
@@ -443,7 +505,7 @@ export default {
     onCheckboxSelect(item) {
       this.radioSelect = item.userId;
       this.radioSelectName = item.userName;
-      this.radioSelectPhone = item.phone
+      this.radioSelectPhone = item.phone;
     },
     onPopupCancel() {
       this.statusList.studentStatus = false;
@@ -515,22 +577,142 @@ export default {
       let last = phone.substr(-4);
       return first + "****" + last;
     },
+    beforeRead(file) {
+      if (file.length) {
+        file.map((item) => {
+          const isLt2M = item.size / 1000 / 1000 < 5;
+          if (!isLt2M) {
+            this.$toast("上传文件大小不能超过 5MB");
+            return false;
+          }
+        });
+      } else {
+        const isLt2M = file.size / 1000 / 1000 < 5;
+        if (!isLt2M) {
+          this.$toast("上传文件大小不能超过 5MB");
+          return false;
+        }
+      }
+
+      return true;
+    },
+    async uploadFile(file) {
+      // console.log("uploadFile", file);
+      try {
+        file.status = "uploading";
+        file.message = "上传中...";
+        let tempName = file.file.name || "";
+        const fileName = tempName && tempName.replace(/ /gi, "_");
+        let key = new Date().getTime() + fileName;
+        let objTemp = {
+          filename: fileName,
+          bucketName: this.bucket_name,
+          postData: {
+            filename: fileName,
+            acl: "public-read",
+            key: key,
+            unknowValueField: [],
+          },
+        };
+
+        const res = await policy(objTemp);
+        const obj = {
+          policy: res.data.policy,
+          signature: res.data.signature,
+          key: key,
+          KSSAccessKeyId: res.data.kssAccessKeyId,
+          acl: "public-read",
+          name: fileName,
+        };
+
+        let formData = new FormData();
+        for (let key in obj) {
+          formData.append(key, obj[key]);
+        }
+        formData.append("file", file.file);
+        // console.log(formData);
+        await axios({
+          method: "post",
+          url: this.ossUploadUrl,
+          data: formData,
+        });
+        const uploadUrl = this.ossUploadUrl + "/" + key;
+        file.url = uploadUrl;
+        file.status = "done";
+      } catch (e) {
+        console.log(e);
+        file.status = "failed";
+        file.message = "上传失败";
+        this.uploader = [];
+      }
+    },
+    async afterRead(file) {
+      // 上传头像
+      const form = this.form;
+      try {
+        if (file && file.length) {
+          file.forEach((item) => {
+            this.uploadFile(item);
+          });
+        } else {
+          this.uploadFile(file);
+        }
+      } catch (e) {
+        console.log(e);
+        return false;
+      }
+      // this.$toast.loading({
+      //   duration: 0,
+      //   forbidClick: true,
+      //   message: "上传中...",
+      // });
+      //
+      // try {
+      //   file.status = "uploading";
+      //   file.message = "上传中...";
+      //   let formData = new FormData();
+      //   formData.append("file", file.file);
+      //   let res = await uploadFile(formData);
+      //   this.$toast.clear();
+      //   let result = res.data;
+      //   if (result.code == 200) {
+      //     file.status = "done";
+      //     form.fileName = file.file.name;
+      //     form.fileUrl = result.data.url;
+      //     form.messageType = this.onCheckFileType(file.file.type);
+      //   } else {
+      //     file.status = "failed";
+      //     file.message = "上传失败";
+      //     this.$toast(result.msg);
+      //     form.fileName = "";
+      //     form.fileUrl = "";
+      //     return false;
+      //   }
+      // } catch (err) {
+      //   this.$toast.clear();
+      //   file.status = "failed";
+      //   file.message = "上传失败";
+      //   form.fileName = "";
+      //   form.fileUrl = "";
+      //   return false;
+      // }
+    },
   },
 };
 </script>
 <style lang='less' scoped>
 @import url("../../assets/commonLess/variable.less");
 /deep/.van-popup--bottom {
-  border-radius: 0px 0px 0px 0px!important;
-  overflow: auto!important;
+  border-radius: 0px 0px 0px 0px !important;
+  overflow: auto !important;
 }
 .addVisit {
   min-height: 100vh;
 }
 .vip-title {
-   padding: .06rem .14rem .04rem;
-    font-size: .14rem;
-    color: #808080;
+  padding: 0.06rem 0.14rem 0.04rem;
+  font-size: 0.14rem;
+  color: #808080;
 }
 /deep/.van-cell-group {
   margin-bottom: 0.1rem;
@@ -619,12 +801,13 @@ export default {
     margin-left: 0.08rem;
   }
 }
-/deep/.van-field__right-icon, .phone_section {
+/deep/.van-field__right-icon,
+.phone_section {
   display: flex;
 }
 .iconPhone {
-  width: .17rem;
-  height: .21rem;
+  width: 0.17rem;
+  height: 0.21rem;
 }
 .paddingB80 {
   padding-bottom: 0.8rem;
@@ -681,4 +864,13 @@ export default {
 .van-icon-search {
   color: @mColor;
 }
+.visiWrap {
+  padding: 10px 16px;
+  p {
+    font-size: 0.16rem;
+    line-height: 0.28rem;
+    color: #646566;
+    margin-bottom: 0.1rem;
+  }
+}
 </style>