|
@@ -0,0 +1,144 @@
|
|
|
+<template>
|
|
|
+ <BasicModal
|
|
|
+ v-bind="$attrs"
|
|
|
+ @register="register"
|
|
|
+ title="新增我共享的人员"
|
|
|
+ @cancel="resetFields"
|
|
|
+ @ok="handleSubmit"
|
|
|
+ >
|
|
|
+ <div class="pt-2px pr-3px">
|
|
|
+ <BasicForm @register="registerForm">
|
|
|
+ <template #text="{ model, field }">
|
|
|
+ {{ model[field] }}
|
|
|
+ </template>
|
|
|
+ </BasicForm>
|
|
|
+ </div>
|
|
|
+ </BasicModal>
|
|
|
+</template>
|
|
|
+<script lang="ts">
|
|
|
+ import { defineComponent, ref, onMounted, reactive } from 'vue';
|
|
|
+ import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
+ import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+ import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
+ import { getByRyId, userShareAdd } from '/@/api/operate';
|
|
|
+
|
|
|
+ const { t } = useI18n();
|
|
|
+ export default defineComponent({
|
|
|
+ components: { BasicModal, BasicForm },
|
|
|
+ props: {
|
|
|
+ userData: { type: Object },
|
|
|
+ },
|
|
|
+ emits: ['ok'],
|
|
|
+ setup(_, { emit }) {
|
|
|
+ const modelRef = ref(false);
|
|
|
+ const fileFlow = reactive({
|
|
|
+ file: null,
|
|
|
+ });
|
|
|
+ const { createMessage } = useMessage();
|
|
|
+ const optionsName = ref([]);
|
|
|
+ const schemas: FormSchema[] = [
|
|
|
+ {
|
|
|
+ field: 'id',
|
|
|
+ component: 'Input',
|
|
|
+ show: false,
|
|
|
+ label: 'id',
|
|
|
+ required: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'ryNo',
|
|
|
+ component: 'AutoComplete',
|
|
|
+ label: '人员编号',
|
|
|
+ required: true,
|
|
|
+ componentProps: {
|
|
|
+ filterOption: onFilterOption,
|
|
|
+ onSearch: onSearch,
|
|
|
+ onChange: (data) => {
|
|
|
+ const item = optionsName.value && optionsName.value.find((ele) => ele.ryNo == data);
|
|
|
+ setFieldsValue({
|
|
|
+ ryNickName: item && item.ryNickName ? item.ryNickName : '',
|
|
|
+ id: item && item.id ? item.id : ''
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ colProps: {
|
|
|
+ span: 20,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'ryNickName',
|
|
|
+ component: 'Input',
|
|
|
+ label: '姓名',
|
|
|
+ required: true,
|
|
|
+ colProps: {
|
|
|
+ span: 20,
|
|
|
+ },
|
|
|
+ componentProps: {
|
|
|
+ disabled: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ const [registerForm, { validate, resetFields, setFieldsValue, updateSchema }] = useForm({
|
|
|
+ labelWidth: 110,
|
|
|
+ schemas,
|
|
|
+ showActionButtonGroup: false,
|
|
|
+ actionColOptions: {
|
|
|
+ span: 24,
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ onMounted(() => {});
|
|
|
+ let addListFunc = () => {};
|
|
|
+ const [register, { closeModal }] = useModalInner(async (data) => {
|
|
|
+ console.log('option', data);
|
|
|
+ });
|
|
|
+ function onFilterOption(inputText: string, option) {
|
|
|
+ console.log('option', inputText, option.value);
|
|
|
+ if (option.value) {
|
|
|
+ return option.value.indexOf(inputText) >= 0;
|
|
|
+ }
|
|
|
+ // return option.value.indexOf(inputText.toUpperCase()) >= 0;
|
|
|
+ }
|
|
|
+ async function onSearch(searchText) {
|
|
|
+ if (searchText.length < 7) return;
|
|
|
+ const list = await getByRyId({ ryNo: searchText });
|
|
|
+ optionsName.value =
|
|
|
+ list.map((ele) => {
|
|
|
+ return { ...ele, value: ele.ryNo };
|
|
|
+ }) || [];
|
|
|
+ // console.log('paramList', optionsList);
|
|
|
+ // optionsName.value = optionsList || [];
|
|
|
+ updateSchema({
|
|
|
+ field: 'ryNo',
|
|
|
+ componentProps: {
|
|
|
+ options: optionsName.value,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+ const handleSubmit = async () => {
|
|
|
+ try {
|
|
|
+ const params = await validate();
|
|
|
+ await userShareAdd(params);
|
|
|
+ closeModal();
|
|
|
+ resetFields();
|
|
|
+ emit('ok');
|
|
|
+ createMessage.success('操作成功');
|
|
|
+ } catch (error) {
|
|
|
+ console.log('not passing', error);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ return {
|
|
|
+ register,
|
|
|
+ schemas,
|
|
|
+ registerForm,
|
|
|
+ modelRef,
|
|
|
+ fileFlow,
|
|
|
+ handleSubmit,
|
|
|
+ addListFunc,
|
|
|
+ resetFields,
|
|
|
+ t,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ });
|
|
|
+</script>
|