cameraScene.vue 15 KB

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