index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <div>
  3. <div class="user_num_content">
  4. <div class="user_item all">
  5. <div class="item_left">
  6. <img src="@/assets/icon/user_all.svg" alt="">
  7. <p>全部用户</p>
  8. </div>
  9. <div class="item_right">{{ userNumber.allUser }}</div>
  10. </div>
  11. <div class="user_item blue">
  12. <div class="item_left">
  13. <img src="@/assets/icon/user_blue.svg" alt="">
  14. <p>正式用户</p>
  15. </div>
  16. <div class="item_right">{{ userNumber.officialUser }}</div>
  17. </div>
  18. <div class="user_item green">
  19. <div class="item_left">
  20. <img src="@/assets/icon/user_green.svg" alt="">
  21. <p>体验用户</p>
  22. </div>
  23. <div class="item_right">{{ userNumber.experienceUser }}</div>
  24. </div>
  25. <div class="user_item orange">
  26. <div class="item_left">
  27. <img src="@/assets/icon/user_orange.svg" alt="">
  28. <p>冻结用户</p>
  29. </div>
  30. <div class="item_right">{{ userNumber.freezeUser }}</div>
  31. </div>
  32. </div>
  33. <SearchMain @FnSearch="FnSearch" />
  34. <div class="page_jg_20"></div>
  35. <div class="page_item">
  36. <div class="page_search">
  37. <div class="search_content">
  38. <div class="content_left">
  39. <el-select v-model="schoolTypeSelect" @change="SearchChange" placeholder="">
  40. <el-option label="全部类型" value=" "></el-option>
  41. <el-option label="单校" :value="0"></el-option>
  42. <el-option label="联考" :value="1"></el-option>
  43. </el-select>
  44. <el-input v-model="schoolNameCode" placeholder="请输入学校名称或编号" @input="SearchChange">
  45. <template #append>
  46. <el-button :icon="Search" @click="SearchChange" />
  47. </template>
  48. </el-input>
  49. </div>
  50. <div class="content_right">
  51. <el-button class="button_border_gray" @click="Refresh">
  52. <img src="@/assets/icon/refresh.svg" alt="" style="margin-right: 5px;">刷新
  53. </el-button>
  54. <el-button class="button_border" @click="OpenSubject">开通科目</el-button>
  55. <el-button class="button_background" @click="addUser">新增用户</el-button>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="page_jg_20"></div>
  60. <div class="page_table">
  61. <el-table :data="tableData" stripe v-loading="tableLoading" element-loading-text="拼命加载中……"
  62. element-loading-spinner="el-icon-loading" element-loading-background="#ffffff">
  63. <el-table-column type="index" label="序号" fixed="left" align="center" />
  64. <el-table-column prop="tenantCode" label="学校编号" width="80" fixed="left" align="center" show-overflow-tooltip />
  65. <el-table-column prop="tenantName" label="学校名称" width="150" fixed="left" align="center" show-overflow-tooltip>
  66. <template #default="{row}">
  67. <span @click="GoTeach(row)" style="color: #2E64FA; cursor: pointer;">{{ row.tenantName }}</span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column prop="abbreviation" label="学校简称" width="100" align="center" show-overflow-tooltip />
  71. <el-table-column prop="cityAndAreaName" label="区域" align="center" show-overflow-tooltip>
  72. <template #default="{ row }">
  73. {{ row.cityAndAreaName || '-' }}
  74. </template>
  75. </el-table-column>
  76. <el-table-column prop="schoolType" label="账号类型" align="center">
  77. <template #default="{ row }">
  78. {{ row.schoolType == 0 ? '单校版' : row.schoolType == 1 ? '联考版' : '-' }}
  79. </template>
  80. </el-table-column>
  81. <el-table-column prop="startDate" label="开始时间" width="100" align="center" show-overflow-tooltip />
  82. <el-table-column prop="endDate" label="结束时间" width="100" align="center" show-overflow-tooltip />
  83. <el-table-column prop="dateDiffDayS" label="剩余天数" align="center" />
  84. <el-table-column prop="type" label="状态" align="center">
  85. <template #default="{ row }">
  86. <div class="table_row_status">
  87. <!-- 冻结 -->
  88. <div class="no_release_icon" v-if="row.status==0"></div>
  89. <!-- 正式 -->
  90. <div class="need_summary_icon" v-if="row.status==1 && row.type==1"></div>
  91. <!-- 体验 -->
  92. <div class="yes_release_icon" v-if="row.status==1 && row.type==0"></div>
  93. <!-- {{ row.statusLabel }} -->
  94. {{ row.status == 0 ? '冻结' : row.type == 1 ? '正式' : row.type == 0 ? '体验' : '-' }}
  95. </div>
  96. </template>
  97. </el-table-column>
  98. <el-table-column prop="sysUserName" label="运维人员" align="center" show-overflow-tooltip>
  99. <template #default="{ row }">
  100. {{ row.sysUserName || '-' }}
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="操作" width="280" fixed="right" align="center">
  104. <template #default="{ row }">
  105. <div class="table_row_option">
  106. <div v-if="row.status == 0" class="button_delete" @click="ChangeStatus(row)">解冻</div>
  107. <div v-else class="button_editor text_color_orange" @click="ChangeStatus(row)">冻结</div>
  108. <div class="button_editor" @click="EditUser(row)">编辑</div>
  109. <div class="button_editor" @click="OpenAuth(row)">权限</div>
  110. <div class="button_editor" @click="resetPassWord(row)">重置密码</div>
  111. <div class="button_editor" @click="GoTeach(row)">进入学校</div>
  112. </div>
  113. </template>
  114. </el-table-column>
  115. </el-table>
  116. </div>
  117. </div>
  118. <div class="page_dialog">
  119. <AddUser v-if="showDialog" @AddUser="RefTable" />
  120. <AuthConfig v-if="authData.showDialog" />
  121. <SubjectList v-if="subjectShowDialog" />
  122. <ResetPassword v-if="passwordDialog.dialogShow" />
  123. </div>
  124. </div>
  125. </template>
  126. <script lang="ts" setup>
  127. import SearchMain from '@/views/school/SearchMain.vue'
  128. import AddUser from '@/views/school/addUser.vue'
  129. import AuthConfig from '@/views/school/authConfig.vue'
  130. import SubjectList from '@/views/school/subjectList.vue'
  131. import ResetPassword from '@/components/resetPassword.vue'
  132. import { Search } from '@element-plus/icons-vue'
  133. import { getSchoolNumber, getSchoolList, changeStatus } from '@/api/school'
  134. import { ref, reactive, provide, onMounted } from 'vue'
  135. interface UserNumber {
  136. allUser: number
  137. officialUser: number
  138. experienceUser: number
  139. freezeUser: number
  140. }
  141. const userNumber = ref<UserNumber>({
  142. allUser: 0,
  143. officialUser: 0,
  144. experienceUser: 0,
  145. freezeUser: 0
  146. })
  147. interface User {
  148. tenantCode: String;
  149. tenantName: String;
  150. status: number;
  151. statusLabel: String;
  152. schoolType: String;
  153. abbreviation: String;
  154. dateDiffDayS: String;
  155. startDate: String;
  156. endDate: String;
  157. sysUserId: String;
  158. sysUserName: String;
  159. cityAndAreaName: String;
  160. }
  161. const tableData = ref<User[]>([])
  162. const schoolTypeSelect = ref<string>(" ")
  163. const schoolNameCode = ref('')
  164. const tableLoading = ref(false)
  165. const showDialog = ref(false)
  166. const dialogData = reactive({
  167. id: '',
  168. pageType: '',
  169. tenantName: ''
  170. })
  171. const subjectShowDialog = ref(false)
  172. const authData = reactive({
  173. showDialog: false,
  174. id: '',
  175. schoolName: '',
  176. tenantCode: ''
  177. })
  178. const passwordDialog = reactive({
  179. dialogShow: false,
  180. id: '',
  181. type: '',
  182. name: '',
  183. label: '',
  184. remark: ''
  185. }) // 重置密码弹窗数据
  186. provide('showDialog', showDialog) // 新增用户弹窗是否展示
  187. provide('dialogData', dialogData) // 新增用户弹窗数据
  188. provide('authData', authData) // 设置权限弹窗数据
  189. provide('subjectShowDialog', subjectShowDialog) // 开通科目弹窗数据
  190. provide('passwordDialog', passwordDialog) // 重置密码弹窗数据
  191. onMounted(() => {
  192. GetSchoolNumber()
  193. GetSchoolList()
  194. })
  195. // 新增用户
  196. const addUser = () => {
  197. showDialog.value = true
  198. dialogData.pageType = 'add'
  199. }
  200. // 编辑
  201. const EditUser = (row: any) => {
  202. console.log(row)
  203. showDialog.value = true
  204. dialogData.pageType = 'edit'
  205. dialogData.id = row.id
  206. dialogData.tenantName = row.tenantName
  207. }
  208. // 设置权限
  209. const OpenAuth = (row: any) => {
  210. authData.id = row.id
  211. authData.schoolName = row.tenantName
  212. authData.tenantCode = row.tenantCode
  213. authData.showDialog = true
  214. }
  215. // 开通科目
  216. const OpenSubject = () => {
  217. console.log('OpenSubject')
  218. subjectShowDialog.value = true
  219. }
  220. // 筛选项数据
  221. const searchData = ref({
  222. provinceCode: '',
  223. cityCode: '',
  224. type: '',
  225. userId: ''
  226. })
  227. // 筛选项查询
  228. const FnSearch = (data: any) => {
  229. searchData.value = data.value
  230. GetSchoolList()
  231. }
  232. // 表格上面筛选查询
  233. const SearchChange = () => {
  234. GetSchoolList()
  235. }
  236. // 获取用户数量
  237. const GetSchoolNumber = () => {
  238. getSchoolNumber().then((res: any) => {
  239. if(res.code == 200 && res.data) {
  240. userNumber.value = res.data
  241. }
  242. })
  243. }
  244. // 获取学校列表
  245. const GetSchoolList = () => {
  246. let params = {
  247. type: searchData.value.type,
  248. userId: searchData.value.userId,
  249. cityCode: searchData.value.cityCode,
  250. provinceCode: searchData.value.provinceCode,
  251. schoolType: schoolTypeSelect.value,
  252. queryStr: schoolNameCode.value
  253. }
  254. tableLoading.value = true
  255. getSchoolList(params).then((res: any) => {
  256. if(res.code == 200 && res.data) {
  257. tableData.value = res.data
  258. }
  259. tableLoading.value = false
  260. }).catch(() => {
  261. tableLoading.value = false
  262. })
  263. }
  264. // 新增/修改学校信息后刷新列表
  265. const RefTable = (val: any) => {
  266. showDialog.value = val
  267. GetSchoolList()
  268. }
  269. // 改变用户状态
  270. const ChangeStatus = (row: any) => {
  271. console.log(row)
  272. changeStatus({
  273. id: row.id,
  274. status: row.status == 0 ? 1 : 0
  275. }).then((res: any) => {
  276. if(res.code == 200) {
  277. GetSchoolList()
  278. }
  279. })
  280. }
  281. const GoTeach = (row: any) => {
  282. let accessToken = localStorage.getItem('token')
  283. window.open(`https://admin.k12100.net/#/otherLogin?schoolId=${row.id}&adminToken=${accessToken}`)
  284. }
  285. const resetPassWord = (row: any) => {
  286. passwordDialog.dialogShow = true
  287. passwordDialog.id = row.id
  288. passwordDialog.type = '2'
  289. passwordDialog.name = row.tenantName
  290. passwordDialog.label = '学校名称'
  291. passwordDialog.remark = '学校编号'
  292. }
  293. const Refresh = () => {
  294. schoolTypeSelect.value = " "
  295. schoolNameCode.value = ""
  296. GetSchoolList()
  297. }
  298. </script>
  299. <style lang="scss" scoped>
  300. .user_num_content {
  301. width: 100%;
  302. display: flex;
  303. gap: 20px;
  304. justify-content: space-between;
  305. align-items: center;
  306. margin-bottom: 20px;
  307. .user_item {
  308. flex-grow: 1;
  309. height: 80px;
  310. padding: 20px;
  311. display: flex;
  312. justify-content: space-between;
  313. align-items: center;
  314. border-radius: 10px;
  315. font-weight: 500;
  316. .item_left {
  317. display: flex;
  318. align-items: center;
  319. img {
  320. margin-right: 10px;
  321. }
  322. }
  323. &.all {
  324. background: #2E64FA;
  325. color: #fff;
  326. .item_right {
  327. color: #fff;
  328. }
  329. }
  330. &.blue {
  331. border: 1px solid #2E64FA;
  332. background: #EAF0FF;
  333. color: #333;
  334. .item_right {
  335. color: #2E64FA;
  336. }
  337. }
  338. &.green {
  339. border: 1px solid #2BC644;
  340. background: #EAF9EC;
  341. color: #333;
  342. .item_right {
  343. color: #2BC644;
  344. }
  345. }
  346. &.orange {
  347. border: 1px solid #FB9F34;
  348. background: #FFF5EB;
  349. color: #333;
  350. .item_right {
  351. color: #FB9F34;
  352. }
  353. }
  354. .item_right {
  355. font-size: 24px;
  356. font-weight: 700;
  357. }
  358. }
  359. }
  360. .button_editor.text_color_orange {
  361. color: #FB9F34;
  362. }
  363. .button_editor.text_color_red {
  364. color: #F56C6C;
  365. }
  366. </style>