index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <div class="h-100 position-relative">
  3. <div class="dashboard-card-wrap">
  4. <div class="dashboard-card-header">
  5. <div class="dashboard-card-header-left">{{ form.fd.name || $t('dashboard.userinfo') }}<a-icon class="ml-2" type="loading" v-if="loading" /></div>
  6. <div class="dashboard-card-header-right">
  7. <slot name="actions" :handle-edit="handleEdit" />
  8. <!-- <router-link v-if="!edit" to="/log" class="ml-2">
  9. <icon type="arrow-right" style="font-size:18px" />
  10. </router-link> -->
  11. </div>
  12. </div>
  13. <div class="dashboard-card-body flex-column justify-content-center">
  14. <div class="flex-fill position-relative d-flex flex-column" style="justify-content: space-around">
  15. <div class="selected-user-content">
  16. <div class="mr-2 name-icon">{{ firstNameWord }}</div>
  17. <div class="selected-user-name">{{$t('dashboard.text_185')}}{{ userInfo.displayname || userInfo.name }}</div>
  18. </div>
  19. <!-- <div v-for="(item, index) in userTableData" :key="index" class="user-info-text">{{item.label}}{{item.value}}</div> -->
  20. <div class="info-content" v-for="(item, index) in userTableData" :key="index">
  21. <div class="info-title">{{item.label}}</div>
  22. <div class="info-text">{{item.value}}</div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. <base-drawer :visible.sync="visible" :title="$t('dashboard.text_5')" @ok="handleSubmit">
  28. <a-form
  29. hideRequiredMark
  30. :form="form.fc"
  31. v-bind="formItemLayout">
  32. <a-form-item :label="$t('dashboard.text_6')">
  33. <a-input v-decorator="decorators.name" />
  34. </a-form-item>
  35. </a-form>
  36. </base-drawer>
  37. </div>
  38. </template>
  39. <script>
  40. import { mapGetters } from 'vuex'
  41. import BaseDrawer from '@Dashboard/components/BaseDrawer'
  42. export default {
  43. name: 'UserInfo',
  44. components: {
  45. BaseDrawer,
  46. },
  47. props: {
  48. options: {
  49. type: Object,
  50. required: true,
  51. },
  52. params: Object,
  53. edit: Boolean,
  54. },
  55. data () {
  56. const initialNameValue = (this.params && this.params.name) || this.$t('dashboard.userinfo')
  57. return {
  58. data: [],
  59. visible: false,
  60. loading: false,
  61. form: {
  62. fc: this.$form.createForm(this),
  63. fd: {
  64. name: initialNameValue,
  65. },
  66. },
  67. decorators: {
  68. name: [
  69. 'name',
  70. {
  71. initialValue: initialNameValue,
  72. rules: [
  73. { required: true, message: this.$t('dashboard.text_8') },
  74. ],
  75. },
  76. ],
  77. },
  78. formItemLayout: {
  79. wrapperCol: {
  80. span: 18,
  81. },
  82. labelCol: {
  83. span: 6,
  84. },
  85. },
  86. }
  87. },
  88. computed: {
  89. ...mapGetters(['scope', 'userInfo']),
  90. firstNameWord () {
  91. const word = (this.userInfo.displayname || this.userInfo.name || '').split('')[0]
  92. return word && word.toUpperCase()
  93. },
  94. userTableData () {
  95. const us = this.userInfo
  96. const ret = [
  97. { label: this.$t('dashboard.text_186'), value: us.roles.join(',') },
  98. { label: this.$t('dashboard.text_187'), value: `${us.projectName} (${us.projectDomain})` },
  99. { label: this.$t('dashboard.text_189'), value: this.$moment(us.last_active_at).format('') },
  100. ]
  101. return ret
  102. },
  103. },
  104. destroyed () {
  105. this.manager = null
  106. },
  107. created () {
  108. this.$emit('update', this.options.i, {
  109. ...this.form.fd,
  110. })
  111. },
  112. methods: {
  113. refresh () {
  114. return function () {}
  115. },
  116. handleEdit () {
  117. this.visible = true
  118. },
  119. async handleSubmit () {
  120. try {
  121. const values = await this.form.fc.validateFields()
  122. this.form.fd = values
  123. this.$emit('update', this.options.i, values)
  124. this.visible = false
  125. } catch (error) {
  126. throw error
  127. }
  128. },
  129. },
  130. }
  131. </script>
  132. <style scoped lang="less">
  133. @import '~@/styles/less/theme';
  134. .selected-user-content {
  135. align-items: center;
  136. // border: 1px solid #d9d9d9;
  137. color: #000000;
  138. display: inline-flex;
  139. font-size: 15px;
  140. letter-spacing: .25px;
  141. max-width: 100%;
  142. padding: 0 7px 13px 0;
  143. margin-bottom: 10px;
  144. border-bottom: 1px solid #e8e8e8;
  145. .selected-user-name {
  146. direction: ltr;
  147. text-align: left;
  148. overflow: hidden;
  149. text-overflow: ellipsis;
  150. }
  151. }
  152. .name-icon {
  153. color: #fff;
  154. height: 30px;
  155. width: 30px;
  156. text-align: center;
  157. line-height: 30px;
  158. border-radius: 50%;
  159. background-color: var(--antd-wave-shadow-color);
  160. font-size: 14px;
  161. }
  162. .user-info-text{
  163. font-size: 14px;
  164. color: #3c4043;
  165. margin-top: 20px;
  166. overflow: hidden;
  167. text-overflow: ellipsis;
  168. white-space: nowrap;
  169. }
  170. .info-content {
  171. padding-bottom: 4px;
  172. border-bottom: 1px solid #F2F2F2;
  173. }
  174. .info-title{
  175. font-size: 12px;
  176. color: #595959;
  177. }
  178. .info-text{
  179. font-size: 12px;
  180. color: #9E9E9E;
  181. border-radius: 5px;
  182. }
  183. </style>