123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464 |
- <template>
- <PageWrapper contentBackground>
- <!-- <template #footer>
- <a-tabs v-model:activeKey="tableType" @change="changeTable">
- <a-tab-pane :key="0" :tab="t('routes.scene.tableType.0')" />
- <a-tab-pane :key="1" :tab="t('routes.scene.tableType.1')" />
- <a-tab-pane :key="2" :tab="t('routes.scene.tableType.2')" />
- <a-tab-pane :key="5" :tab="t('routes.scene.tableType.5')" />
- <a-tab-pane :key="6" :tab="t('routes.scene.tableType.6')" />
- <a-tab-pane :key="7" :tab="t('routes.scene.tableType.7')" />
- </a-tabs></template
- > -->
- <div class="desc-wrap-BasicTable">
- <BasicTable @register="registerTable">
- <template #toolbar>
- <a-button type="primary" @click="handleMove"> 同步场景</a-button>
- </template>
- <template #href="{ record }">
- <a v-if="record.title && record.webSite" target="_blank" :href="record.webSite">{{
- record.title
- }}</a>
- <span v-else-if="record.title">{{ record.title }}</span>
- <span v-else>-</span>
- </template>
- <template #action="{ record }">
- <TableAction
- stopButtonPropagation
- :actions="[
- {
- label: '查看',
- disabled: record.status != 1,
- onClick: handleSee.bind(null, record),
- },
- {
- label: '删除',
- color: 'error',
- onClick: handleDelete.bind(null, record),
- },
- ]"
- />
- </template>
- </BasicTable>
- </div>
- <DownLoadModal
- :downloadOption="downloadOption"
- @cancel="afterClose"
- @register="registerDownModal"
- @update="reload"
- :cancelText="t('routes.scene.canlenDown')"
- :okText="t('routes.scene.down')"
- @cancelDownload="cancelDownload"
- :okButtonProps="{ disabled: canDownload }"
- />
- <!-- <MoveModal @register="registerMoveModal" /> -->
- <SyncModal @register="registerMoveModal" @update="reload" />
- </PageWrapper>
- </template>
- <script lang="ts">
- import { defineComponent, h, reactive, toRefs, ref } from 'vue';
- import {
- BasicTable,
- useTable,
- TableAction,
- BasicColumn,
- TableImg,
- FormProps,
- } from '/@/components/Table';
- import { PageWrapper } from '/@/components/Page';
- import DownLoadModal from './modal/DownLoadModal.vue';
- import MoveModal from './modal/MoveModal.vue';
- import SyncModal from './modal/SyncModal.vue';
- import { Time } from '/@/components/Time';
- import { Descriptions, Tabs, Progress } from 'ant-design-vue';
- import { useI18n } from '/@/hooks/web/useI18n';
- import { useMessage } from '/@/hooks/web/useMessage';
- import { useModal } from '/@/components/Modal';
- import {
- operateSceneList,
- sceneMove,
- sceneDelete,
- sceneReset,
- caseDelApi,
- sceneDownload,
- checkDownLoad,
- downloadProcess,
- sceneCopy,
- rebuildScene,
- } from '/@/api/operate';
- import { message } from 'ant-design-vue';
- import { usePermissionStore } from '/@/store/modules/permission';
- import { func } from 'vue-types';
- export default defineComponent({
- components: {
- DownLoadModal,
- MoveModal,
- BasicTable,
- TableAction,
- PageWrapper,
- SyncModal,
- [Descriptions.name]: Descriptions,
- [Descriptions.Item.name]: Descriptions.Item,
- [Tabs.name]: Tabs,
- [Tabs.TabPane.name]: Tabs.TabPane,
- },
- setup() {
- const { t } = useI18n();
- const { createMessage, createConfirm } = useMessage();
- const permissionStore = usePermissionStore();
- const { getCheckPerm } = permissionStore;
- const tableType = ref<Recordable>(0); //0看看 、1看见、2深时
- const columns: BasicColumn[] = [
- {
- title: t('routes.scene.sceneName'),
- dataIndex: 'sceneName',
- slots: { customRender: 'href' },
- width: 300,
- },
- {
- title: t('routes.scene.num'),
- dataIndex: 'num',
- ellipsis: true,
- width: 180,
- },
- {
- title: t('routes.scene.createTime'),
- dataIndex: 'createTime',
- width: 180,
- customRender: ({ record }) => {
- return (
- record.createTime &&
- h(Time, {
- value: record.createTime,
- mode: 'datetime',
- })
- );
- },
- },
- {
- title: t('routes.scene.amount'),
- dataIndex: 'amount',
- width: 210,
- customRender: ({ record }) => {
- return (
- (record.algorithmTime &&
- h(Time, {
- value: record.algorithmTime,
- mode: 'datetime',
- })) ||
- '-'
- );
- },
- },
- // {
- // title: t('routes.scene.snCode'),
- // dataIndex: 'snCode',
- // width: 180,
- // },
- // {
- // title: t('routes.scene.sceneSize'),
- // dataIndex: 'sceneSize',
- // width: 120,
- // customRender: ({ record }) => {
- // return record.sceneSize && record.sceneSize != 0
- // ? h('span', { class: 'sceneSize' }, Math.ceil(record.sceneSize / 1024 / 1024) + 'M')
- // : '-';
- // },
- // },
- // {
- // title: t('routes.scene.isCopy'),
- // dataIndex: 'isCopy',
- // width: 130,
- // customRender: ({ record }) => {
- // return record.isCopy ? t('common.yes') : t('common.no');
- // },
- // },
- // {
- // title: t('routes.scene.copyTime'),
- // dataIndex: 'copyTime',
- // width: 140,
- // customRender: ({ record }) => {
- // return (
- // (record.copyTime &&
- // h(Time, {
- // value: record.copyTime,
- // mode: 'datetime',
- // })) ||
- // '-'
- // );
- // },
- // },
- // {
- // title: t('routes.scene.userName'),
- // dataIndex: 'userName',
- // width: 140,
- // },
- // {
- // title: t('routes.scene.viewCount'),
- // dataIndex: 'viewCount',
- // width: 80,
- // },
- {
- title: t('routes.scene.status'),
- dataIndex: 'status',
- width: 110,
- customRender: ({ record }) => {
- let str;
- switch (record.status - 0) {
- case 0:
- str = t('routes.scene.statusType.0');
- break;
- case 1:
- str = t('routes.scene.statusType.1');
- break;
- case -2:
- str = t('routes.scene.statusType.-2');
- break;
- case -1:
- str = t('routes.scene.statusType.-1');
- break;
- }
- return record.payStatus == -2 ? t('routes.scene.statusType.-3') : str;
- },
- },
- {
- title: t('common.operating'),
- dataIndex: 'action',
- slots: { customRender: 'action' },
- ifShow: true,
- fixed: 'right',
- flag: 'ACTION',
- width: 180,
- },
- ];
- const searchForm: Partial<FormProps> = {
- labelWidth: 80,
- schemas: [
- {
- field: 'sceneName',
- label: t('routes.scene.sceneName'),
- component: 'Input',
- componentProps: {
- maxLength: 100,
- },
- colProps: {
- xl: 5,
- xxl: 5,
- },
- },
- {
- label: t('routes.scene.num'),
- field: 'num',
- labelWidth: 60,
- component: 'Input',
- componentProps: {
- maxLength: 100,
- },
- colProps: {
- xl: 5,
- xxl: 5,
- },
- },
- {
- field: 'snCode',
- label: t('routes.scene.snCode'),
- component: 'Input',
- labelWidth: 50,
- componentProps: {
- maxLength: 100,
- },
- colProps: {
- xl: 4,
- xxl: 4,
- },
- },
- {
- field: 'userName',
- label: t('routes.scene.userName'),
- component: 'Input',
- componentProps: {
- maxLength: 100,
- },
- colProps: {
- xl: 4,
- xxl: 4,
- },
- },
- ],
- };
- function cancelDownload() {
- downloadOption.value = {};
- }
- const [registerDownModal, { openModal: openDownModal }] = useModal();
- const [registerMoveModal, { openModal: openMoveModal }] = useModal();
- const [registerTable, { reload }] = useTable({
- api: operateSceneList,
- // title: `场景列表`,
- // titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
- columns: columns,
- searchInfo: { type: tableType },
- useSearchForm: true,
- // rowSelection: { type: 'checkbox' },
- formConfig: searchForm,
- showTableSetting: true,
- showIndexColumn: false,
- rowKey: 'num',
- fetchSetting: {
- pageField: 'pageNum',
- sizeField: 'pageSize',
- listField: 'list',
- totalField: 'total',
- },
- canResize: false,
- });
- function changeTable(val: string) {
- tableType.value = val;
- reload();
- }
- async function handleCopy(record: Recordable) {
- createConfirm({
- title: t('routes.scene.copyTipsTitle'),
- content: t('routes.scene.copyTipsText'),
- onOk: async () => {
- sceneCopy({ num: record.num }).then(() => {
- message.success({
- content: t('routes.scene.copySccuse'),
- });
- reload();
- });
- },
- });
- }
- async function handleDelete(record: Recordable) {
- console.log('handleDelete', record);
- createConfirm({
- iconType: 'warning',
- title: '警告',
- content: `此操作将对${record.title}进行删除, 是否继续?`,
- onOk: async () => {
- await caseDelApi([record.id]);
- reload();
- },
- });
- }
- async function handleMove() {
- openMoveModal(true, {});
- }
- function handleSee(record) {
- window.open(record.webSite);
- }
- let timer: null = ref(null);
- const downloadOption = ref<Object>({});
- const canDownload = ref<boolean>(true);
- function handleDownload(record: Recordable) {
- console.log('handleDownload', record, canDownload.value);
- canDownload.value = true;
- checkDownLoad({ num: record.num }).then((res) => {
- console.log(res);
- if (res.downloadStatus != 3) {
- // 未下载过,需要打包
- sceneDownload({ num: record.num }).then((res) => {
- console.log(res);
- openDownModal(true, {
- ...record,
- });
- if (res.downloadStatus == 1) {
- if (timer.value) {
- afterClose();
- }
- timer.value = setInterval(() => {
- downloadProcess({ num: record.num }).then((res) => {
- if (res.status == '1003') {
- createMessage.error(t('routes.scene.downErr'));
- afterClose();
- return;
- }
- if (res.percent >= 100) {
- canDownload.value = false;
- afterClose();
- }
- downloadOption.value = res;
- console.log(res);
- });
- }, 1000);
- }
- });
- } else {
- canDownload.value = false;
- window.open(res.downloadUrl);
- }
- });
- }
- function afterClose() {
- clearInterval(timer.value);
- timer.value = null;
- }
- function handleReset(record: Recordable) {
- createConfirm({
- title: t('routes.scene.reset'),
- content: t('routes.scene.resetTips'),
- onOk: async () => {
- rebuildScene({ num: record.num }).then(() => {
- message.success({
- content: t('common.optSuccess'),
- });
- reload();
- });
- },
- });
- }
- function getTypeCheckPerm(val) {
- let myType = tableType.value;
- return getCheckPerm(val) || getCheckPerm(`${val}-${myType}`);
- }
- return {
- registerTable,
- handleDelete,
- handleCopy,
- handleSee,
- handleMove,
- handleDownload,
- handleReset,
- tableType,
- changeTable,
- reload,
- t,
- openDownModal,
- registerDownModal,
- registerMoveModal,
- afterClose,
- timer,
- canDownload,
- downloadOption,
- cancelDownload,
- getTypeCheckPerm,
- };
- },
- });
- </script>
- <style lang="less" scoped>
- // .tableHeader {
- // height: 50px;
- // display: flex;
- // align-items: center;
- // .item {
- // font-size: 14px;
- // color: #666;
- // margin-right: 10px;
- // cursor: pointer;
- // &.active {
- // font-weight: bold;
- // color: #222;
- // }
- // }
- // }
- .desc-wrap-BasicTable {
- background-color: #f0f2f5;
- .vben-basic-table-form-container {
- padding: 0;
- }
- }
- </style>
|