cameraScene.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <PageWrapper contentBackground>
  3. <template #footer>
  4. <a-tabs v-model:activeKey="tableType" @change="changeTable">
  5. <a-tab-pane :key="0" tab="四维看看" />
  6. <a-tab-pane :key="1" tab="四维看见" />
  7. <a-tab-pane :key="2" tab="四维深时" />
  8. <a-tab-pane :key="3" tab="四维双目Lite" /> </a-tabs
  9. ></template>
  10. <div class="desc-wrap-BasicTable">
  11. <BasicTable @register="registerTable">
  12. <template #toolbar>
  13. <!-- <a-button type="primary" @click="exportExcel"> 导出1</a-button> -->
  14. </template>
  15. <template #href="{ record }">
  16. <a v-if="record.sceneName" target="_blank" :href="record.thumb">{{record.sceneName}}</a>
  17. <span v-else>-</span>
  18. </template>
  19. <template #action="{ record }">
  20. <TableAction
  21. stopButtonPropagation
  22. :actions="[
  23. {
  24. label: '迁移',
  25. disabled:!(record.status == 1 || record.status == -2),
  26. ifShow:getTypeCheckPerm('scenes-move') && tableType != 3,
  27. onClick: handleMove.bind(null, record),
  28. },
  29. {
  30. label: '下载',
  31. ifShow:getTypeCheckPerm('scenes-download') && tableType != 3,
  32. disabled:!(record.status == 1 || (record.status == -2 && record.payStatus == 1)),
  33. //icon: 'carbon:download',
  34. onClick: handleDownload.bind(null, record),
  35. },
  36. {
  37. label: '重算',
  38. disabled: record.status == 0 || (record.status == -2 && record.payStatus != 1),
  39. ifShow:getTypeCheckPerm('scenes-recalculate') && tableType != 3,
  40. popConfirm: {
  41. title: '是否重算?',
  42. confirm: handleReset.bind(null, record),
  43. },
  44. },
  45. {
  46. label: '复制',
  47. disabled:!(record.status == 1 || (record.status == -2 && record.payStatus == 1)),
  48. ifShow:getTypeCheckPerm('scenes-copy') && tableType != 3,
  49. onClick: handleCopy.bind(null, record),
  50. },
  51. {
  52. label: '删除',
  53. //icon: 'ic:outline-delete-outline',
  54. color: 'error',
  55. ifShow:getTypeCheckPerm('scenes-delete'),
  56. disabled:record.status == 0,
  57. //onClick: handleDelete.bind(null, record),
  58. popConfirm: {
  59. title: '是否删除?',
  60. confirm: handleDelete.bind(null, record),
  61. placement: 'topRight',
  62. },
  63. },
  64. ]"
  65. />
  66. </template>
  67. </BasicTable>
  68. </div>
  69. <DownLoadModal
  70. :downloadOption="downloadOption"
  71. @cancel="afterClose"
  72. @register="registerDownModal"
  73. @update="reload"
  74. cancelText="取消下载"
  75. okText="下载"
  76. @cancelDownload="cancelDownload"
  77. :okButtonProps="{ disabled: canDownload }"
  78. />
  79. <MoveModal @register="registerMoveModal" />
  80. </PageWrapper>
  81. </template>
  82. <script lang="ts">
  83. import { defineComponent, h, reactive, toRefs, ref } from 'vue';
  84. import {
  85. BasicTable,
  86. useTable,
  87. TableAction,
  88. BasicColumn,
  89. TableImg,
  90. FormProps,
  91. } from '/@/components/Table';
  92. import { PageWrapper } from '/@/components/Page';
  93. import DownLoadModal from './modal/DownLoadModal.vue';
  94. import MoveModal from './modal/MoveModal.vue';
  95. import { Time } from '/@/components/Time';
  96. import { Descriptions, Tabs, Progress } from 'ant-design-vue';
  97. import { useI18n } from '/@/hooks/web/useI18n';
  98. import { useMessage } from '/@/hooks/web/useMessage';
  99. import { useModal } from '/@/components/Modal';
  100. import {
  101. operateSceneList,
  102. sceneMove,
  103. sceneDelete,
  104. sceneReset,
  105. sceneDownload,
  106. checkDownLoad,
  107. downloadProcess,
  108. sceneCopy,
  109. rebuildScene,
  110. } from '/@/api/operate';
  111. import { message } from 'ant-design-vue';
  112. import { usePermissionStore } from '/@/store/modules/permission';
  113. import { func } from 'vue-types';
  114. export default defineComponent({
  115. components: {
  116. DownLoadModal,
  117. MoveModal,
  118. BasicTable,
  119. TableAction,
  120. PageWrapper,
  121. [Descriptions.name]: Descriptions,
  122. [Descriptions.Item.name]: Descriptions.Item,
  123. [Tabs.name]: Tabs,
  124. [Tabs.TabPane.name]: Tabs.TabPane,
  125. },
  126. setup() {
  127. const { t } = useI18n();
  128. const { createMessage, createConfirm } = useMessage();
  129. const permissionStore = usePermissionStore();
  130. const { getCheckPerm } = permissionStore;
  131. const tableType = ref<Recordable>(0); //0看看 、1看见、2深时
  132. const tabList = ref<Array>(['四维看看', '四维看见', '四维深时', '四维双目Lite']);
  133. const columns: BasicColumn[] = [
  134. {
  135. title: '场景标题',
  136. dataIndex: 'sceneName',
  137. slots: { customRender: 'href' },
  138. width: 150,
  139. },
  140. {
  141. title: '场景码',
  142. dataIndex: 'num',
  143. ellipsis: true,
  144. width: 180,
  145. },
  146. {
  147. title: '拍摄时间',
  148. dataIndex: 'createTime',
  149. width: 180,
  150. customRender: ({ record }) => {
  151. return (
  152. record.createTime &&
  153. h(Time, {
  154. value: record.createTime,
  155. mode: 'datetime',
  156. })
  157. );
  158. },
  159. },
  160. {
  161. title: '计算完成时间',
  162. dataIndex: 'amount',
  163. width: 180,
  164. customRender: ({ record }) => {
  165. return (
  166. record.algorithmTime &&
  167. h(Time, {
  168. value: record.algorithmTime,
  169. mode: 'datetime',
  170. })||'-'
  171. );
  172. },
  173. },
  174. {
  175. title: 'SN码',
  176. dataIndex: 'snCode',
  177. width: 180,
  178. },
  179. {
  180. title: '场景大小',
  181. dataIndex: 'sceneSize',
  182. width: 80,
  183. customRender: ({ record }) => {
  184. return (record.sceneSize && record.sceneSize != 0)?h(
  185. 'span',
  186. { class: 'sceneSize' },
  187. Math.ceil(record.sceneSize / 1024 / 1024) + 'M',
  188. ):'-';
  189. },
  190. },
  191. {
  192. title: '是否复制',
  193. dataIndex: 'isCopy',
  194. width: 80,
  195. customRender: ({ record }) => {
  196. return record.isCopy ? '是' : '否';
  197. },
  198. },
  199. {
  200. title: '复制时间',
  201. dataIndex: 'copyTime',
  202. width: 180,
  203. customRender: ({ record }) => {
  204. return record.copyTime
  205. ? h(Time, {
  206. value: record.copyTime,
  207. mode: 'datetime',
  208. })
  209. : '-';
  210. },
  211. },
  212. {
  213. title: '绑定账号',
  214. dataIndex: 'userName',
  215. width: 100,
  216. },
  217. {
  218. title: '浏览量',
  219. dataIndex: 'viewCount',
  220. width: 80,
  221. },
  222. {
  223. title: '状态',
  224. dataIndex: 'status',
  225. width: 80,
  226. customRender: ({ record }) => {
  227. let str;
  228. switch (record.status - 0) {
  229. case 0:
  230. str = '计算中';
  231. break;
  232. case 1:
  233. str = '计算成功';
  234. break;
  235. case -2:
  236. str = '计算成功';
  237. break;
  238. case -1:
  239. str = '计算失败';
  240. break;
  241. }
  242. return record.payStatus == -2 ? '封存' : str;
  243. },
  244. },
  245. {
  246. title: '操作',
  247. dataIndex: 'action',
  248. slots: { customRender: 'action' },
  249. ifShow: true,
  250. fixed: 'right',
  251. flag: 'ACTION',
  252. width: 250,
  253. },
  254. ];
  255. const searchForm: Partial<FormProps> = {
  256. labelWidth: 100,
  257. schemas: [
  258. {
  259. field: 'sceneName',
  260. label: '场景标题',
  261. component: 'Input',
  262. componentProps: {
  263. maxLength: 100,
  264. },
  265. colProps: {
  266. xl: 7,
  267. xxl: 7,
  268. },
  269. },
  270. {
  271. field: 'snCode',
  272. label: 'SN码',
  273. component: 'Input',
  274. componentProps: {
  275. maxLength: 100,
  276. },
  277. colProps: {
  278. xl: 7,
  279. xxl: 7,
  280. },
  281. },
  282. {
  283. field: 'userName',
  284. label: '绑定账号',
  285. component: 'Input',
  286. componentProps: {
  287. maxLength: 100,
  288. },
  289. colProps: {
  290. xl: 6,
  291. xxl: 6,
  292. },
  293. },
  294. ],
  295. };
  296. function cancelDownload() {
  297. downloadOption.value = {};
  298. }
  299. const [registerDownModal, { openModal: openDownModal }] = useModal();
  300. const [registerMoveModal, { openModal: openMoveModal }] = useModal();
  301. const [registerTable, { reload }] = useTable({
  302. api: operateSceneList,
  303. title: `场景列表`,
  304. // titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
  305. columns: columns,
  306. searchInfo: { type: tableType },
  307. useSearchForm: true,
  308. formConfig: searchForm,
  309. showTableSetting: true,
  310. rowKey: 'num',
  311. fetchSetting: {
  312. pageField: 'pageNum',
  313. sizeField: 'pageSize',
  314. listField: 'list',
  315. totalField: 'total',
  316. },
  317. canResize: true,
  318. });
  319. function changeTable(val: string) {
  320. tableType.value = val;
  321. reload();
  322. }
  323. async function handleCopy(record: Recordable) {
  324. createConfirm({
  325. title: '复制场景',
  326. content: '复制场景,场景归属在原相机下。<br/>确定要复制场景吗?',
  327. onOk: async () => {
  328. sceneCopy({ num: record.num })
  329. .then(() => {
  330. message.success({
  331. content: '复制成功',
  332. });
  333. })
  334. },
  335. });
  336. }
  337. async function handleDelete(record: Recordable) {
  338. console.log('handleDelete', record);
  339. // createConfirm({
  340. // title: '删除',
  341. // content: '确定要删除场景吗?',
  342. // onOk: async () => {
  343. sceneDelete({ num: record.num })
  344. .then(() => {
  345. message.success({
  346. content: '删除成功',
  347. });
  348. reload();
  349. })
  350. // },
  351. // });
  352. }
  353. async function handleMove(record: Recordable) {
  354. openMoveModal(true, {
  355. ...record,
  356. });
  357. // sceneMove({ snCode: record.snCode, num: record.num })
  358. // .then(() => {
  359. // message.success({
  360. // content: '迁移成功',
  361. // });
  362. // })
  363. // .catch(() => {
  364. // message.success({
  365. // content: '迁移失败',
  366. // });
  367. // });
  368. }
  369. let timer: null = ref(null);
  370. const downloadOption = ref<Object>({});
  371. const canDownload = ref<boolean>(true);
  372. function handleDownload(record: Recordable) {
  373. console.log('handleDownload', record,canDownload.value);
  374. canDownload.value = true;
  375. checkDownLoad({ num: record.num }).then((res) => {
  376. console.log(res);
  377. if (res.downloadStatus != 3) {
  378. // 未下载过,需要打包
  379. sceneDownload({ num: record.num }).then((res) => {
  380. console.log(res);
  381. openDownModal(true, {
  382. ...record,
  383. });
  384. if (res.downloadStatus == 1) {
  385. if (timer.value) {
  386. afterClose();
  387. }
  388. timer.value = setInterval(() => {
  389. downloadProcess({ num: record.num }).then((res) => {
  390. if(res.status == '1003'){
  391. createMessage.error('下载失败');
  392. afterClose();
  393. return
  394. }
  395. if (res.percent >= 100) {
  396. canDownload.value = false;
  397. afterClose();
  398. }
  399. downloadOption.value = res;
  400. console.log(res);
  401. });
  402. }, 1000);
  403. }
  404. });
  405. } else {
  406. canDownload.value = false;
  407. window.open(res.downloadUrl);
  408. }
  409. });
  410. }
  411. function afterClose() {
  412. clearInterval(timer.value);
  413. timer.value = null;
  414. }
  415. function handleReset(record: Recordable) {
  416. console.log('handleReset', record);
  417. rebuildScene({ num: record.num })
  418. .then(() => {
  419. message.success({
  420. content: '操作成功',
  421. });
  422. reload();
  423. })
  424. }
  425. function getTypeCheckPerm(val){
  426. let myType = tableType.value
  427. return getCheckPerm(val) || getCheckPerm(`${val}-${myType}`)
  428. }
  429. return {
  430. registerTable,
  431. handleDelete,
  432. handleCopy,
  433. handleMove,
  434. handleDownload,
  435. handleReset,
  436. tableType,
  437. changeTable,
  438. t,
  439. openDownModal,
  440. registerDownModal,
  441. registerMoveModal,
  442. afterClose,
  443. timer,
  444. canDownload,
  445. downloadOption,
  446. cancelDownload,
  447. getTypeCheckPerm,
  448. };
  449. },
  450. });
  451. </script>
  452. <style lang="less" scoped>
  453. // .tableHeader {
  454. // height: 50px;
  455. // display: flex;
  456. // align-items: center;
  457. // .item {
  458. // font-size: 14px;
  459. // color: #666;
  460. // margin-right: 10px;
  461. // cursor: pointer;
  462. // &.active {
  463. // font-weight: bold;
  464. // color: #222;
  465. // }
  466. // }
  467. // }
  468. .desc-wrap-BasicTable {
  469. background-color: #f0f2f5;
  470. .vben-basic-table-form-container {
  471. padding: 0;
  472. }
  473. }
  474. </style>