Kaynağa Gözat

文件上传id修改

zhaoxiaohai 2 yıl önce
ebeveyn
işleme
8cb3fa4cd5

+ 51 - 43
Eservice/components/autoUpload/upload.js

@@ -4,14 +4,19 @@ Component({
   /**
    * 组件的属性列表
    */
-  properties: { 
-    source:{
-      value:'media',
-      type:String
+  properties: {
+    source: {
+      value: 'media',
+      type: String
     },
-    bindData:{
-      value:{},
-      type:Object
+    bindData: {
+      value: {},
+      type: Object
+    },
+    /* 文件夹ID */
+    parentid: {
+      type: String,
+      value: wx.getStorageSync('siteP').appfolderid
     }
   },
 
@@ -20,8 +25,8 @@ Component({
    */
   data: {
     originFiles: [],
-    filelist:[],
-    attachmentids:[],
+    filelist: [],
+    attachmentids: [],
     gridConfig: {
       column: 5,
       width: 120,
@@ -30,70 +35,74 @@ Component({
     config: {
       count: 1,
     },
-    timer:null,
-    uploadCount:0
+    timer: null,
+    uploadCount: 0
   },
-  lifetimes:{
-    attached () {
+  lifetimes: {
+    attached() {
       setTimeout(() => {
         this.fileData()
       }, 1000);
-      
+
     }
   },
   /**
    * 组件的方法列表
    */
   methods: {
-    handleAdd (file) {
+    handleAdd(file) {
       console.log(file)
-      let files = file.detail.files.map(e=>{
+      let files = file.detail.files.map(e => {
         e.status = 'loading'
         return e
       })
       this.setData({
-        uploadCount:files.length,
-        originFiles:files,
-        attachmentids:[]
+        uploadCount: files.length,
+        originFiles: files,
+        attachmentids: []
       })
       this.toSetFileData()
     },
-    handleClick () {
+    handleClick() {
       let that = this
       wx.chooseMessageFile({
         count: 10,
         type: 'file',
         success(res) {
-          let arr = res.tempFiles.map(e=>{
+          let arr = res.tempFiles.map(e => {
             return {
-              name:e.name,
-              url:e.path,
-              type:e.type,
+              name: e.name,
+              url: e.path,
+              type: e.type,
+            }
+          })
+          that.handleAdd({
+            detail: {
+              files: arr
             }
           })
-          that.handleAdd({detail:{files:arr}})
         }
       })
     },
-    handleRemove (data) {
+    handleRemove(data) {
       console.log(data)
       let file = {
-        currentTarget:{
-          dataset:{
-            item:data.detail.file
+        currentTarget: {
+          dataset: {
+            item: data.detail.file
           }
         }
       }
       this.deleteFile(file)
     },
-    toSetFileData () {
-      
+    toSetFileData() {
+
       let files = this.data.originFiles
 
       for (let i = 0; i < files.length; i++) {
         // 初始化数据
         let that = this,
-            data = this.requestType(files[i]);
+          data = this.requestType(files[i]);
         data.content.filename = data.content.filename ? data.content.filename : `${Date.now()}.${data.content.filetype}`;
         //发送请求
         wx.getFileSystemManager().readFile({
@@ -110,7 +119,7 @@ Component({
           fail: console.error
         })
       }
-      this.data.timer = setInterval(e=>{
+      this.data.timer = setInterval(e => {
         if (this.data.uploadCount === 0) {
           clearInterval(this.data.timer)
           this.filebindData()
@@ -128,8 +137,7 @@ Component({
         "content": {
           "filename": file.name,
           "filetype": ext,
-          "parentid": 2
-          // this.data.parentid
+          "parentid": this.data.parentid
         }
       }
     },
@@ -153,7 +161,7 @@ Component({
           }).then(rs => {
 
             that.setData({
-              originFiles:that.data.originFiles.map(e=>{
+              originFiles: that.data.originFiles.map(e => {
                 if (e.name === res.filename) {
                   e.status = ''
                 }
@@ -164,7 +172,7 @@ Component({
             that.data.attachmentids.push(rs.data.attachmentids[0])
 
             that.setData({
-              uploadCount:that.data.uploadCount - 1
+              uploadCount: that.data.uploadCount - 1
             })
           }).catch(err => {
             console.log(err)
@@ -172,8 +180,8 @@ Component({
         }
       })
     },
-    async filebindData () {
-      
+    async filebindData() {
+
       this.data.bindData.attachmentids = this.data.attachmentids
       const res = await api._post({
         "classname": "system.attachment.Attachment",
@@ -182,17 +190,17 @@ Component({
       })
       this.fileData()
     },
-    async fileData () {
+    async fileData() {
       const res = await api._post({
         "classname": "system.attachment.Attachment",
         "method": "queryFileLink",
         "content": this.data.bindData
       })
       this.setData({
-        originFiles:res.data
+        originFiles: res.data
       })
     },
-    async deleteFile (data) {
+    async deleteFile(data) {
       let item = data.currentTarget.dataset.item
       const res = await api._post({
         "classname": "system.attachment.Attachment",
@@ -204,4 +212,4 @@ Component({
       this.fileData()
     }
   }
-})
+})

+ 31 - 27
Eservice/components/upload/upload.js

@@ -4,10 +4,15 @@ Component({
   /**
    * 组件的属性列表
    */
-  properties: { 
-    source:{
-      value:'media',
-      type:String
+  properties: {
+    source: {
+      value: 'media',
+      type: String
+    },
+    /* 文件夹ID */
+    parentid: {
+      type: String,
+      value: wx.getStorageSync('siteP').appfolderid
     }
   },
 
@@ -16,9 +21,9 @@ Component({
    */
   data: {
     originFiles: [
-    
+
     ],
-    attachmentids:[],
+    attachmentids: [],
     gridConfig: {
       column: 5,
       width: 120,
@@ -27,41 +32,41 @@ Component({
     config: {
       count: 1,
     },
-    timer:null,
-    uploadCount:0
+    timer: null,
+    uploadCount: 0
   },
 
   /**
    * 组件的方法列表
    */
   methods: {
-    handleAdd (file) {
-      let files = file.detail.files.map(e=>{
+    handleAdd(file) {
+      let files = file.detail.files.map(e => {
         e.status = 'loading'
         return e
       })
       this.setData({
-        uploadCount:files.length,
-        originFiles:files,
-        attachmentids:[]
+        uploadCount: files.length,
+        originFiles: files,
+        attachmentids: []
       })
     },
-    handleRemove (data) {
+    handleRemove(data) {
       let file = data.detail.file
       this.setData({
-        originFiles:this.data.originFiles.filter(e=>{
+        originFiles: this.data.originFiles.filter(e => {
           return e.name !== file.name
         })
       })
     },
-    toSetFileData () {
-      
+    toSetFileData() {
+
       let files = this.data.originFiles
 
       for (let i = 0; i < files.length; i++) {
         // 初始化数据
         let that = this,
-            data = this.requestType(files[i]);
+          data = this.requestType(files[i]);
         data.content.filename = data.content.filename ? data.content.filename : `${Date.now()}.${data.content.filetype}`;
         //发送请求
         wx.getFileSystemManager().readFile({
@@ -79,13 +84,13 @@ Component({
         })
       }
 
-      return new Promise ((reslove,reject)=>{
-        this.data.timer = setInterval(e=>{
+      return new Promise((reslove, reject) => {
+        this.data.timer = setInterval(e => {
           if (this.data.uploadCount === 0) {
             clearInterval(this.data.timer)
             reslove()
           }
-        },1000)
+        }, 1000)
       })
     },
     /* 请求类型 */
@@ -99,8 +104,7 @@ Component({
         "content": {
           "filename": file.name,
           "filetype": ext,
-          "parentid": 2
-          // this.data.parentid
+          "parentid": this.data.parentid
         }
       }
     },
@@ -124,7 +128,7 @@ Component({
           }).then(rs => {
 
             that.setData({
-              originFiles:that.data.originFiles.map(e=>{
+              originFiles: that.data.originFiles.map(e => {
                 if (e.name === res.filename) {
                   e.status = ''
                 }
@@ -135,13 +139,13 @@ Component({
             that.data.attachmentids.push(rs.data.attachmentids[0])
 
             that.setData({
-              uploadCount:that.data.uploadCount - 1
+              uploadCount: that.data.uploadCount - 1
             })
           }).catch(err => {
             console.log(err)
           })
         }
       })
-  },
+    },
   }
-})
+})

+ 43 - 16
Eservice/signName/index.js

@@ -6,7 +6,7 @@ Page({
    * 页面的初始数据
    */
   data: {
-    attachmentids:[],
+    attachmentids: [],
     canvasName: 'signCanvas',
     ctx: '', // 上下文实例
     canvas: '', // 画布实例
@@ -24,7 +24,12 @@ Page({
     currentLine: [], // 当前线条
     firstTouch: true, // 第一次触发
     radius: 1, //画圆的半径
-    cutArea: { top: 0, right: 0, bottom: 0, left: 0 }, //裁剪区域
+    cutArea: {
+      top: 0,
+      right: 0,
+      bottom: 0,
+      left: 0
+    }, //裁剪区域
     bethelPoint: [], //保存所有线条 生成的贝塞尔点;
     lastPoint: 0,
     chirography: [], //笔迹
@@ -42,7 +47,7 @@ Page({
    */
   onLoad: function (options) {
     this.setData({
-      id:options.id
+      id: options.id
     })
     this.data.dpr = wx.getSystemInfoSync().pixelRatio
     const query = wx.createSelectorQuery()
@@ -56,7 +61,10 @@ Page({
     const query1 = wx.createSelectorQuery()
     query1
       .select('#signCanvas')
-      .fields({ node: true, size: true })
+      .fields({
+        node: true,
+        size: true
+      })
       .exec(res => {
         const canvas = res[0].node
         this.data.ctx = canvas.getContext('2d')
@@ -65,14 +73,17 @@ Page({
         /* 将canvas背景设置为 白底,不设置  导出的canvas的背景为透明 */
         // console.log(this, 'hahah');
         this.data.canvas = canvas
-        
+
         this.data.ctx.scale(this.data.dpr, this.data.dpr)
         this.setCanvasBg('#fff')
       })
     const query2 = wx.createSelectorQuery()
     query2
       .select('#offCanvas')
-      .fields({ node: true, size: true })
+      .fields({
+        node: true,
+        size: true
+      })
       .exec(res => {
         const canvas = res[0].node
         const ctx = canvas.getContext('2d')
@@ -113,7 +124,7 @@ Page({
     console.log('========subOver')
   },
 
-  
+
   //画两点之间的线条;参数为:line,会绘制最近的开始的两个点;
   pointToLine(line) {
     this.calcBethelLine(line)
@@ -291,7 +302,13 @@ Page({
       y2 = y1 + (line[0].y - y1) * curveValue
     }
     //从计算公式看,三个点分别是(x0,y0),(x1,y1),(x2,y2) ;(x1,y1)这个是控制点,控制点不会落在曲线上;实际上,这个点还会手写获取的实际点,却落在曲线上
-    len = this.distance({ x: x2, y: y2 }, { x: x0, y: y0 })
+    len = this.distance({
+      x: x2,
+      y: y2
+    }, {
+      x: x0,
+      y: y0
+    })
     lastRadius = this.data.radius
     for (let n = 0; n < line.length - 1; n++) {
       dis += line[n].dis
@@ -299,8 +316,7 @@ Page({
       if (dis > this.data.smoothness) break
     }
     this.setData({
-      radius:
-        Math.min((time / len) * this.data.pressure + this.data.lineMin, this.data.lineMax) *
+      radius: Math.min((time / len) * this.data.pressure + this.data.lineMin, this.data.lineMax) *
         this.data.lineSize
     })
     line[0].r = this.data.radius
@@ -322,7 +338,11 @@ Page({
       let x = (1 - t) * (1 - t) * x0 + 2 * t * (1 - t) * x1 + t * t * x2
       let y = (1 - t) * (1 - t) * y0 + 2 * t * (1 - t) * y1 + t * t * y2
       let r = lastRadius + ((this.data.radius - lastRadius) / n) * i
-      point.push({ x: x, y: y, r: r })
+      point.push({
+        x: x,
+        y: y,
+        r: r
+      })
       if (point.length == 3) {
         let a = this.ctaCalc(
           point[0].x,
@@ -341,7 +361,11 @@ Page({
         // console.log(this.data.bethelPoint)
         // bethelPoint = bethelPoint.push(a);
         this.bethelDraw(a, 1)
-        point = [{ x: x, y: y, r: r }]
+        point = [{
+          x: x,
+          y: y,
+          r: r
+        }]
       }
     }
     this.setData({
@@ -379,7 +403,11 @@ Page({
     vy21 = (vy21 / norm) * r2
     n_x2 = -vy21
     n_y2 = vx21
-    a.push({ mx: x0 + n_x0, my: y0 + n_y0, color: '#1A1A1A' })
+    a.push({
+      mx: x0 + n_x0,
+      my: y0 + n_y0,
+      color: '#1A1A1A'
+    })
     a.push({
       c1x: x1 + n_x0,
       c1y: y1 + n_y0,
@@ -543,8 +571,7 @@ Page({
               "content": {
                 "filename": '客户签字',
                 "filetype": 'jpg',
-                "parentid": 2
-                // this.data.parentid
+                "parentid": wx.getStorageSync('siteP').appfolderid
               }
             }).then(res => {
               if (res.msg == "成功") {
@@ -585,7 +612,7 @@ Page({
       }
     })
   },
-  async filebindData () {
+  async filebindData() {
     let pages = getCurrentPages()[getCurrentPages().length - 2]
     const res = await api._post({
       "classname": "system.attachment.Attachment",