|
@@ -41,15 +41,18 @@
|
|
|
import { BasicForm, useForm, FormSchema } from '/@/components/Form/index';
|
|
|
// import { Card } from 'ant-design-vue';
|
|
|
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
|
|
-
|
|
|
- // import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
+ import { useUserStore } from '/@/store/modules/user';
|
|
|
|
|
|
import {
|
|
|
brandTypeListApi,
|
|
|
uploadLiveApi,
|
|
|
getAllSceneApi,
|
|
|
uploadLiveVideoApi,
|
|
|
+ addSave,
|
|
|
+ getLiveInfoApi,
|
|
|
+ brandUpdateApi,
|
|
|
// LiveSceneDeleteApi,
|
|
|
} from '/@/api/scene/live';
|
|
|
import { data as CascaderData } from '/@/utils/cascaderData';
|
|
@@ -67,9 +70,12 @@
|
|
|
name: 'MenuDrawer',
|
|
|
components: { BasicDrawer, BasicForm },
|
|
|
emits: ['success', 'register'],
|
|
|
- setup() {
|
|
|
+ setup(_, { emit }) {
|
|
|
const isUpdate = ref(true);
|
|
|
const detailAddr = ref('');
|
|
|
+ const userStore = useUserStore();
|
|
|
+ const token = userStore.getToken;
|
|
|
+ const userinfo = computed(() => userStore.getUserInfo);
|
|
|
const wrapRef = ref<HTMLDivElement | null>(null);
|
|
|
interface AddressComponentType {
|
|
|
city: string;
|
|
@@ -81,12 +87,26 @@
|
|
|
addressComponent: AddressComponentType;
|
|
|
formattedAddress: string;
|
|
|
location: {
|
|
|
- lng: string;
|
|
|
- lat: string;
|
|
|
+ lng: number;
|
|
|
+ lat: number;
|
|
|
};
|
|
|
}
|
|
|
+ interface infoItem {
|
|
|
+ province?: string;
|
|
|
+ city?: string;
|
|
|
+ address?: string;
|
|
|
+ district?: string;
|
|
|
+ picList?: string[];
|
|
|
+ appListPicUrl?: string[];
|
|
|
+ introduceVideo?: string[];
|
|
|
+ }
|
|
|
let map;
|
|
|
// Lat(120.262337, 30.178285),
|
|
|
+ const myData = reactive({
|
|
|
+ sceneNum: '',
|
|
|
+ id: '',
|
|
|
+ introduceVideoCover: '',
|
|
|
+ });
|
|
|
const defaultAddress = reactive({
|
|
|
address: '山阴路688号恒隆广场B座1217',
|
|
|
// address: '权晖花园21栋',
|
|
@@ -101,17 +121,16 @@
|
|
|
const { toPromise } = useScript({ src: A_MAP_URL });
|
|
|
|
|
|
const { t } = useI18n();
|
|
|
- // const { createMessage } = useMessage();
|
|
|
+ const { createMessage } = useMessage();
|
|
|
const schemas: FormSchema[] = [
|
|
|
{
|
|
|
field: 'type',
|
|
|
label: t('routes.scenes.liveType'),
|
|
|
component: 'ApiSelect',
|
|
|
- // colProps: {
|
|
|
- // xl: 5,
|
|
|
- // xxl: 5,
|
|
|
- // },
|
|
|
required: true,
|
|
|
+ itemProps: {
|
|
|
+ validateTrigger: 'blur',
|
|
|
+ },
|
|
|
componentProps: {
|
|
|
api: brandTypeListApi,
|
|
|
resultField: 'list',
|
|
@@ -127,7 +146,6 @@
|
|
|
field: 'name',
|
|
|
component: 'Input',
|
|
|
label: t('routes.scenes.liveName'),
|
|
|
-
|
|
|
required: true,
|
|
|
},
|
|
|
{
|
|
@@ -152,6 +170,12 @@
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
+ field: 'simpleDesc',
|
|
|
+ component: 'InputTextArea',
|
|
|
+ label: t('routes.scenes.simpleDesc'),
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
field: 'sceneUrl',
|
|
|
label: t('routes.scenes.sceneUrl'),
|
|
|
component: 'ApiSelect',
|
|
@@ -159,12 +183,19 @@
|
|
|
colProps: {
|
|
|
span: 10,
|
|
|
},
|
|
|
+ itemProps: {
|
|
|
+ validateTrigger: 'blur',
|
|
|
+ },
|
|
|
componentProps: {
|
|
|
api: getAllSceneApi,
|
|
|
immediate: true,
|
|
|
resultField: 'list',
|
|
|
labelField: 'sceneName',
|
|
|
valueField: 'webSite',
|
|
|
+ onChange: function (value, item) {
|
|
|
+ console.log('onChange', value, item, arguments);
|
|
|
+ myData.sceneNum = item.num;
|
|
|
+ },
|
|
|
params: {
|
|
|
page: 1,
|
|
|
limit: 100,
|
|
@@ -176,6 +207,9 @@
|
|
|
field: 'location',
|
|
|
label: '直播间位置',
|
|
|
component: 'ApiCascader',
|
|
|
+ itemProps: {
|
|
|
+ validateTrigger: 'blur',
|
|
|
+ },
|
|
|
componentProps: {
|
|
|
api: () => {
|
|
|
return CascaderData;
|
|
@@ -183,14 +217,28 @@
|
|
|
apiParamKey: 'provinceCode',
|
|
|
dataField: 'children',
|
|
|
labelField: 'name',
|
|
|
- valueField: 'code',
|
|
|
+ valueField: 'name',
|
|
|
// numberToString: true,
|
|
|
isLeaf: (record) => {
|
|
|
return !(record.levelType < 3);
|
|
|
},
|
|
|
onChange: (data) => {
|
|
|
- console.log('data', data);
|
|
|
- defaultAddress.location = data;
|
|
|
+ try {
|
|
|
+ let location: string[] = data;
|
|
|
+ // [a,b,c].map(ele => {
|
|
|
+ // return ele && ele.code
|
|
|
+ // } ),
|
|
|
+ let province = data[0],
|
|
|
+ city = data[1],
|
|
|
+ district = data[2];
|
|
|
+ defaultAddress.location = location;
|
|
|
+ defaultAddress.province = province;
|
|
|
+ defaultAddress.city = city;
|
|
|
+ defaultAddress.district = district;
|
|
|
+ console.log('defaultAddress', data, defaultAddress);
|
|
|
+ } catch (error) {
|
|
|
+ console.error('error', error);
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
colProps: {
|
|
@@ -241,12 +289,13 @@
|
|
|
component: 'Upload',
|
|
|
componentProps: {
|
|
|
api: uploadLiveVideoApi,
|
|
|
- maxSize: 5,
|
|
|
+ maxSize: 100,
|
|
|
emptyHidePreview: true,
|
|
|
- maxNumber: 15,
|
|
|
+ maxNumber: 1,
|
|
|
accept: ['video/*'],
|
|
|
afterFetch: function (data) {
|
|
|
Reflect.set(data, 'url', data.message.video);
|
|
|
+ myData.introduceVideoCover = data.message.image;
|
|
|
return data;
|
|
|
},
|
|
|
},
|
|
@@ -255,7 +304,37 @@
|
|
|
span: 20,
|
|
|
},
|
|
|
},
|
|
|
-
|
|
|
+ {
|
|
|
+ field: 'sortOrder',
|
|
|
+ component: 'InputNumber',
|
|
|
+ label: t('routes.scenes.sortOrder'),
|
|
|
+ required: true,
|
|
|
+ defaultValue: 1,
|
|
|
+ componentProps: {
|
|
|
+ min: 0,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'livestreamStatus',
|
|
|
+ component: 'RadioGroup',
|
|
|
+ label: t('routes.scenes.livestream'),
|
|
|
+ required: true,
|
|
|
+ defaultValue: '0',
|
|
|
+ componentProps: {
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ label: '全部',
|
|
|
+ value: '1',
|
|
|
+ key: '1',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '正常',
|
|
|
+ value: '0',
|
|
|
+ key: '0',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
{
|
|
|
field: 'contractPhone',
|
|
|
component: 'Input',
|
|
@@ -278,12 +357,46 @@
|
|
|
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
|
|
resetFields();
|
|
|
setDrawerProps({ confirmLoading: false });
|
|
|
- isUpdate.value = !!data?.isUpdate;
|
|
|
-
|
|
|
+ console.log('openLiveDrawer', data);
|
|
|
+ isUpdate.value = !!data?.id;
|
|
|
+ const { id } = data;
|
|
|
if (unref(isUpdate)) {
|
|
|
- console.log('data.record', data);
|
|
|
+ try {
|
|
|
+ const res = await getLiveInfoApi({ id, token });
|
|
|
+ console.log('getLiveInfo', res, res.address.split(' '));
|
|
|
+ let setDAta: infoItem = {
|
|
|
+ province: '',
|
|
|
+ city: '',
|
|
|
+ district: '',
|
|
|
+ address: '',
|
|
|
+ picList: [],
|
|
|
+ appListPicUrl: [],
|
|
|
+ introduceVideo: [],
|
|
|
+ };
|
|
|
+ let ssq = res.address.split(' ');
|
|
|
+ try {
|
|
|
+ let ssqlist = ssq[0].split(',');
|
|
|
+ setDAta.province = ssqlist[0];
|
|
|
+ setDAta.city = ssqlist[1];
|
|
|
+ setDAta.district = ssqlist[2];
|
|
|
+ setDAta.address = ssq[2];
|
|
|
+ setDAta.picList = res.picList.split('#$#');
|
|
|
+ setDAta.appListPicUrl = [res.appListPicUrl];
|
|
|
+ setDAta.introduceVideo = [res.introduceVideo];
|
|
|
+ } catch (error) {}
|
|
|
+ myData.introduceVideoCover = res.introduceVideoCover;
|
|
|
+ myData.sceneNum = res.sceneNum;
|
|
|
+ await setFieldsValue({
|
|
|
+ ...data,
|
|
|
+ ...setDAta,
|
|
|
+ });
|
|
|
+ myData.sceneNum = res.sceneNum;
|
|
|
+ myData.introduceVideoCover = res.introduceVideoCover;
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+ myData.id = id || false;
|
|
|
initMap();
|
|
|
});
|
|
|
|
|
@@ -318,9 +431,8 @@
|
|
|
console.log('result', result);
|
|
|
const { geocodes } = result;
|
|
|
if (geocodes?.length > 0) {
|
|
|
- const { adcode, addressComponent } = geocodes[0] as any as GeocodesType;
|
|
|
- defaultAddress.location = getCodeArray(adcode);
|
|
|
-
|
|
|
+ const { addressComponent } = geocodes[0] as any as GeocodesType;
|
|
|
+ defaultAddress.location = getCodeArray(addressComponent);
|
|
|
await updateSchema({
|
|
|
field: 'location',
|
|
|
componentProps: {
|
|
@@ -347,10 +459,9 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- function getCodeArray(code: string) {
|
|
|
- const pdCode = code.slice(0, 2);
|
|
|
- const cityCode = code.slice(2, 4);
|
|
|
- return [pdCode, cityCode, code];
|
|
|
+ function getCodeArray(addressComponent) {
|
|
|
+ let { province, city, district } = addressComponent;
|
|
|
+ return [province, city, district];
|
|
|
}
|
|
|
const getTitle = computed(() => (!unref(isUpdate) ? '新增直播间' : '编辑直播间'));
|
|
|
|
|
@@ -358,7 +469,7 @@
|
|
|
if (detailAddr.value?.length > 0) {
|
|
|
console.log('detailAddr.value', detailAddr.value);
|
|
|
const AMap = (window as any).AMap;
|
|
|
- console.log('adcode', defaultAddress.location[2]);
|
|
|
+ console.log('adcode', defaultAddress);
|
|
|
AMap.plugin('AMap.Geocoder', function () {
|
|
|
const geocoder = new AMap.Geocoder({
|
|
|
// city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode
|
|
@@ -377,7 +488,7 @@
|
|
|
const { geocodes } = result;
|
|
|
if (geocodes?.length > 0) {
|
|
|
// map.setCenter([lng, lat]);
|
|
|
- const { adcode, addressComponent, formattedAddress, location } =
|
|
|
+ const { addressComponent, formattedAddress, location } =
|
|
|
geocodes[0] as any as GeocodesType;
|
|
|
console.log('location', location);
|
|
|
map.setCenter(location);
|
|
@@ -386,7 +497,9 @@
|
|
|
title: formattedAddress,
|
|
|
});
|
|
|
map.add(marker);
|
|
|
- defaultAddress.location = getCodeArray(adcode);
|
|
|
+ defaultAddress.lng = location.lng;
|
|
|
+ defaultAddress.lat = location.lat;
|
|
|
+ defaultAddress.location = getCodeArray(addressComponent);
|
|
|
await updateSchema({
|
|
|
field: 'location',
|
|
|
componentProps: {
|
|
@@ -414,13 +527,41 @@
|
|
|
handleMapSearch();
|
|
|
}
|
|
|
async function handleSubmit() {
|
|
|
+ console.log('userinfo', userinfo.value);
|
|
|
+ const { phone, companyId, id } = userinfo.value;
|
|
|
+ const { lng, lat } = defaultAddress;
|
|
|
+ let requerApi = isUpdate.value ? brandUpdateApi : addSave;
|
|
|
try {
|
|
|
map && map.destroy();
|
|
|
const values = await validate();
|
|
|
- console.log('values', values);
|
|
|
+ const { location, picList, appListPicUrl = [], introduceVideo = [] } = values;
|
|
|
+ let address = unref(location);
|
|
|
+ console.log('values', values, phone, myData);
|
|
|
+ let apiData = {
|
|
|
+ ...values,
|
|
|
+ // contractPhone:phone,
|
|
|
+ createUserDeptId: companyId,
|
|
|
+ latitude: lat,
|
|
|
+ longitude: lng,
|
|
|
+ createUserId: id,
|
|
|
+ address: address.join(',') + ' ' + detailAddr.value,
|
|
|
+ picList: picList && picList.join('#$#'),
|
|
|
+ appListPicUrl: appListPicUrl[0],
|
|
|
+ introduceVideo: introduceVideo[0],
|
|
|
+ sceneNum: myData.sceneNum,
|
|
|
+ introduceVideoCover: myData.introduceVideoCover,
|
|
|
+ };
|
|
|
+ if (myData.id) {
|
|
|
+ apiData.id = myData.id;
|
|
|
+ }
|
|
|
+ await requerApi(apiData);
|
|
|
resetFields();
|
|
|
closeDrawer();
|
|
|
- } catch (error) {}
|
|
|
+ createMessage.success(t('common.optSuccess'));
|
|
|
+ emit('success');
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error);
|
|
|
+ }
|
|
|
}
|
|
|
async function handleClose() {
|
|
|
map && map.destroy();
|
|
@@ -430,6 +571,7 @@
|
|
|
|
|
|
return {
|
|
|
detailAddr,
|
|
|
+ myData,
|
|
|
registerDrawer,
|
|
|
registerForm,
|
|
|
getTitle,
|
|
@@ -439,6 +581,7 @@
|
|
|
handleMapReset,
|
|
|
handleClose,
|
|
|
t,
|
|
|
+ token,
|
|
|
};
|
|
|
},
|
|
|
});
|