odc.xiaohui
2023-03-03 752ad6211b54bbf38bf7dfc5c3a572ae3e15b0d4
src/views/manager/User.vue
@@ -30,8 +30,9 @@
          <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="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>
            </template>
          </el-table-column>
@@ -75,46 +76,41 @@
      </span>
    </el-dialog>
     <el-dialog title="编辑" :visible.sync="detailsVisible" width="50%" :append-to-body="true"
          :before-close="detailsVisibleclose">
          <el-row :gutter="15">
            <el-form ref="detailsRow" :model="detailsRow" size="medium"
              label-width="100px">
              <el-col :span="12">
                <el-form-item label="用户名" prop="nickName">
                  <el-input v-model="detailsRow.nickName" placeholder="请输入用户名" clearable
                    :style="{ width: '100%' }">
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="用户姓名" prop="realName">
                  <el-input v-model="detailsRow.realName" placeholder="请输入用户姓名" clearable
                    :style="{ width: '100%' }">
                  </el-input>
                </el-form-item>
              </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>
                </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>
                </el-form-item>
              </el-col>
            </el-form>
          </el-row>
          <span slot="footer" class="dialog-footer">
            <el-button @click="detailsVisible = false">取 消</el-button>
            <el-button type="primary" @click="update">确 定</el-button>
          </span>
        </el-dialog>
    <el-dialog title="编辑" :visible.sync="detailsVisible" width="50%" :append-to-body="true"
      :before-close="detailsVisibleclose">
      <el-row :gutter="15">
        <el-form ref="detailsRow" :model="detailsRow" size="medium" label-width="100px">
          <el-col :span="12">
            <el-form-item label="用户名" prop="nickName">
              <el-input v-model="detailsRow.nickName" placeholder="请输入用户名" clearable :style="{ width: '100%' }">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户姓名" prop="realName">
              <el-input v-model="detailsRow.realName" placeholder="请输入用户姓名" clearable :style="{ width: '100%' }">
              </el-input>
            </el-form-item>
          </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>
            </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>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="detailsVisible = false">取 消</el-button>
        <el-button type="primary" @click="update">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
@@ -131,13 +127,13 @@
  data() {
    return {
 rules: {
      rules: {
        nickName: [{
          required: true,
          message: '请输入用户名 ',
          trigger: 'blur'
        }],
         realName: [{
        realName: [{
          required: true,
          message: '请输入用户姓名',
          trigger: 'blur'
@@ -147,18 +143,18 @@
          message: '请输入手机号 ',
          trigger: 'blur'
        }],
           userIdcard: [{
        userIdcard: [{
          required: true,
          message: '请输入身份证 ',
          trigger: 'blur'
        }],
        },
      },
      //详细内容弹框
      detailsVisible: false,
      //详细内容
      detailsRow:
        {
        }
      detailsRow:
      {
      }
      ,
      //表单提交内容
      addPublicityForm: {
@@ -207,16 +203,20 @@
  },
  methods:
  {
    //删除
    remove(val) {
      this.$http.delete('/api/user', { params: { id: val } }).then(res => {
        this.$message({
          message: '删除成功',
          type: 'success'
    //更新用户状态
    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();
        })
      }
      )
        this.search();
      })
    },
    // //发布/下架
    // punlish(val, val2) {
@@ -246,16 +246,19 @@
    //编辑
    details(val) {
      this.detailsVisible = true;
            this.detailsRow = Object.assign({}, val);
      this.detailsRow = Object.assign({}, val);
    },
    update(){
          this.$http.put('/api/user',this.detailsRow).then(res => {this.$message({
        message: '编辑成功',
        type: 'success'}
    update() {
      this.$http.put('/api/user', this.detailsRow).then(res => {
        this.$message({
          message: '编辑成功',
          type: 'success'
        }
        )
         this.search();}
        );
          this.detailsVisible =false;
        this.search();
      }
      );
      this.detailsVisible = false;
    },
    //重置密码
@@ -267,20 +270,20 @@
    },
    //添加
    add() {
        this.$refs.addPublicityForm.validate(async (vaild) => {
      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;
        let param = null;
        param = this.addPublicityForm;
        addPublicityList(param).then(res => {
          this.$message({
            message: '操作成功',
            type: 'success'
          });
          this.addPublicityForm = {};
          this.init();
        }
        )
        this.addPublicityVisibel = false;
      })
    },
    //关闭之前
@@ -327,4 +330,4 @@
::v-deep(.el-table thead) {
  color: #000000;
}
</style>
</style>