index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <!-- 账号权限 -->
  3. <div class="account-management-page">
  4. <s-header :name="$t('accountPer.accountPermission')" :noback="false" />
  5. <div class="management-container">
  6. <!-- 操作工具栏 -->
  7. <div class="dashboard-toolbar">
  8. <!-- 统计信息 -->
  9. <div class="statistics-card">
  10. <van-icon name="user" class="statistics-icon" />
  11. <div class="statistics-content">
  12. <div class="statistics-label">{{ $t('accountPer.chirdAccountTotal') }}</div>
  13. <div class="statistics-value">{{ accountPerList.length }}</div>
  14. </div>
  15. </div>
  16. <!-- 操作按钮 -->
  17. <div class="action-buttons">
  18. <van-button icon="friends" class="action-btn" @click="pushRole">
  19. {{ $t('accountPer.rolePermissions') }}
  20. </van-button>
  21. <van-button type="primary" icon="plus" class="action-btn" @click="pushAdd">
  22. {{ $t('accountPer.add') }}
  23. </van-button>
  24. <van-button icon="filter-o" class="action-btn" @click="searchClick">
  25. {{ $t('accountPer.screen') }}
  26. </van-button>
  27. </div>
  28. </div>
  29. <!-- 账户列表 -->
  30. <div class="account-list">
  31. <van-cell-group>
  32. <div v-for="(item, index) in accountPerList" :key="index" class="account-card" @click="accountClick(item)">
  33. <div class="card-header">
  34. <div class="account-info">
  35. <h3 class="account-name">
  36. {{ decodeURIComponent(item.name) }}
  37. <van-tag :color="item.isEnabled ? '#e8f5e9' : '#ffebee'"
  38. :text-color="item.isEnabled ? '#4caf50' : '#ff5252'" class="status-tag">
  39. {{ item.isEnabled ? $t('accountPer.effective') : $t('accountPer.paused') }}
  40. </van-tag>
  41. </h3>
  42. <div class="account-id">@{{ item.username }}</div>
  43. </div>
  44. <van-icon name="arrow" class="arrow-icon" />
  45. </div>
  46. <div class="role-info">
  47. <van-icon name="user" class="role-icon" />
  48. <span class="role-text">{{ item.roleName }}</span>
  49. </div>
  50. </div>
  51. </van-cell-group>
  52. </div>
  53. </div>
  54. <accountPerSearch ref="searchRef" @search="search($event)" />
  55. </div>
  56. </template>
  57. <script>
  58. import { onMounted, reactive, toRefs, ref } from 'vue';
  59. import sHeader from "../../components/SimpleHeader";
  60. import { getChildAdminList } from '../../service/accountPar/index';
  61. import { showFailToast } from 'vant';
  62. import { getLoginUser } from "../../common/js/utils";
  63. import accountPerSearch from './search.vue';
  64. import { useRouter } from "vue-router";
  65. export default {
  66. name: 'accountPer',
  67. components: { sHeader, accountPerSearch },
  68. // components: { accountPerSearch },
  69. setup() {
  70. const router = useRouter();
  71. const searchRef = ref(null);
  72. const accountPerList = ref([]); // 列表集合
  73. let searchParams = reactive({
  74. adminId: "", // 用户账户id
  75. current: 1, // 页数
  76. size: 20, // 页大小
  77. isUse: '0', // 是否使用
  78. // type: null // 优惠码类型 0或null:折扣优惠码;1:抵扣价优惠码
  79. });
  80. // 初始化页面获取列表
  81. onMounted(async () => {
  82. // 加载样式
  83. // styleUrl('accountPer')
  84. // 初始化列表及页码
  85. const user = getLoginUser();
  86. if (user) {
  87. searchParams.adminId = user.id;
  88. searchGetList();
  89. }
  90. });
  91. // 搜索点击
  92. const searchClick = () => { searchRef.value.showSearch(); };
  93. // 跳转添加账号
  94. const pushAdd = () => { localStorage.removeItem('accoutPerSet'); router.push('/accountPerAdd'); }
  95. // 跳转角色权限页面
  96. const pushRole = () => { router.push('/role'); }
  97. // 查询列表
  98. const searchGetList = () => {
  99. accountPerList.value = [];
  100. searchParams.current = 1;
  101. getList();
  102. }
  103. // 搜索弹窗触发搜索
  104. const search = (data) => {
  105. searchParams = Object.assign(searchParams, data);
  106. searchGetList();
  107. };
  108. // 获取设备列表数据
  109. const getList = async () => {
  110. const { data } = await getChildAdminList(Object.assign({}, searchParams));
  111. if (data.code === "00000") {
  112. accountPerList.value = accountPerList.value.concat(data.data);
  113. } else { showFailToast(data.message); }
  114. };
  115. // 跳转修改
  116. const accountClick = (item) => {
  117. localStorage.setItem('accoutPerSet', JSON.stringify(item));
  118. router.push('/accountPerAdd');
  119. };
  120. // 回到上一页 账户操作页
  121. // const onClickLeft = () => {
  122. // router.push('/accountOperation');
  123. // };
  124. return {
  125. searchRef,
  126. searchClick,
  127. pushAdd,
  128. pushRole,
  129. search,
  130. accountPerList,
  131. ...toRefs(searchParams),
  132. accountClick,
  133. // onClickLeft,
  134. };
  135. },
  136. };
  137. </script>
  138. <style lang="less" scoped>
  139. @import "../../common/style/common.less";
  140. .account-management-page {
  141. background: #f8f9fa;
  142. min-height: 100vh;
  143. .management-container {
  144. padding: 16px;
  145. .dashboard-toolbar {
  146. display: flex;
  147. justify-content: space-between;
  148. align-items: center;
  149. gap: 16px;
  150. margin-bottom: 24px;
  151. padding: 0 16px;
  152. .statistics-card {
  153. flex: 1;
  154. background: linear-gradient(135deg, #f8f9ff, #ffffff);
  155. border-radius: 12px;
  156. padding: 16px;
  157. display: flex;
  158. align-items: center;
  159. box-shadow: 0 4px 12px rgba(78, 107, 221, 0.08);
  160. .statistics-icon {
  161. font-size: 24px;
  162. color: #4e6bdd;
  163. margin-right: 12px;
  164. padding: 8px;
  165. background: rgba(78, 107, 221, 0.1);
  166. border-radius: 8px;
  167. }
  168. .statistics-content {
  169. .statistics-label {
  170. font-size: 12px;
  171. color: #8787a6;
  172. margin-bottom: 4px;
  173. }
  174. .statistics-value {
  175. font-size: 24px;
  176. font-weight: 600;
  177. color: #2c3e50;
  178. }
  179. }
  180. }
  181. .action-buttons {
  182. display: flex;
  183. gap: 12px;
  184. flex-shrink: 0;
  185. .action-btn {
  186. height: 40px;
  187. padding: 0 16px;
  188. border-radius: 20px;
  189. font-size: 14px;
  190. transition: all 0.2s;
  191. &:hover {
  192. transform: translateY(-1px);
  193. box-shadow: 0 4px 12px rgba(78, 107, 221, 0.15);
  194. }
  195. &:active {
  196. transform: translateY(0);
  197. }
  198. // 主按钮特殊样式
  199. &[type="primary"] {
  200. background: linear-gradient(135deg, #4e6bdd, #3b5ab3);
  201. border: none;
  202. }
  203. }
  204. }
  205. }
  206. @media (max-width: 768px) {
  207. .dashboard-toolbar {
  208. flex-direction: column;
  209. .statistics-card {
  210. width: 100%;
  211. }
  212. .action-buttons {
  213. width: 100%;
  214. flex-wrap: wrap;
  215. .action-btn {
  216. flex: 1;
  217. min-width: 120px;
  218. }
  219. }
  220. }
  221. }
  222. .account-list {
  223. .account-card {
  224. margin-bottom: 12px;
  225. padding: 16px;
  226. background: #fff;
  227. border-radius: 8px;
  228. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  229. transition: transform 0.2s;
  230. &:active {
  231. transform: scale(0.98);
  232. }
  233. .card-header {
  234. display: flex;
  235. justify-content: space-between;
  236. align-items: center;
  237. margin-bottom: 12px;
  238. .account-info {
  239. flex: 1;
  240. .account-name {
  241. margin: 0 0 4px 0;
  242. font-size: 16px;
  243. color: #2c3e50;
  244. display: flex;
  245. align-items: center;
  246. .status-tag {
  247. margin-left: 8px;
  248. font-size: 12px;
  249. border: none;
  250. }
  251. }
  252. .account-id {
  253. font-size: 12px;
  254. color: #8787a6;
  255. }
  256. }
  257. .arrow-icon {
  258. color: #c0c4cc;
  259. font-size: 16px;
  260. }
  261. }
  262. .role-info {
  263. display: flex;
  264. align-items: center;
  265. padding: 8px 0;
  266. border-top: 1px solid #eee;
  267. .role-icon {
  268. color: #4e6bdd;
  269. font-size: 14px;
  270. margin-right: 6px;
  271. }
  272. .role-text {
  273. font-size: 14px;
  274. color: #666;
  275. }
  276. }
  277. }
  278. }
  279. }
  280. }
  281. </style>