image-view.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <div class="hc-layout-box">
  3. <div class="hc-layout-left-box" :style="'width:' + leftWidth + 'px;'">
  4. <template v-if="dataType === 1">
  5. <div class="hc-project-box">
  6. <div class="hc-project-icon-box">
  7. <HcIcon name="layers"/>
  8. </div>
  9. <div class="ml-2 project-name-box">
  10. <span class="text-xl text-cut project-alias">{{projectInfo['projectAlias']}}</span>
  11. <div class="text-xs text-cut project-name">{{projectInfo['name']}}</div>
  12. </div>
  13. </div>
  14. <div class="hc-tree-box">
  15. <el-scrollbar>
  16. <WbsTree :autoExpandKeys="TreeAutoExpandKeys" :projectId="projectId" :contractId="contractId" @nodeTap="nodeWbsElTreeClick"/>
  17. </el-scrollbar>
  18. </div>
  19. </template>
  20. <div class="hc-tree-box date-tree" v-else>
  21. <el-scrollbar>
  22. <HcTreeData :datas="dateElTreeData" :autoExpandKeys="TreeExpandedKeys" @nodeTap="dateWbsElTreeClick"/>
  23. </el-scrollbar>
  24. </div>
  25. <!--左右拖动-->
  26. <div class="horizontal-drag-line" @mousedown="onmousedown"/>
  27. </div>
  28. <div class="hc-layout-content-box">
  29. <HcCard :scrollbar="false" actionSize="lg">
  30. <template #header>
  31. <HcTooltip keys="image-data-add">
  32. <el-button type="primary" hc-btn :disabled="!queryKey" @click="addFormFile">
  33. <HcIcon name="add_box"/>
  34. <span>新增文件</span>
  35. </el-button>
  36. </HcTooltip>
  37. <HcTooltip keys="image-data-download">
  38. <el-button hc-btn :disabled="tableCheckedKeys.length <= 0" @click="downloadClick">
  39. <HcIcon name="download"/>
  40. <span>下载</span>
  41. </el-button>
  42. </HcTooltip>
  43. <HcTooltip keys="image-data-del">
  44. <el-button hc-btn :disabled="tableCheckedKeys.length <= 0" @click="delClick">
  45. <HcIcon name="delete"/>
  46. <span>删除</span>
  47. </el-button>
  48. </HcTooltip>
  49. </template>
  50. <template #extra>
  51. <div class="w-60">
  52. <el-input v-model="searchForm.queryStr" size="large" placeholder="根据题名名称或拍摄者搜索" clearable @keyup="keyUpEvent"/>
  53. </div>
  54. <div class="ml-2">
  55. <el-button type="primary" size="large" @click="searchClick">搜索</el-button>
  56. </div>
  57. </template>
  58. <el-scrollbar>
  59. <div class="hc-table-ref-box">
  60. <el-table ref="tableListRef" hc :data="tableListData" :loading="tableLoading" stripe @selection-change="tableSelectionChange">
  61. <el-table-column type="selection" width="50" />
  62. <el-table-column prop="num" label="序号" width="80">
  63. <template #default="scope">
  64. {{scope.$index + 1}}
  65. </template>
  66. </el-table-column>
  67. <el-table-column prop="info" label="文件详情">
  68. <template #default="scope">
  69. <div class="hc-table-col-item">
  70. <div class="img-box" v-if="scope.row.type !== 1">
  71. <HcImg class="hc-image" :src="setImageUrl(scope.row.imageUrl)"/>
  72. </div>
  73. <div class="img-box" v-else>
  74. <video :src="scope.row.imageUrl">
  75. 您的浏览器不支持 video
  76. </video>
  77. </div>
  78. <div class="content-box">
  79. <div class="text-cut title">{{scope.row.title}}</div>
  80. <div class="shootingUser">拍摄者:{{scope.row.shootingUser}}</div>
  81. <div class="shootingTimeStr">拍摄时间:{{scope.row.shootingTimeStr}}</div>
  82. <div class="fileSize">文件大小:{{scope.row.fileSize}}</div>
  83. </div>
  84. </div>
  85. </template>
  86. </el-table-column>
  87. <el-table-column prop="textContent" label="文字说明"/>
  88. <el-table-column label="操作" align="center" width="130">
  89. <template #default="scope">
  90. <HcTooltip keys="image-data-preview">
  91. <el-button type="primary" size="small" text @click="previewClick(scope.row)">查看</el-button>
  92. </HcTooltip>
  93. <HcTooltip keys="image-data-edit">
  94. <el-button type="primary" size="small" text @click="editClick(scope.row)">编辑</el-button>
  95. </HcTooltip>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. </div>
  100. </el-scrollbar>
  101. <template #action>
  102. <div class="lr-dialog-footer">
  103. <div class="left">
  104. <el-button size="large" @click="goToBack">返回上级</el-button>
  105. </div>
  106. <div class="right">
  107. <HcPages :pages="searchForm" @change="pageChange"/>
  108. </div>
  109. </div>
  110. </template>
  111. </HcCard>
  112. </div>
  113. <!--视频预览 弹框-->
  114. <el-dialog v-model="previewVideoModal" title="预览" width="47rem" destroy-on-close custom-class="hc-modal-border">
  115. <video class="preview-video" :src="previewVideoUrl" controls="controls" autoplay="autoplay" v-if="previewVideoUrl">
  116. 您的浏览器不支持 video
  117. </video>
  118. </el-dialog>
  119. </div>
  120. </template>
  121. <script setup>
  122. import {onMounted, ref, watch} from 'vue'
  123. import {useAppStore} from "~src/store";
  124. import {useRouter, useRoute} from 'vue-router'
  125. import WbsTree from "./components/WbsTree.vue"
  126. import HcTreeData from "./components/HcTreeData.vue"
  127. import imageApi from '~api/other-file/imageData';
  128. import {getStoreData, setStoreData} from '~src/utils/storage'
  129. import {getArrValue,getObjNullValue} from "vue-utils-plus"
  130. //变量
  131. const router = useRouter()
  132. const useRoutes = useRoute()
  133. const useAppState = useAppStore()
  134. const projectId = ref(useAppState.getProjectId);
  135. const contractId = ref(useAppState.getContractId);
  136. const projectInfo = ref(useAppState.getProjectInfo);
  137. const isCollapse = ref(useAppState.getCollapse)
  138. //路由参数
  139. const routerQuery = useRoutes?.query;
  140. //存储目录格式 1按部位存储,2按日期存储
  141. const dataId = routerQuery?.id || '';
  142. const dataType = parseInt(routerQuery?.type + '') || 1;
  143. const fileType = parseInt(routerQuery?.fileType + '') || 2;
  144. //监听
  145. watch(() => [
  146. useAppState.getCollapse
  147. ], ([Collapse]) => {
  148. isCollapse.value = Collapse
  149. })
  150. //自动展开缓存
  151. const TreeAutoExpandKeys = ref(getStoreData('TreeExpandKeys') || [])
  152. const TreeExpandedKeys = ref(getStoreData('TreeExpandedKeys') || [])
  153. const TreeCurrentNodeKey = ref(getStoreData('TreeCurrentNodeKey') || '')
  154. //渲染完成
  155. onMounted(() => {
  156. const nodeKey = TreeCurrentNodeKey.value
  157. if (dataType === 2 && dataId) {
  158. getYearDateTree()
  159. queryKey.value = nodeKey
  160. searchForm.value.queryDate = nodeKey
  161. searchForm.value.current = 1;
  162. getTableData()
  163. } else {
  164. queryKey.value = ''
  165. }
  166. })
  167. //获取时间结构
  168. const dateElTreeData = ref([])
  169. const getYearDateTree = async () => {
  170. const { error, code, data } = await imageApi.getYearDateTree({
  171. projectId: projectId.value,
  172. contractId: contractId.value,
  173. classifyId: dataId
  174. })
  175. //处理数据
  176. if (!error && code === 200) {
  177. dateElTreeData.value = getArrValue(data)
  178. } else {
  179. dateElTreeData.value = []
  180. }
  181. }
  182. //日期树被点击
  183. const nodeDataInfo = ref({})
  184. const dateWbsElTreeClick = ({data, keys, key}) => {
  185. queryKey.value = key
  186. nodeDataInfo.value = data
  187. //缓存自动展开
  188. TreeExpandedKeys.value = keys
  189. TreeCurrentNodeKey.value = key
  190. setStoreData('TreeExpandedKeys', keys)
  191. setStoreData('TreeCurrentNodeKey', key)
  192. //改变搜索表单数据
  193. searchForm.value.queryDate = data['hierarchy'] || ''
  194. searchForm.value.wbsIdsStr = null
  195. searchForm.value.current = 1;
  196. getTableData()
  197. }
  198. //项目树被点击
  199. const nodeWbsElTreeClick = ({data, keys}) => {
  200. if (data.leaf === true) {
  201. nodeDataInfo.value = data
  202. queryKey.value = data['primaryKeyId'] || ''
  203. //缓存自动展开
  204. TreeAutoExpandKeys.value = keys
  205. setStoreData('TreeExpandKeys', keys)
  206. //改变搜索表单数据
  207. searchForm.value.queryDate = null
  208. searchForm.value.wbsIdsStr = data?.primaryKeyId || ''
  209. searchForm.value.current = 1;
  210. getTableData()
  211. } else {
  212. queryKey.value = ''
  213. nodeDataInfo.value = {}
  214. searchForm.value.queryDate = null
  215. searchForm.value.wbsIdsStr = null
  216. tableListData.value = []
  217. searchForm.value.total = 0
  218. }
  219. }
  220. //搜索和分页数据
  221. const queryKey = ref(null)
  222. const searchForm = ref({
  223. queryStr: null, classifyId: dataId, wbsIdsStr: null,
  224. current: 1, size: 20, total: 0
  225. })
  226. //回车搜索
  227. const keyUpEvent = (e) => {
  228. if (e.key === "Enter") {
  229. searchClick()
  230. }
  231. }
  232. //搜索
  233. const searchClick = () => {
  234. if (queryKey.value) {
  235. searchForm.value.current = 1;
  236. getTableData()
  237. } else {
  238. window?.$message?.warning('请先在左边选择一个树节点')
  239. }
  240. }
  241. //分页被点击
  242. const pageChange = ({current, size}) => {
  243. searchForm.value.current = current
  244. searchForm.value.size = size
  245. getTableData()
  246. }
  247. //获取数据
  248. const tableListRef = ref(null)
  249. const tableLoading = ref(false)
  250. const tableListData = ref([])
  251. const getTableData = async () => {
  252. tableLoading.value = true
  253. const {error, code, data} = await imageApi.getPageList({
  254. ...searchForm.value,
  255. projectId: projectId.value,
  256. contractId: contractId.value
  257. })
  258. //判断状态
  259. tableLoading.value = false
  260. if (!error && code === 200) {
  261. tableListData.value = getArrValue(data['records'])
  262. searchForm.value.total = data['total'] || 0
  263. } else {
  264. tableListData.value = []
  265. searchForm.value.total = 0
  266. }
  267. }
  268. //多选
  269. const tableCheckedKeys = ref([]);
  270. const tableSelectionChange = (rows) => {
  271. tableCheckedKeys.value = rows.filter((item) => {
  272. return (item??'') !== '';
  273. })
  274. }
  275. //处理图片预览问题
  276. const setImageUrl = (url) => {
  277. if (url) {
  278. const urlArr = url.split(',')
  279. if (urlArr.length > 0 && urlArr[0]) {
  280. return urlArr[0]
  281. } else {
  282. return ''
  283. }
  284. } else {
  285. return ''
  286. }
  287. }
  288. //预览
  289. const previewVideoUrl = ref('')
  290. const previewVideoModal = ref(false)
  291. const previewClick = async ({id,type,imageUrl}) => {
  292. if (imageUrl) {
  293. if (parseInt(type) === 1) {
  294. previewVideoUrl.value = imageUrl
  295. previewVideoModal.value = true
  296. } else {
  297. const {error, code, data} = await imageApi.imageClassificationFile({ids: id}, false)
  298. //判断状态
  299. const imgUrl = getObjNullValue(data)
  300. if (!error && code === 200 && imgUrl) {
  301. window.open(data?.data,"_blank");
  302. } else {
  303. window.$message?.warning('预览资料文件异常');
  304. }
  305. }
  306. } else {
  307. window.$message?.warning('暂无可预览的资料文件');
  308. }
  309. }
  310. //新增文件
  311. const addFormFile = () => {
  312. router.push({
  313. path: '/other-file/image-form',
  314. query: {
  315. wbsId: queryKey.value, //树节点ID
  316. dataType: dataType, //存储目录格式 1按部位存储,2按日期存储
  317. fileType: fileType, //文件类型,1视频文件,2图片文件
  318. classifyId: dataId, //classifyId,分类ID,
  319. }
  320. })
  321. }
  322. //编辑修改
  323. const editClick = ({id}) => {
  324. router.push({
  325. path: '/other-file/image-form',
  326. query: {
  327. wbsId: queryKey.value, //树节点ID
  328. dataType: dataType, //存储目录格式 1按部位存储,2按日期存储
  329. fileType: fileType, //文件类型,1视频文件,2图片文件
  330. classifyId: dataId, //classifyId,分类ID,
  331. id: id //数据ID
  332. }
  333. })
  334. }
  335. //下载文件
  336. const downloadClick = () => {
  337. /*let url = imageUrl || '';
  338. if (url) {
  339. let urlArr = url.split(',')
  340. if (urlArr.length === 1) {
  341. window.open(urlArr[0],"_blank");
  342. } else {
  343. imageData.batchDownloadFileToZip({ids: id}).then(res => {
  344. download(res) //下载文件
  345. })
  346. }
  347. } else {
  348. window.$message?.warning('暂无可下载的资料文件');
  349. }*/
  350. }
  351. //删除文件
  352. const delClick = () => {
  353. /*imageData.removeImageclassifyFile({
  354. ids: item.id
  355. }).then(({data}) => {
  356. if (data.code === 200) {
  357. window.$message?.success('删除成功')
  358. getTableData()
  359. } else {
  360. window.$message?.error(data.msg || '删除异常')
  361. }
  362. })*/
  363. }
  364. //回到影像资料页
  365. const goToBack = () => {
  366. router.push({path: '/other-file/image-data'})
  367. }
  368. //左右拖动,改变树形结构宽度
  369. const leftWidth = ref(382);
  370. const onmousedown = () => {
  371. const leftNum = isCollapse.value ? 142 : 272
  372. document.onmousemove = (ve) => {
  373. let diffVal = ve.clientX - leftNum;
  374. if(diffVal >= 310 && diffVal <= 900) {
  375. leftWidth.value = diffVal;
  376. }
  377. }
  378. document.onmouseup = () => {
  379. document.onmousemove = null;
  380. document.onmouseup = null;
  381. }
  382. }
  383. </script>
  384. <style lang="scss" scoped>
  385. @import '../../styles/other-file/image-view.scss';
  386. </style>
  387. <style lang="scss">
  388. </style>