odc.xiaohui
2023-03-07 034d8675792fee6af5af592df0b69acd3ad8a215
src/views/manager/User.vue
@@ -30,21 +30,23 @@
          <el-table-column label="操作" align="conter">
            <template slot-scope="scope">
              <el-button type="text" size="medium" @click="details(scope.row)">编辑</el-button>
<!--              <el-button type="text" size="medium" @click="reset(scope.row.id)">重置密码</el-button>-->
<!--              <el-button type="text" size="medium" @click="remove(scope.row.id)" style="color:#ff0000">删除-->
                <el-button type="text" size="medium" @click="updateStatus(scope.row.id,scope.row.status)">{{scope.row.status==1?"禁用":"启用"}}
              <!--              <el-button type="text" size="medium" @click="reset(scope.row.id)">重置密码</el-button>-->
              <!--              <el-button type="text" size="medium" @click="remove(scope.row.id)" style="color:#ff0000">删除-->
              <el-button type="text" size="medium" @click="handleToManager(scope.row)">设为警员</el-button>
              <el-button type="text" size="medium" @click="updateStatus(scope.row.id,scope.row.status)">
                {{ scope.row.status == 1 ? "禁用" : "启用" }}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </template>
      <el-pagination @current-change="handleCurrentChange" :current-page="queryInfo.current" :page-size="queryInfo.size"
        layout="prev, pager, next" :total="total"></el-pagination>
                     layout="prev, pager, next" :total="total"></el-pagination>
    </el-card>
    <!--添加用户弹窗-->
    <el-dialog title="用户添加" :visible.sync="addPublicityVisibel" width="50%" :before-close="addPublicityClose"
      :append-to-body="true">
               :append-to-body="true">
      <el-row :gutter="15">
        <el-form ref="addPublicityForm" :model="addPublicityForm" :rules="rules" size="medium" label-width="100px">
@@ -65,7 +67,7 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="身份证" prop="userIdcard">
              <el-input v-model="addPublicityForm.userIdcard" clearable placeholder="请输入身份证"> </el-input>
              <el-input v-model="addPublicityForm.userIdcard" clearable placeholder="请输入身份证"></el-input>
            </el-form-item>
          </el-col>
        </el-form>
@@ -77,7 +79,7 @@
    </el-dialog>
    <el-dialog title="编辑" :visible.sync="detailsVisible" width="50%" :append-to-body="true"
      :before-close="detailsVisibleclose">
               :before-close="detailsVisibleclose">
      <el-row :gutter="15">
        <el-form ref="detailsRow" :model="detailsRow" size="medium" label-width="100px">
          <el-col :span="12">
@@ -94,13 +96,15 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="手机号码" prop="userMobile">
              <el-input v-model="detailsRow.userMobile" placeholder="请输入手机号码" clearable :style="{ width: '100%' }">
              <el-input v-model="detailsRow.userMobile" placeholder="请输入手机号码" clearable
                        :style="{ width: '100%' }">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="身份证号" prop="userIdcard">
              <el-input v-model="detailsRow.userIdcard" placeholder="请输入身份证号" clearable :style="{ width: '100%' }">
              <el-input v-model="detailsRow.userIdcard" placeholder="请输入身份证号" clearable
                        :style="{ width: '100%' }">
              </el-input>
            </el-form-item>
          </el-col>
@@ -118,7 +122,8 @@
<script>
import {
  getPublicityList,
  addPublicityList
  addPublicityList,
  toManager
} from '@/api/User'
@@ -153,8 +158,7 @@
      detailsVisible: false,
      //详细内容
      detailsRow:
      {
      }
          {}
      ,
      //表单提交内容
      addPublicityForm: {
@@ -202,127 +206,136 @@
  },
  methods:
  {
    //更新用户状态
    updateStatus(id,status) {
      var _this = this;
      this.$confirm('确认修改账户状态吗?').then(() => {
        _this.$http.get('/api/user/status', { params: { id: id ,status:status} }).then(res => {
          _this.$message({
            message: '修改成功',
            type: 'success'
      {
        handleToManager(data) {
          toManager(data.id).then(res => {
            this.$message({
              message: '设置成功',
              type: 'success'
            })
            this.search();
          })
          this.search();
        })
      }
      )
        },
        //更新用户状态
        updateStatus(id, status) {
          var _this = this;
          this.$confirm('确认修改账户状态吗?').then(() => {
                _this.$http.get('/api/user/status', {params: {id: id, status: status}}).then(res => {
                  _this.$message({
                    message: '修改成功',
                    type: 'success'
                  })
                  this.search();
                })
              }
          )
    },
    // //发布/下架
    // punlish(val, val2) {
    //   if (val2 == 0) {
    //     this.$http.get('/api/commonQuestion/release/' + val).then(res => {
    //       this.$message({
    //         message: '发布成功',
    //         type: 'success'
    //       })
        },
        // //发布/下架
        // punlish(val, val2) {
        //   if (val2 == 0) {
        //     this.$http.get('/api/commonQuestion/release/' + val).then(res => {
        //       this.$message({
        //         message: '发布成功',
        //         type: 'success'
        //       })
    //       this.search();
    //     }
    //     )
    //   }
    //   if (val2 == 1) {
    //     this.$http.get('/api/commonQuestion/offline/' + val).then(res => {
    //       this.$message({
    //         message: '下架成功',
    //         type: 'success'
    //       })
    //       this.search();
    //     }
    //     );
    //   }
    // },
        //       this.search();
        //     }
        //     )
        //   }
        //   if (val2 == 1) {
        //     this.$http.get('/api/commonQuestion/offline/' + val).then(res => {
        //       this.$message({
        //         message: '下架成功',
        //         type: 'success'
        //       })
        //       this.search();
        //     }
        //     );
        //   }
        // },
    //编辑
    details(val) {
      this.detailsVisible = true;
      this.detailsRow = Object.assign({}, val);
    },
    update() {
      this.$http.put('/api/user', this.detailsRow).then(res => {
        this.$message({
          message: '编辑成功',
          type: 'success'
        }
        )
        this.search();
      }
      );
      this.detailsVisible = false;
    },
        //编辑
        details(val) {
          this.detailsVisible = true;
          this.detailsRow = Object.assign({}, val);
        },
        update() {
          this.$http.put('/api/user', this.detailsRow).then(res => {
                this.$message({
                      message: '编辑成功',
                      type: 'success'
                    }
                )
                this.search();
              }
          );
          this.detailsVisible = false;
        },
    //重置密码
    reset(val) {
      this.$http.get('/api/user/resetPassword/' + val).then(res => this.$message({
        message: '重置成功',
        type: 'success'
      }));
    },
    //添加
    add() {
      this.$refs.addPublicityForm.validate(async (vaild) => {
        if (!vaild) return this.$message.error('输入有误')
        let param = null;
        param = this.addPublicityForm;
        addPublicityList(param).then(res => {
          this.$message({
            message: '操作成功',
        //重置密码
        reset(val) {
          this.$http.get('/api/user/resetPassword/' + val).then(res => this.$message({
            message: '重置成功',
            type: 'success'
          });
          this.addPublicityForm = {};
          this.init();
        }
        )
        this.addPublicityVisibel = false;
      })
    },
    //关闭之前
    addPublicityClose() {
      this.addPublicityVisibel = false;
    },
    detailsVisibleclose() {
      this.detailsVisible = false;
    },
    //分页方法
    handleCurrentChange(val) {
      this.queryInfo.current = val;
      this.search();
    },
          }));
        },
        //添加
        add() {
          this.$refs.addPublicityForm.validate(async (vaild) => {
            if (!vaild) return this.$message.error('输入有误')
            let param = null;
            param = this.addPublicityForm;
            addPublicityList(param).then(res => {
                  this.$message({
                    message: '操作成功',
                    type: 'success'
                  });
                  this.addPublicityForm = {};
                  this.init();
                }
            )
            this.addPublicityVisibel = false;
          })
        },
        //关闭之前
        addPublicityClose() {
          this.addPublicityVisibel = false;
        },
        detailsVisibleclose() {
          this.detailsVisible = false;
        },
        //分页方法
        handleCurrentChange(val) {
          this.queryInfo.current = val;
          this.search();
        },
    //公共宣传加载
    init() {
      let param = {}
      param.current = this.queryInfo.current
      param.size = this.queryInfo.size
      getPublicityList(param).then(res => {
        this.publicityList = res.records;
        this.total = res.total
      })
    },
    //查询
    search() {
      let param = {}
      param.realName = this.queryInfo.realName
      param.nickName = this.queryInfo.nickName
      param.size = this.queryInfo.size
      getPublicityList(param).then(res => {
        this.publicityList = res.records;
        this.total = res.total
        this.current = res.current
      })
    },
        //公共宣传加载
        init() {
          let param = {}
          param.current = this.queryInfo.current
          param.size = this.queryInfo.size
          getPublicityList(param).then(res => {
            this.publicityList = res.records;
            this.total = res.total
          })
        },
        //查询
        search() {
          let param = {}
          param.realName = this.queryInfo.realName
          param.nickName = this.queryInfo.nickName
          param.size = this.queryInfo.size
          getPublicityList(param).then(res => {
            this.publicityList = res.records;
            this.total = res.total
            this.current = res.current
          })
        },
  }
      }
}
</script>