index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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>
  52. <img src="@/assets/icon/refresh.svg" alt="" style="margin-right: 5px;">刷新
  53. </el-button>
  54. <el-button @click="OpenSubject">开通科目</el-button>
  55. <el-button type="primary" @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. <el-table-column prop="schoolAbbreviation" label="学校简称" width="100" align="center" show-overflow-tooltip />
  67. <el-table-column prop="region" label="区域" align="center" show-overflow-tooltip />
  68. <el-table-column prop="schoolType" label="账号类型" align="center">
  69. <template #default="{ row }">
  70. {{ row.schoolType == 0 ? '单校版' : row.schoolType == 1 ? '联考版' : '-' }}
  71. </template>
  72. </el-table-column>
  73. <el-table-column prop="startDate" label="开始时间" width="100" align="center" show-overflow-tooltip />
  74. <el-table-column prop="endDate" label="结束时间" width="100" align="center" show-overflow-tooltip />
  75. <el-table-column prop="dateDiffDayS" label="剩余天数" align="center" />
  76. <el-table-column prop="status" label="状态" align="center">
  77. <template #default="{ row }">
  78. <div class="table_row_status">
  79. <!-- 正式 -->
  80. <div class="need_summary_icon" v-if="row.status==1"></div>
  81. <!-- 试用 -->
  82. <div class="yes_release_icon" v-else-if="row.status==2"></div>
  83. <!-- 冻结 -->
  84. <div class="no_release_icon" v-else-if="row.status==3"></div>
  85. <!-- {{ row.statusLabel }} -->
  86. {{ row.status == 1 ? '正式' : row.status == 2 ? '试用' : row.status == 3 ? '冻结' : '-' }}
  87. </div>
  88. </template>
  89. </el-table-column>
  90. <el-table-column prop="ityAndAreaNam" label="运维人员" align="center" />
  91. <el-table-column label="操作" width="280" fixed="right" align="center">
  92. <template #default="{ row }">
  93. <div class="table_row_option">
  94. <div v-if="row.status == 3" class="button_delete" @click="ChangeStatus(row)">解冻</div>
  95. <div v-else class="button_editor text_color_orange" @click="ChangeStatus(row)">冻结</div>
  96. <div class="button_editor" @click="EditUser(row)">编辑</div>
  97. <div class="button_editor" @click="OpenAuth(row)">权限</div>
  98. <div class="button_editor">重置密码</div>
  99. <div class="button_editor" @click="GoTeach">进入学校</div>
  100. </div>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. </div>
  105. </div>
  106. <div class="page_dialog">
  107. <AddUser v-if="showDialog" @AddUser="RefTable" />
  108. <AuthConfig v-if="authData.showDialog" />
  109. <SubjectList v-if="subjectShowDialog" />
  110. </div>
  111. </div>
  112. </template>
  113. <script lang="ts" setup>
  114. import SearchMain from '@/views/school/SearchMain.vue'
  115. import AddUser from '@/views/school/addUser.vue'
  116. import AuthConfig from '@/views/school/authConfig.vue'
  117. import SubjectList from '@/views/school/subjectList.vue'
  118. import { Search } from '@element-plus/icons-vue'
  119. import { getSchoolNumber, getSchoolList, changeStatus } from '@/api/school'
  120. import { ref, reactive, provide, onMounted } from 'vue'
  121. interface UserNumber {
  122. allUser: number
  123. officialUser: number
  124. experienceUser: number
  125. freezeUser: number
  126. }
  127. const userNumber = ref<UserNumber>({
  128. allUser: 0,
  129. officialUser: 0,
  130. experienceUser: 0,
  131. freezeUser: 0
  132. })
  133. interface User {
  134. tenantCode: String;
  135. tenantName: String;
  136. status: number;
  137. statusLabel: String;
  138. schoolType: String;
  139. abbreviation: String;
  140. dateDiffDayS: String;
  141. startDate: String;
  142. endDate: String;
  143. ityAndAreaNam: string;
  144. region: String;
  145. }
  146. const tableData = ref<User[]>([])
  147. const schoolTypeSelect = ref<string>(" ")
  148. const schoolNameCode = ref('')
  149. const tableLoading = ref(false)
  150. const showDialog = ref(false)
  151. const dialogData = reactive({
  152. id: '',
  153. pageType: '',
  154. tenantName: ''
  155. })
  156. const subjectShowDialog = ref(false)
  157. const authData = reactive({
  158. showDialog: false,
  159. id: '',
  160. schoolName: '',
  161. tenantCode: ''
  162. })
  163. provide('showDialog', showDialog) // 新增用户弹窗是否展示
  164. provide('dialogData', dialogData) // 新增用户弹窗数据
  165. provide('authData', authData) // 设置权限弹窗数据
  166. provide('subjectShowDialog', subjectShowDialog) // 开通科目弹窗数据
  167. onMounted(() => {
  168. GetSchoolNumber()
  169. GetSchoolList()
  170. })
  171. // 新增用户
  172. const addUser = () => {
  173. showDialog.value = true
  174. dialogData.pageType = 'add'
  175. }
  176. // 编辑
  177. const EditUser = (row) => {
  178. console.log(row)
  179. showDialog.value = true
  180. dialogData.pageType = 'edit'
  181. dialogData.id = row.id
  182. dialogData.tenantName = row.tenantName
  183. }
  184. // 设置权限
  185. const OpenAuth = (row) => {
  186. authData.id = row.id
  187. authData.schoolName = row.tenantName
  188. authData.tenantCode = row.tenantCode
  189. authData.showDialog = true
  190. }
  191. // 开通科目
  192. const OpenSubject = () => {
  193. console.log('OpenSubject')
  194. subjectShowDialog.value = true
  195. }
  196. // 筛选项数据
  197. const searchData = ref({
  198. provinceCode: '',
  199. cityCode: '',
  200. status: '',
  201. userId: ''
  202. })
  203. // 筛选项查询
  204. const FnSearch = (data) => {
  205. searchData.value = data.value
  206. GetSchoolList()
  207. }
  208. // 表格上面筛选查询
  209. const SearchChange = () => {
  210. GetSchoolList()
  211. }
  212. // 获取用户数量
  213. const GetSchoolNumber = () => {
  214. getSchoolNumber().then(res => {
  215. if(res.code == 200 && res.data) {
  216. userNumber.value = res.data
  217. }
  218. })
  219. }
  220. // 获取学校列表
  221. const GetSchoolList = () => {
  222. let params = {
  223. status: searchData.value.status,
  224. // userId: searchData.value.userId,
  225. cityCode: searchData.value.cityCode,
  226. provinceCode: searchData.value.provinceCode,
  227. schoolType: schoolTypeSelect.value,
  228. queryStr: schoolNameCode.value
  229. }
  230. tableLoading.value = true
  231. getSchoolList(params).then(res => {
  232. if(res.code == 200 && res.data) {
  233. tableData.value = res.data
  234. }
  235. tableLoading.value = false
  236. }).catch(err => {
  237. tableLoading.value = false
  238. })
  239. }
  240. // 新增/修改学校信息后刷新列表
  241. const RefTable = (val) => {
  242. showDialog.value = val
  243. GetSchoolList()
  244. }
  245. // 改变用户状态
  246. const ChangeStatus = (row) => {
  247. console.log(row)
  248. changeStatus({
  249. id: row.id,
  250. status: row.status
  251. }).then(res => {
  252. if(res.code == 200) {
  253. GetSchoolList()
  254. }
  255. })
  256. }
  257. const GoTeach = () => {
  258. console.log('GoTeach')
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. .user_num_content {
  263. width: 100%;
  264. display: flex;
  265. gap: 20px;
  266. justify-content: space-between;
  267. align-items: center;
  268. margin-bottom: 20px;
  269. .user_item {
  270. flex-grow: 1;
  271. height: 80px;
  272. padding: 20px;
  273. display: flex;
  274. justify-content: space-between;
  275. align-items: center;
  276. border-radius: 10px;
  277. font-weight: 500;
  278. .item_left {
  279. display: flex;
  280. align-items: center;
  281. img {
  282. margin-right: 10px;
  283. }
  284. }
  285. &.all {
  286. background: #2E64FA;
  287. color: #fff;
  288. .item_right {
  289. color: #fff;
  290. }
  291. }
  292. &.blue {
  293. border: 1px solid #2E64FA;
  294. background: #EAF0FF;
  295. color: #333;
  296. .item_right {
  297. color: #2E64FA;
  298. }
  299. }
  300. &.green {
  301. border: 1px solid #2BC644;
  302. background: #EAF9EC;
  303. color: #333;
  304. .item_right {
  305. color: #2BC644;
  306. }
  307. }
  308. &.orange {
  309. border: 1px solid #FB9F34;
  310. background: #FFF5EB;
  311. color: #333;
  312. .item_right {
  313. color: #FB9F34;
  314. }
  315. }
  316. .item_right {
  317. font-size: 24px;
  318. font-weight: 700;
  319. }
  320. }
  321. }
  322. .button_editor.text_color_orange {
  323. color: #FB9F34;
  324. }
  325. .button_editor.text_color_red {
  326. color: #F56C6C;
  327. }
  328. </style>