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.

201 lines
6.6 KiB

2 years ago
  1. <template>
  2. <v-dialog v-model="companyInfoDialogActive" fullscreen @click:outside="$emit('close-company-dialog')">
  3. <v-card>
  4. <v-spacer v-if="$vuetify.breakpoint.smAndUp" class="pt-9"></v-spacer>
  5. <v-spacer class="pt-15 pa-7">
  6. <v-spacer :class="$vuetify.breakpoint.smAndUp ? 'd-flex align-center pt-15' : 'd-flex align-center pt-10'">
  7. <div class="circle-decoration me-2"></div>
  8. <div class="circle-decoration me-2"></div>
  9. <span class="font-weight-bold text-size-20 ms-7 text-height-26">{{ $t("userProfile.companyInfo") }}</span>
  10. </v-spacer>
  11. </v-spacer>
  12. <v-card class="mx-7 mb-5 py-3 pe-5 ps-3 border-radius-10" v-for="(item,index) in userCompanyList" :key="index" color="neutrals">
  13. <v-spacer class="d-flex">
  14. <v-spacer class="px-3">
  15. <div>{{ item.company_tax_no }}</div>
  16. <div>{{ item.company_name }}</div>
  17. <div class="d-flex align-center">
  18. <span>{{ countrySortOptions[item.company_country] }}</span>
  19. <div class="circle-delimeter mx-1"></div>
  20. <span>{{ item.company_city }}</span>
  21. </div>
  22. <div>
  23. <span v-if="item.company_address1">{{ item.company_address1 }}</span>
  24. <span v-if="item.company_address2 && !item.company_address1">{{ item.company_address2 }}</span>
  25. </div>
  26. </v-spacer>
  27. <div class="d-flex align-center">
  28. <v-btn @click="activeEditCompanyInfoDialog(item)" class="d-flex justify-center" icon>
  29. <unicon name="pen" height="20px" fill="neutrals-darken5"/>
  30. </v-btn>
  31. <v-btn @click="deleteUserCompany(item)" icon>
  32. <unicon name="trash-alt" height="20px" fill="neutrals-darken5"/>
  33. </v-btn>
  34. </div>
  35. </v-spacer>
  36. </v-card>
  37. <v-spacer class="d-flex justify-center mb-15">
  38. <v-btn @click="activeAddNewCompanyInfoDialog" color="primary border-radius-12 text-capitalize" width="150px">
  39. <v-icon>mdi-plus</v-icon>
  40. <span>{{ $t("userProfile.addNewCompany") }}</span>
  41. </v-btn>
  42. </v-spacer>
  43. <v-spacer class="mb-4"></v-spacer>
  44. </v-card>
  45. <CompanyEditInfoDialog
  46. :companyEditInfoDialogActive="companyEditDialogActive"
  47. :userCompany="propUserCompany"
  48. :countryOptions="countryOptions"
  49. :user_uuid="user_uuid"
  50. @refetch-company="getCompanyList"
  51. @refetch-user="fetchUserData"
  52. @close-edit-dialog="companyEditDialogActive = !companyEditDialogActive"
  53. ></CompanyEditInfoDialog>
  54. <CompanyAddNewDialog
  55. :companyAddNewDialogActive="companyAddNewDialogActive"
  56. :countryOptions="countryOptions"
  57. :addNewCompanyList="userAddNewCompanyList"
  58. :user_uuid="user_uuid"
  59. @refetch-company="getCompanyList"
  60. @refetch-user="fetchUserData"
  61. @close-add-new-dialog="companyAddNewDialogActive = !companyAddNewDialogActive"
  62. ></CompanyAddNewDialog>
  63. <CompanyDeleteDialog
  64. :deleteCompanyInfoDialogAcitve="companyDeleteDialogAcitve"
  65. :companyData="propUserCompany"
  66. @refetch-company="getCompanyList"
  67. @refetch-user="fetchUserData"
  68. @closeCompanyDeleteDialog="companyDeleteDialogAcitve = !companyDeleteDialogAcitve"
  69. ></CompanyDeleteDialog>
  70. </v-dialog>
  71. </template>
  72. <script>
  73. import CompanyDeleteDialog from '../../components/user/companyDeleteDialog.vue'
  74. import CompanyEditInfoDialog from '../../components/user/companyEditInfoDialog.vue'
  75. import CompanyAddNewDialog from '../../components/user/companyAddNewDialog.vue'
  76. import jwt_decode from 'jwt-decode'
  77. export default {
  78. name: "CompanyInfoDialog",
  79. components: {
  80. CompanyEditInfoDialog,CompanyAddNewDialog,CompanyDeleteDialog
  81. },
  82. props: {
  83. companyInfoDialogActive: {
  84. type: Boolean,
  85. required: true,
  86. default: false
  87. },
  88. userCompanyId: {
  89. type: Array,
  90. required: true,
  91. default: () => []
  92. },
  93. countrySortOptions: {
  94. type: Array,
  95. required: true,
  96. default: () => []
  97. }
  98. },
  99. data() {
  100. return {
  101. companyEditDialogActive: false,
  102. companyAddNewDialogActive: false,
  103. companyDeleteDialogAcitve: false,
  104. propUserCompany:{},
  105. countryOptions:[],
  106. user_uuid: '',
  107. emptyImage: require('~/assets/img/companyEmpty.png'),
  108. userCompanyList:[],
  109. userAddNewCompanyList:[],
  110. companyTableColumns: [
  111. {
  112. text: 'Company Name',
  113. value: 'company_name',
  114. sortable:false,
  115. width:'16%'
  116. },
  117. {
  118. text: 'Tax Number',
  119. value: 'company_tax_no',
  120. sortable:false,
  121. width:'16%'
  122. },
  123. {
  124. text: 'Country',
  125. value: 'company_country',
  126. sortable:false,
  127. width:'10%'
  128. },
  129. {
  130. text: 'City',
  131. value: 'company_city',
  132. sortable:false,
  133. width:'12%'
  134. },
  135. {
  136. text: 'Address',
  137. value: 'company_address',
  138. sortable:false,
  139. width:'39%'
  140. },
  141. {
  142. text: '',
  143. value: 'action',
  144. sortable:false,
  145. width:'7%'
  146. },
  147. ]
  148. }
  149. },
  150. created() {
  151. this.getCompanyList()
  152. this.fetchCountry()
  153. if (this.$auth.$storage.getUniversal('jwt')) {
  154. const jsonPayload = jwt_decode(this.$auth.$storage.getUniversal('jwt').token)
  155. this.user_uuid = JSON.parse(jsonPayload.ueid)
  156. }
  157. },
  158. methods: {
  159. activeEditCompanyInfoDialog(item) {
  160. this.companyEditDialogActive = !this.companyEditDialogActive
  161. this.propUserCompany = {...item}
  162. },
  163. activeAddNewCompanyInfoDialog() {
  164. this.companyAddNewDialogActive = !this.companyAddNewDialogActive
  165. },
  166. deleteUserCompany(item) {
  167. this.companyDeleteDialogAcitve = !this.companyDeleteDialogAcitve
  168. this.propUserCompany = {...item}
  169. },
  170. getCompanyList() {
  171. this.$axios.post( `/member/company/list?jwt=${this.$auth.$storage.getUniversal('jwt').token || ''}`,this.userCompanyId)
  172. .then((res) => {
  173. this.userCompanyList = res.data.company_list
  174. this.userAddNewCompanyList = res.data.add_new_company_list
  175. })
  176. .catch((err) => { console.log(err);})
  177. },
  178. fetchCountry() {
  179. this.$axios.get("/users/countries")
  180. .then((res) => {
  181. this.countryOptions = res.data.result
  182. })
  183. .catch((err) => { console.log(err);})
  184. },
  185. fetchUserData() {
  186. this.getCompanyList()
  187. this.$emit('refetch-user')
  188. },
  189. },
  190. watch: {
  191. userCompanyId: {
  192. handler:function() {
  193. this.getCompanyList()
  194. },
  195. deep:true
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. </style>