123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <template>
- <view>
- <view class="ordertop">
- <view>
- <view class="iconblue"></view>
- <text class="license">附件</text>
- </view>
- <view class="line">
- <u-line color="#ccc" border-style='dashed'/>
- </view>
- <view class="basic" v-for="(item,index) in list" :key="index">
- <view>{{item.fName}}</view>
- <view>
- <u-button type="primary" :ripple="true" ripple-bg-color="#909399" size="mini"
- @click="previewDocx(item.fUrl)">{{progress?'进度:'+progress:'查看'}}</u-button>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- form: {},
- progress:'',
- list: []
- }
- },
- onLoad(option) {
- this.form = JSON.parse(option.item)
- this.$u.get('/warehouseBusiness/enclosure/infoByPid', {
- pId: 946
- }).then(res => {
- this.list = res.data
- })
- },
- methods: {
- //预览
- previewDocx(item){
- if(item == null){
- uni.showToast({
- icon: 'none',
- title: '无附件',
- position: "bottom"
- })
- }else{
- uni.downloadFile({
- url: item,
- success: (res) => {
- if (res.statusCode === 200) {
- const downloadTask = uni.openDocument({
- filePath: res.tempFilePath,
- // 如果文件名包含中文,建议使用escape(res.tempFilePath)转码,防止ios和安卓客户端导致的差异
- success: function(res) {
- uni.showToast({
- icon: 'none',
- title: '打开附件成功',
- position: "bottom"
- })
- },
- fail:function(res){
- uni.showToast({
- icon: 'none',
- title: '打开附件失败',
- position: "bottom"
- })
- }
- });
- downloadTask.onProgressUpdate((res) => {
- this.progress = res.progress
- });
- }
- }
- })
- }
- },
- }
- }
- </script>
- <style scoped lang="scss">
- .ordertop {
- width: 96%;
- background-color: #fff;
- margin: 20rpx auto;
- border-radius: 20rpx;
- padding-top: 20rpx;
- box-shadow: 0px 0px 8px 0px rgba(165, 189, 251, 0.4);
- padding-bottom: 10rpx;
- }
-
- .ordertop>view:nth-child(1) {
- width: 98%;
- margin-bottom: 60rpx;
- }
- .iconblue {
- width: 10rpx;
- height: 45rpx;
- float: left;
- background-color: #3a63cf;
- margin-right: 10rpx;
- }
- .line {
- width: 92%;
- margin: 0 auto;
- }
-
- .various {
- float: right;
- width: 150rpx;
- border: 2rpx solid #3a63cf;
- text-align: center;
- border-radius: 100rpx;
- color: #3a63cf;
- }
- .basic {
- width: 94%;
- margin: 10rpx auto;
- display: flex;
- justify-content: space-between;
- }
-
- .basic>view {
- margin-bottom: 10rpx;
- }
-
- .basic>view:nth-child(1) {
- color: #797979;
- }
- </style>
|