ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<script lang="ts" setup>
import type { FormInstance } from 'ant-design-vue';
 
import { reactive, ref, toRefs } from 'vue';
 
import { ModalClose } from '@jnpf/ui/modal';
 
import { $t } from '@vben/locales';
 
import { globalShareState } from '@vben-core/shared/global-state';
 
import { Modal as AModal } from 'ant-design-vue';
 
interface State {
  dataForm: any;
  options: any[];
  visible: boolean;
}
const emit = defineEmits(['register', 'confirm']);
defineExpose({ openModal });
const { getSignatureListByIds } = globalShareState.getApi();
const formElRef = ref<FormInstance>();
const state = reactive<State>({
  dataForm: {
    innerValue: '',
  },
  options: [],
  visible: false,
});
const { dataForm, options, visible } = toRefs(state);
 
function openModal(data) {
  state.visible = true;
  state.dataForm.innerValue = data.value || '';
  if (!data.ableIds || data.ableIds.length === 0) return;
  getSignatureListByIds(data.ableIds).then((res) => {
    const list = res?.data?.list || [];
    state.options = list.map((o) => ({ fullName: o.fullName, id: o.icon }));
  });
}
function handleCancel() {
  state.visible = false;
}
async function handleSubmit() {
  const values = await formElRef.value?.validate();
  if (!values) return;
  emit('confirm', values.innerValue || '');
  handleCancel();
}
</script>
<template>
  <AModal v-model:open="visible" :keyboard="false" :mask-closable="false" :width="600" centered class="jnpf-signature-modal" title="选择签章">
    <template #closeIcon>
      <ModalClose :can-fullscreen="false" @cancel="handleCancel" />
    </template>
    <template #footer>
      <a-button @click="handleCancel">{{ $t('common.cancelText') }}</a-button>
      <a-button type="primary" @click="handleSubmit">{{ $t('common.okText') }}</a-button>
    </template>
    <div class="sign-main">
      <a-form ref="formElRef" :colon="false" :label-col="{ style: { width: '80px' } }" :model="dataForm">
        <a-form-item label="电子签章" name="innerValue">
          <jnpf-select v-model:value="dataForm.innerValue" :options="options" allow-clear show-search />
        </a-form-item>
      </a-form>
    </div>
  </AModal>
</template>
<style lang="scss">
.jnpf-signature-modal {
  .ant-modal-body {
    padding: 40px 50px !important;
  }
}
</style>