list.vue 18 KB

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