| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- <template>
- <div class="form-wrapper">
- <el-form
- class="search-box"
- ref="form"
- :model="form"
- :inline="true"
- >
- <div class="block-title">
- 查询条件
- </div>
- <el-form-item
- label="登录账号"
- prop="loginName">
- <el-input v-model="form.loginName"></el-input>
- </el-form-item>
- <el-form-item
- label="手机号"
- prop="phone">
- <el-input v-model="form.phone"></el-input>
- </el-form-item>
- <div class="btn-wrap">
- <el-button
- @click="reset"
- >
- 重置
- </el-button>
- <el-button
- type="primary"
- @click="getAccountList"
- >
- 搜索
- </el-button>
- <el-button
- type="primary"
- size="mini"
- @click="showDialog('add')"
- >
- 新增账号
- </el-button>
- </div>
- </el-form>
- <div class="table-box">
- <!-- <div class="block-title">
- 账号列表
- </div> -->
- <el-table
- border
- stripe
- v-loading="loading"
- :data="tableData"
- >
- <!-- <el-table-column
- prop="id"
- label="ID"
- >
- </el-table-column> -->
- <el-table-column
- prop="loginName"
- label="账号名"
- >
- </el-table-column>
- <el-table-column
- prop="name"
- label="姓名"
- >
- </el-table-column>
- <el-table-column
- prop="roles"
- label="角色"
- >
- <template slot-scope="scope">
- <el-tag
- v-for="(item,index) in scope.row.roleList"
- :key="index"
- >
- {{ item.name }}
- </el-tag>
- </template>
- </el-table-column>
- <el-table-column
- prop="type"
- label="用户属性"
- width="100"
- >
- <template slot-scope="scope">
- <span>{{ scope.row.type === 2 ? '组内员工' : scope.row.type === 1 ? '管理员' : '员工' }}</span>
- </template>
- </el-table-column>
- <!-- <el-table-column
- prop="creator"
- label="创建人">
- </el-table-column> -->
- <el-table-column
- label="上次登录时间"
- width="140"
- >
- <template slot-scope="scope">
- {{ scope.row.lastLoginTime | formatTime }}
- </template>
- </el-table-column>
- <el-table-column
- label="创建时间"
- width="140"
- >
- <template slot-scope="scope">
- {{ scope.row.createTime | formatTime }}
- </template>
- </el-table-column>
- <el-table-column
- prop="phone"
- label="电话"
- >
- </el-table-column>
- <!-- 雷锋纪念馆定制 -->
- <!-- <el-table-column
- width="120"
- label="状态">
- <template slot-scope="scope">
- <span>{{ scope.row.isUse ? '已激活' : '已禁用' }}</span>
- <el-button
- type="text"
- size="small"
- @click="offSale(scope.row)"
- class="offSale-btn"
- v-if="scope.row.isUse"
- >
- <i class="iconfont icon-offSale"></i>禁用
- </el-button>
- <el-button
- type="text"
- size="small"
- @click="onSale(scope.row)"
- class="onSale-btn"
- v-else
- >
- <i class="iconfont icon-onSale"></i>激活
- </el-button>
- </template>
- </el-table-column> -->
- <el-table-column
- fixed="right"
- label="操作"
- width="120"
- >
- <template slot-scope="scope">
- <el-button
- type="text"
- size="small"
- @click="showDialog('edit',scope.row)"
- >
- 编辑
- </el-button>
- <el-button
- type="text"
- size="small"
- @click="deleteAccount(scope.row.id)"
- >
- 删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- background
- :page-size="form.pageSize"
- :current-page.sync="form.pageNum"
- :page-sizes="[10, 20, 50, 100]"
- @size-change="handleSizeChange"
- @current-change="handlePage"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- >
- </el-pagination>
- </div>
- <ElDialog
- :title="dialogType === 'add' ? '新增账户' : '编辑账户'"
- width="660px"
- v-model="dialogVisible">
- <EditDialog
- :scenic-list="scenicList"
- :dialog-type="dialogType"
- :account-item="curItem"
- @updateList="handleUpdate"
- ></EditDialog>
- </ElDialog>
- </div>
- </template>
- <script>
- import { getAccountList, deleteAccount, updateAccount } from '@/api/systemSetting/account'
- import ElDialog from '@/components/Dialog'
- import EditDialog from './account/EditDialog'
- import moment from 'moment'
- export default {
- components: {
- ElDialog,
- EditDialog
- },
- created () {
- this.getAccountList()
- },
- data () {
- return {
- projectName: process.env.VUE_APP_PROJECT,
- loading: false,
- dialogType: 'add',
- dialogVisible: false,
- tableData: [],
- scenicList: [],
- total: 0,
- form: {
- export: false,
- pageNum: 1,
- pageSize: 10,
- loginName: '',
- name: '',
- phone: ''
- },
- // 当前账号对象
- curItem: {}
- }
- },
- methods: {
- reset () {
- this.form.loginName = ''
- this.form.phone = ''
- },
- showDialog (type, item) {
- this.dialogType = type
- this.curItem = item
- this.dialogVisible = true
- },
- handleSizeChange (size) {
- this.pageSize = size
- this.getAccountList()
- },
- getAccountList () {
- this.loading = true
- getAccountList(this.form).then(res => {
- this.tableData = res?.data?.records || []
- this.total = res?.data?.total || 0
- }).finally(() => {
- this.loading = false
- })
- },
- deleteAccount (id) {
- this.$confirm('此操作将永久删除, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- deleteAccount(id).then(res => {
- this.$message.success('删除成功')
- this.getAccountList()
- })
- })
- },
- handlePage (pageNum) {
- this.form.pageNum = pageNum
- this.getAccountList()
- },
- offSale (data) {
- let form = Object.assign({}, data)
- form.isUse = 0
- updateAccount(form).then(res => {
- this.$message.success('操作成功')
- this.getAccountList()
- })
- },
- onSale (data) {
- if (moment().isAfter(data.use_end_time)) {
- this.$alert('请先修改账号过期时间', '账号已过期', {
- confirmButtonText: '知道了'
- })
- } else {
- let form = Object.assign({}, data)
- form.isUse = 1
- updateAccount(form).then(res => {
- this.$message.success('操作成功')
- this.getAccountList()
- })
- }
- },
- handleChange (data) {
- let form = Object.assign({}, data)
- if (data.workStatus) {
- form.workStatus = 1
- } else {
- form.workStatus = 0
- }
- updateAccount(form).then(res => {
- this.$message.success('操作成功')
- this.getAccountList()
- })
- },
- handleChange2 (data) {
- let form = Object.assign({}, data)
- if (data.onDuty) {
- form.onDuty = 1
- } else {
- form.onDuty = 0
- }
- updateAccount(form).then(res => {
- this.$message.success('操作成功')
- this.getAccountList()
- })
- },
- handleUpdate () {
- this.$store.dispatch('getAccount')
- this.getAccountList()
- }
- }
- }
- </script>
- <style scoped>
- .offSale-btn{
- color: #F56C6C
- }
- .onSale-btn{
- color: #67C23A
- }
- </style>
|