123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- import {
- researcherList,
- telTypes,
- addActivity,
- editActivity,
- companyInfo
- } from '@/api/roadshow/index.js';
- import { getDefaultOption } from './common.js';
- import { validateForm } from '../utils/validate.js';
- import { areaList } from '../utils/area.js';
- const moment = require('../utils/_moment.js');
- moment.locale('zh-cn');
- export default {
- data() {
- return {
- edit_id: '',
- edit_rs_id: '',
- formData: {
- activityType: '',
- activityClass: '',
- roadshowType: '',
- roadshowPlatform: '',
- roadshowCity: '',
- companyId: 0,
- companyName: '',
- meetingTheme: '',
- partnersName: '',
- selectResearchers: [
- {
- researcherId: '',
- startTime: '',
- endTime: '',
- }
- ],
- },
-
- isActivityPicker: false,
- isResearcherPicker: false,
- isTimePicker: false,
- isAreaPicker: false,
- isRoadshowTypePicker: false,
- isActivityClassPicker: false,
- rs_picker: {
- firstindex:0,
- id:[],
- },
- pickerForm: {
- time: '',
- area:'',
- },
- selectObj: {},
- selectRsIndex: '',
-
-
-
-
-
-
-
-
-
- activiytyTypes: [],
- researcherList: [],
- telTypeList: [],
- areaList,
- companyInfo: null,
- }
- },
- computed: {
-
- dynamic_prefix() {
- return this.formData.activityType === '路演' ? '路演' : '会议';
- },
-
- addResearchersIdx() {
- return this.formData.selectResearchers.map((item, index) => index).slice(1);
- },
- },
- watch: {
- },
- methods: {
-
- async getResearcherList() {
- const res = await researcherList();
- if (res.code !== 200) return
- this.researcherList = res.data.map(group => ({
- ...group,
- text: group.GroupName,
- children: group.ResearcherList ? group.ResearcherList.map(child => ({
- ...child,
- text: child.RealName,
- id: child.AdminId
- })) : []
- }));
- },
-
-
- async getCompanyInfo() {
- const res = await companyInfo({
- CompanyId: this.formData.companyId,
- EnglishCompany:this.formData.englishCompany
- })
- if(res.code !== 200) return
- this.companyInfo = res.data;
- this.formData.companyName = res.data.CompanyName;
-
- },
-
-
- async getTelType() {
- const { code,data } = await telTypes();
- if (code !== 200) return
- this.telTypeList = data[0].ChildList.map(_ => _.ActivityTypeName);
- },
-
-
- addActivityLink({text,content,link,query}) {
- uni.showModal({
- title:text,
- content,
- confirmText:'去查看',
- cancelColor: '#A9AFB8',
- confirmColor: '#3385FF',
- success: function(res) {
- if(res.confirm){
- uni.redirectTo({
- url:`${link}?type=${query.type}`,
- })
- }else {
- uni.navigateBack({
- delta:1
- })
- }
- }
- })
- },
-
-
- async submitHandle() {
-
- console.log(this.formData)
- let isCheck = validateForm(this.formData.activityType,this.formData);
- console.log(isCheck)
- if(!isCheck) return
-
-
- let parmas;
- const param_research = ['公开会议', '路演'].includes(
- this.formData.activityType
- ) ?
- this.formData.selectResearchers.map((item) => ({
- ResearcherId: Number(item.researcherId),
- ResearcherName: this.findName(item.researcherId),
- StartDate: moment(item.startTime).format('YYYY-MM-DD'),
- EndDate: moment(item.endTime).format('YYYY-MM-DD'),
- StartTime: moment(item.startTime).format('HH:mm:ss'),
- EndTime: moment(item.endTime).format('HH:mm:ss'),
- StartWeek: moment(item.startTime).format('ddd'),
- EndWeek: moment(item.endTime).format('ddd'),
- })) :
- this.formData.selectResearchers[0].researcherId.map((item) => ({
- ResearcherId: Number(item),
- ResearcherName: item === 99 ? 'ficc全体' : this.findName(item),
- StartDate: moment(
- this.formData.selectResearchers[0].startTime
- ).format('YYYY-MM-DD'),
- EndDate: moment(
- this.formData.selectResearchers[0].endTime
- ).format('YYYY-MM-DD'),
- StartTime: moment(
- this.formData.selectResearchers[0].startTime
- ).format('HH:mm:ss'),
- EndTime: moment(
- this.formData.selectResearchers[0].endTime
- ).format('HH:mm:ss'),
- StartWeek: moment(this.formData.selectResearchers[0].startTime).format('ddd'),
- EndWeek: moment(this.formData.selectResearchers[0].endTime).format('ddd'),
- }));
-
- parmas = {
- ActivityType: this.formData.activityType,
- ActivityCategory: this.formData.activityClass,
- City: this.formData.roadshowCity[1],
- Province: this.formData.roadshowCity[0],
- CooperationName: this.formData.partnersName,
- Theme: this.formData.meetingTheme,
- RoadshowType: this.formData.roadshowType,
- RoadshowPlatform: this.formData.roadshowPlatform,
- CompanyId: this.formData.companyId || 0,
- CompanyName: this.formData.companyName || '',
- ResearcherList: param_research,
- EnglishCompany:this.formData.englishCompany
- };
-
-
-
- const res = this.edit_id ?
- await editActivity({
- ...parmas,
- RsCalendarId: Number(this.edit_id),
- RsCalendarResearcherId: Number(this.edit_rs_id),
- EditType: ['公开会议', '路演'].includes(this.formData.activityType) ? 2 : 1
- }) : await addActivity(parmas);
-
- if (res.code !== 200) return;
-
- const { text,content,link,query } = this.setDynamicLink(this.formData.activityType);
-
-
- this.edit_id ? uni.showToast({
- title: '提交成功',
- icon: 'success'
- }) : this.addActivityLink({text,content,link,query});
-
- this.edit_id && setTimeout(() => {
- this.cancelHandle();
- },1500);
- },
-
-
- addResearcherHandle() {
- const {
- startTime,
- endTime
- } =
- this.formData.selectResearchers[0];
- this.formData.selectResearchers.push({
- researcherId: null,
- startTime,
- endTime,
- });
- },
-
- delResearcherHandle(index) {
- this.formData.selectResearchers.splice(index, 1);
- },
-
-
- cancelHandle() {
- uni.navigateBack({
- delta:1
- })
- },
- findName(id) {
- const flat_arr = JSON.parse(JSON.stringify(this.researcherList))
- .map((item) => item.ResearcherList || [])
- .flat(Infinity);
- return flat_arr.find((user) => user.AdminId === id)
- ? flat_arr.find((user) => user.AdminId === id).RealName
- : '';
- },
-
-
- confirmActivityType({detail}) {
- this.formData.activityType = detail.value;
- this.initOtherForm();
- this.isActivityPicker = false;
- },
-
-
- initOtherForm() {
- const {
- RoleTypeCode
- } = JSON.parse(uni.getStorageSync('userInfo')) || null;
- const {
- defaultActivityType,
- activityTypeList,
- startTime,
- endTime
- } = getDefaultOption(RoleTypeCode, 2);
-
- this.formData.roadshowType = '';
- this.formData.roadshowPlatform = '';
- this.formData.roadshowCity = '';
- this.formData.companyId = 0;
- this.formData.companyName = '';
- this.formData.meetingTheme = '';
- this.formData.partnersName = '';
- this.formData.activityClass = '';
- this.companyInfo = '';
-
- let pages = getCurrentPages();
- let route = pages[pages.length-1].route;
-
- if(route === 'pages-roadshow/addActivity/byCell') {
-
- this.formData.selectResearchers = ['内部会议','报告电话会'].includes(this.formData.activityType)
- ? [{
- researcherId: [ this.defaultResearcher[0].researcherId ],
- startTime: this.defaultResearcher[0].startTime,
- endTime: this.defaultResearcher[0].endTime
- }]
- : this.defaultResearcher;
- } else {
-
- this.formData.selectResearchers = [{
- researcherId: '',
- startTime: startTime,
- endTime: endTime,
- }];
- }
- },
-
-
- confirmActivityClass({detail}) {
- this.formData.activityClass = detail.value;
- this.isActivityClassPicker = false;
- },
-
- goSearchCompany() {
- uni.navigateTo({
- url: `/pages-approve/search/index?type=roadshow`
- })
- },
-
-
- clickRsChoose(index,type='') {
- if((this.edit_id && ['路演','公开会议'].includes(this.formData.activityType)) || type) return;
-
- this.isResearcherPicker = true;
- console.log(this.formData.selectResearchers[index])
-
- this.selectRsIndex = index;
- this.rs_picker= {
- firstindex:0,
- id: this.formData.selectResearchers[index].researcherId ?
- (['路演','公开会议'].includes(this.formData.activityType) ?
- this.formData.selectResearchers[index].researcherId :
- this.formData.selectResearchers[index].researcherId.map(item => item))
- : []
- }
-
- },
-
-
- clickFirstHandle({detail}) {
-
- this.rs_picker.firstindex = detail.index;
- },
-
-
- clickItemHandle({detail}) {
- const { activityType } = this.formData;
-
- if(['内部会议', '报告电话会'].includes(activityType)) {
-
- let index = this.rs_picker.id.indexOf(detail.AdminId);
- index > -1 ? this.rs_picker.id.splice(index, 1) : this.rs_picker.id.push(detail.AdminId);
-
- }else {
- this.rs_picker.id = detail.AdminId;
- }
- },
-
-
- cancelResearcher() {
- this.rs_picker = {
- firstindex: 0,
- id: []
- }
-
- this.isResearcherPicker = false;
- },
-
- confirmResearcher() {
- console.log('确认选择')
- this.formData.selectResearchers[this.selectRsIndex].researcherId = this.rs_picker.id;
-
- this.isResearcherPicker = false;
- },
-
-
- formatRsLable(arr) {
- if(!arr) return '';
- if( arr instanceof Array ) {
- return arr.map(item => {
- return this.findName(item)
- })
- }else {
- return this.findName(arr)
- }
- },
-
- confirmRoadshowType({
- detail
- }) {
- this.formData.roadshowType = detail.value;
-
- this.formData.roadshowPlatform = '';
- this.formData.roadshowCity = '';
- this.isRoadshowTypePicker = false;
- },
-
-
- clickAreaChoose() {
- const city = this.formData.roadshowCity.length ? this.formData.roadshowCity[1] : '';
- let cityCode = '';
- if(city) for(let i in this.areaList.city_list) {
- if(this.areaList.city_list[i] === city){
- cityCode = String(i);
- break;
- }
- }
-
- this.pickerForm.area = cityCode;
- this.isAreaPicker = true
- },
-
-
- confirmArea({detail}) {
- const { values } = detail;
- this.formData.roadshowCity = values.map(item => item.name);
-
- this.isAreaPicker = false;
- },
-
- clickTimeChoose(index, type) {
- console.log(this.formData.selectResearchers[index])
- this.pickerForm.time = type === 'start' ? this.formData.selectResearchers[index].startTime : this.formData.selectResearchers[index].endTime;
- this.selectObj = {
- index,
- type
- }
- setTimeout(() => {
- this.isTimePicker = true;
- })
- },
-
- confirmTime({detail}) {
-
- const {
- index,
- type
- } = this.selectObj;
- if (type === 'start') {
- this.formData.selectResearchers[index].startTime = detail;
- } else {
- this.formData.selectResearchers[index].endTime = detail;
- }
- this.isTimePicker = false;
- this.pickerForm.time = '';
- },
-
-
- setDynamicLink(type) {
- switch (type) {
- case '内部会议' : return {
- text: '添加成功,已加入研究员日历',
- content: `可前往【我的日历】-【${type}】查看`,
- link: '/pages-approve/activity/list',
- query: {
- type
- },
- }
- case '报告电话会' : return {
- text: '添加成功,已加入研究员日历',
- content: `可前往【我的日历】-【${type}】查看`,
- link: '/pages-approve/activity/list',
- query: {
- type
- },
- }
- case '路演' : return {
- text: '活动申请已提交,请等待研究员处理',
- content: `可前往【我的日历】-【活动申请】查看`,
- link: '/pages-approve/activity/list',
- query: {
- type: '活动申请'
- },
- }
- case '公开会议' : return {
- text: '活动申请已提交,请等待研究员处理',
- content: `可前往【我的日历】-【活动申请】查看`,
- link: '/pages-approve/activity/list',
- query: {
- type: '活动申请'
- },
- }
- }
- },
-
- bindInputHandle(key,{detail}) {
- this.formData[key] = detail;
- },
-
- formatterLabelTime(val) {
- if(!val) return '';
- const date = moment(val).format('MM.DD(ddd) HH:mm');
- return date;
- },
-
- formatterPickerTime(type, val) {
- switch (type) {
- case 'year':
- return val + '年';
- case 'month':
- return val + '月';
- case 'day':
- return val + '日';
- case 'hour':
- return val + '时';
- case 'minute':
- return val + '分';
- }
- }
- }
- }
|