多媒体信息发布平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

373 lines
12 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="app-container">
  3. fff
  4. <!--工具栏-->
  5. <div class="head-container">
  6. <el-row type="flex">
  7. <el-col :span="20" class="col_flex">
  8. <!-- 搜索 -->
  9. <div class="form_item">
  10. <span>角色名称</span>
  11. <el-input
  12. v-model="blurry"
  13. clearable
  14. size="small"
  15. placeholder="角色名称"
  16. style="width: 200px;"
  17. class="filter-item"
  18. @keyup.enter.native="crud.toQuery"
  19. />
  20. </div>
  21. <div class="form_item">
  22. <span>管理员名称</span>
  23. <el-input
  24. v-model="blurry"
  25. clearable
  26. size="small"
  27. placeholder="管理员名称"
  28. style="width: 200px;"
  29. class="filter-item"
  30. @keyup.enter.native="crud.toQuery"
  31. />
  32. </div>
  33. <rrOperation />
  34. </el-col>
  35. <el-col class="page_add" :span="4">
  36. <el-button class="table_add" type="primary" round @click="addDialogVisible = true">新增</el-button>
  37. </el-col>
  38. </el-row>
  39. </div>
  40. <!--新增用户-->
  41. <el-dialog
  42. append-to-body
  43. :close-on-click-modal="false"
  44. :show-close="false"
  45. :visible.sync="addDialogVisible"
  46. title="新增"
  47. width="576px"
  48. >
  49. <el-form ref="form" :inline="true" :model="form" size="small" label-width="100px">
  50. <el-form-item
  51. label="手机号"
  52. prop="account"
  53. :rules="[
  54. { required: true, message: '请输入手机号', trigger: 'blur' }
  55. ]"
  56. >
  57. <el-input v-model="form.account" style="width: 336px" />
  58. </el-form-item>
  59. <el-form-item
  60. label="管理员名称"
  61. prop="nickName"
  62. :rules="[
  63. { required: true, message: '请输入管理员名称', trigger: 'blur' },
  64. { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
  65. ]"
  66. >
  67. <el-input v-model="form.nickName" style="width: 336px" />
  68. </el-form-item>
  69. <el-form-item
  70. label="管理员角色"
  71. prop="roles"
  72. :rules="[
  73. { required: true, message: '请选择管理员角色', trigger: 'change' }
  74. ]"
  75. >
  76. <el-select v-model="form.roles" placeholder="请选择管理员角色" style="width: 336px">
  77. <el-option label="机构超级管理员" value="1" />
  78. <el-option label="普通用户" value="2" />
  79. </el-select>
  80. </el-form-item>
  81. <el-form-item
  82. label="管理员状态"
  83. prop="enabled"
  84. :rules="[
  85. { required: true, trigger: 'change', message: '请选择管理员状态' }
  86. ]"
  87. >
  88. <el-select v-model="form.enabled" placeholder="请选择管理员状态" style="width: 336px">
  89. <el-option label="启用" value="1" />
  90. <el-option label="关闭" value="0" />
  91. </el-select>
  92. </el-form-item>
  93. </el-form>
  94. <div slot="footer" class="dialog-footer">
  95. <el-button :loading="crud.status.cu === 2" type="primary" round @click="crud.submitCU">保存</el-button>
  96. <el-button round @click="addDialogVisible=false">关闭</el-button>
  97. </div>
  98. </el-dialog>
  99. <!-- 编辑用户 -->
  100. <el-dialog
  101. append-to-body
  102. :close-on-click-modal="false"
  103. :show-close="false"
  104. :visible.sync="editDialogVisible"
  105. title="编辑"
  106. width="576px"
  107. >
  108. <el-form
  109. ref="form"
  110. :inline="true"
  111. :model="editForm"
  112. :rules="rules"
  113. size="small"
  114. label-width="100px"
  115. >
  116. <el-form-item label="管理员名称" prop="nickName">
  117. <el-input v-model="editForm.nickName" style="width: 336px" />
  118. </el-form-item>
  119. <el-form-item label="管理员角色" prop="roles">
  120. <el-input v-model="editForm.roles" disabled style="width: 336px" />
  121. </el-form-item>
  122. <el-form-item label="机构名称" prop="orgName">
  123. <el-input v-model="editForm.orgName" disabled style="width: 336px" />
  124. </el-form-item>
  125. <el-form-item label="更改手机号" prop="phone">
  126. <el-input v-model.number="editForm.phone" style="width: 336px" />
  127. </el-form-item>
  128. <el-form-item label="验证码" prop="code" class="auth_code">
  129. <el-input v-model.number="editForm.code" style="width: 336px" />
  130. <div class="login-code">
  131. <span @click="countdown()">{{ verification }}</span>
  132. </div>
  133. </el-form-item>
  134. <el-form-item label="登录密码" prop="password">
  135. <el-input v-model="editForm.password" style="width: 336px" />
  136. </el-form-item>
  137. </el-form>
  138. <div slot="footer" class="dialog-footer">
  139. <el-button :loading="crud.status.cu === 2" type="primary" round @click="crud.submitCU">保存</el-button>
  140. <el-button round @click="editDialogVisible=false">关闭</el-button>
  141. </div>
  142. </el-dialog>
  143. <!--表格渲染-->
  144. <el-row :gutter="15">
  145. <el-col>
  146. <!-- :data="crud.data" -->
  147. <el-table
  148. ref="table"
  149. v-loading="crud.loading"
  150. :data="tableData"
  151. :header-cell-style="{ background: '#3a8aeb', color: '#fff' }"
  152. style="width: 100%;"
  153. @selection-change="crud.selectionChangeHandler"
  154. >
  155. <el-table-column :selectable="checkboxT" type="selection" width="55" />
  156. <el-table-column prop="account" width="135" align="center" label="登录账号" />
  157. <el-table-column prop="nickName" align="center" label="管理员名称" />
  158. <el-table-column prop="roles" align="center" label="管理角色" />
  159. <el-table-column prop="orgName" align="center" label="机构名称" />
  160. <el-table-column prop="phone" align="center" label="手机号码" />
  161. <el-table-column label="状态" align="center" prop="enabled">
  162. <template slot-scope="scope">
  163. <div>{{ scope.row.enabled == 0 ? '启用' : '关闭' }}</div>
  164. </template>
  165. </el-table-column>
  166. <el-table-column prop="createTime" width="135" label="创建日期" />
  167. <!-- v-if="checkPer(['admin','user:edit','user:del'])" -->
  168. <el-table-column label="操作" width="120" align="center" fixed="right">
  169. <template slot-scope="scope">
  170. <!-- <udOperation
  171. :data="scope.row"
  172. :permission="permission"
  173. :disabled-dle="scope.row.id === user.id"
  174. />-->
  175. <el-button
  176. type="primary"
  177. class="edit_btn"
  178. @click="editFormData(scope.$index, scope.row)"
  179. >编辑</el-button>
  180. <el-button type="danger" class="delt_btn">删除</el-button>
  181. </template>
  182. </el-table-column>
  183. </el-table>
  184. <!--分页组件-->
  185. <pagination />
  186. </el-col>
  187. </el-row>
  188. </div>
  189. </template>
  190. <script>
  191. // import crudUser from '@/api/system/user'
  192. import { isvalidPhone } from '@/utils/validate'
  193. // import CRUD, { presenter, header, form, crud } from '@crud/crud'
  194. import rrOperation from '@crud/RR.operation'
  195. // import crudOperation from '@crud/CRUD.operation'
  196. // import udOperation from '@crud/UD.operation'
  197. import pagination from '@crud/Pagination'
  198. import { mapGetters } from 'vuex'
  199. // const defaultForm = {
  200. // id: null,
  201. // account: null,
  202. // nickName: '',
  203. // roles: null,
  204. // enabled: ''
  205. // }
  206. export default {
  207. name: 'User',
  208. components: { rrOperation, pagination },
  209. // cruds() {
  210. // return CRUD({ title: '用户', url: 'api/users', crudMethod: { ...crudUser }})
  211. // },
  212. // mixins: [presenter(), header(), form(defaultForm), crud()],
  213. // 数据字典
  214. data() {
  215. // 自定义验证
  216. const validPhone = (rule, value, callback) => {
  217. if (!value) {
  218. callback(new Error('请输入电话号码'))
  219. } else if (!isvalidPhone(value)) {
  220. callback(new Error('请输入正确的11位手机号码'))
  221. } else {
  222. callback()
  223. }
  224. }
  225. return {
  226. addDialogVisible: false,
  227. editDialogVisible: false,
  228. editForm: {
  229. nickName: '',
  230. roles: '',
  231. orgName: '',
  232. phone: '',
  233. code: '',
  234. password: ''
  235. },
  236. disabledSendCode: false,
  237. verification: '获取验证码',
  238. countNum: 60,
  239. height: document.documentElement.clientHeight - 180 + 'px;',
  240. permission: {
  241. add: ['admin', 'user:add'],
  242. edit: ['admin', 'user:edit'],
  243. del: ['admin', 'user:del']
  244. },
  245. tableData: [
  246. {
  247. id: 1,
  248. account: '15100701025',
  249. nickName: '王XX',
  250. roles: '机构超级管理员',
  251. orgName: 'XX机构',
  252. phone: '15100701025',
  253. enabled: '0',
  254. createTime: '2021-11-10'
  255. }
  256. ],
  257. rules: {
  258. nickName: [
  259. { required: true, message: '请输入管理员名称', trigger: 'blur' },
  260. { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
  261. ],
  262. phone: [
  263. { required: true, trigger: 'blur', validator: validPhone }
  264. ],
  265. code: [
  266. { required: true, trigger: 'blur', message: '请输入验证码' }
  267. ],
  268. password: [
  269. { required: true, trigger: 'blur', message: '请输入密码' }
  270. ]
  271. }
  272. }
  273. },
  274. computed: {
  275. ...mapGetters([
  276. 'user'
  277. ])
  278. },
  279. created() {
  280. // this.crud.msg.add = '新增成功,默认密码:123456'
  281. },
  282. mounted: function() {
  283. const that = this
  284. window.onresize = function temp() {
  285. that.height = document.documentElement.clientHeight - 180 + 'px;'
  286. }
  287. },
  288. methods: {
  289. // 编辑
  290. editFormData(index, row) {
  291. this.editDialogVisible = true
  292. this.editForm.nickName = row.nickName
  293. this.editForm.roles = row.roles
  294. this.editForm.orgName = row.orgName
  295. this.editForm.phone = row.phone
  296. this.editForm.enabled = row.enabled
  297. },
  298. // 获取验证码
  299. getAuthCode() {
  300. // const param = {
  301. // phone: this.editForm.phone
  302. // }
  303. // proxy.$http
  304. // .post(proxy.$API.SENDMSGCODE,
  305. // param
  306. // )
  307. // .then(res => {
  308. // if (res.type == 200) {
  309. // this.countdown()
  310. // } else {
  311. // console.log(res.content)
  312. // }
  313. // })
  314. // .catch(res => {
  315. // console.log(res)
  316. // })
  317. },
  318. countdown() {
  319. if (this.disabledSendCode) {
  320. return
  321. }
  322. if (!/^1\d{10}$/.test(this.editForm.phone)) {
  323. this.$message.error('手机号错误,请重新输入')
  324. return
  325. }
  326. this.getAuthCode()
  327. this.disabledSendCode = true
  328. // this.isSendAuth = true
  329. this.countNum = 60
  330. const timer = setInterval(() => {
  331. this.verification = this.countNum + '重新获取'
  332. this.countNum -= 1
  333. if (this.countNum < 1) {
  334. clearInterval(timer)
  335. this.verification = '重新获取'
  336. this.disabledSendCode = false
  337. // this.isSendAuth = false
  338. console.log('倒计时结束')
  339. }
  340. }, 1000)
  341. },
  342. // 改变状态
  343. // changeEnabled(data, val) {
  344. // this.$confirm('此操作将 "' + this.dict.label.user_status[val] + '" ' + data.username + ', 是否继续?', '提示', {
  345. // confirmButtonText: '确定',
  346. // cancelButtonText: '取消',
  347. // type: 'warning'
  348. // }).then(() => {
  349. // crudUser.edit(data).then(res => {
  350. // this.crud.notify(this.dict.label.user_status[val] + '成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
  351. // }).catch(() => {
  352. // data.enabled = !data.enabled
  353. // })
  354. // }).catch(() => {
  355. // data.enabled = !data.enabled
  356. // })
  357. // },
  358. checkboxT(row, rowIndex) {
  359. return row.id !== this.user.id
  360. }
  361. }
  362. }
  363. </script>
  364. <style rel="stylesheet/scss" lang="scss" scoped>
  365. .el-dialog__header {
  366. background-color: #f1f1f1;
  367. }
  368. .edit_code {
  369. margin-left: 20px;
  370. }
  371. </style>