index.vue 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <PageWrapper title="拖动校验示例">
  3. <div class="flex justify-center p-4 items-center bg-gray-700">
  4. <BasicDragVerify ref="el1" @success="handleSuccess" />
  5. <a-button type="primary" class="ml-2" @click="handleBtnClick(el1)"> 还原 </a-button>
  6. </div>
  7. <div class="flex justify-center p-4 items-center bg-gray-700">
  8. <BasicDragVerify ref="el2" @success="handleSuccess" circle />
  9. <a-button type="primary" class="ml-2" @click="handleBtnClick(el2)"> 还原 </a-button>
  10. </div>
  11. <div class="flex justify-center p-4 items-center bg-gray-700">
  12. <BasicDragVerify
  13. ref="el3"
  14. @success="handleSuccess"
  15. text="拖动以进行校验"
  16. successText="校验成功"
  17. :barStyle="{
  18. backgroundColor: '#018ffb',
  19. }"
  20. />
  21. <a-button type="primary" class="ml-2" @click="handleBtnClick(el3)"> 还原 </a-button>
  22. </div>
  23. <div class="flex justify-center p-4 items-center bg-gray-700">
  24. <BasicDragVerify ref="el4" @success="handleSuccess">
  25. <template #actionIcon="isPassing">
  26. <BugOutlined v-if="isPassing" />
  27. <RightOutlined v-else />
  28. </template>
  29. </BasicDragVerify>
  30. <a-button type="primary" class="ml-2" @click="handleBtnClick(el4)"> 还原 </a-button>
  31. </div>
  32. <div class="flex justify-center p-4 items-center bg-gray-700">
  33. <BasicDragVerify ref="el5" @success="handleSuccess">
  34. <template #text="isPassing">
  35. <div v-if="isPassing">
  36. <BugOutlined />
  37. 成功
  38. </div>
  39. <div v-else>
  40. 拖动
  41. <RightOutlined />
  42. </div>
  43. </template>
  44. </BasicDragVerify>
  45. <a-button type="primary" class="ml-2" @click="handleBtnClick(el5)"> 还原 </a-button>
  46. </div>
  47. </PageWrapper>
  48. </template>
  49. <script lang="ts">
  50. import { defineComponent, ref } from 'vue';
  51. import { BasicDragVerify, DragVerifyActionType, PassingData } from '/@/components/Verify/index';
  52. import { useMessage } from '/@/hooks/web/useMessage';
  53. import { BugOutlined, RightOutlined } from '@ant-design/icons-vue';
  54. import { PageWrapper } from '/@/components/Page';
  55. export default defineComponent({
  56. components: { BasicDragVerify, BugOutlined, RightOutlined, PageWrapper },
  57. setup() {
  58. const { createMessage } = useMessage();
  59. const el1 = ref<Nullable<DragVerifyActionType>>(null);
  60. const el2 = ref<Nullable<DragVerifyActionType>>(null);
  61. const el3 = ref<Nullable<DragVerifyActionType>>(null);
  62. const el4 = ref<Nullable<DragVerifyActionType>>(null);
  63. const el5 = ref<Nullable<DragVerifyActionType>>(null);
  64. function handleSuccess(data: PassingData) {
  65. const { time } = data;
  66. createMessage.success(`校验成功,耗时${time}秒`);
  67. }
  68. function handleBtnClick(elRef: Nullable<DragVerifyActionType>) {
  69. if (!elRef) {
  70. return;
  71. }
  72. elRef.resume();
  73. }
  74. return {
  75. handleSuccess,
  76. el1,
  77. el2,
  78. el3,
  79. el4,
  80. el5,
  81. handleBtnClick,
  82. };
  83. },
  84. });
  85. </script>
  86. <style lang="less" scoped>
  87. .bg-gray-700 {
  88. background-color: #4a5568;
  89. }
  90. </style>