yangfeng
2024-01-06 9ada19d01d0cb6aaa0dec99e24bf7a9b511750bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<template>
  <div class="review-dialog">
    <el-dialog
      :title="editCommonConfig.title"
      :visible.sync="editConfig.visible"
      :width="dialogWidth"
      :before-close="handleClose"
      append-to-body
      custom-class="iframe-dialog"
    >
      <div class="drawerContent" style="overflow: auto">
        <el-form ref="form" :rules="rules" :model="editConfig.infomation" label-position="right" label-width="100px">
          <el-form-item label="审核结果:" prop="result">
            <el-select v-model="editConfig.infomation.result" placeholder="请选择审核结果">
              <el-option label="审核通过" :value="3"></el-option>
              <el-option label="审核拒绝" :value="4"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item v-if="editConfig.infomation.result === 4" label="未通过原因:" prop="reason">
            <el-input v-model="editConfig.infomation.reason" type="textarea"></el-input>
          </el-form-item>
          <el-form-item v-if="editConfig.infomation.result === 3" label="用户等级:" prop="roleIDs">
            <el-checkbox-group
              v-model="editConfig.infomation.roleIDs"
              :disabled="editConfig.title == '查看' ? true : false"
            >
              <el-checkbox v-for="role in roleList" :label="role.id" :key="role.id">{{ role.name }}</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取消</el-button>
        <el-button v-if="editConfig.title == '查看' ? false : true" type="primary" @click="onSubmit('form')"
          >确定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import { getRoleIDs, userExamine } from "@/api/unifiedManage/userManage"
export default {
  name: "ReviewDialog",
  props: {
    editCommonConfig: {
      type: Object,
      default: () => {
        return {
          visible: false,
          title: "用户审核",
          infomation: {
            result: 3,
            roleIDs: []
          }
        }
      }
    }
  },
  components: {},
  computed: {},
  data() {
    return {
      dialogWidth: "30%",
      editConfig: this.editCommonConfig,
      rules: {
        result: [{ required: true, message: "请选择审核结果", trigger: "change" }],
        reason: [{ required: true, message: "请输入拒绝原因", trigger: "blur" }],
        roleIDs: [{ required: true, message: "请选择用户等级", trigger: "change" }]
      },
      roleList: [] // 用户等级
    }
  },
  watch: {
    "editCommonConfig.visible"(val) {
      if (val) {
        this.$refs.form.resetFields()
      }
    },
    "editCommonConfig.infomation"(val) {
      if (this.isopen) {
        this.$refs.form.resetFields()
        if (val.id) {
          // this.form = val
          // this.getDataInfo(val)
        }
      }
    }
  },
  created() {
    this.getDataInfo()
  },
  methods: {
    handleClose() {
      this.editConfig.visible = false
    },
    // 获取等级信息
    async getDataInfo() {
      const rsp = await getRoleIDs({ useType: 1 })
      if (rsp.code == 200) {
        this.roleList = rsp.data ? rsp.data : []
      }
    },
    // 确定
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        console.log(valid)
        if (valid) {
          let param = this.saveParams()
          userExamine(param).then((reply) => {
            if (reply && reply.code === 200) {
              this.$message.success("保存成功")
              this.handleClose()
              this.$parent.getData()
            }
          })
        }
      })
    },
    saveParams() {
      let reason = this.editConfig.infomation.result == 3 ? "" : this.editConfig.infomation.reason
      let roleIds = this.editConfig.infomation.result == 3 ? this.editConfig.infomation.roleIDs : []
      let params = {
        reason: reason,
        roleIds: roleIds,
        status: this.editConfig.infomation.result,
        userId: this.editConfig.infomation.id
      }
      return params
    }
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
::v-deep {
  .iframe-dialog .el-dialog__body {
    .drawerContent {
      width: 80%;
      padding: 20px 0;
      margin: auto;
      overflow: hidden;
      margin-top: 15px;
      // 溢出隐藏滚动条
      scrollbar-width: none; /* firefox */
      -ms-overflow-style: none; /* IE 10+ */
    }
  }
  .el-dialog__footer {
    background-color: #f5f5f5;
    height: 55px;
    line-height: 55px;
    text-align: right;
    padding-right: 20px;
  }
}
</style>