Browse Source

修改链接

lex 11 months ago
parent
commit
e250651983
2 changed files with 509 additions and 525 deletions
  1. 235 238
      src/components/Protocol.vue
  2. 274 287
      src/views/message/control/fileUpload.vue

+ 235 - 238
src/components/Protocol.vue

@@ -1,252 +1,249 @@
 <template>
-	<div class="protocol">
-		<div class="agreeProtocol" v-show="isProtocol">
-			<slot>
-				<van-checkbox @click="onChange" :checked-color="checkedColor" v-model="checked" v-if="!exists">
-					<template #icon="props">
-						<!-- {{ props.checked }} -->
-						<img :src="props.checked ? activeButtonIcon : inactiveButtonIcon" >
-					</template>
-				</van-checkbox>
-				<i :style="leftStyle" @click="onClick" v-if="!exists">{{ leftString }}</i>
-				<i :style="leftStyle" v-if="exists">查看</i>
-				<span @click="onPopupClose" :style="rightStyle">《{{ rightString }}》</span>
-			</slot>
-		</div>
+  <div class="protocol">
+    <div class="agreeProtocol" v-show="isProtocol">
+      <slot>
+        <van-checkbox @click="onChange" :checked-color="checkedColor" v-model="checked" v-if="!exists">
+          <template #icon="props">
+            <!-- {{ props.checked }} -->
+            <img :src="props.checked ? activeButtonIcon : inactiveButtonIcon" />
+          </template>
+        </van-checkbox>
+        <i :style="leftStyle" @click="onClick" v-if="!exists">{{ leftString }}</i>
+        <i :style="leftStyle" v-if="exists">查看</i>
+        <span @click="onPopupClose" :style="rightStyle">《{{ rightString }}》</span>
+      </slot>
+    </div>
 
-		<!-- 协议 -->
-		<van-popup id="protocolPopup" v-model="popupStatus" position="bottom">
-			<m-protocol :protocolHTML="protocolHTML" :popupStatus="popupStatus" :checked="checked" :tenantId="tenantId" @onClose="onPopupClose" @onPopupSure="onPopupSure" />
-		</van-popup>
-	</div>
+    <!-- 协议 -->
+    <van-popup id="protocolPopup" v-model="popupStatus" position="bottom">
+      <m-protocol :protocolHTML="protocolHTML" :popupStatus="popupStatus" :checked="checked" :tenantId="tenantId" @onClose="onPopupClose" @onPopupSure="onPopupSure" />
+    </van-popup>
+  </div>
 </template>
 
 <script>
-	import MProtocol from './MProtocol'
-	import {
-		queryProduceContract,
-		getContract
-	} from '@/api/smallWeb'
-	// import setLoading from '@/utils/loading'
-	export default {
-		name: 'mheader',
-		components: {
-			MProtocol
-		},
-		props: {
-			value: {
-				type: Boolean,
-				default () {
-					return false
-				}
-			},
-			tenantId: [String, Number], // 机构签署协议
-			type: {
-				type: [String, Number],
-				default: 0
-			},
-			musicGroupId: String,
-			checkedColor: String,
-			userId: String,
-			activeIcon: String,
-			inactiveIcon: String,
-			leftStyle: String,
-			leftString: {
-				type: String,
-				default () {
-					return '我已阅读并同意'
-				}
-			},
-			rightStyle: String,
-			rightString: {
-				type: String,
-				default () {
-					return '产品及服务协议'
-				}
-			}
-		},
-		data() {
-			return {
-				popupStatus: false,
-				checked: this.value,
-				exists: true, // 是否已经生成过协议
-				protocolHTML: null, // 协议内容
-				fullPath: null, //保存
-				isProtocol: false // 是否有协议内容
-			}
-		},
-		mounted() {
-			this.__init()
-			// window.onhashchange = () => {
-			// 	this.popupStatus = false
-			// }
-			window.addEventListener('hashchange', this.onHash, false)
-		},
-		methods: {
-			onHash() {
-				this.popupStatus = false
-			},
-			async __init() {
-				if(this.tenantId) {
-					try {
-						const res = await getContract({ id: this.tenantId, type: this.type })
-						this.protocolHTML = res.data
-						this.isProtocol = this.protocolHTML ? true : false
-						this.exists = false
-						this.checked = false
-						this.$emit('input', this.exists)
-					} catch(e) {
-						//
-					}
-				} else {
-					let params = {
-						userId: this.userId ? this.userId : null,
-						musicGroupId: this.musicGroupId ? this.musicGroupId : null
-					}
-					const token = sessionStorage.getItem('token')
-					if(token) {
-						localStorage.setItem('Authorization', token)
-						localStorage.setItem('userInfo', token)
-					}
+import MProtocol from "./MProtocol";
+import { queryProduceContract, getContract } from "@/api/smallWeb";
+// import setLoading from '@/utils/loading'
+export default {
+  name: "mheader",
+  components: {
+    MProtocol,
+  },
+  props: {
+    value: {
+      type: Boolean,
+      default() {
+        return false;
+      },
+    },
+    tenantId: [String, Number], // 机构签署协议
+    type: {
+      type: [String, Number],
+      default: 0,
+    },
+    musicGroupId: String,
+    checkedColor: String,
+    userId: String,
+    activeIcon: String,
+    inactiveIcon: String,
+    leftStyle: String,
+    leftString: {
+      type: String,
+      default() {
+        return "我已阅读并同意";
+      },
+    },
+    rightStyle: String,
+    rightString: {
+      type: String,
+      default() {
+        return "产品及服务协议";
+      },
+    },
+  },
+  data() {
+    return {
+      popupStatus: false,
+      checked: this.value,
+      exists: true, // 是否已经生成过协议
+      protocolHTML: null, // 协议内容
+      fullPath: null, //保存
+      isProtocol: false, // 是否有协议内容
+    };
+  },
+  mounted() {
+    this.__init();
+    // window.onhashchange = () => {
+    // 	this.popupStatus = false
+    // }
+    window.addEventListener("hashchange", this.onHash, false);
+  },
+  methods: {
+    onHash() {
+      this.popupStatus = false;
+    },
+    async __init() {
+      if (this.tenantId) {
+        try {
+          const res = await getContract({ id: this.tenantId, type: this.type });
+          this.protocolHTML = res.data;
+          this.isProtocol = this.protocolHTML ? true : false;
+          this.exists = false;
+          this.checked = false;
+          this.$emit("input", this.exists);
+        } catch (e) {
+          //
+        }
+      } else {
+        let params = {
+          userId: this.userId ? this.userId : null,
+          musicGroupId: this.musicGroupId ? this.musicGroupId : null,
+        };
+        const token = sessionStorage.getItem("token");
+        if (token) {
+          localStorage.setItem("Authorization", token);
+          localStorage.setItem("userInfo", token);
+        }
 
-					await queryProduceContract(params).then(res => {
-						let result = res.data
-						this.protocolHTML = '' // 重置协议
-						if (result.code == 200) {
-							this.protocolHTML = result.data.productContract
-							this.isProtocol = this.protocolHTML ? true : false
-							this.exists = result.data.exists
-							this.checked = this.exists
-							this.$emit('input', this.exists)
-						}
-					})
-				}
-				// 如果没有协议内容则不 显示协议
-				if(!this.protocolHTML) {
-					this.isProtocol = this.protocolHTML ? true : false
-					this.checked = true // 默认选中,学生端则不用默认选中
-					this.$emit('input', this.checked || this.exists)
-				}
-			},
-			// onChange() {
-			// 	this.$emit('input', this.checked)
-			// },
-			// onClick() {
-			// 	this.checked = !this.checked
-			// 	this.$emit('input', this.checked)
-			// },
-			onChange() {
-				if(this.tenantId) {
-					if(this.checked) {
-						this.checked = false
-						this.onPopupClose()
-					} else {
-						this.$emit('input', false)
-					}
-				} else {
-					this.$emit('input', this.checked)
-				}
-			},
-			onClick() {
-				if(this.tenantId) {
-					if(this.checked) {
-						this.checked = false
-						this.$emit('input', false)
-					} else {
-						this.onPopupClose()
-					}
-				} else {
-					this.checked = !this.checked
-					this.$emit('input', this.checked)
-				}
-			},
-			onPopupSure() {
-				this.$emit('input', true)
-				this.checked = true
-				this.onPopupClose()
-			},
-			onPopupClose() {
-				// 判断是否有协议内容
-				if(!this.protocolHTML) {
-					return
-				}
-				this.popupStatus = !this.popupStatus
-				// 打开弹窗
-				if(this.popupStatus) {
-					const route = this.$route
-					let times = 0
-					/* eslint-disable */
-					for(let i in route.query) {
-						times += 1
-					}
-					let fullPath = route.fullPath
-					const origin = window.location.origin
-					const url = times > 0 ? '&pto=1' : '?pto=1'
-					history.pushState("", "", `${origin}/#${fullPath}${url}`)
-				} else {
-					window.history.go(-1)
-				}
-				let popup = document.querySelector('#protocolPopup')
-				if (popup) {
-					popup.scrollTop = 0
-				}
-			}
-		},
-		watch: {
-			popupStatus(newValue) {
-				this.$emit('changeCheck', newValue)
-			},
-			value(nowValue) {
-				if (nowValue) {
-					this.checked = nowValue
-				}
-			}
-		},
-		destroyed() {
-			window.removeEventListener('hashchange', this.onHash)
-		}
-	}
+        await queryProduceContract(params).then((res) => {
+          let result = res.data;
+          this.protocolHTML = ""; // 重置协议
+          if (result.code == 200) {
+            this.protocolHTML = result.data.productContract;
+            this.isProtocol = this.protocolHTML ? true : false;
+            this.exists = result.data.exists;
+            this.checked = this.exists;
+            this.$emit("input", this.exists);
+          }
+        });
+      }
+      // 如果没有协议内容则不 显示协议
+      if (!this.protocolHTML) {
+        this.isProtocol = this.protocolHTML ? true : false;
+        this.checked = true; // 默认选中,学生端则不用默认选中
+        this.$emit("input", this.checked || this.exists);
+      }
+    },
+    // onChange() {
+    // 	this.$emit('input', this.checked)
+    // },
+    // onClick() {
+    // 	this.checked = !this.checked
+    // 	this.$emit('input', this.checked)
+    // },
+    onChange() {
+      if (this.tenantId) {
+        if (this.checked) {
+          this.checked = false;
+          this.onPopupClose();
+        } else {
+          this.$emit("input", false);
+        }
+      } else {
+        this.$emit("input", this.checked);
+      }
+    },
+    onClick() {
+      if (this.tenantId) {
+        if (this.checked) {
+          this.checked = false;
+          this.$emit("input", false);
+        } else {
+          this.onPopupClose();
+        }
+      } else {
+        this.checked = !this.checked;
+        this.$emit("input", this.checked);
+      }
+    },
+    onPopupSure() {
+      this.$emit("input", true);
+      this.checked = true;
+      this.onPopupClose();
+    },
+    onPopupClose() {
+      // 判断是否有协议内容
+      if (!this.protocolHTML) {
+        return;
+      }
+      this.popupStatus = !this.popupStatus;
+      // 打开弹窗
+      if (this.popupStatus) {
+        const route = this.$route;
+        let times = 0;
+        /* eslint-disable */
+        for (let i in route.query) {
+          times += 1;
+        }
+        let fullPath = route.fullPath;
+        const origin = window.location.origin + +location.pathname;
+        const url = times > 0 ? "&pto=1" : "?pto=1";
+        history.pushState("", "", `${origin}#${fullPath}${url}`);
+      } else {
+        window.history.go(-1);
+      }
+      let popup = document.querySelector("#protocolPopup");
+      if (popup) {
+        popup.scrollTop = 0;
+      }
+    },
+  },
+  watch: {
+    popupStatus(newValue) {
+      this.$emit("changeCheck", newValue);
+    },
+    value(nowValue) {
+      if (nowValue) {
+        this.checked = nowValue;
+      }
+    },
+  },
+  destroyed() {
+    window.removeEventListener("hashchange", this.onHash);
+  },
+};
 </script>
 
 <style lang="less" scoped>
-	.agreeProtocol {
-		display: flex;
-		align-items: center;
-		color: #333333;
-		padding: .1rem .16rem;
-		font-size: .14rem;
-		line-height: 1;
-		i {
-			font-style: normal;
-		}
-		.van-checkbox {
-			padding-right: .08rem;
-			img {
-				width: 20px;
-				height: 20px;
-			}
-		}
+.agreeProtocol {
+  display: flex;
+  align-items: center;
+  color: #333333;
+  padding: 0.1rem 0.16rem;
+  font-size: 0.14rem;
+  line-height: 1;
+  i {
+    font-style: normal;
+  }
+  .van-checkbox {
+    padding-right: 0.08rem;
+    img {
+      width: 20px;
+      height: 20px;
+    }
+  }
 
-		/deep/.van-checkbox__icon .van-icon {
-			border-color: #e9eaef;
-			background-color: #fff;
-		}
+  /deep/.van-checkbox__icon .van-icon {
+    border-color: #e9eaef;
+    background-color: #fff;
+  }
 
-		/deep/.van-checkbox__icon--checked .van-icon {
-			color: #fff;
-			background-color: #F85043;
-			border-color: #F85043;
-		}
+  /deep/.van-checkbox__icon--checked .van-icon {
+    color: #fff;
+    background-color: #f85043;
+    border-color: #f85043;
+  }
 
-		span {
-			color: #01C1B5;
-		}
-	}
+  span {
+    color: #01c1b5;
+  }
+}
 
-	@media screen and (max-width: 320px) {
-		.agreeProtocol .van-checkbox img {
-			width: 20px;
-			height: 20px;
-		}
-	}
+@media screen and (max-width: 320px) {
+  .agreeProtocol .van-checkbox img {
+    width: 20px;
+    height: 20px;
+  }
+}
 </style>

+ 274 - 287
src/views/message/control/fileUpload.vue

@@ -1,50 +1,40 @@
 <template>
-    <div class="oFileUpload controller" :class="[preview ? '' : 'o-unit']" v-if="widget.type == 'file'">
-        <van-field
-            :name="widget.model"
-            :label="widget.name || '附件'"
-            :required="fileCheck ? false : options.required || false"
-            :rules="rule"
-            v-if="!preview"
+  <div class="oFileUpload controller" :class="[preview ? '' : 'o-unit']" v-if="widget.type == 'file'">
+    <van-field :name="widget.model" :label="widget.name || '附件'" :required="fileCheck ? false : options.required || false" :rules="rule" v-if="!preview">
+      <template #input>
+        <!-- image/*, *.xlsx, *.xls, application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document, *.txt, *.pdf -->
+        <van-uploader
+          v-model="dataModel"
+          :before-read="beforeRead"
+          :before-delete="beforeDelete"
+          :after-read="afterRead"
+          :disabled="options.disabled || false"
+          :max-count="options.length"
+          accept="image/*, *.xlsx, *.xls,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document, *.txt, *.pdf"
+          preview-size="0.6rem"
         >
-            <template #input>
-                <!-- image/*, *.xlsx, *.xls, application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document, *.txt, *.pdf -->
-                <van-uploader
-                    v-model="dataModel"
-                    :before-read="beforeRead"
-                    :before-delete="beforeDelete"
-                    :after-read="afterRead"
-                    :disabled="options.disabled || false"
-                    :max-count="options.length"
-                    accept="image/*, *.xlsx, *.xls,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document, *.txt, *.pdf"
-                    preview-size="0.6rem">
-                    <!-- <template v-slot:preview-cover="props">
+          <!-- <template v-slot:preview-cover="props">
                         {{ props }}
                     </template> -->
-                    <!-- <template #preview-cover>
+          <!-- <template #preview-cover>
                         2323
                     </template> -->
-                </van-uploader>
-            </template>
-        </van-field>
-        <van-field
-            v-else
-            :name="widget.model"
-            :label="widget.name || '附件'"
-            class="preview"
-        >
-            <template #input>
-                <div class="preview_file" v-for="(item, index) in dataModel" :key="index">
-                    <div class="preview_item">
-                        <i class="van-icon van-icon-description van-uploader__file-icon"></i>
-                        <span style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;width: 2rem;">{{ item.name || item.url }}</span>
-                    </div>
-                    <div class="preview_btn">
-                        <van-button @click="downLoadFile2(item.url)" type="info" size="mini">下载</van-button>
-                        <van-button :disabled="!checkFileSuffix(item.url)" v-if="checkFileSuffix(item.url)" @click="downLoadFile(item.url)" type="info" size="mini">预览</van-button>
-                    </div>
-                </div>
-                <!-- <div class="van-uploader__preview" v-for="(item, index) in dataModel" :key="index">
+        </van-uploader>
+      </template>
+    </van-field>
+    <van-field v-else :name="widget.model" :label="widget.name || '附件'" class="preview">
+      <template #input>
+        <div class="preview_file" v-for="(item, index) in dataModel" :key="index">
+          <div class="preview_item">
+            <i class="van-icon van-icon-description van-uploader__file-icon"></i>
+            <span style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 2rem">{{ item.name || item.url }}</span>
+          </div>
+          <div class="preview_btn">
+            <van-button @click="downLoadFile2(item.url)" type="info" size="mini">下载</van-button>
+            <van-button :disabled="!checkFileSuffix(item.url)" v-if="checkFileSuffix(item.url)" @click="downLoadFile(item.url)" type="info" size="mini">预览</van-button>
+          </div>
+        </div>
+        <!-- <div class="van-uploader__preview" v-for="(item, index) in dataModel" :key="index">
                     <div class="van-uploader__file" style="width: 0.6rem; height: 0.6rem;" >
                         <i class="van-icon van-icon-description van-uploader__file-icon"></i>
                         <div class="van-uploader__file-name van-ellipsis">
@@ -56,269 +46,266 @@
                         <van-button :disabled="!checkFileSuffix(item.url)" @click="downLoadFile(item.url)" type="info" size="mini">预览</van-button>
                     </div>
                 </div> -->
-            </template>
-        </van-field>
+      </template>
+    </van-field>
 
-        <van-popup position="bottom" v-model="filePreview" style="height: 100%;border-radius: 0;">
-            <van-sticky>
-                <m-header :backUrl="backUrl" :isFixed="false" name="预览" />
-            </van-sticky>
-            <div id="previewIframe" style="height: calc(100vh - 0.44rem);" v-if="filePreview && (fileType == 'xls' || fileType == 'pdf')">
-            </div>
-            <div style="height: calc(100vh - 0.44rem);" v-if="filePreview && fileType == 'doc'">
-            </div>
-            <!-- <div ref="pdf" style="height: calc(100vh - 0.44rem);" v-if="filePreview && fileType == 'pdf'">
+    <van-popup position="bottom" v-model="filePreview" style="height: 100%; border-radius: 0">
+      <van-sticky>
+        <m-header :backUrl="backUrl" :isFixed="false" name="预览" />
+      </van-sticky>
+      <div id="previewIframe" style="height: calc(100vh - 0.44rem)" v-if="filePreview && (fileType == 'xls' || fileType == 'pdf')"></div>
+      <div style="height: calc(100vh - 0.44rem)" v-if="filePreview && fileType == 'doc'"></div>
+      <!-- <div ref="pdf" style="height: calc(100vh - 0.44rem);" v-if="filePreview && fileType == 'pdf'">
             </div> -->
-        </van-popup>
-    </div>
+    </van-popup>
+  </div>
 </template>
 <script>
-import MHeader from '@/components/MHeader'
-import setLoading from '@/common/loading'
-import { uploadFile, oaUploadFile } from '@/views/message/api'
-import { browser } from '@/common/common'
-import { postMessage } from '@/helpers/native-message'
+import MHeader from "@/components/MHeader";
+import setLoading from "@/common/loading";
+import { uploadFile, oaUploadFile } from "@/views/message/api";
+import { browser } from "@/common/common";
+import { postMessage } from "@/helpers/native-message";
 export default {
-    name: 'oFileUpload',
-    components: { MHeader },
-    props: ['widget', 'preview', 'value', 'fileCheck'],
-    data() {
-        // xls, doc, pdf
-        return {
-            dataModel: this.widget.options?.defaultValue || null,
-            filePreview: false,
-            fileType: 'xls',
-            previewUrl: '',
-            numPages: 1,
-            backUrl: {
-                status: true,
-                callBack: () => {
-                    this.filePreview = false;
-                },
-            },
+  name: "oFileUpload",
+  components: { MHeader },
+  props: ["widget", "preview", "value", "fileCheck"],
+  data() {
+    // xls, doc, pdf
+    return {
+      dataModel: this.widget.options?.defaultValue || null,
+      filePreview: false,
+      fileType: "xls",
+      previewUrl: "",
+      numPages: 1,
+      backUrl: {
+        status: true,
+        callBack: () => {
+          this.filePreview = false;
+        },
+      },
+    };
+  },
+  mounted() {
+    // 初始化参数
+    if (this.value) {
+      const widget = this.widget;
+      const model = widget.originModel || widget.model;
+      for (let v in this.value) {
+        if (v == model) {
+          this.dataModel = this.value[v];
         }
+      }
+    }
+  },
+  methods: {
+    checkFileSuffix(url) {
+      let urlArr = url.split(".");
+      let suffix = urlArr[urlArr.length - 1];
+      //  || suffix == 'doc' || suffix == 'docx'
+      if (suffix == "xlsx" || suffix == "xls" || suffix == "pdf") {
+        return true;
+      } else {
+        return false;
+      }
     },
-    mounted() {
-        // 初始化参数
-        if(this.value) {
-            const widget = this.widget
-            const model = widget.originModel || widget.model
-            for(let v in this.value) {
-                if(v == model) {
-                    this.dataModel = this.value[v]
-                }
-            }
+    getFileSuffix(url) {
+      let urlArr = url.split(".");
+      let suffix = urlArr[urlArr.length - 1];
+      if (suffix == "xlsx" || suffix == "xls") {
+        return "xls";
+      } else if (suffix == "doc" || suffix == "docx") {
+        return "doc";
+      } else if (suffix == "pdf") {
+        return "pdf";
+      } else {
+        return "";
+      }
+    },
+    beforeRead(file) {
+      const isLt2M = file.size / 1024 / 1024 < 5;
+      if (!isLt2M) {
+        this.$toast("上传文件大小不能超过 5MB");
+        return false;
+      }
+      return true;
+    },
+    beforeDelete(file, detail) {
+      this.dataModel.splice(detail.index, 1);
+      if (!this.dataModel || (this.dataModel && this.dataModel.length <= 0)) {
+        this.$emit("fileCheckRequired", false);
+      }
+      return true;
+    },
+    async afterRead(file, detail) {
+      // 上传头像
+      try {
+        setLoading(true);
+        file.status = "uploading";
+        file.message = "上传中...";
+        let formData = new FormData();
+        formData.append("file", file.file);
+        let res = null;
+        const query = this.$route.query;
+        if (query.processId) {
+          formData.append("processId", query.processId);
+          res = await oaUploadFile(formData);
+        } else {
+          res = await uploadFile(formData);
         }
+        let result = res.data;
+        if (result.code == 200) {
+          file.status = "done";
+          this.dataModel[detail.index] = {
+            url: result.data.url,
+            name: file.file.name,
+            file: {
+              name: file.file.name,
+            },
+          };
+          // 目前只对 退费模板做处理(id: 19)
+          if (query.processId == 19) {
+            this.$emit("fileCheckRequired", true);
+          }
+        } else {
+          file.status = "failed";
+          file.message = "上传失败";
+          this.$toast(result.msg);
+          this.dataModel.splice(detail.index, 1);
+          return false;
+        }
+        setLoading(false);
+      } catch (err) {
+        setLoading(false);
+        file.status = "failed";
+        file.message = "上传失败";
+        this.dataModel.splice(detail.index, 1);
+        return false;
+      }
     },
-    methods: {
-        checkFileSuffix(url) {
-            let urlArr = url.split('.')
-            let suffix = urlArr[urlArr.length-1]
-            //  || suffix == 'doc' || suffix == 'docx'
-            if(suffix == 'xlsx' || suffix == 'xls' || suffix == 'pdf') {
-                return true
-            } else {
-                return false
-            }
-        },
-        getFileSuffix(url) {
-            let urlArr = url.split('.')
-            let suffix = urlArr[urlArr.length-1]
-            if(suffix == 'xlsx' || suffix == 'xls') {
-                return 'xls'
-            } else if(suffix == 'doc' || suffix == 'docx') {
-                return 'doc'
-            } else if(suffix == 'pdf') {
-                return 'pdf'
-            } else {
-                return ''
-            }
-        },
-        beforeRead(file) {
-            const isLt2M = file.size / 1024 / 1024 < 5
-            if (!isLt2M) {
-                this.$toast('上传文件大小不能超过 5MB')
-                return false
-            }
-            return true
-        },
-        beforeDelete(file, detail) {
-            this.dataModel.splice(detail.index, 1)
-            if(!this.dataModel || this.dataModel && this.dataModel.length <= 0) {
-                this.$emit('fileCheckRequired', false)
-            }
-            return true
-        },
-        async afterRead(file, detail) { // 上传头像
-            try {
-                setLoading(true)
-                file.status = 'uploading'
-                file.message = '上传中...'
-                let formData = new FormData()
-                formData.append('file', file.file)
-                let res = null
-                const query = this.$route.query
-                if(query.processId) {
-                    formData.append('processId', query.processId)
-                    res = await oaUploadFile(formData)
-                } else {
-                    res = await uploadFile(formData)
-                }
-                let result = res.data
-                if(result.code == 200) {
-                    file.status = 'done'
-                    this.dataModel[detail.index] = {
-                        url: result.data.url,
-                        name: file.file.name,
-                        file: {
-                            name: file.file.name
-                        }
-                    }
-                    // 目前只对 退费模板做处理(id: 19)
-                    if(query.processId == 19) {
-                        this.$emit('fileCheckRequired', true)
-                    }
-                } else {
-                    file.status = 'failed'
-                    file.message = '上传失败'
-                    this.$toast(result.msg)
-                    this.dataModel.splice(detail.index, 1)
-                    return false
-                }
-                setLoading(false)
-            } catch (err) {
-                setLoading(false)
-                file.status = 'failed'
-                file.message = '上传失败'
-                this.dataModel.splice(detail.index, 1)
-                return false
-            }
-        },
-        downLoadFile2(file) {
-            this.$toast.loading({
-                duration: 0, // 持续展示 toast
-                forbidClick: true,
-                message: '下载中...',
-            })
-            if(browser().isApp) {
-                postMessage({ api: 'downloadFile', content: { downloadUrl: file } }, () => {
-                    this.$toast.clear()
-                })
+    downLoadFile2(file) {
+      this.$toast.loading({
+        duration: 0, // 持续展示 toast
+        forbidClick: true,
+        message: "下载中...",
+      });
+      if (browser().isApp) {
+        postMessage({ api: "downloadFile", content: { downloadUrl: file } }, () => {
+          this.$toast.clear();
+        });
+      } else {
+        this.$toast.clear();
+        window.location.href = file;
+      }
+    },
+    downLoadFile(file) {
+      // this.previewUrl = 'https://view.officeapps.live.com/op/view.aspx?src=' + file
+      this.filePreview = true;
+      this.fileType = this.getFileSuffix(file);
+
+      if (this.fileType == "xls" || this.fileType == "pdf") {
+        this.$toast.loading({
+          duration: 0, // 持续展示 toast
+          forbidClick: true,
+          message: "加载中...",
+        });
+        let _this = this;
+        this.$nextTick(() => {
+          let iframe = document.createElement("iframe");
+          iframe.id = "preview_iframe";
+          iframe.style.width = "100%";
+          iframe.style.height = "100%";
+          iframe.style.border = "none";
+          if (this.fileType == "xls") {
+            if (browser().android) {
+              iframe.src = "https://api.idocv.com/view/url?url=" + encodeURIComponent(file + "?times=" + new Date().getTime());
             } else {
-                this.$toast.clear()
-                window.location.href = file
+              iframe.src = "https://view.officeapps.live.com/op/view.aspx?src=" + file;
             }
-        },
-        downLoadFile(file) {
-            // this.previewUrl = 'https://view.officeapps.live.com/op/view.aspx?src=' + file
-            this.filePreview = true
-            this.fileType = this.getFileSuffix(file)
+          } else {
+            iframe.src = window.location.origin + location.pathname + "/pdf/web/viewer.html?file=" + encodeURIComponent(file);
+          }
+          if (iframe.attachEvent) {
+            iframe.attachEvent("onload", function () {
+              _this.$toast.clear();
+            });
+          } else {
+            iframe.onload = function () {
+              _this.$toast.clear();
 
-            if(this.fileType == 'xls' || this.fileType == 'pdf') {
-                this.$toast.loading({
-                    duration: 0, // 持续展示 toast
-                    forbidClick: true,
-                    message: '加载中...',
-                })
-                let _this = this
-                this.$nextTick(() => {
-                    let iframe = document.createElement("iframe");
-                    iframe.id = 'preview_iframe'
-                    iframe.style.width = '100%';
-                    iframe.style.height = '100%';
-                    iframe.style.border = 'none';
-                    if(this.fileType == 'xls') {
-                        if(browser().android) {
-                            iframe.src = 'https://api.idocv.com/view/url?url=' + encodeURIComponent(file + '?times=' + new Date().getTime())
-                        } else {
-                            iframe.src = 'https://view.officeapps.live.com/op/view.aspx?src=' + file
-                        }
-                    } else {
-                        iframe.src = window.location.origin + '/pdf/web/viewer.html?file=' + encodeURIComponent(file)
-                    }
-                    if (iframe.attachEvent){
-                        iframe.attachEvent("onload", function(){
-                            _this.$toast.clear()
-                        });
-                    } else {
-                        iframe.onload = function(){
-                            _this.$toast.clear()
-
-                            // setTimeout(() => {
-                            //     let dom =  document.querySelector('#preview_iframe').contentWindow.document
-                            //     let scripts = dom.querySelectorAll('script[src]')
-                            //     if(scripts)
-                            // }, 2000);
-                        };
-                    }
-                    document.querySelector('#previewIframe').appendChild(iframe);
-                })
-            } else if(this.fileType == 'doc') {
-            //     // this.previewUrl = 'https://view.officeapps.live.com/op/view.aspx?src=' + file
-
-            }
-        },
+              // setTimeout(() => {
+              //     let dom =  document.querySelector('#preview_iframe').contentWindow.document
+              //     let scripts = dom.querySelectorAll('script[src]')
+              //     if(scripts)
+              // }, 2000);
+            };
+          }
+          document.querySelector("#previewIframe").appendChild(iframe);
+        });
+      } else if (this.fileType == "doc") {
+        //     // this.previewUrl = 'https://view.officeapps.live.com/op/view.aspx?src=' + file
+      }
     },
-    computed: {
-        options() {
-            return this.widget.options || {}
-        },
-        rule() {
-            let rules = this.widget.rules || []
-            if(rules && rules.length > 0) {
-                rules.forEach(item => {
-                    if(item.pattern) {
-                        item.pattern = eval(item.pattern)
-                    }
-                    // 判断是否上传文件
-                    if(this.fileCheck) {
-                        item.required = false
-                    }
-                });
-            }
-            return rules
-        }
+  },
+  computed: {
+    options() {
+      return this.widget.options || {};
     },
-    watch: {
-        // dataModel: {
-        //     deep: true,
-        //     handler(newValue) {
-        //         if (newValue !== undefined && newValue !== null) {
-        //         }
-        //     }
-        // },
-    }
-}
+    rule() {
+      let rules = this.widget.rules || [];
+      if (rules && rules.length > 0) {
+        rules.forEach((item) => {
+          if (item.pattern) {
+            item.pattern = eval(item.pattern);
+          }
+          // 判断是否上传文件
+          if (this.fileCheck) {
+            item.required = false;
+          }
+        });
+      }
+      return rules;
+    },
+  },
+  watch: {
+    // dataModel: {
+    //     deep: true,
+    //     handler(newValue) {
+    //         if (newValue !== undefined && newValue !== null) {
+    //         }
+    //     }
+    // },
+  },
+};
 </script>
 
-<style lang='less' scoped>
-@import url('./controlCommon.less');
+<style lang="less" scoped>
+@import url("./controlCommon.less");
 .oFileUpload {
-    /deep/.van-uploader__wrapper--disabled {
-        opacity: 0.9;
-    }
-    /deep/.van-field__control--custom {
-        flex-wrap: wrap;
-    }
+  /deep/.van-uploader__wrapper--disabled {
+    opacity: 0.9;
+  }
+  /deep/.van-field__control--custom {
+    flex-wrap: wrap;
+  }
 
-    .preview_file {
-        width: 100%;
-        font-size: 14px;
-        display: flex;
-        justify-content: space-between;
-        background: #f7f7f7;
-        padding: .08rem;
-        margin-bottom: 0.08rem;
-        .preview_item {
-            display: flex;
-            padding-top: .03rem;
-            flex-basis: 70%;
-        }
-        .preview_btn {
-            text-align: right;
-            flex-basis: 30%;
-        }
+  .preview_file {
+    width: 100%;
+    font-size: 14px;
+    display: flex;
+    justify-content: space-between;
+    background: #f7f7f7;
+    padding: 0.08rem;
+    margin-bottom: 0.08rem;
+    .preview_item {
+      display: flex;
+      padding-top: 0.03rem;
+      flex-basis: 70%;
     }
+    .preview_btn {
+      text-align: right;
+      flex-basis: 30%;
+    }
+  }
 }
-
-</style>
+</style>