viewKankan.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <BasicTable @register="registerTable">
  3. <template #toolbar>
  4. <!-- <a-button type="primary" @click="exportExcel"> 导出1</a-button> -->
  5. </template>
  6. <template #href="{ record }">
  7. <a v-if="record.name" target="_blank" :href="record.share">{{record.name}}</a>
  8. <span v-else>-</span>
  9. </template>
  10. <template #action="{ record }">
  11. <TableAction
  12. stopButtonPropagation
  13. :actions="[
  14. {
  15. label: '删除',
  16. color: 'error',
  17. ifShow:getCheckPerm('projects-delete'),
  18. popConfirm: {
  19. title: '是否删除?',
  20. confirm: handleDelete.bind(null, record),
  21. placement: 'topLeft',
  22. },
  23. },
  24. ]"
  25. />
  26. </template>
  27. </BasicTable>
  28. </template>
  29. <script lang="ts">
  30. import { defineComponent, h, reactive, toRefs } from 'vue';
  31. import {
  32. BasicTable,
  33. useTable,
  34. TableAction,
  35. BasicColumn,
  36. TableImg,
  37. FormProps,
  38. } from '/@/components/Table';
  39. import { PageWrapper } from '/@/components/Page';
  40. import { Time } from '/@/components/Time';
  41. import { Descriptions } from 'ant-design-vue';
  42. import { useI18n } from '/@/hooks/web/useI18n';
  43. import { useMessage } from '/@/hooks/web/useMessage';
  44. import { Switch } from 'ant-design-vue';
  45. import { overallList, overallDelete } from '/@/api/operate';
  46. import { message } from 'ant-design-vue';
  47. import { usePermissionStore } from '/@/store/modules/permission';
  48. export default defineComponent({
  49. components: {
  50. BasicTable,
  51. TableAction,
  52. PageWrapper,
  53. TableImg,
  54. [Descriptions.name]: Descriptions,
  55. [Descriptions.Item.name]: Descriptions.Item,
  56. },
  57. setup() {
  58. const { t } = useI18n();
  59. const { createMessage, createConfirm } = useMessage();
  60. const permissionStore = usePermissionStore();
  61. const { getCheckPerm } = permissionStore;
  62. const columns: BasicColumn[] = [
  63. {
  64. title: '作品标题',
  65. dataIndex: 'name',
  66. slots: { customRender: 'href' },
  67. width: 150,
  68. // customRender: ({ record }) => {
  69. // return record.name ? h('span', record.name) : '-';
  70. // },
  71. },
  72. {
  73. title: '作品码',
  74. dataIndex: 'sceneCodes',
  75. ellipsis: true,
  76. width: 180,
  77. },
  78. {
  79. title: '用户账号',
  80. dataIndex: 'userId',
  81. width: 100,
  82. },
  83. {
  84. title: '创建时间',
  85. dataIndex: 'createTime',
  86. width: 180,
  87. customRender: ({ record }) => {
  88. return record.createTime
  89. ? h(Time, {
  90. value: record.createTime,
  91. mode: 'datetime',
  92. })
  93. : '-';
  94. },
  95. },
  96. {
  97. title: '最新编辑时间',
  98. dataIndex: 'updateTime',
  99. width: 180,
  100. customRender: ({ record }) => {
  101. return record.updateTime
  102. ? h(Time, {
  103. value: record.updateTime,
  104. mode: 'datetime',
  105. })
  106. : '-';
  107. },
  108. },
  109. {
  110. title: '是否加密',
  111. dataIndex: 'status',
  112. width: 80,
  113. customRender: ({ record }) => {
  114. return record.isCopy ? '是' : '否';
  115. },
  116. },
  117. {
  118. title: '浏览量',
  119. dataIndex: 'visit',
  120. width: 80,
  121. },
  122. {
  123. title: '操作',
  124. dataIndex: 'action',
  125. slots: { customRender: 'action' },
  126. ifShow: true,
  127. fixed: 'right',
  128. flag: 'ACTION',
  129. width: 50,
  130. },
  131. ];
  132. const searchForm: Partial<FormProps> = {
  133. labelWidth: 100,
  134. schemas: [
  135. {
  136. field: 'sceneName',
  137. label: '作品标题',
  138. component: 'Input',
  139. componentProps: {
  140. maxLength: 100,
  141. },
  142. colProps: {
  143. xl: 7,
  144. xxl: 7,
  145. },
  146. },
  147. {
  148. field: 'userName',
  149. label: '用户账号',
  150. component: 'Input',
  151. componentProps: {
  152. maxLength: 100,
  153. },
  154. colProps: {
  155. xl: 6,
  156. xxl: 6,
  157. },
  158. },
  159. ],
  160. };
  161. const [registerTable, { reload }] = useTable({
  162. api: overallList,
  163. title: '全景看看作品列表',
  164. // titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
  165. columns: columns,
  166. searchInfo: { type: 1 },
  167. useSearchForm: true,
  168. formConfig: searchForm,
  169. showTableSetting: true,
  170. rowKey: 'num',
  171. fetchSetting: {
  172. pageField: 'pageNum',
  173. sizeField: 'pageSize',
  174. listField: 'list',
  175. totalField: 'total',
  176. },
  177. canResize: false,
  178. });
  179. async function handleDelete(record: Recordable) {
  180. console.log('handleDelete', record);
  181. overallDelete({ id: record.id })
  182. .then(() => {
  183. message.success({
  184. content: '删除成功',
  185. });
  186. reload();
  187. })
  188. .catch(() => {
  189. message.success({
  190. content: '删除失败',
  191. });
  192. });
  193. }
  194. async function handleMove(record: Recordable) {
  195. sceneMove({ snCode: record.snCode, num: record.num })
  196. .then(() => {
  197. message.success({
  198. content: '迁移成功',
  199. });
  200. })
  201. .catch(() => {
  202. message.success({
  203. content: '迁移失败',
  204. });
  205. });
  206. }
  207. function handleDownload(record: Recordable) {
  208. console.log('handleDownload', record);
  209. }
  210. function handleReset(record: Recordable) {
  211. console.log('handleReset', record);
  212. }
  213. // function exportExcel() {
  214. // createConfirm({
  215. // iconType: 'warning',
  216. // title: () => h('span', '温馨提示'),
  217. // content: () => h('span', '确定当前标签下的订单记录?'),
  218. // onOk: async () => {
  219. // // await DownExport();
  220. // },
  221. // });
  222. // }
  223. return {
  224. registerTable,
  225. handleDelete,
  226. handleMove,
  227. handleDownload,
  228. handleReset,
  229. getCheckPerm,
  230. };
  231. },
  232. });
  233. </script>