123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- <template>
- <div class="hc-layout-box">
- <div :style="`width:${leftWidth}px;`" class="hc-layout-left-box bg-white">
- <template v-if="dataType === 1">
- <div class="hc-project-box">
- <div class="hc-project-icon-box">
- <HcIcon name="stack" />
- </div>
- <div class="project-name-box ml-2">
- <span class="project-alias">{{ projectInfo.projectName }}</span>
- </div>
- </div>
- <div v-if="dataType === 1" class="hc-tree-box">
- <el-scrollbar>
- <WbsTree
- :auto-expand-keys="TreeAutoExpandKeys" :contract-id="contractId" :project-id="projectId"
- :class-id="dataId" @node-tap="nodeWbsElTreeClick"
- />
- </el-scrollbar>
- </div>
- </template>
- <div v-else class="hc-tree-box date-tree">
- <el-scrollbar v-if="dataType === 2">
- <HcTreeData
- :auto-expand-keys="TreeExpandedKeys" :datas="dateElTreeData"
- @node-tap="dateWbsElTreeClick"
- />
- </el-scrollbar>
- </div>
-
- <div class="horizontal-drag-line" @mousedown="onmousedown" />
- </div>
- <div class="hc-layout-content-box">
- <HcNewCard :scrollbar="false" action-size="lg">
- <template #header>
- <HcTooltip keys="image-data-add">
- <el-button :disabled="!queryKey && dataType === 1" hc-btn type="primary" @click="addFormFile">
- <HcIcon name="add_box" />
- <span>新增文件</span>
- </el-button>
- </HcTooltip>
- <HcTooltip keys="image-data-download">
- <el-button
- :disabled="tableCheckedKeys.length <= 0" :loading="downloadLoading" hc-btn
- @click="downloadClick"
- >
- <HcIcon name="download" />
- <span>下载</span>
- </el-button>
- </HcTooltip>
- <HcTooltip keys="image-data-del">
- <el-button
- :disabled="tableCheckedKeys.length <= 0" :loading="delLoading" hc-btn
- @click="delClick"
- >
- <HcIcon name="delete" />
- <span>删除</span>
- </el-button>
- </HcTooltip>
- </template>
- <template #extra>
- <div class="w-60">
- <el-input v-model="searchForm.queryStr" clearable placeholder="根据题名名称或拍摄者搜索" @keyup="keyUpEvent" />
- </div>
- <div class="ml-2">
- <el-button type="primary" @click="searchClick">搜索</el-button>
- </div>
- </template>
- <HcTable
- ref="tableListRef" :column="tableListColumn" :datas="tableListData" :loading="tableLoading"
- is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
- @selection-change="tableSelectionChange"
- >
- <template #info="{ row }">
- <div class="hc-table-col-item">
- <div v-if="row.type !== 1" class="img-box">
- <HcImg :src="setImageUrl(row.imageUrl)" class="hc-image" :is-https="isHttps" />
- </div>
- <div v-else class="img-box">
- <video :src="row.imageUrl">
- 您的浏览器不支持 video
- </video>
- </div>
- <div class="content-box">
- <div class="text-cut title">{{ row.title }}</div>
- <div class="shootingUser">拍摄者:{{ row.shootingUser }}</div>
- <div class="shootingTimeStr">拍摄时间:{{ row.shootingTimeStr }}</div>
- <div class="fileSize">文件大小:{{ row.fileSize }}</div>
- </div>
- </div>
- </template>
- <template #operate="{ row }">
- <HcTooltip keys="image-data-preview">
- <el-button
- :loading="previewLoading" size="small" text type="primary"
- @click="previewClick(row)"
- >
- 查看
- </el-button>
- </HcTooltip>
- <HcTooltip keys="image-data-edit">
- <el-button size="small" text type="primary" @click="editClick(row)">编辑</el-button>
- </HcTooltip>
- </template>
- </HcTable>
- <template #action>
- <div class="lr-dialog-footer">
- <div class="left">
- <el-button size="large" @click="goToBack">
- <HcIcon name="arrow-go-back" />
- <span>返回</span>
- </el-button>
- </div>
- <div class="right">
- <HcPages :pages="searchForm" @change="pageChange" />
- </div>
- </div>
- </template>
- </HcNewCard>
- </div>
-
- <hc-new-dialog v-model="previewVideoModal" title="预览" widths="47rem">
- <video
- v-if="previewVideoUrl" :src="previewVideoUrl" autoplay="autoplay" class="preview-video"
- controls="controls"
- >
- 您的浏览器不支持 video
- </video>
- </hc-new-dialog>
- </div>
- </template>
- <script setup>
- import { onActivated, onMounted, ref, watch } from 'vue'
- import { useAppStore } from '~src/store'
- import { useRoute, useRouter } from 'vue-router'
- import WbsTree from './components/WbsTree.vue'
- import HcTreeData from './components/HcTreeData.vue'
- import imageApi from '~api/other-file/imageData'
- import { getStoreValue, setStoreValue } from '~src/utils/storage'
- import { arrToId, downloadBlob, getArrValue } from 'js-fast-way'
- import { HcDelMsg } from 'hc-vue3-ui'
- import { toPdfPage } from '~uti/btn-auth'
- import website from '~src/config'
- const router = useRouter()
- const useRoutes = useRoute()
- const useAppState = useAppStore()
- const projectId = ref(useAppState.getProjectId)
- const contractId = ref(useAppState.getContractId)
- const projectInfo = ref(useAppState.getProjectInfo)
- const isCollapse = ref(useAppState.getCollapse)
- const routerQuery = useRoutes?.query
- const dataId = ref(routerQuery?.id || '')
- const dataType = ref(parseInt(routerQuery?.type + '') )
- const fileType = ref(parseInt(routerQuery?.fileType + '') || 2)
- watch(() => [
- useAppState.getCollapse,
- useAppState.getContractId,
- ], ([Collapse, ContractId]) => {
- isCollapse.value = Collapse
- contractId.value = ContractId
- })
- watch(() => [
- useRoutes?.query,
- ], ([query]) => {
- console.log(query, 'query')
- dataId.value = query?.id || ''
- dataType.value = parseInt(query?.type + '')
- fileType.value = parseInt(query?.fileType + '') || 2
- searchForm.value.classifyId = query?.id || ''
- initMounted()
- }, { deep: true })
- watch(contractId, (val) => {
- if (val) {
- console.log(val)
- router.push({
- path: '/other-file/image-data',
- })
- }
- })
- const TreeAutoExpandKeys = ref([])
- const TreeExpandedKeys = ref([])
- const TreeCurrentNodeKey = ref(getStoreValue('TreeCurrentNodeKey') || '')
- const isHttps = ref(false)
- onMounted(() => {
- isHttps.value = !website.localModel
- })
- onActivated(()=>{
- initMounted()
- })
- const initMounted = () => {
- console.log('onMounted')
- const nodeKey = TreeCurrentNodeKey.value
- if (dataType.value === 1) {
- TreeAutoExpandKeys.value = getStoreValue('TreeExpandKeys') || []
- } else {
- TreeExpandedKeys.value = getStoreValue('TreeExpandedKeys') || []
- }
- if (dataType.value === 2 && dataId.value) {
- getYearDateTree()
- queryKey.value = nodeKey
-
- if (isNaN(queryKey.value) && !isNaN(Date.parse(queryKey.value))) {
- queryKey.value = ''
- }
- searchForm.value.queryDate = nodeKey
- searchForm.value.current = 1
- getTableData()
- } else {
- queryKey.value = ''
- getTableData()
- }
- }
- const dateElTreeData = ref([])
- const getYearDateTree = async () => {
- const { error, code, data } = await imageApi.getYearDateTree({
- projectId: projectId.value,
- contractId: contractId.value,
- classifyId: dataId.value,
- })
-
- if (!error && code === 200) {
- dateElTreeData.value = getArrValue(data)
- } else {
- dateElTreeData.value = []
- }
- }
- const nodeDataInfo = ref({})
- const dateWbsElTreeClick = ({ data, keys, key }) => {
-
- queryKey.value = ''
- nodeDataInfo.value = data
-
- TreeExpandedKeys.value = keys
- TreeCurrentNodeKey.value = key
- setStoreValue('TreeExpandedKeys', keys)
- setStoreValue('TreeCurrentNodeKey', key)
-
- searchForm.value.queryDate = data['hierarchy'] || ''
- searchForm.value.wbsIdsStr = null
- searchForm.value.current = 1
- getTableData()
- }
- const nodeWbsElTreeClick = ({ data, keys }) => {
- searchForm.value.wbsIdsStr = data?.primaryKeyId || ''
- if (data?.notExsitChild === true) {
- nodeDataInfo.value = data
- queryKey.value = data['primaryKeyId'] || ''
-
- TreeAutoExpandKeys.value = keys
- setStoreValue('TreeExpandKeys', keys)
-
- searchForm.value.queryDate = null
-
- searchForm.value.current = 1
- getTableData()
- } else {
- getTableData()
- queryKey.value = ''
- nodeDataInfo.value = {}
- searchForm.value.queryDate = null
- searchForm.value.wbsIdsStr = null
- tableListData.value = []
- searchForm.value.total = 0
- }
- }
- const queryKey = ref(null)
- const searchForm = ref({
- queryStr: null, classifyId: dataId.value, wbsIdsStr: null,
- current: 1, size: 20, total: 0,
- })
- const keyUpEvent = (e) => {
- if (e.key === 'Enter') {
- searchClick()
- }
- }
- const searchClick = () => {
- if (queryKey.value) {
- searchForm.value.current = 1
- getTableData()
- } else {
- window?.$message?.warning('请先在左边选择一个树节点')
- }
- }
- const pageChange = ({ current, size }) => {
- searchForm.value.current = current
- searchForm.value.size = size
- getTableData()
- }
- const tableListRef = ref(null)
- const tableLoading = ref(false)
- const tableListData = ref([])
- const tableListColumn = ref([
- { key: 'info', name: '文件详情' },
- { key: 'textContent', name: '文字说明' },
- { key: 'operate', name: '操作', align: 'center', width: '140' },
- ])
- const getTableData = async () => {
- tableLoading.value = true
- const { error, code, data } = await imageApi.getPageList({
- ...searchForm.value,
- projectId: projectId.value,
- contractId: contractId.value,
- })
-
- tableLoading.value = false
- if (!error && code === 200) {
- tableListData.value = getArrValue(data['records'])
- searchForm.value.total = data['total'] || 0
- } else {
- tableListData.value = []
- searchForm.value.total = 0
- }
- }
- const tableCheckedKeys = ref([])
- const tableSelectionChange = (rows) => {
- tableCheckedKeys.value = rows.filter((item) => {
- return (item ?? '') !== ''
- })
- }
- const setImageUrl = (url) => {
- if (url) {
- const urlArr = url.split(',')
- if (urlArr.length > 0 && urlArr[0]) {
- return urlArr[0]
- } else {
- return ''
- }
- } else {
- return ''
- }
- }
- const previewVideoUrl = ref('')
- const previewVideoModal = ref(false)
- const previewLoading = ref(false)
- const previewClick = async (item) => {
- const { id, type, imageUrl, margePdfUrl } = item
- console.log(parseInt(type), 'parseInt(type)')
- if (parseInt(type) === 1 ) {
- if (imageUrl) {
- previewVideoUrl.value = imageUrl
- previewVideoModal.value = true
- } else {
- window.$message?.warning('暂无可预览的资料文件')
- }
- } else if (parseInt(type) === 2 || type === null || type === -1) {
- if (margePdfUrl) {
- toPdfPage(margePdfUrl)
-
- } else {
- window.$message?.warning('暂无可预览的资料文件')
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
- const addFormFile = () => {
- router.push({
- path: '/other-file/image-form',
- query: {
- wbsId: queryKey.value,
- dataType: dataType.value,
- fileType: fileType.value,
- classifyId: dataId.value,
- },
- })
- }
- const editClick = ({ id }) => {
- router.push({
- path: '/other-file/image-form',
- query: {
- wbsId: queryKey.value,
- dataType: dataType.value,
- fileType: fileType.value,
- classifyId: dataId.value,
- id: id,
- },
- })
- }
- const downloadLoading = ref(false)
- const downloadClick = async () => {
- const rows = tableCheckedKeys.value
- if (rows.length > 0) {
- downloadLoading.value = true
- const ids = arrToId(rows)
- const { error, disposition, res } = await imageApi.batchDownloadFileToZip({ ids: ids }, false)
-
- if (!error) {
- if (disposition) {
- downloadBlob(res, disposition)
- } else {
- window.$message?.error('下载异常')
- }
- }
- } else {
- window.$message?.warning('请先勾选需要下载的资料文件')
- }
- }
- const delLoading = ref(false)
- const delClick = () => {
- const rows = tableCheckedKeys.value
- if (rows.length > 0) {
- const ids = arrToId(rows)
- HcDelMsg( async ( resolve) => {
- await removeImageclassifyFile(ids)
- resolve()
- })
- } else {
- window.$message?.warning('请先勾选需要删除的资料文件')
- }
- }
- const removeImageclassifyFile = async (ids) => {
- delLoading.value = true
- const { error, code } = await imageApi.removeImageclassifyFile({ ids: ids }, false)
-
- delLoading.value = false
- if (!error && code === 200) {
- window.$message?.success('删除成功')
- getTableData()
- } else {
- window.$message?.error('删除异常')
- }
- }
- const goToBack = () => {
- router.push({ path: '/other-file/image-data' })
- }
- const leftWidth = ref(dataType.value === 1 ? 382 : 220)
- const onmousedown = () => {
- const leftNum = isCollapse.value ? 142 : 272
- document.onmousemove = (ve) => {
- const diffVal = ve.clientX - leftNum
- const minWidth = dataType.value === 1 ? 310 : 200
- const maxWidth = dataType.value === 1 ? 900 : 300
- if (diffVal >= minWidth && diffVal <= maxWidth) {
- leftWidth.value = diffVal
- }
- }
- document.onmouseup = () => {
- document.onmousemove = null
- document.onmouseup = null
- }
- }
- </script>
- <style lang="scss" scoped>
- @import '../../styles/other-file/image-view.scss';
- </style>
- <style lang="scss">
- .preview-video {
- width: 100%;
- }
- </style>
|