|
@@ -22,7 +22,7 @@
|
|
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
- import { companyAdd } from '/@/api/customer';
|
|
|
+ import { companyAdd, companyUpdate } from '/@/api/customer';
|
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
import { uploadApi } from '/@/api/product/index';
|
|
|
import { useModalInner } from '/@/components/Modal';
|
|
@@ -34,7 +34,7 @@
|
|
|
},
|
|
|
emits: ['update', 'register'],
|
|
|
setup(props, { emit }) {
|
|
|
- const modelRef = ref({});
|
|
|
+ const modelRef = ref(null);
|
|
|
const fileFlow = reactive({
|
|
|
file: null,
|
|
|
});
|
|
@@ -135,7 +135,7 @@
|
|
|
maxNumber: 1,
|
|
|
maxSize: 5,
|
|
|
accept: ['jpg', 'png'],
|
|
|
- afterFetch: function (data) {
|
|
|
+ afterFetch: function (data) {
|
|
|
Reflect.set(data, 'url', data.data);
|
|
|
return data;
|
|
|
},
|
|
@@ -167,16 +167,16 @@
|
|
|
field: 'showLogo',
|
|
|
component: 'RadioGroup',
|
|
|
label: '初始LOGO',
|
|
|
- defaultValue: '1',
|
|
|
+ defaultValue: 1,
|
|
|
componentProps: {
|
|
|
options: [
|
|
|
{
|
|
|
label: '显示',
|
|
|
- value: '1',
|
|
|
+ value: 1,
|
|
|
},
|
|
|
{
|
|
|
label: '不显示',
|
|
|
- value: '2',
|
|
|
+ value: 2,
|
|
|
},
|
|
|
],
|
|
|
},
|
|
@@ -198,13 +198,12 @@
|
|
|
let addListFunc = () => {};
|
|
|
const [register, { closeModal }] = useModalInner((data) => {
|
|
|
if (data) {
|
|
|
- console.log(data);
|
|
|
modelRef.value = data;
|
|
|
setFieldsValue({
|
|
|
...data,
|
|
|
- floorLogo:data.floorLogo?[data.floorLogo]:[],
|
|
|
- qrLogo:data.qrLogo?[data.qrLogo]:[],
|
|
|
- topLogo:data.topLogo?[data.topLogo]:[],
|
|
|
+ floorLogo: data.floorLogo ? [data.floorLogo] : [],
|
|
|
+ qrLogo: data.qrLogo ? [data.qrLogo] : [],
|
|
|
+ topLogo: data.topLogo ? [data.topLogo] : [],
|
|
|
});
|
|
|
}
|
|
|
});
|
|
@@ -219,17 +218,27 @@
|
|
|
const handleSubmit = async () => {
|
|
|
try {
|
|
|
const params = await validate();
|
|
|
- const apiData = {
|
|
|
+ const apiData = {
|
|
|
...params,
|
|
|
- floorLogo:params.floorLogo && params.floorLogo[0],
|
|
|
- qrLogo:params.qrLogo && params.qrLogo[0],
|
|
|
- topLogo:params.topLogo && params.topLogo[0],
|
|
|
- };
|
|
|
- await companyAdd(apiData);
|
|
|
+ floorLogo: params.floorLogo && params.floorLogo[0],
|
|
|
+ qrLogo: params.qrLogo && params.qrLogo[0],
|
|
|
+ topLogo: params.topLogo && params.topLogo[0],
|
|
|
+ };
|
|
|
+ console.log(modelRef.value);
|
|
|
+ let tips: string;
|
|
|
+ if (modelRef.value) {
|
|
|
+ apiData.id = modelRef.value.id;
|
|
|
+ await companyUpdate(apiData);
|
|
|
+ tips = '修改成功。';
|
|
|
+ } else {
|
|
|
+ tips = '添加成功。';
|
|
|
+ await companyAdd(apiData);
|
|
|
+ }
|
|
|
+
|
|
|
closeModal();
|
|
|
resetFields();
|
|
|
emit('update');
|
|
|
- createMessage.success('添加成功。');
|
|
|
+ createMessage.success(tips);
|
|
|
} catch (error) {
|
|
|
console.log('not passing', error);
|
|
|
}
|