diff --git a/index.html b/index.html
index f923a93..f7cfb69 100644
--- a/index.html
+++ b/index.html
@@ -9,8 +9,8 @@
#result{text-align:center;padding:20px}.bi-check-circle-fill,.bi-exclamation-circle-fill,.bi-x-circle-fill{fill:#d54e21}.bi-x-circle-fill{fill:#d54e21}
-
-
+
+
@@ -54,7 +54,7 @@
Thank you for completing the Feedback Evaluation. Once submitted the tour guide would not be able to view your comments.
@@ -134,10 +134,10 @@
- {{group.cityName}}
+ {{currentCity.cityName}}
' +
- '' +
+ '' +
'' +
'
' +
'
{{selectedRatingText}}' +
@@ -275,9 +275,11 @@
currentCity: {},
cityListOpen: false,
+ feedbackCity: {},
+
isFilled: false,
feedbackItemList: [],
- feedbackItem: { guide: [], driver: [], experience: [] },
+ feedbackItem: { guide: [], driver: [], experience: [], hotel: [] },
tourGuideList: [],
feedbackEvaluation: {},
group: {},
@@ -324,32 +326,53 @@
const that = this;
get(
`${HOST}/get_feedback_city`,
- // g=338947&v=30008&e=245176&c=1186
{ GRI_SN: that.param.g, VEI_SN: that.param.v, lgc: this.param.l },
{ headers: { ...{} } }
).then((res) => {
that.loading = false;
- that.cityList = res.cityList;
- console.log(groupBy(res.cityList, 'tourGuideId'));
that.error = res.cityList.length === 0;
that.errorMsg = 'No city found';
+
+ const mergeCity = groupBy(res.cityList, ele => isEmpty(ele.tourGuideId) ? 'unknown' : ele.tourGuideId);
+ const mergeCityA = Object.keys(mergeCity).reduce((r, tgid) => {
+ if ( (tgid !== 'unknown')) {
+ return r.concat(mergeCity[tgid].length > 1 ? [{
+ ...mergeCity[tgid][0],
+ cii_sn: mergeCity[tgid].map(v => v.cii_sn).join('_'),
+ cii_sn_arr: mergeCity[tgid].map(v => v.cii_sn),
+ cityName: mergeCity[tgid].map((v) => v.cityName).join(' & '),
+ cities: mergeCity[tgid],
+ }] : mergeCity[tgid][0] );
+ }
+ return r.concat(mergeCity[tgid]);
+ }, []);
+ that.cityList = mergeCityA;
});
},
selectCity(city) {
+ window.scrollTo({ top: 100, behavior: 'smooth' });
+ this.cityListOpen = false;
+ if (this.currentCity.cii_sn === city.cii_sn) {
+ return false;
+ }
this.cityListPage = false;
this.loading = true;
const _param = {
GRI_SN: this.param.g,
VEI_SN: this.param.v,
- CITY_SN: city.cii_sn,
+ // CITY_SN: city.cii_sn,
lgc: this.param.l
};
- this.currentCity = Object.assign({}, city, _param);
-
- this.getData(_param);
- window.scrollTo({ top: 100, behavior: 'smooth' });
- this.cityListOpen = false;
-
+ const selectedCity = Object.assign({}, city, _param);
+ // console.log(selectedCity);
+ this.currentCity = selectedCity;
+ if (selectedCity.cii_sn_arr) {
+ for (const iterator of selectedCity.cii_sn_arr) {
+ this.getData(Object.assign({}, _param, { CITY_SN: iterator }), true);
+ }
+ } else {
+ this.getData(Object.assign({}, _param, { CITY_SN: selectedCity.cii_sn }));
+ }
},
initSignature() {
var canvas = document.getElementById('signature-pad');
@@ -362,16 +385,11 @@
// console.log(data);
this.signaturePad.clear();
},
- getData(param) {
+ getData(param, continually = false) {
const that = this;
get(
- // `${HOST}/feedback/customer_feedback`,
`${HOST}/get_feedback_service_item`,
- // {group_id: 69291, tour_guide_id: 730},
- // { group_id: that.param.g, tour_guide_id: that.param.tg },
- // g=338947&v=30008&e=245176&c=1186
param,
- // { GRI_SN: that.param.g, VEI_SN: that.param.v, EOI_SN: that.param.e, CITY_SN: that.param.c, lgc: 1 },
{ headers: { ...{} } }
).then((res) => {
that.loading = false;
@@ -380,13 +398,11 @@
that.errorMsg = 'Data error.';
return false;
}
+ that.feedbackCity[`city_${res.feedbackEvaluation[0].feedback_cii_sn}`] = res;
+
const itemGroup = groupBy(res.feedbackItemList, ele => ele.type);
that.feedbackItem.guide = itemGroup.W ? itemGroup.W : [];
that.feedbackItem.driver = itemGroup.Y ? itemGroup.Y : [];
- // that.feedbackItem.experience = [
- // ...(itemGroup['7'] || []),
- // ...(itemGroup.C || []),
- // ...(itemGroup.A || []).map(ele => ({ ...ele, Describe: 'Hotel\n' + ele.name })),];
let experience = [];
if (itemGroup['7']) {
experience = experience.concat(itemGroup['7']);
@@ -397,14 +413,22 @@
if (itemGroup.G) {
experience = experience.concat(itemGroup.G);
}
+ let hotel = [];
if (itemGroup.A) {
- experience = experience.concat(itemGroup.A.map(function (ele) {
+ hotel = hotel.concat(itemGroup.A.map(function (ele) {
var newEle = Object.assign({}, ele);
newEle.Describe = 'Hotel\n' + ele.name;
return newEle;
}));
+ that.currentCity[`city_${res.feedbackEvaluation[0].feedback_cii_sn}`] = hotel;
+ }
+ if (continually) {
+ const mergeHotel = [].concat(that.feedbackItem.hotel, hotel);
+ that.feedbackItem.experience = [].concat(experience, mergeHotel);
+ that.feedbackItem.hotel = mergeHotel;
+ } else {
+ that.feedbackItem.experience = [].concat(experience, hotel);
}
- that.feedbackItem.experience = experience;
that.feedbackItemList = res.feedbackItemList;
that.tourGuideList = res.tourGuideList;
@@ -428,9 +452,9 @@
submitForm() {
const that = this;
- if (that.signaturePad.isEmpty()) {
- alert("Please provide a signature first.");
- event.preventDefault();
+ event.preventDefault();
+ if (that.signaturePad?.isEmpty()) {
+ // alert("Please provide a signature first.");
} else {
that.loading = true;
// var data = that.signaturePad.toDataURL(); // default: image/png
@@ -446,38 +470,41 @@
return obj;
}, {});
- // Print the form values to the console
- var rateArr = that.feedbackItemList.map(ele => {
- return { id: ele.id, sn: ele.sn, rate: formValues[`rate-${ele.id}`] || 0, };
- });
- // Send data to server along with the form data...
- // Submit the form manually
- // form.submit();
- // console.log(formValues); return;
- postForm(
- `${HOST}/save_feedback`,
- {
- EOI_SN: that.group.EOI_SN,
- GRI_SN: that.currentCity.GRI_SN,
- VEI_SN: that.currentCity.VEI_SN,
- // country_id:,
- city_sn: that.currentCity.cii_sn,
- tour_guide_id: that.currentCity.tourGuideId,
- use_the_photos: formValues.photo_permission || -1,
- other_comments: formValues.comments,
- service_item_answer: JSON.stringify(rateArr),
- signature_data_url: formValues.signature,
- feedback_id: that.feedbackEvaluation.feedbackId || undefined,
- },
- { headers: { ...{} } }
- ).then(res => {
- that.loading = false;
- if (res.errcode == 0) {
- that.isFilled = true;
- that.cityListPage = true;
- that.currentCity = {};
- } else { }
- });
+ const citySNList = that.currentCity.cii_sn_arr || [that.currentCity.cii_sn]
+ for (const iterator of citySNList) {
+ const rateArr = that.feedbackCity[`city_${iterator}`].feedbackItemList.map(ele => {
+ return { id: ele.id, rate: formValues[`rate-${ele.type}-${ele.syc_sn}-${ele.sn}`] || 0, };
+ });
+ // Submit the form manually
+ // console.log(formValues, rateArr);
+ // continue;
+ postForm(
+ `${HOST}/save_feedback`,
+ {
+ EOI_SN: that.group.EOI_SN,
+ GRI_SN: that.currentCity.GRI_SN,
+ VEI_SN: that.currentCity.VEI_SN,
+ // country_id:,
+ // tour_guide_id: that.currentCity.tourGuideId,
+ tour_guide_id: that.feedbackCity[`city_${iterator}`].feedbackEvaluation[0]?.tourGuideId || undefined,
+ city_sn: iterator,
+ use_the_photos: formValues.photo_permission || -1,
+ other_comments: formValues.comments,
+ feedback_id: that.feedbackCity[`city_${iterator}`].feedbackEvaluation[0]?.feedbackId || undefined,
+ service_item_answer: JSON.stringify(rateArr),
+ signature_data_url: formValues.signature,
+ },
+ { headers: { ...{} } }
+ ).then(res => {
+ that.loading = false;
+ if (res.errcode == 0) {
+ that.isFilled = true;
+ that.cityListPage = true;
+ that.currentCity = {};
+ } else { }
+ });
+ }
+
}
},