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.

383 lines
13 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
  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. <CompanyEditInfoDialog :userCompany="propUserCompany"
  94. :countryOptions="countryOptions" :user_uuid="user_uuid" @refetch-company="getCompanyList"
  95. @refetch-user="getCompanyList" @close-edit-dialog="
  96. companyEditDialogActive = !companyEditDialogActive
  97. "></CompanyEditInfoDialog>
  98. <CompanyAddNewDialog :companyAddNewDialogActive="companyAddNewDialogActive" :countryOptions="countryOptions"
  99. :addNewCompanyList="userAddNewCompanyList" :user_uuid="user_uuid" @refetch-company="getCompanyList"
  100. @refetch-user="getCompanyList" @close-add-new-dialog="
  101. companyAddNewDialogActive = !companyAddNewDialogActive
  102. "></CompanyAddNewDialog>
  103. <CompanyDeleteDialog :deleteCompanyInfoDialogAcitve="companyDeleteDialogAcitve" :userCompany="propUserCompany"
  104. @refetch-company="getCompanyList" @closeCompanyDeleteDialog="
  105. companyDeleteDialogAcitve = !companyDeleteDialogAcitve
  106. "></CompanyDeleteDialog>
  107. </div>
  108. </div>
  109. <loading :isLoading="isPageLoading"></loading>
  110. </div>
  111. </template>
  112. <script>
  113. import TwoDots from "@/components/TwoDots";
  114. import CompanyDeleteDialog from "../../components/user/companyDeleteDialog.vue";
  115. import CompanyEditInfoDialog from "../../components/user/companyEditInfoDialog.vue";
  116. import CompanyAddNewDialog from "../../components/user/companyAddNewDialog.vue";
  117. import jwt_decode from "jwt-decode";
  118. import userSidebar from "@/components/user/userSidebar.vue";
  119. import loading from "@/components/newComponent/loading/loading.vue";
  120. export default {
  121. name: "companyInfo",
  122. layout: "profile",
  123. components: {
  124. TwoDots,
  125. CompanyDeleteDialog,
  126. CompanyEditInfoDialog,
  127. CompanyAddNewDialog,
  128. userSidebar,
  129. loading
  130. },
  131. data() {
  132. return {
  133. firstName: "",
  134. lastName: "",
  135. userData: {},
  136. userCompanyId: [],
  137. userCompanyList: [],
  138. userAddNewCompanyList: [],
  139. userSavedExhibitionList: [],
  140. userVisibleSavedExhibitionList: [],
  141. userSavedExhibitionPageLength: 0,
  142. countryOptions: [],
  143. countrySortOptions: [],
  144. yearSelect: "",
  145. monthSelect: "",
  146. daySelect: "",
  147. phoneValid: false,
  148. companyEditDialogActive: false,
  149. companyAddNewDialogActive: false,
  150. companyDeleteDialogAcitve: false,
  151. propUserCompany: {},
  152. countryOptions: [],
  153. user_uuid: "",
  154. emptyImage: require("~/assets/img/companyEmpty.png"),
  155. userAddNewCompanyList: [],
  156. regionList:[],
  157. countryList:[],
  158. cityList:[],
  159. location:[],
  160. companyTableColumns: [
  161. {
  162. text: "Company Name",
  163. value: "CompanyName",
  164. sortable: false,
  165. width: "16%",
  166. },
  167. {
  168. text: "Tax Number",
  169. value: "TaxNumber",
  170. sortable: false,
  171. width: "16%",
  172. },
  173. {
  174. text: "Country",
  175. value: "company_country",
  176. sortable: false,
  177. width: "10%",
  178. },
  179. {
  180. text: "City",
  181. value: "company_city",
  182. sortable: false,
  183. width: "12%",
  184. },
  185. {
  186. text: "Address",
  187. value: "Street1",
  188. sortable: false,
  189. width: "39%",
  190. },
  191. {
  192. text: "",
  193. value: "action",
  194. sortable: false,
  195. width: "7%",
  196. },
  197. ],
  198. isPageLoading: false,
  199. };
  200. },
  201. beforeCreate(){
  202. },
  203. created() {
  204. this.isPageLoading = true;
  205. this.fetchUserData();
  206. this.getCompanyList();
  207. this.fetchCountry();
  208. this.$nextTick(()=>{
  209. this.isPageLoading = false;
  210. });
  211. },
  212. mounted() {
  213. this.yearOptions = Array.from(new Array(103), (val, index) =>
  214. (index + 1920).toString()
  215. );
  216. this.monthOptions = Array.from(new Array(13), (val, index) => {
  217. if (index < 10 && index > 0) {
  218. return "0" + index.toString();
  219. }
  220. if (index >= 10) {
  221. return index.toString();
  222. }
  223. });
  224. this.dayOptions = Array.from(new Array(32), (val, index) => {
  225. if (index < 10 && index > 0) {
  226. return "0" + index.toString();
  227. }
  228. if (index >= 10) {
  229. return index.toString();
  230. }
  231. });
  232. this.$nextTick(() => {
  233. window.addEventListener("resize", this.onResize);
  234. });
  235. },
  236. methods: {
  237. fetchUserData() {
  238. this.$axios
  239. .get(
  240. `/trending/api/Members/Info`
  241. )
  242. .then((response) => {
  243. //console.log(JSON.stringify(response));
  244. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  245. let data = response.data.DATA.rel
  246. if(data){
  247. this.userData = data;
  248. this.firstName = this.userData.FirstName;
  249. this.lastName = this.userData.LastName;
  250. this.userData.Phone ? (this.phoneValid = true): (this.phoneValid = false);
  251. this.userData.phone
  252. ? (this.phoneValid = true)
  253. : (this.phoneValid = false);
  254. // if(this.userData.ArgumentID == "en-US"){
  255. // this.languageSelect.en = true;
  256. // }else if(this.userData.ArgumentID == "zh-TW"){
  257. // this.languageSelect.zhtw = true;
  258. // }else{
  259. // this.languageSelect.en = "";
  260. // this.languageSelect.zhtw = "";
  261. // }
  262. if (
  263. this.userData.BirthDate && typeof this.userData.BirthDate === "object"
  264. ){
  265. this.yearSelect = "";
  266. this.monthSelect = "";
  267. this.daySelect = "";
  268. }else{
  269. const space = this.userData.BirthDate.split("T");
  270. const date = space[0].split("-");
  271. this.yearSelect = date[0];
  272. this.monthSelect = date[1];
  273. this.daySelect = date[2];
  274. }
  275. }
  276. }
  277. })
  278. .catch((error) => {
  279. console.log(error);
  280. });
  281. },
  282. logout() {
  283. this.$auth.$storage.removeUniversal("jwt");
  284. this.$auth.$storage.removeUniversal("userPicture");
  285. this.$auth.$storage.removeUniversal("userLastName");
  286. this.$auth.$storage.removeUniversal("userBeforePath");
  287. if (window.innerWidth < 1024) {
  288. this.$router.push(this.localePath("/"));
  289. } else {
  290. this.$router.push(this.localePath("/user"));
  291. }
  292. this.$auth.logout();
  293. },
  294. activeEditCompanyInfoDialog(item) {
  295. this.companyEditDialogActive = !this.companyEditDialogActive;
  296. this.propUserCompany = { ...item };
  297. this.$modal.show("edit-company-modal");
  298. },
  299. activeAddNewCompanyInfoDialog() {
  300. this.companyAddNewDialogActive = !this.companyAddNewDialogActive;
  301. },
  302. deleteUserCompany(item) {
  303. // this.companyDeleteDialogAcitve = !this.companyDeleteDialogAcitve;
  304. this.$modal.show("delete-company-modal");
  305. this.propUserCompany = { ...item };
  306. },
  307. getCompanyList() {
  308. this.$axios
  309. .get(
  310. `/trending/api/Members/Companies?Lang=${this.$i18n.localeProperties["langQuery"]}`
  311. )
  312. .then((response) => {
  313. //console.log(JSON.stringify(response));
  314. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  315. let data = response.data.DATA.rel
  316. if(data){
  317. this.userCompanyList = data;
  318. }
  319. }
  320. })
  321. .catch((error) => {
  322. console.log(error);
  323. });
  324. },
  325. fetchCountry() {
  326. this.$axios
  327. .get(`/trending/api/location/countries?RegionID&Lang=${this.$i18n.localeProperties["langQuery"]}`)
  328. .then((response) => {
  329. //console.log(JSON.stringify(response));
  330. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  331. let data = response.data.DATA.rel
  332. if(data){
  333. this.countryList = data;
  334. //console.log(this.countryList);
  335. this.countryOptions = this.countryList.map((item) => {
  336. return {
  337. id: item.CountryID,
  338. name: item.CountryName,
  339. };
  340. });
  341. }
  342. }
  343. })
  344. .catch((error) => {
  345. console.log(error);
  346. });
  347. },
  348. },
  349. watch: {
  350. userCompanyId: {
  351. handler: function () {
  352. this.getCompanyList();
  353. },
  354. deep: true,
  355. },
  356. },
  357. };
  358. </script>
  359. <style scoped lang="scss">
  360. </style>