Browse Source

修复文件预览打不开的问题

master
parent
commit
4e15d4f17a
  1. 224
      sub/task/detail.vue

224
sub/task/detail.vue

@ -1,8 +1,11 @@
<template> <template>
<cs-page> <cs-page>
<view class="detail-container" :style="{ <view
class="detail-container"
:style="{
paddingBottom: isSelect.length > 0 ? '140rpx' : '40rpx' paddingBottom: isSelect.length > 0 ? '140rpx' : '40rpx'
}"> }"
>
<view class="box detail"> <view class="box detail">
<text class="wd-font-800 wd-text-16" style="color: #071437"> <text class="wd-font-800 wd-text-16" style="color: #071437">
{{ detail.title }} {{ detail.title }}
@ -16,14 +19,24 @@
$dict.echoDicValue(dictMap.task_priority, detail.priority) $dict.echoDicValue(dictMap.task_priority, detail.priority)
}} }}
</view> </view>
<view v-for="(tag, index) in detail.tagList" :key="index" class="tag"> <view
v-for="(tag, index) in detail.tagList"
:key="index"
class="tag"
>
{{ tag }} {{ tag }}
</view> </view>
</view> </view>
<view class="wd-flex wd-text-13" style="justify-content: space-between"> <view
class="wd-flex wd-text-13"
style="justify-content: space-between"
>
<view class="wd-flex" style="align-items: center; gap: 8rpx"> <view class="wd-flex" style="align-items: center; gap: 8rpx">
<u-icon name="calendar" color="#17C653" size="16" /> <u-icon name="calendar" color="#17C653" size="16" />
<text class="wd-text-13" style="font-weight: bold; margin-right: 8rpx"> <text
class="wd-text-13"
style="font-weight: bold; margin-right: 8rpx"
>
{{ {{
`${$util.formatDate( `${$util.formatDate(
detail.startDate, detail.startDate,
@ -35,39 +48,69 @@
</view> </view>
<cs-text-more :value="detail.description" /> <cs-text-more :value="detail.description" />
<view class="file-list" v-if="files && files.length > 0"> <view class="file-list" v-if="files && files.length > 0">
<view class="file" v-for="(file, index) in files" :key="index" @click="openFile(file)" <view
style="cursor: pointer; width: 48%;"> class="file"
v-for="(file, index) in files"
:key="index"
@click="openFile(file)"
>
<u-icon name="attach" color="#17C653" size="16" /> <u-icon name="attach" color="#17C653" size="16" />
<text class="name" style="var(--LightMode-Grey-Grey-900, #071437);">{{ file.name }}</text> <text
class="name"
style="var(--LightMode-Grey-Grey-900, #071437);"
>
{{ file.name }}
</text>
</view> </view>
</view> </view>
<view class="audit"> <view class="audit">
<cs-dict-tag :dict="dictMap.task_state" :value="detail.status"></cs-dict-tag> <cs-dict-tag
:dict="dictMap.task_state"
:value="detail.status"
></cs-dict-tag>
</view> </view>
</view> </view>
<u-sticky> <u-sticky>
<view :class="[ <view
:class="[
'options-container', 'options-container',
OptionsOffset.isTop ? 'isTop' : '' OptionsOffset.isTop ? 'isTop' : ''
]" ref="optionRef" id="options"> ]"
ref="optionRef"
id="options"
>
<van-dropdown-menu active-color="#17C653" style="flex: 1"> <van-dropdown-menu active-color="#17C653" style="flex: 1">
<van-dropdown-item v-if="showItem(['director'])" :value="queryParams.departmentId" <van-dropdown-item
:options="dropOption.dept" @change=" v-if="showItem(['director'])"
:value="queryParams.departmentId"
:options="dropOption.dept"
@change="
v => { v => {
querySelect(v, 'departmentId') querySelect(v, 'departmentId')
} }
" /> "
<van-dropdown-item v-if="showItem(['queue', 'director'])" :value="queryParams.userId" use-before-toggle />
@before-toggle="getUserOption" :options="userList" @change=" <van-dropdown-item
v-if="showItem(['queue', 'director'])"
:value="queryParams.userId"
use-before-toggle
@before-toggle="getUserOption"
:options="userList"
@change="
v => { v => {
querySelect(v, 'userId') querySelect(v, 'userId')
} }
" /> "
<van-dropdown-item :value="queryParams.Inspections_status" :options="dropOption.status" @change=" />
<van-dropdown-item
:value="queryParams.Inspections_status"
:options="dropOption.status"
@change="
v => { v => {
querySelect(v, 'inspectionsStatus') querySelect(v, 'inspectionsStatus')
} }
" /> "
/>
</van-dropdown-menu> </van-dropdown-menu>
<view style="flex: 0 0 120rpx"> <view style="flex: 0 0 120rpx">
<text style="color: #17c653">{{ list.length }}</text> <text style="color: #17c653">{{ list.length }}</text>
@ -75,11 +118,20 @@
</view> </view>
</view> </view>
</u-sticky> </u-sticky>
<view class="record" v-for="record in list" :key="record.id" @tap="goRecord(record)"> <view
<view :class="{ class="record"
v-for="record in list"
:key="record.id"
@tap="goRecord(record)"
>
<view
:class="{
select: true, select: true,
isSelect: isSelect.includes(record.id) isSelect: isSelect.includes(record.id)
}" @tap.native.stop="select(record.id)" v-if="['3', null].includes(record.inspectionStatus)"> }"
@tap.native.stop="select(record.id)"
v-if="['3', null].includes(record.inspectionStatus)"
>
<u-icon name="checkbox-mark" size="16" color="#fff"></u-icon> <u-icon name="checkbox-mark" size="16" color="#fff"></u-icon>
</view> </view>
<view class="disable" v-else></view> <view class="disable" v-else></view>
@ -87,7 +139,8 @@
<view class="name"> <view class="name">
{{ record.enterpriseName }} {{ record.enterpriseName }}
</view> </view>
<view style=" <view
style="
font-size: 26rpx; font-size: 26rpx;
padding-right: 3rem; padding-right: 3rem;
margin-bottom: 4rpx; margin-bottom: 4rpx;
@ -95,26 +148,44 @@
text-overflow: ellipsis; text-overflow: ellipsis;
width: 528rpx; width: 528rpx;
overflow: hidden; overflow: hidden;
"> "
>
{{ record.enterpriseAddress }} {{ record.enterpriseAddress }}
</view> </view>
<view class="tagList" style="margin-top: 16rpx"> <view class="tagList" style="margin-top: 16rpx">
<view v-for="(item, index) in record.tagList" :key="index" class="tag"> <view
v-for="(item, index) in record.tagList"
:key="index"
class="tag"
>
{{ item }} {{ item }}
</view> </view>
</view> </view>
</view> </view>
<view class="audit" v-show="record.inspectionStatus"> <view class="audit" v-show="record.inspectionStatus">
<cs-dict-tag :dict="dictMap.Inspections_status" :value="record.inspectionStatus"></cs-dict-tag> <cs-dict-tag
:dict="dictMap.Inspections_status"
:value="record.inspectionStatus"
></cs-dict-tag>
</view> </view>
</view> </view>
<u-loadmore :status="load" marginTop="12" marginBottom="12" v-if="load != 'nomore'" /> <u-loadmore
:status="load"
marginTop="12"
marginBottom="12"
v-if="load != 'nomore'"
/>
<view class="btn-box" v-if="isSelect.length > 0"> <view class="btn-box" v-if="isSelect.length > 0">
<view class="confirm-btn" @tap="replay"> <view class="confirm-btn" @tap="replay">
已选择({{ isSelect.length }}) 已选择({{ isSelect.length }})
</view> </view>
</view> </view>
<u-modal :show="model.show" closeOnClickOverlay @close="closeModel" borderRadius="32rpx"> <u-modal
:show="model.show"
closeOnClickOverlay
@close="closeModel"
borderRadius="32rpx"
>
<view class="wd-flex wd-flex-col" style="gap: 20px"> <view class="wd-flex wd-flex-col" style="gap: 20px">
<view class="header"> <view class="header">
<view class="row-1"> <view class="row-1">
@ -125,17 +196,31 @@
<view class="row-2">每次只能选择一人</view> <view class="row-2">每次只能选择一人</view>
</view> </view>
<view class="staff-list"> <view class="staff-list">
<view class="staff" v-for="staff in model.list" :key="staff.userId" :style="{ <view
class="staff"
v-for="staff in model.list"
:key="staff.userId"
:style="{
'--select-color': '--select-color':
model.isSelect == staff.userId ? '#17c653' : '#f1f1f4' model.isSelect == staff.userId ? '#17c653' : '#f1f1f4'
}" @click="selectUser(staff.userId)"> }"
<u-avatar size="40" shape="circle" :src="staff.avatar"></u-avatar> @click="selectUser(staff.userId)"
>
<u-avatar
size="40"
shape="circle"
:src="staff.avatar"
></u-avatar>
<view class="info"> <view class="info">
<view class="name">{{ staff.realName }}</view> <view class="name">{{ staff.realName }}</view>
<view class="dept">{{ staff.roleName[0] }}</view> <view class="dept">{{ staff.roleName[0] }}</view>
</view> </view>
<view class="isSelect"> <view class="isSelect">
<u-icon name="checkbox-mark" size="16px" color="#fff"></u-icon> <u-icon
name="checkbox-mark"
size="16px"
color="#fff"
></u-icon>
</view> </view>
</view> </view>
</view> </view>
@ -151,19 +236,10 @@
</template> </template>
<script> <script>
import { import { getDeptTree, getDictBatchByType } from '@/api/system/dict.js'
getDeptTree, import { TaskApi } from '@/api/task/index.js'
getDictBatchByType import { InspectionsApi } from '@/api/inspections/index.js'
} from '@/api/system/dict.js' import { getUserList } from '@/api/system/user.js'
import {
TaskApi
} from '@/api/task/index.js'
import {
InspectionsApi
} from '@/api/inspections/index.js'
import {
getUserList
} from '@/api/system/user.js'
export default { export default {
data() { data() {
return { return {
@ -199,10 +275,12 @@
list: [], list: [],
isSelect: '' isSelect: ''
}, },
userList: [{ userList: [
{
value: '', value: '',
text: '按人员' text: '按人员'
}], }
],
// //
dropOption: { dropOption: {
dept: [], dept: [],
@ -233,21 +311,25 @@
}, },
methods: { methods: {
openFile(file) { openFile(file) {
uni.downloadFile({ uni.downloadFile({
url: file.url, url: file.url,
success: function (res) { success: function (res) {
var filePath = res.tempFilePath; const filePath = res.tempFilePath
uni.openDocument({ uni.openDocument({
filePath: filePath, filePath: filePath,
showMenu: true, showMenu: true,
success: function (res) { fail(err) {
console.log('打开文档成功'); uni.showToast({
title: '文件打开失败',
icon: 'none'
})
} }
}); })
},
fail(err) {
uni.showToast({ title: '文件下载失败', icon: 'none' })
} }
}); })
}, },
getOptionOffset() { getOptionOffset() {
const query = uni.createSelectorQuery().in(this) const query = uni.createSelectorQuery().in(this)
@ -276,7 +358,8 @@
dept: dept.data dept: dept.data
} }
this.dropOption = { this.dropOption = {
dept: [{ dept: [
{
value: '', value: '',
text: '按部门' text: '按部门'
}, },
@ -287,7 +370,8 @@
} }
}) })
], ],
status: [{ status: [
{
value: '', value: '',
text: '按状态' text: '按状态'
}, },
@ -364,9 +448,7 @@
icon: 'loading' icon: 'loading'
}) })
this.load = 'loading' this.load = 'loading'
const { const { data } = await InspectionsApi.getList({
data
} = await InspectionsApi.getList({
...this.queryParams, ...this.queryParams,
taskId: this.detail.id taskId: this.detail.id
}) })
@ -379,11 +461,10 @@
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
uni.hideToast() uni.hideToast()
}, },
getUserOption({ getUserOption({ detail }) {
detail
}) {
this.getUser().then(res => { this.getUser().then(res => {
this.userList = [{ this.userList = [
{
value: '', value: '',
text: '按人员' text: '按人员'
}, },
@ -508,24 +589,25 @@
.file-list { .file-list {
border-radius: 4px; border-radius: 4px;
background: var(--LightMode-Grey-Grey-100, #F9F9F9); background: var(--LightMode-Grey-Grey-100, #f9f9f9);
padding: 8rpx 16rpx; padding: 8rpx 16rpx;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 24rpx; gap: 24rpx;
width: 100%; width: 100%;
.file { .file {
display: flex; display: flex;
flex-flow: row nowarp; flex-flow: row nowarp;
gap: 8rpx; gap: 8rpx;
cursor: pointer;
align-items: center;
.name { .name {
color: var(--LightMode-Grey-Grey-900, #071437); color: var(--LightMode-Grey-Grey-900, #071437);
font-family: "PingFang SC"; font-family: 'PingFang SC';
font-size: 24rpx; font-size: 26rpx;
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
line-height: normal; line-height: 160%;
text-decoration-line: underline; text-decoration-line: underline;
text-decoration-style: solid; text-decoration-style: solid;
text-decoration-skip-ink: auto; text-decoration-skip-ink: auto;
@ -688,9 +770,11 @@
top: 0; top: 0;
width: 30px; width: 30px;
height: 30px; height: 30px;
background-image: linear-gradient(45deg, background-image: linear-gradient(
45deg,
rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0) 50%,
var(--select-color, #f1f1f4) 50%); var(--select-color, #f1f1f4) 50%
);
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
align-items: flex-start; align-items: flex-start;

Loading…
Cancel
Save