cameraScene.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <template>
  2. <div class="scren">
  3. <div class="noScene" v-if="qrCodeUrl.show">
  4. <div class="noScene-content">
  5. <p>您还没有场景,请使用手机扫二维码安装App后连接相机拍摄后上传</p>
  6. <div class="codelist">
  7. <div class="codediv">
  8. <QrCode
  9. :value="qrCodeUrl.android"
  10. class="enter-x flex justify-center xl:justify-start"
  11. :width="128"
  12. />
  13. <div class="codetext">
  14. <Icon icon="uiw:android" :size="20" />
  15. Android
  16. </div>
  17. </div>
  18. <div class="codediv">
  19. <QrCode
  20. :value="qrCodeUrl.ios"
  21. class="enter-x flex justify-center xl:justify-start"
  22. :width="128"
  23. />
  24. <div class="codetext">
  25. <Icon icon="ic:twotone-apple" :size="20" />
  26. iOS
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. <PageWrapper v-else contentBackground>
  33. <template #footer>
  34. <a-tabs v-model:activeKey="tableType" @change="changeTable">
  35. <!-- <a-tab-pane :key="0" tab="四维看看" :disabled="loading"/> -->
  36. <a-tab-pane :key="1" tab="四维看见" :disabled="loading" />
  37. <!-- <a-tab-pane :key="2" tab="四维深时" :disabled="loading"/>
  38. <a-tab-pane :key="3" tab="四维双目Lite" :disabled="loading"/>
  39. <a-tab-pane :key="4" tab="四维全景" :disabled="loading"/> -->
  40. <a-tab-pane :key="2" tab="深时点云场景" :disabled="loading" />
  41. <a-tab-pane :key="5" tab="深时Mesh场景" :disabled="loading" />
  42. <a-tab-pane :key="6" tab="深光点云场景" :disabled="loading" />
  43. <a-tab-pane :key="7" tab="深光Mesh场景" :disabled="loading" /> </a-tabs
  44. ></template>
  45. <div class="desc-wrap-BasicTable">
  46. <BasicTable @register="registerTable">
  47. <template #toolbar>
  48. <!-- <a-button type="primary" @click="exportExcel"> 导出1</a-button> -->
  49. </template>
  50. <template #href="{ record }">
  51. <a
  52. v-if="record.status == 1 || (record.status == -2 && record.payStatus == 1)"
  53. target="_blank"
  54. :title="record.sceneName"
  55. :href="record.webSite"
  56. >{{ record.sceneName }}</a
  57. >
  58. <span v-else-if="record.sceneName">{{ record.sceneName }}</span>
  59. <span v-else>-</span>
  60. </template>
  61. <template #action="{ record }">
  62. <TableAction
  63. stopButtonPropagation
  64. :actions="[
  65. {
  66. label: '编辑',
  67. disabled: !(record.status == 1 || record.status == -2),
  68. ifShow: getTypeCheckPerm('scenes-edit') && tableType != 3 && record.isEdit,
  69. onClick: handlegotoEdit.bind(null, record),
  70. },
  71. {
  72. label: '权限',
  73. disabled: !(record.status == 1 || record.status == -2) || !record.isAuth,
  74. ifShow: getTypeCheckPerm('scenes-powers'),
  75. onClick: handlePowers.bind(null, record),
  76. },
  77. {
  78. label: '迁移',
  79. disabled: !(record.status == 1 || record.status == -2),
  80. ifShow:
  81. getTypeCheckPerm('scenes-move') &&
  82. tableType != 3 &&
  83. (record.userName == userInfo.userName ||
  84. userInfo.roleId == 1 ||
  85. userInfo.roleId == 45),
  86. onClick: handleMove.bind(null, record),
  87. },
  88. {
  89. label: '下载',
  90. ifShow:
  91. getTypeCheckPerm('scenes-download') &&
  92. tableType != 3 &&
  93. (record.userName == userInfo.userName ||
  94. userInfo.roleId == 1 ||
  95. userInfo.roleId == 45),
  96. disabled: !(record.status == 1 || (record.status == -2 && record.payStatus == 1)),
  97. //icon: 'carbon:download',
  98. onClick: handleDownload.bind(null, record),
  99. },
  100. {
  101. label: '重算',
  102. disabled: record.status == 0 || (record.status == -2 && record.payStatus != 1),
  103. ifShow:
  104. getTypeCheckPerm('scenes-recalculate') &&
  105. tableType != 3 &&
  106. (userInfo.roleId == 1 || userInfo.roleId == 45),
  107. popConfirm: {
  108. title: '是否重算?',
  109. confirm: handleReset.bind(null, record),
  110. },
  111. },
  112. {
  113. label: '复制',
  114. disabled: !(record.status == 1 || (record.status == -2 && record.payStatus == 1)),
  115. ifShow:
  116. getTypeCheckPerm('scenes-copy') &&
  117. tableType != 3 &&
  118. (record.userName == userInfo.userName ||
  119. userInfo.roleId == 1 ||
  120. userInfo.roleId == 45),
  121. onClick: handleCopy.bind(null, record),
  122. },
  123. {
  124. label: '生成 obj',
  125. ifShow:
  126. getTypeCheckPerm('scenes-creatobj') &&
  127. record.status == -2 &&
  128. (tableType == 2 || tableType == 6) &&
  129. (record.userName == userInfo.userName ||
  130. userInfo.roleId == 1 ||
  131. userInfo.roleId == 45),
  132. onClick: handleGenerate.bind(null, record),
  133. },
  134. {
  135. label: '删除',
  136. //icon: 'ic:outline-delete-outline',
  137. color: 'error',
  138. ifShow:
  139. getTypeCheckPerm('scenes-delete') &&
  140. (record.userName == userInfo.userName ||
  141. userInfo.roleId == 1 ||
  142. userInfo.roleId == 45),
  143. disabled: record.status == 0,
  144. //onClick: handleDelete.bind(null, record),
  145. popConfirm: {
  146. title: '是否删除?',
  147. confirm: handleDelete.bind(null, record),
  148. placement: 'topRight',
  149. },
  150. },
  151. ]"
  152. />
  153. </template>
  154. </BasicTable>
  155. </div>
  156. <DownLoadModal
  157. :downloadOption="downloadOption"
  158. @cancel="afterClose"
  159. @register="registerDownModal"
  160. @update="reload"
  161. cancelText="取消下载"
  162. okText="下载"
  163. @cancelDownload="cancelDownload"
  164. :okButtonProps="{ disabled: canDownload }"
  165. />
  166. <MoveModal @register="registerMoveModal" />
  167. <PowersModal @register="registerPowersModal" />
  168. </PageWrapper>
  169. </div>
  170. </template>
  171. <script lang="ts">
  172. import { defineComponent, h, computed, toRefs, ref, onMounted } from 'vue';
  173. import Icon from '/@/components/Icon/index';
  174. import dayjs from 'dayjs';
  175. import { QrCode } from '/@/components/Qrcode/index';
  176. import {
  177. BasicTable,
  178. useTable,
  179. TableAction,
  180. BasicColumn,
  181. TableImg,
  182. FormProps,
  183. } from '/@/components/Table';
  184. import { PageWrapper } from '/@/components/Page';
  185. import DownLoadModal from './modal/DownLoadModal.vue';
  186. import MoveModal from './modal/MoveModal.vue';
  187. import PowersModal from './modal/PowersModal.vue';
  188. import { Time } from '/@/components/Time';
  189. import { Descriptions, Tabs, Progress } from 'ant-design-vue';
  190. import { useI18n } from '/@/hooks/web/useI18n';
  191. import { useMessage } from '/@/hooks/web/useMessage';
  192. import { useModal } from '/@/components/Modal';
  193. import {
  194. operateSceneList,
  195. sceneMove,
  196. sceneDelete,
  197. sceneReset,
  198. sceneDownload,
  199. checkDownLoad,
  200. downloadProcess,
  201. sceneCopy,
  202. rebuildScene,
  203. buildSceneObj,
  204. sceneDetail,
  205. sceneCount,
  206. } from '/@/api/operate';
  207. import { message } from 'ant-design-vue';
  208. import { usePermissionStore } from '/@/store/modules/permission';
  209. import { useUserStore } from '/@/store/modules/user';
  210. import { func } from 'vue-types';
  211. export default defineComponent({
  212. components: {
  213. DownLoadModal,
  214. MoveModal,
  215. PowersModal,
  216. BasicTable,
  217. TableAction,
  218. PageWrapper,
  219. [Descriptions.name]: Descriptions,
  220. [Descriptions.Item.name]: Descriptions.Item,
  221. QrCode,
  222. Icon,
  223. // [Tabs.name]: Tabs,
  224. // [Tabs.TabPane?.name]: Tabs.TabPane,
  225. },
  226. setup() {
  227. const { t } = useI18n();
  228. const { createMessage, createConfirm } = useMessage();
  229. const userStore = useUserStore();
  230. const userInfo = computed(() => userStore.getUserInfo);
  231. const permissionStore = usePermissionStore();
  232. const { getCheckPerm } = permissionStore;
  233. const loading = ref(false);
  234. const tableType = ref<Recordable>(1); //0看看 、1看见、2深时
  235. const tabList = ref<Array>(['四维看看', '四维看见', '四维深时', '四维双目Lite']);
  236. const qrCodeUrl = ref({
  237. show: false,
  238. ios: 'https://sit-nanhuacs.4dage.com/web/index.html#/login',
  239. android: 'https://sit-nanhuacs.4dage.com/web/index.html#/login',
  240. });
  241. const columns: BasicColumn[] = [
  242. {
  243. title: '场景标题',
  244. dataIndex: 'sceneName',
  245. ellipsis: true,
  246. slots: { customRender: 'href' },
  247. resizable: true,
  248. minWidth: 150,
  249. width: 150,
  250. },
  251. {
  252. title: '场景码',
  253. dataIndex: 'num',
  254. ellipsis: true,
  255. width: 180,
  256. },
  257. {
  258. title: '拍摄时间',
  259. dataIndex: 'createTime',
  260. width: 180,
  261. customRender: ({ record }) => {
  262. return (
  263. record.createTime &&
  264. h(Time, {
  265. value: record.createTime,
  266. mode: 'datetime',
  267. })
  268. );
  269. },
  270. },
  271. {
  272. title: '计算完成时间',
  273. dataIndex: 'amount',
  274. width: 180,
  275. customRender: ({ record }) => {
  276. return (
  277. (record.algorithmTime &&
  278. h(Time, {
  279. value: record.algorithmTime,
  280. mode: 'datetime',
  281. })) ||
  282. '-'
  283. );
  284. },
  285. },
  286. {
  287. title: 'SN码',
  288. dataIndex: 'snCode',
  289. width: 180,
  290. },
  291. {
  292. title: '场景大小',
  293. dataIndex: 'sceneSize',
  294. width: 80,
  295. customRender: ({ record }) => {
  296. return record.sceneSize && record.sceneSize != 0
  297. ? h('span', { class: 'sceneSize' }, Math.ceil(record.sceneSize / 1024 / 1024) + 'M')
  298. : '-';
  299. },
  300. },
  301. {
  302. title: '是否复制',
  303. dataIndex: 'isCopy',
  304. width: 80,
  305. customRender: ({ record }) => {
  306. return record.isCopy ? '是' : '否';
  307. },
  308. },
  309. {
  310. title: '复制时间',
  311. dataIndex: 'copyTime',
  312. width: 180,
  313. customRender: ({ record }) => {
  314. return record.copyTime
  315. ? h(Time, {
  316. value: record.copyTime,
  317. mode: 'datetime',
  318. })
  319. : '-';
  320. },
  321. },
  322. {
  323. title: '人员编号',
  324. dataIndex: 'userName',
  325. width: 100,
  326. },
  327. {
  328. title: t('routes.staff.userName'),
  329. dataIndex: 'nickName',
  330. width: 100,
  331. customRender: ({ record }) => {
  332. return record.nickName || '-';
  333. },
  334. },
  335. {
  336. title: '浏览量',
  337. dataIndex: 'viewCount',
  338. width: 80,
  339. },
  340. {
  341. title: '状态',
  342. dataIndex: 'status',
  343. width: 80,
  344. customRender: ({ record }) => {
  345. let str;
  346. switch (record.status - 0) {
  347. case 0:
  348. str = '计算中';
  349. break;
  350. case 1:
  351. str = '计算成功';
  352. break;
  353. case -2:
  354. str = '计算成功';
  355. break;
  356. case -1:
  357. str = '计算失败';
  358. break;
  359. }
  360. return record.payStatus == -2 ? '封存' : str;
  361. },
  362. },
  363. {
  364. title: '操作',
  365. dataIndex: 'action',
  366. slots: { customRender: 'action' },
  367. ifShow: true,
  368. fixed: 'right',
  369. flag: 'ACTION',
  370. width: 400,
  371. },
  372. ];
  373. const searchForm: Partial<FormProps> = {
  374. labelWidth: 100,
  375. autoSubmitOnEnter: true,
  376. autoAdvancedLine: 1,
  377. schemas: [
  378. {
  379. field: 'sceneName',
  380. label: '场景标题',
  381. component: 'Input',
  382. componentProps: {
  383. maxLength: 100,
  384. },
  385. colProps: {
  386. xl: 7,
  387. xxl: 7,
  388. },
  389. },
  390. {
  391. field: 'snCode',
  392. label: 'SN码',
  393. component: 'Input',
  394. componentProps: {
  395. maxLength: 100,
  396. },
  397. colProps: {
  398. xl: 7,
  399. xxl: 7,
  400. },
  401. },
  402. {
  403. field: 'num',
  404. label: '场景码',
  405. component: 'Input',
  406. componentProps: {
  407. maxLength: 100,
  408. },
  409. colProps: {
  410. xl: 6,
  411. xxl: 6,
  412. },
  413. },
  414. {
  415. field: 'userName',
  416. label: '人员编号',
  417. component: 'Input',
  418. componentProps: {
  419. maxLength: 100,
  420. },
  421. colProps: {
  422. xl: 6,
  423. xxl: 6,
  424. },
  425. },
  426. ],
  427. };
  428. function cancelDownload() {
  429. downloadOption.value = {};
  430. }
  431. const [registerDownModal, { openModal: openDownModal }] = useModal();
  432. const [registerMoveModal, { openModal: openMoveModal }] = useModal();
  433. const [registerPowersModal, { openModal: openPowersModal }] = useModal();
  434. const [registerTable, { reload }] = useTable({
  435. api: operateSceneList,
  436. title: `场景列表`,
  437. // titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
  438. columns: columns,
  439. searchInfo: { type: tableType },
  440. useSearchForm: true,
  441. formConfig: searchForm,
  442. showTableSetting: true,
  443. beforeFetch: (T) => {
  444. loading.value = true;
  445. return T;
  446. },
  447. afterFetch: (T) => {
  448. loading.value = false;
  449. return T;
  450. },
  451. rowKey: 'num',
  452. fetchSetting: {
  453. pageField: 'pageNum',
  454. sizeField: 'pageSize',
  455. listField: 'list',
  456. totalField: 'total',
  457. },
  458. canResize: true,
  459. });
  460. function changeTable(val: string) {
  461. tableType.value = val;
  462. reload();
  463. }
  464. async function handleCopy(record: Recordable) {
  465. createConfirm({
  466. title: '复制场景',
  467. content: '确定要复制场景吗?',
  468. onOk: async () => {
  469. sceneCopy({ num: record.num }).then(() => {
  470. message.success({
  471. content: '复制成功',
  472. });
  473. reload();
  474. });
  475. },
  476. });
  477. }
  478. async function handleDelete(record: Recordable) {
  479. console.log('handleDelete', record);
  480. // createConfirm({
  481. // title: '删除',
  482. // content: '确定要删除场景吗?',
  483. // onOk: async () => {
  484. sceneDelete({ num: record.num }).then(() => {
  485. message.success({
  486. content: '删除成功',
  487. });
  488. reload();
  489. });
  490. // },
  491. // });
  492. }
  493. async function handleMove(record: Recordable) {
  494. openMoveModal(true, {
  495. ...record,
  496. });
  497. // sceneMove({ snCode: record.snCode, num: record.num })
  498. // .then(() => {
  499. // message.success({
  500. // content: '迁移成功',
  501. // });
  502. // })
  503. // .catch(() => {
  504. // message.success({
  505. // content: '迁移失败',
  506. // });
  507. // });
  508. }
  509. let timer: null = ref(null);
  510. const downloadOption = ref<Object>({});
  511. const canDownload = ref<boolean>(true);
  512. function handleDownload(record: Recordable) {
  513. console.log('handleDownload', record, canDownload.value);
  514. canDownload.value = true;
  515. let isObj = tableType.value == 5 || tableType.value == 7 ? 1 : 0;
  516. checkDownLoad({ num: record.num, isObj }).then((res) => {
  517. console.log(res);
  518. if (res.downloadStatus != 3) {
  519. // 未下载过,需要打包
  520. sceneDownload({ num: record.num, isObj }).then((res) => {
  521. console.log(res);
  522. openDownModal(true, {
  523. ...record,
  524. });
  525. if (res.downloadStatus == 1) {
  526. if (timer.value) {
  527. afterClose();
  528. }
  529. timer.value = setInterval(() => {
  530. downloadProcess({ num: record.num, isObj }).then((res) => {
  531. if (res.status == '1003') {
  532. createMessage.error('下载失败');
  533. afterClose();
  534. return;
  535. }
  536. if (res.percent >= 100) {
  537. canDownload.value = false;
  538. afterClose();
  539. }
  540. downloadOption.value = res;
  541. console.log(res);
  542. });
  543. }, 1000);
  544. }
  545. });
  546. } else {
  547. canDownload.value = false;
  548. window.open(res.downloadUrl);
  549. }
  550. });
  551. }
  552. function handleEdit(record: Recordable) {
  553. window.open(record.thumbEdit + '&&token=' + token.value);
  554. }
  555. async function handleGenerate(record: Recordable) {
  556. console.log('record', record);
  557. let data = await sceneDetail({ id: record.id });
  558. console.log('data', data);
  559. let { buildObjStatus } = data;
  560. let toastText =
  561. buildObjStatus == 2
  562. ? 'Mesh场景正在计算中,请耐心等待'
  563. : buildObjStatus == 1
  564. ? '重新生成Mesh场景将覆盖现有场景信息,计算过程中Mesh场景无法打开,确定要重新生成吗?'
  565. : '生成obj需要较长时间,请耐心等待';
  566. // if (data.code === 200) {
  567. createConfirm({
  568. iconType: 'warning',
  569. title: () => h('span', '生成 obj'),
  570. content: () => h('span', toastText),
  571. onOk: async () => {
  572. if (buildObjStatus !== 2) {
  573. await buildSceneObj({ id: record.id, sceneNum: record.num });
  574. }
  575. createMessage.success(t('common.optSuccess'));
  576. reload();
  577. },
  578. });
  579. // } else {
  580. // createMessage.error(t(`apiCode.errCode${data.code}`));
  581. // }
  582. }
  583. function afterClose() {
  584. clearInterval(timer.value);
  585. timer.value = null;
  586. }
  587. function handleReset(record: Recordable) {
  588. console.log('handleReset', record);
  589. rebuildScene({ num: record.num }).then(() => {
  590. message.success({
  591. content: '操作成功',
  592. });
  593. reload();
  594. });
  595. }
  596. function getTypeCheckPerm(val) {
  597. let myType = tableType.value;
  598. return getCheckPerm(val) || getCheckPerm(`${val}-${myType}`);
  599. }
  600. function handlegotoEdit(record: Recordable) {
  601. let url = record.webSite.replace('smg', 'epg');
  602. if (!record.editAuthTime || (record.editAuthTime && dayjs() < dayjs(record.editAuthTime))) {
  603. window.open(url);
  604. } else {
  605. createMessage.error('编辑权限已过期');
  606. }
  607. }
  608. function handlePowers(record: Recordable) {
  609. openPowersModal(true, {
  610. ...record,
  611. });
  612. }
  613. onMounted(() => {
  614. sceneCount({}).then((res) => {
  615. console.log('res', res);
  616. if (res == 0) {
  617. qrCodeUrl.value.show = true;
  618. }
  619. });
  620. fetch('http://4dkk.4dage.com/apps/customApp/udrive_preview/Android/version.json')
  621. .then((response) => response.json())
  622. .then((data) => {
  623. qrCodeUrl.value.android = data.link;
  624. });
  625. fetch('http://4dkk.4dage.com/apps/customApp/udrive_preview/iOS/version.json')
  626. .then((response) => response.json())
  627. .then((data) => {
  628. qrCodeUrl.value.ios = data.link;
  629. });
  630. });
  631. return {
  632. registerTable,
  633. registerPowersModal,
  634. handleDelete,
  635. handleCopy,
  636. handleMove,
  637. handleDownload,
  638. handleReset,
  639. tableType,
  640. loading,
  641. changeTable,
  642. t,
  643. openDownModal,
  644. registerDownModal,
  645. registerMoveModal,
  646. afterClose,
  647. timer,
  648. canDownload,
  649. downloadOption,
  650. cancelDownload,
  651. handleGenerate,
  652. getTypeCheckPerm,
  653. handlegotoEdit,
  654. handlePowers,
  655. userInfo,
  656. qrCodeUrl,
  657. };
  658. },
  659. });
  660. </script>
  661. <style lang="less" scoped>
  662. .scren {
  663. .noScene {
  664. position: absolute;
  665. top: calc(50% - 126px);
  666. width: 100%;
  667. text-align: center;
  668. &-content {
  669. font-size: 14px;
  670. color: rgba(0, 0, 0, 0.85);
  671. line-height: 22px;
  672. font-style: normal;
  673. text-transform: none;
  674. .codelist {
  675. margin-top: 36px;
  676. width: 424px;
  677. height: auto;
  678. display: flex;
  679. justify-content: space-between;
  680. margin: 0 auto;
  681. .codediv {
  682. font-weight: 400;
  683. font-size: 17px;
  684. color: rgba(0, 0, 0, 0.85);
  685. line-height: 22px;
  686. height: auto;
  687. padding: 24px;
  688. background: #fff;
  689. text-align: center;
  690. .codetext {
  691. margin-top: 10px;
  692. }
  693. }
  694. }
  695. }
  696. }
  697. }
  698. // .tableHeader {
  699. // height: 50px;
  700. // display: flex;
  701. // align-items: center;
  702. // .item {
  703. // font-size: 14px;
  704. // color: #666;
  705. // margin-right: 10px;
  706. // cursor: pointer;
  707. // &.active {
  708. // font-weight: bold;
  709. // color: #222;
  710. // }
  711. // }
  712. // }
  713. .desc-wrap-BasicTable {
  714. background-color: #f0f2f5;
  715. .vben-basic-table-form-container {
  716. padding: 0;
  717. }
  718. }
  719. </style>