You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

502 lines
17 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="companyInfo xl:tw-max-w-[1246px] xl:tw-mx-auto">
  3. <div class="xl:tw-flex xl:tw-justify-between xl:tw-items-start">
  4. <userSidebar :userData="userData" :firstName="firstName" :lastName="lastName" class="tw-hidden xl:tw-block">
  5. </userSidebar>
  6. <!-- <div class="xl:tw-hidden"></div> -->
  7. <div class="tw-bg-white xl:tw-p-[30px] xl:tw-rounded-[20px] xl:tw-min-w-[900px] xl:tw-max-w-[900px]">
  8. <div class="tw-text-[20px] tw-mb-[20px] tw-font-bold tw-text-base-primary md:t24 md:tw-mb-[30px]">
  9. <two-dots class="tw-mr-[30px]"></two-dots>{{ $t('userProfile.companyInfo')}}
  10. </div>
  11. <div v-if="userCompanyList.length < 1" class="tw-flex tw-flex-col tw-mb-[50px] tw-mt-[80px] md:tw-mb-[30px]">
  12. <img src="~/assets/svg/noCompanyInfo.svg" class="tw-max-w-[160px] tw-mx-auto md:tw-max-w-[210px]" alt="" />
  13. <div class="tw-text-[16px] tw-text-neutrals-800 tw-w-fit tw-mx-auto md:tw-text-[18px]">
  14. {{ $t("No Company info yet ...") }}
  15. </div>
  16. </div>
  17. <div v-else class="tw-mb-[20px] xl:tw-mb-[30px]">
  18. <!-- 手機版 -->
  19. <div v-for="(item, index) in userCompanyList" :key="`mobile-${index}`"
  20. class="tw-flex tw-justify-between tw-w-full tw-bg-white tw-border tw-border-solid tw-py-[15px] tw-px-[15px] tw-rounded-[10px] tw-border-neutrals-200 xl:tw-px-0 tw-mb-[20px] last:tw-mb-0 md:tw-mb-[30px] xl:tw-hidden">
  21. <div>
  22. <div class="tw-pb-[6px] tw-body-4 tw-text-base-primary tw-font-medium">
  23. {{ item.TaxNumber }}
  24. </div>
  25. <div class="tw-pb-[6px] tw-text-[14px] tw-font-medium tw-text-base-primary">
  26. {{ item.CompanyName }}
  27. </div>
  28. <div class="tw-pb-[6px] tw-body-4 tw-text-base-primary tw-font-medium">
  29. {{
  30. item.Country.CountryName +
  31. "." +
  32. item.CityName
  33. }}
  34. </div>
  35. <div class="tw-text-[14px] tw-text-neutrals-700">
  36. {{ item.Street1 + item.Street2 }}
  37. </div>
  38. </div>
  39. <div class="tw-flex tw-flex-col md:tw-flex-row tw-my-auto xl:tw-hidden">
  40. <button @click="activeEditCompanyInfoDialog(item)" type="button">
  41. <img src="~/assets/svg/edit.svg" alt=""
  42. class="tw-h-[28px] tw-w-[28px] tw-mb-[20px] md:tw-mb-0 md:tw-mr-[15px]" />
  43. </button>
  44. <button @click="deleteUserCompany(item)" type="button">
  45. <img src="~/assets/svg/delete.svg" alt="" class="tw-h-[28px] tw-w-[28px]" />
  46. </button>
  47. </div>
  48. </div>
  49. <!-- 電腦版 -->
  50. <div class="xl:tw-grid tw-gap-[15px] tw-grid-cols-[148px_116px_86px_110px_220px] tw-hidden tw-mb-[30px]">
  51. <div class="tw-text-neutrals-500 tw-body-4">
  52. {{ $t("userProfile.companyName") }}
  53. </div>
  54. <div class="tw-text-neutrals-500 tw-body-4">
  55. {{ $t("userProfile.taxNumber") }}
  56. </div>
  57. <div class="tw-text-neutrals-500 tw-body-4">
  58. {{ $t("userProfile.companyCountry") }}
  59. </div>
  60. <div class="tw-text-neutrals-500 tw-body-4">{{ $t("userProfile.companyCity") }}</div>
  61. <div class="tw-text-neutrals-500 tw-body-4">
  62. {{ $t("userProfile.companyAddress") }}
  63. </div>
  64. </div>
  65. <div v-for="(item, index) in userCompanyList" :key="index"
  66. class="tw-hidden tw-bg-white tw-mb-[20px] last:tw-mb-0 md:tw-mb-[30px] xl:tw-block">
  67. <div class="tw-flex tw-flex-row">
  68. <div class="xl:tw-grid tw-gap-[15px] tw-grid-cols-[148px_116px_86px_110px_220px] tw-mr-[15px]">
  69. <div>{{ item.CompanyName }}</div>
  70. <div>{{ item.TaxNumber }}</div>
  71. <div>{{ item.Country.CountryName }}</div>
  72. <div>{{ item.CityName }}</div>
  73. <div>{{ item.Street1 + item.Street2 }}</div>
  74. </div>
  75. <div>
  76. <button @click="activeEditCompanyInfoDialog(item)" type="button">
  77. <img src="~/assets/svg/edit.svg" alt="" class="tw-h-[28px] tw-w-[28px] tw-mr-[20px]" />
  78. </button>
  79. <button @click="deleteUserCompany(item)" type="button">
  80. <img src="~/assets/svg/delete.svg" alt="" class="tw-h-[28px] tw-w-[28px]" />
  81. </button>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. <button
  87. class="tw-grid tw-grid-cols-[18px_auto] tw-gap-[6px] tw-bg-complementary-1 tw-bg-opacity-10 tw-px-[12px] tw-py-[11px] tw-rounded-[10px] tw-mx-auto tw-mb-[30px] xl:tw-mb-0">
  88. <img src="~/assets/svg/addCompany.svg" alt="" />
  89. <div class="tw-text-[14px] tw-font-medium tw-text-complementary-1" @click="$modal.show('addCompany')">
  90. {{ $t("userProfile.addNewCompany") }}
  91. </div>
  92. </button>
  93. <!-- <v-card
  94. class="mx-7 mb-5 py-3 pe-5 ps-3 border-radius-10"
  95. v-for="(item, index) in userCompanyList"
  96. :key="index"
  97. color="neutrals"
  98. >
  99. <v-spacer class="d-flex">
  100. <v-spacer class="px-3">
  101. <div>{{ item.TaxNumber }}</div>
  102. <div>{{ item.CompanyName }}</div>
  103. <div class="d-flex align-center">
  104. <span>{{ countrySortOptions[item.company_country] }}</span>
  105. <div class="circle-delimeter mx-1"></div>
  106. <span>{{ item.company_city }}</span>
  107. </div>
  108. <div>
  109. <span v-if="item.company_address1">{{
  110. item.company_address1
  111. }}</span>
  112. <span v-if="item.company_address2 && !item.company_address1">{{
  113. item.company_address2
  114. }}</span>
  115. </div>
  116. </v-spacer>
  117. <div class="d-flex align-center">
  118. <v-btn
  119. @click="activeEditCompanyInfoDialog(item)"
  120. class="d-flex justify-center"
  121. icon
  122. >
  123. <unicon name="pen" height="20px" fill="neutrals-darken5" />
  124. </v-btn>
  125. <v-btn @click="deleteUserCompany(item)" icon>
  126. <unicon
  127. name="trash-alt"
  128. height="20px"
  129. fill="neutrals-darken5"
  130. />
  131. </v-btn>
  132. </div>
  133. </v-spacer>
  134. </v-card>
  135. <v-spacer class="d-flex justify-center mb-15">
  136. <v-btn
  137. @click="$modal.show('addCompany')"
  138. color="primary border-radius-12 text-capitalize"
  139. width="150px"
  140. >
  141. <v-icon>mdi-plus</v-icon>
  142. <span>{{ $t("userProfile.addNewCompany") }}</span>
  143. </v-btn>
  144. </v-spacer>
  145. <v-spacer class="mb-4"></v-spacer> -->
  146. <CompanyEditInfoDialog :userCompany="propUserCompany"
  147. :countryOptions="countryOptions" :user_uuid="user_uuid" @refetch-company="getCompanyList"
  148. @refetch-user="getCompanyList" @close-edit-dialog="
  149. companyEditDialogActive = !companyEditDialogActive
  150. "></CompanyEditInfoDialog>
  151. <CompanyAddNewDialog :companyAddNewDialogActive="companyAddNewDialogActive" :countryOptions="countryOptions"
  152. :addNewCompanyList="userAddNewCompanyList" :user_uuid="user_uuid" @refetch-company="getCompanyList"
  153. @refetch-user="getCompanyList" @close-add-new-dialog="
  154. companyAddNewDialogActive = !companyAddNewDialogActive
  155. "></CompanyAddNewDialog>
  156. <CompanyDeleteDialog :deleteCompanyInfoDialogAcitve="companyDeleteDialogAcitve" :userCompany="propUserCompany"
  157. @refetch-company="getCompanyList" @closeCompanyDeleteDialog="
  158. companyDeleteDialogAcitve = !companyDeleteDialogAcitve
  159. "></CompanyDeleteDialog>
  160. </div>
  161. </div>
  162. </div>
  163. </template>
  164. <script>
  165. import TwoDots from "@/components/TwoDots";
  166. import CompanyDeleteDialog from "../../components/user/companyDeleteDialog.vue";
  167. import CompanyEditInfoDialog from "../../components/user/companyEditInfoDialog.vue";
  168. import CompanyAddNewDialog from "../../components/user/companyAddNewDialog.vue";
  169. import jwt_decode from "jwt-decode";
  170. import userSidebar from "@/components/user/userSidebar.vue";
  171. export default {
  172. name: "companyInfo",
  173. layout: "profile",
  174. components: {
  175. TwoDots,
  176. CompanyDeleteDialog,
  177. CompanyEditInfoDialog,
  178. CompanyAddNewDialog,
  179. userSidebar,
  180. },
  181. data() {
  182. return {
  183. firstName: "",
  184. lastName: "",
  185. userData: {},
  186. userCompanyId: [],
  187. userCompanyList: [],
  188. userAddNewCompanyList: [],
  189. userSavedExhibitionList: [],
  190. userVisibleSavedExhibitionList: [],
  191. userSavedExhibitionPageLength: 0,
  192. yearOptions: [],
  193. monthOptions: [],
  194. dayOptions: [],
  195. countryOptions: [],
  196. countrySortOptions: [],
  197. yearSelect: "",
  198. monthSelect: "",
  199. daySelect: "",
  200. phoneValid: false,
  201. companyEditDialogActive: false,
  202. companyAddNewDialogActive: false,
  203. companyDeleteDialogAcitve: false,
  204. propUserCompany: {},
  205. countryOptions: [],
  206. user_uuid: "",
  207. emptyImage: require("~/assets/img/companyEmpty.png"),
  208. userAddNewCompanyList: [],
  209. regionList:[],
  210. countryList:[],
  211. cityList:[],
  212. location:[],
  213. companyTableColumns: [
  214. {
  215. text: "Company Name",
  216. value: "CompanyName",
  217. sortable: false,
  218. width: "16%",
  219. },
  220. {
  221. text: "Tax Number",
  222. value: "TaxNumber",
  223. sortable: false,
  224. width: "16%",
  225. },
  226. {
  227. text: "Country",
  228. value: "company_country",
  229. sortable: false,
  230. width: "10%",
  231. },
  232. {
  233. text: "City",
  234. value: "company_city",
  235. sortable: false,
  236. width: "12%",
  237. },
  238. {
  239. text: "Address",
  240. value: "Street1",
  241. sortable: false,
  242. width: "39%",
  243. },
  244. {
  245. text: "",
  246. value: "action",
  247. sortable: false,
  248. width: "7%",
  249. },
  250. ],
  251. };
  252. },
  253. beforeCreate(){
  254. },
  255. created() {
  256. this.fetchUserData();
  257. // this.fetchSortCountry();
  258. this.getCompanyList();
  259. this.fetchCountry();
  260. if (this.$auth.$storage.getUniversal("jwt")) {
  261. const jsonPayload = jwt_decode(
  262. this.$auth.$storage.getUniversal("jwt").token
  263. );
  264. this.user_uuid = JSON.parse(jsonPayload.ueid);
  265. }
  266. },
  267. mounted() {
  268. this.yearOptions = Array.from(new Array(103), (val, index) =>
  269. (index + 1920).toString()
  270. );
  271. this.monthOptions = Array.from(new Array(13), (val, index) => {
  272. if (index < 10 && index > 0) {
  273. return "0" + index.toString();
  274. }
  275. if (index >= 10) {
  276. return index.toString();
  277. }
  278. });
  279. this.dayOptions = Array.from(new Array(32), (val, index) => {
  280. if (index < 10 && index > 0) {
  281. return "0" + index.toString();
  282. }
  283. if (index >= 10) {
  284. return index.toString();
  285. }
  286. });
  287. this.$nextTick(() => {
  288. window.addEventListener("resize", this.onResize);
  289. });
  290. },
  291. methods: {
  292. fetchSortCountry() {
  293. this.$axios
  294. .get(
  295. `t/exhibitions/locations?lang=${this.$i18n.locale.replace(
  296. "-",
  297. ""
  298. )}&sort=False`
  299. )
  300. .then((res) => {
  301. this.countrySortOptions = res.data.country_name_list;
  302. })
  303. .catch((err) => {
  304. console.log(err);
  305. });
  306. },
  307. patchUserData() {
  308. if (this.width < 1366) {
  309. this.isEditInfoDialogActive = !this.isEditInfoDialogActive;
  310. }
  311. //this.userData.prefer_country = JSON.stringify(this.languageSelect);
  312. if (this.$vuetify.breakpoint.name !== "xs") {
  313. this.userData.birth_date =
  314. this.yearSelect + "-" + this.monthSelect + "-" + this.daySelect;
  315. if (this.userData.birth_date.length < 10) {
  316. this.userData.birth_date = null;
  317. }
  318. }
  319. const patchData = JSON.parse(JSON.stringify(this.userData));
  320. delete patchData.LoginLog;
  321. delete patchData.UserCompany;
  322. delete patchData.UserSocialRelation;
  323. delete patchData.UserExhibition;
  324. this.$axios
  325. .put(
  326. `/member/users/${this.$auth.$storage.getUniversal("jwt").user_id
  327. }?jwt=${this.$auth.$storage.getUniversal("jwt").token || ""}`,
  328. patchData
  329. )
  330. .then((res) => {
  331. this.successUpdate = !this.successUpdate;
  332. setTimeout(() => {
  333. this.successUpdate = !this.successUpdate;
  334. }, 1000);
  335. this.fetchUserData();
  336. this.$auth.$storage.setUniversal("userPicture", patchData.picture);
  337. this.$auth.$storage.setUniversal("userLastName", patchData.last_name);
  338. this.$store.dispatch("updatePicture");
  339. })
  340. .catch((err) => {
  341. console.log(err);
  342. });
  343. },
  344. fetchUserData() {
  345. this.$axios
  346. .get(
  347. `/trending/api/Members/Info`
  348. )
  349. .then((response) => {
  350. //console.log(JSON.stringify(response));
  351. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  352. let data = response.data.DATA.rel
  353. if(data){
  354. this.userData = data;
  355. this.firstName = this.userData.FirstName;
  356. this.lastName = this.userData.LastName;
  357. this.userData.Phone ? (this.phoneValid = true): (this.phoneValid = false);
  358. this.userData.phone
  359. ? (this.phoneValid = true)
  360. : (this.phoneValid = false);
  361. // if(this.userData.ArgumentID == "en-US"){
  362. // this.languageSelect.en = true;
  363. // }else if(this.userData.ArgumentID == "zh-TW"){
  364. // this.languageSelect.zhtw = true;
  365. // }else{
  366. // this.languageSelect.en = "";
  367. // this.languageSelect.zhtw = "";
  368. // }
  369. if (
  370. this.userData.BirthDate && typeof this.userData.BirthDate === "object"
  371. ){
  372. this.yearSelect = "";
  373. this.monthSelect = "";
  374. this.daySelect = "";
  375. }else{
  376. const space = this.userData.BirthDate.split("T");
  377. const date = space[0].split("-");
  378. this.yearSelect = date[0];
  379. this.monthSelect = date[1];
  380. this.daySelect = date[2];
  381. }
  382. }
  383. }
  384. })
  385. .catch((error) => {
  386. console.log(error);
  387. });
  388. },
  389. logout() {
  390. this.$auth.$storage.removeUniversal("jwt");
  391. this.$auth.$storage.removeUniversal("userPicture");
  392. this.$auth.$storage.removeUniversal("userLastName");
  393. this.$auth.$storage.removeUniversal("userBeforePath");
  394. if (window.innerWidth < 1024) {
  395. this.$router.push(this.localePath("/"));
  396. } else {
  397. this.$router.push(this.localePath("/user"));
  398. }
  399. this.$auth.logout();
  400. },
  401. handleImageUpdate(pictureURL) {
  402. this.userData.picture = pictureURL;
  403. //this.patchUserData();
  404. this.closeCropDialog();
  405. },
  406. activeEditCompanyInfoDialog(item) {
  407. this.companyEditDialogActive = !this.companyEditDialogActive;
  408. this.propUserCompany = { ...item };
  409. this.$modal.show("edit-company-modal");
  410. },
  411. activeAddNewCompanyInfoDialog() {
  412. this.companyAddNewDialogActive = !this.companyAddNewDialogActive;
  413. },
  414. deleteUserCompany(item) {
  415. // this.companyDeleteDialogAcitve = !this.companyDeleteDialogAcitve;
  416. this.$modal.show("delete-company-modal");
  417. this.propUserCompany = { ...item };
  418. },
  419. getCompanyList() {
  420. this.$axios
  421. .get(
  422. `/trending/api/Members/Companies?Lang=${this.$i18n.localeProperties["langQuery"]}`
  423. )
  424. .then((response) => {
  425. //console.log(JSON.stringify(response));
  426. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  427. let data = response.data.DATA.rel
  428. if(data){
  429. this.userCompanyList = data;
  430. }
  431. }
  432. })
  433. .catch((error) => {
  434. console.log(error);
  435. });
  436. },
  437. fetchCountry() {
  438. this.$axios
  439. .get(`/trending/api/location/countries?RegionID&Lang=${this.$i18n.localeProperties["langQuery"]}`)
  440. .then((response) => {
  441. //console.log(JSON.stringify(response));
  442. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  443. let data = response.data.DATA.rel
  444. if(data){
  445. this.countryList = data;
  446. //console.log(this.countryList);
  447. this.countryOptions = this.countryList.map((item) => {
  448. return {
  449. id: item.CountryID,
  450. name: item.CountryName,
  451. };
  452. });
  453. }
  454. }
  455. })
  456. .catch((error) => {
  457. console.log(error);
  458. });
  459. },
  460. },
  461. watch: {
  462. userCompanyId: {
  463. handler: function () {
  464. this.getCompanyList();
  465. },
  466. deep: true,
  467. },
  468. },
  469. };
  470. </script>
  471. <style scoped lang="scss">
  472. </style>