123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <template>
- <BasicModal
- v-bind="$attrs"
- @cancel="resetFields"
- @register="register"
- :title="title"
- :min-height="150"
- @ok="handleOk"
- >
- <BasicForm @register="registerForm" />
- </BasicModal>
- </template>
- <script lang="ts">
- import { defineComponent, ref, computed, h } from 'vue';
- import { updateUcenterUser } from '/@/api/staff/list'; //roleLIstApi
- import { BasicModal, useModalInner } from '/@/components/Modal';
- import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
- import { useI18n } from '/@/hooks/web/useI18n';
- import { useMessage } from '/@/hooks/web/useMessage';
- import { useUserStore } from '/@/store/modules/user';
- import { addOrUpdate } from '/@/api/jyUserPlatform/index';
- const { t } = useI18n();
- export default defineComponent({
- components: { BasicModal, BasicForm },
- props: {
- userData: { type: Object },
- },
- emits: ['ok'],
- setup(_, context) {
- const modelRef = ref({});
- const userStore = useUserStore();
- const userinfo = computed(() => userStore.getUserInfo);
- const preventAutoFill = ref(true);
- const { companyId } = userinfo.value;
- console.log('companyId', companyId);
- const schemas: FormSchema[] = [
- {
- field: 'label1',
- component: 'Divider',
- label: '平台首页',
- colProps: {
- span: 24,
- },
- },
- {
- field: 'platformName',
- component: 'Input',
- label: '平台名称',
- required: true,
- colProps: {
- span: 20,
- },
- componentProps: {
- maxLength: 50,
- required: true,
- },
- },
- {
- field: 'label2',
- component: 'Divider',
- label: '平台管理员',
- colProps: {
- span: 24,
- },
- },
- {
- field: 'name',
- component: 'Input',
- label: '姓名',
- colProps: {
- span: 20,
- },
- required: true,
- componentProps: {
- maxLength: 18,
- },
- },
- {
- field: 'idCard',
- component: 'Input',
- required: true,
- label: '身份证',
- colProps: {
- span: 20,
- },
- componentProps: {
- maxLength: 18,
- },
- },
- // {
- // field: 'phone',
- // component: 'Input',
- // required: true,
- // label: '手机号码',
- // colProps: {
- // span: 20,
- // },
- // componentProps: {
- // maxLength: 15,
- // },
- // },
- {
- field: 'id',
- component: 'Input',
- label: 'id',
- show: false,
- },
- ];
- const title = ref('创建平台');
- const { createMessage, createConfirm } = useMessage();
- const [registerForm, { setFieldsValue, validate, updateSchema, resetFields }] = useForm({
- labelWidth: 120,
- schemas,
- showActionButtonGroup: false,
- actionColOptions: {
- span: 24,
- },
- });
- const [register, { closeModal }] = useModalInner((data) => {
- data && onDataReceive(data);
- });
- function onDataReceive(data) {
- // 方式1;
- title.value = data.id ? '修改平台' : '启用平台';
- // preventAutoFill.value = false
- setTimeout(() => {
- console.log('useModalInner', data);
- setFieldsValue({
- ...data,
- userName: '',
- password: '',
- roleId: data.roleId != 2 ? data.roleId : '',
- });
- }, 200);
- }
- function companyIdChange(companyId) {
- // resetFields(['permList'])
- updateSchema([
- {
- field: 'permList',
- componentProps: {
- params: {
- companyId: companyId,
- },
- },
- },
- ]);
- setFieldsValue({
- permList: [],
- });
- }
- async function handleOk() {
- let data = await validate();
- let res = await addOrUpdate({
- ...data,
- // userName: data.phone,
- phone: data.phone,
- nickName: data.nickName,
- roleId: data.roleId,
- id: data.id,
- });
- console.log('res', res);
- context && context.emit('ok', res);
- createConfirm({
- iconType: 'warning',
- title: () => h('span', data.id ? '修改成功' : '平台创建成功'),
- content: () =>
- h('div', {}, [
- h('div', null, `平台名称:${res.platformName}`),
- h('div', null, `平台地址:${res.platformAddress}`),
- h('div', null, `平台管理员:${res.name}`),
- ]),
- onOk: async () => {
- // await this.logout(true);
- },
- });
- createMessage.success(t('common.optSuccess'));
- closeModal();
- resetFields();
- }
- return {
- register,
- title,
- preventAutoFill,
- schemas,
- registerForm,
- modelRef,
- handleOk,
- resetFields,
- };
- },
- });
- </script>
- .
|