unknown
2023-10-23 5672f352d0ba114e2ae96c8cefad6c74ae6d2934
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
<template>
  <div class="role">
    <!-- https://juejin.cn/post/7042597964618924069?searchId=202310071305486BA29870D97939288832#heading-8 -->
    <!-- https://juejin.cn/post/7139110255748710436?searchId=2023092815420483B1983D44854DBE6608#comment -->
    <el-form 
      ref="ruleForm" 
      class="rule-form" 
      :model="formConfig.formModels"
      :rules="formConfig.formRules"
      :label-width="formConfig.labelWidth || 'auto'">
      <el-row>
        <el-col v-for="item in formConfig.formItems" :key="item.label" :span="item.span || 24">
          <el-form-item :label="item.label" :style="formConfig.itemStyle || null">
 
            <template v-if="item.type === 'input' || item.type === 'password'">
              <el-input :placeholder="item.placeholder || `请输入${item.label}`"
                :show-password="item.type === 'password'"></el-input>
            </template>
 
            <template v-else-if="item.type === 'select'">
              <el-select :placeholder="item.placeholder || `请选择${item.label}`">
                <el-option v-for="option in item.options" :key="option.label" :label="option.label"
                  :value="option.value"></el-option>
              </el-select>
            </template>
 
            <template v-else>
              <el-date-picker v-bind="item.otherOptions"></el-date-picker>
            </template>
 
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {}
  },
  props: {
    formConfig: {
      type: Object,
      default: () => ({})
    }
  }
}
</script>
<style scoped lang="scss">
.el-form {
  padding-right: 15px;
  max-height: 550px;
  overflow-y: auto;
}
 
::v-deep .el-form-item__label {
  color: #fff
}
 
.el-select {
  width: 100%;
}
</style>