|
@@ -12,7 +12,7 @@
|
|
|
</BasicModal>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
- import { defineComponent, ref, computed } from 'vue';
|
|
|
+ import { defineComponent, ref, computed, h } from 'vue';
|
|
|
import {
|
|
|
checkUserApi,
|
|
|
saveApi,
|
|
@@ -27,6 +27,8 @@
|
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
import { useUserStore } from '/@/store/modules/user';
|
|
|
+ import { CropperAvatar } from '/@/components/Cropper';
|
|
|
+ import { Result } from '/#/axios';
|
|
|
const { t } = useI18n();
|
|
|
export default defineComponent({
|
|
|
components: { BasicModal, BasicForm },
|
|
@@ -211,22 +213,37 @@
|
|
|
field: 'head',
|
|
|
label: '员工头像',
|
|
|
component: 'Upload',
|
|
|
- required: true,
|
|
|
+ required: false,
|
|
|
// defaultValue: 1,
|
|
|
itemProps: {
|
|
|
validateTrigger: 'blur',
|
|
|
},
|
|
|
helpMessage: '推荐大小:400 * 400 像素',
|
|
|
- componentProps: {
|
|
|
- api: uploadApi,
|
|
|
- maxNumber: 1,
|
|
|
- accept: ['jpg', 'jpeg', 'gif', 'png'],
|
|
|
- afterFetch: function (data) {
|
|
|
- console.log('data', data);
|
|
|
- Reflect.set(data, 'url', data.message);
|
|
|
- return data;
|
|
|
- },
|
|
|
+ render: ({ model, field }) => {
|
|
|
+ return h(CropperAvatar, {
|
|
|
+ value: model[field],
|
|
|
+ maxlength: 200,
|
|
|
+ uploadApi: uploadApi,
|
|
|
+ showBtn: false,
|
|
|
+ maxNumber: 1,
|
|
|
+ accept: ['jpg', 'jpeg', 'gif', 'png'],
|
|
|
+ onChange: (_, source: Result) => {
|
|
|
+ console.log('onChange', source.message);
|
|
|
+ model[field] = source.message;
|
|
|
+ },
|
|
|
+ showImageUpload: true,
|
|
|
+ });
|
|
|
},
|
|
|
+ // componentProps: {
|
|
|
+ // api: uploadApi,
|
|
|
+ // maxNumber: 1,
|
|
|
+ // accept: ['jpg', 'jpeg', 'gif', 'png'],
|
|
|
+ // afterFetch: function (data) {
|
|
|
+ // console.log('data', data);
|
|
|
+ // Reflect.set(data, 'url', data.message);
|
|
|
+ // return data;
|
|
|
+ // },
|
|
|
+ // },
|
|
|
},
|
|
|
// {
|
|
|
// field: 'avatar',
|
|
@@ -278,6 +295,7 @@
|
|
|
function onDataReceive(data) {
|
|
|
// 方式1;
|
|
|
console.log('useModalInner', data);
|
|
|
+ resetFields();
|
|
|
setFieldsValue({
|
|
|
...data,
|
|
|
roleId: data.roleId != 2 ? data.roleId : '',
|
|
@@ -351,7 +369,7 @@
|
|
|
let res = await requestApi({
|
|
|
...data,
|
|
|
userName: data.phone,
|
|
|
- head: data.head[0],
|
|
|
+ head: data.head,
|
|
|
phone: data.phone,
|
|
|
nickName: data.nickName,
|
|
|
roleId: data.roleId,
|