pageList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <CardList
  3. :searchFormSchema="searchFormSchema"
  4. :params="params"
  5. :api="list"
  6. @getMethod="getMethod"
  7. @delete="handleDelete"
  8. @view="handleView"
  9. @design="handleDesign"
  10. @edit="handleEdit"
  11. @copy="handleCopy"
  12. @template="handleTemplate"
  13. >
  14. <template #header>
  15. <a-button preIcon="ant-design:plus-outlined" type="primary" @click="handleCreate">新增</a-button>
  16. </template>
  17. <template #cardTitle>
  18. <a-tabs defaultActiveKey="1" @change="tabChange" size="small">
  19. <a-tab-pane key="1">
  20. <template #tab>
  21. <span>
  22. <Icon icon="ant-design:bar-chart-outlined" :size="20"></Icon>
  23. 仪表盘设计
  24. </span>
  25. </template>
  26. </a-tab-pane>
  27. <a-tab-pane key="3">
  28. <template #tab>
  29. <span>
  30. <Icon icon="ant-design:star-outlined" :size="20"></Icon>
  31. 模板
  32. </span>
  33. </template>
  34. </a-tab-pane>
  35. </a-tabs>
  36. </template>
  37. </CardList>
  38. <!--编辑弹窗-->
  39. <PageModal @register="registerModal" @success="handleOk" />
  40. <!--保护密码弹窗-->
  41. <PasswordModal ref="passwordRef" @success="checkPassOk"/>
  42. <!--页面配置弹窗-->
  43. <DragPageModal @register="registerDragModal" @success="success" :isLowApp="false"/>
  44. </template>
  45. <script lang="ts" setup name="drag-page">
  46. import CardList from './components/CardList.vue';
  47. import PageModal from './components/PageModal.vue';
  48. import PasswordModal from './components/PasswordModal.vue';
  49. import DragPageModal from './components/DragPageModal.vue';
  50. import { ref,reactive } from 'vue';
  51. import { useModal } from '/@/components/Modal';
  52. import { router } from '/@/router';
  53. import { list, deleteOne, copyPage ,saveOrUpdate} from './page.api';
  54. import { searchFormSchema } from './page.data';
  55. const [registerModal, { openModal }] = useModal();
  56. const [registerDragModal, { openModal: openDragModal }] = useModal();
  57. const passwordRef = ref()
  58. let reload = (params?) => {};
  59. //额外的查询参数
  60. const params = reactive({type:"1",izTemplate:'0'});
  61. // 获取内部fetch方法;
  62. function getMethod(m: any) {
  63. reload = m;
  64. }
  65. /**
  66. * 提交后的回调
  67. */
  68. function handleOk(record) {
  69. reload();
  70. record && handleDesign(record);
  71. }
  72. /**
  73. * 新增事件
  74. */
  75. function handleCreate() {
  76. openModal(true, {
  77. isUpdate: false,
  78. });
  79. }
  80. /**
  81. * 编辑
  82. */
  83. function handleEdit(record: Recordable) {
  84. //判断是否有保护密码
  85. let hasPassword = record.protectionCode && record.protectionCode.length > 0;
  86. if (hasPassword) {
  87. passwordRef.value.showModal('edit', record);
  88. //passwordRef.value.extraMsg = '面板被保护中,编辑前请先输入保护码';
  89. } else {
  90. openModal(true, {
  91. record,
  92. isUpdate: true,
  93. });
  94. }
  95. }
  96. /**
  97. * 密码校验成功
  98. */
  99. async function checkPassOk(type, record) {
  100. if (type == 'edit') {
  101. openModal(true, {
  102. record,
  103. isUpdate: true,
  104. });
  105. } else if (type == 'delete') {
  106. await deleteOne({ id: record.id }, reload);
  107. }
  108. }
  109. /**
  110. * 删除事件
  111. */
  112. async function handleDelete(record) {
  113. //判断是否有保护密码
  114. let hasPassword = record.protectionCode && record.protectionCode.length > 0;
  115. if (hasPassword) {
  116. passwordRef.value.showModal('delete', record);
  117. passwordRef.value.extraMsg = '面板被保护中,删除前请先输入保护码';
  118. } else {
  119. await deleteOne({ id: record.id }, reload);
  120. }
  121. }
  122. /**
  123. * 页面配置
  124. */
  125. function handleDesign(record) {
  126. openDragModal(true, {
  127. record,
  128. isUpdate: true,
  129. });
  130. }
  131. /**
  132. * 页面预览
  133. */
  134. function handleView(id) {
  135. router.push({ name: 'drag-page-view-@id'!, params: { id } });
  136. }
  137. /**
  138. * 面板复制
  139. */
  140. async function handleCopy(id) {
  141. await copyPage({ id }, reload);
  142. }
  143. /**
  144. * 收藏模板
  145. */
  146. async function handleTemplate(id,template) {
  147. let params = {id, izTemplate:template};
  148. const res = await saveOrUpdate(params,true);
  149. console.log('handleTemplate-------------->res:',res)
  150. reload();
  151. }
  152. // 面板类型
  153. function tabChange(key) {
  154. if(key!=='3'){
  155. params.type = key;
  156. params.izTemplate = '0';
  157. }else{
  158. params.type = '';
  159. params.izTemplate = '1';
  160. }
  161. reload({pageNo:1});
  162. }
  163. /**
  164. * 成功回调,刷新列表
  165. */
  166. function success() {
  167. reload();
  168. }
  169. </script>