EnterpriseAdmin.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div>
  3. <message-list :messages="messages">
  4. <button class="btn btn-default btn-change" slot="action" @click="changeAdmin">更换管理员</button>
  5. <button class="btn btn-default" slot="action" @click="showRecords">更换记录</button>
  6. </message-list>
  7. <!-- 更换管理员对话框 -->
  8. <el-dialog
  9. title="更换管理员"
  10. :visible.sync="changeAdminVisible"
  11. width="450px"
  12. :show-close="true"
  13. :append-to-body="true">
  14. <!-- 对话框内容 -->
  15. <el-row type="flex" class="row-bg">
  16. <el-select v-model="key" placeholder="请选择">
  17. <el-option
  18. v-for="item in items"
  19. :key="item.value"
  20. :label="item.label"
  21. :value="item.value">
  22. </el-option>
  23. </el-select>
  24. <div class="input-group search-group" style="width: 242px;margin-left: 5px;">
  25. <el-input placeholder="请输入内容" v-model="keyword"></el-input>
  26. <!--<el-autocomplete
  27. v-model="keyword"
  28. placeholder="请输入内容">
  29. </el-autocomplete>-->
  30. <span class="input-group-btn">
  31. <button class="btn btn-default btn-search" type="button" @click="searchAndSelectAdmin">搜索</button>
  32. </span>
  33. </div>
  34. </el-row>
  35. <!-- 用户信息展示 -->
  36. <div class="selected-user-info">
  37. <div class="row">
  38. <div class="message-label">UU号</div>
  39. <div class="message-value" v-text="adminUser.userUU">U0516</div>
  40. </div>
  41. <div class="row">
  42. <div class="message-label">姓名</div>
  43. <div class="message-value" v-text="adminUser.realName || adminUser.vipName">陈正亮</div>
  44. </div>
  45. <div class="row">
  46. <div class="message-label">手机号</div>
  47. <div class="message-value" v-text="adminUser.mobile">13600001122</div>
  48. </div>
  49. <div class="row">
  50. <div class="message-label">邮箱</div>
  51. <div class="message-value" v-text="adminUser.email">1891141208@qq.com</div>
  52. </div>
  53. </div>
  54. <!-- 对话框尾部 -->
  55. <span slot="footer" class="dialog-footer">
  56. <el-button type="primary" @click="submitToBeChangedUser">确 定</el-button>
  57. <el-button @click="changeAdminVisible = false">取 消</el-button>
  58. </span>
  59. </el-dialog>
  60. </div>
  61. </template>
  62. <script>
  63. import axios from '@/assets/js/axios'
  64. import MessageList from './common/MessageList'
  65. import * as types from '@/store/mutation-types'
  66. const keys = [
  67. {
  68. label: 'UU号',
  69. value: 'userUU'
  70. },
  71. {
  72. label: '手机号',
  73. value: 'mobile'
  74. },
  75. {
  76. label: '邮箱',
  77. value: 'email'
  78. }
  79. ]
  80. export default {
  81. name: 'enterprise-admin',
  82. components: {
  83. MessageList
  84. },
  85. data () {
  86. return {
  87. changeAdminVisible: false,
  88. items: keys,
  89. key: 'userUU',
  90. keyword: '',
  91. adminUser: {}
  92. }
  93. },
  94. computed: {
  95. messages () {
  96. const adminInfo = this.$store.getters.enAdmin
  97. const enterprise = this.enterprise
  98. for (let info of adminInfo) {
  99. if (info.label === '管理员名称' && info.value) {
  100. info.suffixClass = 'admin-message'
  101. info.action = () => {
  102. const routeLocation = {name: 'UserBasicInfo', params: enterprise.admin, replace: true}
  103. this.$router.push(routeLocation)
  104. }
  105. } else if (info.label === '申诉状态' && info.value) {
  106. info.suffixClass = 'admin-message'
  107. info.action = () => {
  108. const routeLocation = {name: 'AppealHome', replace: true}
  109. this.$router.push(routeLocation)
  110. }
  111. }
  112. }
  113. return adminInfo
  114. },
  115. enterprise () {
  116. const enterprise = this.$store.state.enterprises.savedEnterprise
  117. if (enterprise) {
  118. this.adminUser = enterprise.admin
  119. }
  120. return enterprise
  121. }
  122. },
  123. methods: {
  124. changeAdmin () {
  125. // 初始化对话框信息
  126. this.key = 'userUU'
  127. this.keyword = ''
  128. this.adminUser = this.enterprise.admin || {}
  129. this.changeAdminVisible = true
  130. },
  131. showRecords () {
  132. // TODO 查看更换记录
  133. this.$message.info('此功能暂未实现')
  134. },
  135. searchAndSelectAdmin () {
  136. const params = { spaceUU: this.enterprise.spaceUU, key: this.key, keyword: this.keyword }
  137. const error = error => {
  138. console.log(error)
  139. }
  140. axios.get('/api/user//searchUserByKeyword', { params })
  141. .then(userList => {
  142. // 展示查询到的用户信息
  143. if (userList && userList.length > 0) {
  144. this.adminUser = userList[0]
  145. } else {
  146. this.$message.info('没有找到对应的用户信息!')
  147. }
  148. })
  149. .catch(error)
  150. },
  151. submitToBeChangedUser () {
  152. const spaceUU = this.enterprise.spaceUU
  153. const params = {}
  154. if (this.adminUser && this.adminUser.userUU) {
  155. params.userUU = this.adminUser.userUU
  156. }
  157. const success = userSpace => {
  158. this.$store.commit(types.CHOOSE_ENTERPRISE, userSpace)
  159. this.$message.success('保存成功')
  160. }
  161. const error = response => {
  162. this.$message.error(response)
  163. }
  164. axios.put(`/api/user/space/${spaceUU}/changeAdmin`, {}, { params })
  165. .then(success)
  166. .catch(error)
  167. }
  168. }
  169. }
  170. </script>
  171. <style scoped>
  172. .message-panel .message-action button.btn-change {
  173. border-color: #4E8EFC;
  174. background-color: #4E8EFC;
  175. color: #FFFFFF;
  176. }
  177. .selected-user-info {
  178. margin-top: 20px;
  179. margin-bottom: 50px;
  180. }
  181. .selected-user-info .row {
  182. margin: 15px 0;
  183. height: 34px;
  184. }
  185. .selected-user-info .row div {
  186. display: inline-block;
  187. }
  188. .selected-user-info .row .message-label {
  189. padding: 10px;
  190. width: 90px;
  191. height: 34px;
  192. line-height: 14px;
  193. color: #000000;
  194. font-size: 14px;
  195. font-weight: normal;
  196. font-family: "SimHei", sans-serif;
  197. }
  198. .selected-user-info .row .message-value {
  199. padding: 10px;
  200. width: 280px;
  201. height: 34px;
  202. line-height: 14px;
  203. background-color: #F1F1F1;
  204. color: #646464;
  205. font-size: 14px;
  206. font-weight: normal;
  207. font-family: "Microsoft YaHei", sans-serif;
  208. }
  209. .input-group {
  210. border: 1px solid #D2D2D2;
  211. }
  212. .input-group-btn::before {
  213. content: '';
  214. position: absolute;
  215. top: 10px;
  216. left: 0;
  217. width: 1px;
  218. height: 13px;
  219. background: #D2D2D2;
  220. z-index: 5;
  221. }
  222. .btn-search {
  223. width: 58px;
  224. height: 30px;
  225. border-radius: 0;
  226. outline: none;
  227. border: none;
  228. color: #2190E1;
  229. }
  230. .btn-search:active,
  231. .btn-search:hover,
  232. .btn-search:visited,
  233. .btn-search:focus {
  234. outline: none;
  235. background: none;
  236. box-shadow: none;
  237. color: #4A7DE1;
  238. }
  239. </style>
  240. <style>
  241. .admin-message span:first-child {
  242. text-decoration: underline;
  243. color: #006ACD;
  244. cursor: pointer;
  245. }
  246. .admin-message span:last-child::after {
  247. content: '>';
  248. color: #646464;
  249. }
  250. .el-dialog {
  251. border-radius: 5px;
  252. }
  253. .el-dialog__header {
  254. padding: 14px 20px;
  255. height: 44px;
  256. line-height: 16px;
  257. border: 1px none #D2D2D2;
  258. border-bottom-style: solid;
  259. }
  260. .el-dialog__header .el-dialog__title {
  261. color: #000000;
  262. font-size: 16px;
  263. font-weight: normal;
  264. font-family: "SimHei", sans-serif;
  265. }
  266. .el-dialog__body {
  267. padding: 22px 0 22px 40px;
  268. }
  269. .el-select .el-input__inner {
  270. border-radius: 0;
  271. width: 128px;
  272. height: 32px;
  273. }
  274. .search-group .el-input__inner {
  275. width: 186px;
  276. height: 30px;
  277. border-radius: 0;
  278. border: none;
  279. }
  280. .el-dialog__footer {
  281. text-align: center;
  282. }
  283. .el-dialog__footer .el-button {
  284. width: 180px;
  285. height: 30px;
  286. border-radius: 15px;
  287. line-height: 14px;
  288. padding: 8px 0;
  289. background: none;
  290. color: #656565;
  291. }
  292. .el-dialog__footer .el-button--primary {
  293. background-color: #4E8EFC;
  294. color: #FFFFFF;
  295. }
  296. </style>