index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" @submit.native.prevent>
  4. <el-form-item label="账号状态" prop="state">
  5. <el-select v-model="queryParams.state" placeholder="账号状态" class="se" clearable>
  6. <el-option value="0" label="正常"></el-option>
  7. <el-option value="1" label="禁用"></el-option>
  8. </el-select>
  9. </el-form-item>
  10. <el-form-item>
  11. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  12. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  13. </el-form-item>
  14. </el-form>
  15. <el-row :gutter="10" class="mb8">
  16. <el-button type="primary" icon="el-icon-plus" :disabled="ids.length > 0" @click="op('add')" v-hasPermi="['work:user:add']">新增</el-button>
  17. <el-button type="success" icon="el-icon-edit" :disabled="ids.length != 1" @click="op('edit', ids)" v-hasPermi="['work:user:edit']">修改</el-button>
  18. <el-button type="danger" icon="el-icon-delete" :disabled="ids.length == 0" @click="del" v-hasPermi="['work:user:remove']">删除{{ ids.length > 0 ? '(' + ids.length + ')' : '' }}</el-button>
  19. </el-row>
  20. <el-table :data="response.rows" border @selection-change="selects" height="calc(100vh - 270px)">
  21. <el-table-column type="selection" width="55" align="center" />
  22. <el-table-column label="微信openId" align="left" prop="openId" />
  23. <el-table-column label="绑定就诊人" align="center" width="160">
  24. <template slot-scope="scope">
  25. <el-tag type="success" v-if="scope.row.patientId">已绑定</el-tag>
  26. <el-tag type="danger" v-else>未绑定</el-tag>
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="当前绑定" prop="patientName" align="center" width="160" />
  30. <el-table-column label="账号状态" align="center" prop="state" width="110">
  31. <template slot-scope="scope">
  32. <div class="switch">
  33. <el-switch v-model="scope.row.state" :active-value="0" :width="50" :inactive-value="1" @change="op('change', scope.row)"></el-switch>
  34. <span class="zc" v-if="scope.row.state == 0" style="left: 22px">正常</span>
  35. <span class="ty" v-else style="left: 35px">禁用</span>
  36. </div>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="创建时间" align="center" prop="createTime" width="160" />
  40. <el-table-column label="操作" align="center" width="160">
  41. <template slot-scope="scope">
  42. <el-button size="mini" type="text" icon="el-icon-delete" @click="del(scope.row)" v-hasPermi="['work:user:remove']">删除</el-button>
  43. </template>
  44. </el-table-column>
  45. <template slot="empty">
  46. <el-empty></el-empty>
  47. </template>
  48. </el-table>
  49. <pagination v-if="response.total > 0" :total="response.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  50. </div>
  51. </template>
  52. <script>
  53. import edit from './edit';
  54. export default {
  55. name: 'User',
  56. data() {
  57. return {
  58. queryParams: {
  59. pageNum: 1,
  60. pageSize: 10,
  61. openId: null,
  62. state: null,
  63. orderByColumn: 'id', //排序字段
  64. isAsc: 'desc' //排序方式
  65. }
  66. };
  67. },
  68. created() {
  69. this.getList();
  70. },
  71. methods: {
  72. getList() {
  73. this.ajax({ url: '/work/user/list', data: this.queryParams }).then((response) => {
  74. this.response = response;
  75. });
  76. },
  77. handleQuery() {
  78. this.queryParams.pageNum = 1;
  79. this.getList();
  80. },
  81. resetQuery() {
  82. this.resetForm('queryForm');
  83. this.handleQuery();
  84. },
  85. selects(rows) {
  86. this.ids = rows.map((item) => item.id);
  87. },
  88. op(tag, row) {
  89. if (tag == 'add') {
  90. this.iframe({ obj: edit, param: {}, title: '新增', width: '45%', height: '55%' });
  91. }
  92. if (tag == 'edit') {
  93. const id = row.id || this.ids[0];
  94. this.iframe({ obj: edit, param: { id: id }, title: '编辑', width: '50%', height: '50%' });
  95. }
  96. //账号状态
  97. if (tag == 'change') {
  98. let text = row.state === 0 ? '启用' : '禁用';
  99. this.$confirm('确认要' + text + '该用户吗?', '警告', { type: 'warning' })
  100. .then(() => {
  101. this.post({ url: '/work/user/edit', data: { id: row.id, state: row.state } })
  102. .then((response) => {
  103. this.$modal.msgSuccess(text + '成功');
  104. })
  105. .catch(() => {
  106. row.state = row.state === 0 ? 1 : 0;
  107. });
  108. })
  109. .catch(() => {
  110. row.state = row.state === 0 ? 1 : 0;
  111. });
  112. }
  113. },
  114. del(row) {
  115. this.$confirm('是否确认删除选中数据?', '警告', { type: 'warning' }).then(() => {
  116. this.get({ url: '/work/user/remove/' + (row.id || this.ids) }).then((response) => {
  117. this.$modal.msgSuccess('删除成功');
  118. this.getList();
  119. });
  120. });
  121. }
  122. }
  123. };
  124. </script>