分支自 SuZhouGuanHong/TaiYuanTaiZhong

huanghongfeng
2024-07-15 a765da90e5ee63e04d2d8460a5ad1ebd0e8eb4db
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<template>
  <div class="t-dis1">
    <VolHeader
      icon="el-icon-warning-outline"
      text="表单属性(显示纯文本)"
      style="margin-bottom: 20px"
    >
   <template #content>
         <div style="color: #909090;">设置type='label'以纯文本方式显示(只读表单默认对下拉框字典转换,不需要手动处理下拉框数据源)</div>
   </template>
    </VolHeader>
    <VolForm
      ref="myform1"
      :label-width="75"
      :formFields="formFields"
      :formRules="formRules2"
    ></VolForm>
  </div>
  <el-alert style="margin: 0 20px;width: auto;" type="success" :closable="false">
    <p>设置type='label'以纯文本方式显示,设置readonly=true以组件只读方式显示。具体使用见:框架文档->组件api->VolForm。<a
          href="http://v2.volcore.xyz/document/api"
          target="_blank"
          >点击查看文档
        </a></p>
  </el-alert>
  <div class="t-dis2">
    <VolHeader
      icon="el-icon-warning-outline"
      text="表单属性(显示原组件)"
      style="margin-bottom: 20px"
    >
       <template #content>
         <div style="color: #909090;">设置readonly=true以组件只读方式显示</div>
   </template>
    </VolHeader>
    <VolForm
      ref="myform2"
      :label-width="75"
      :formFields="formFields"
      :formRules="formRules"
    ></VolForm>
  </div>
</template>
<script>
import VolForm from "@/components/basic/VolForm.vue";
import VolHeader from "@/components/basic/VolHeader.vue";
export default {
  components: { VolForm, VolHeader },
  methods: {
    getForm() {
      this.$message.error(JSON.stringify(this.formFields));
    },
    reset() {},
  },
  mounted() {},
  data() {
    return {
      loadKey: true,
      formFields: {
        Variety: "日用品",
        DateRange: "2019-09-01",
        City: "北京市",
        AvgPrice: 1238000,
        Variety1: "",
        DateRange1: "2019-09-02",
        City1: "上海市",
        AvgPrice1: 7.72,
        DateRange2: "2019-09-03",
        City2: "广州市",
        AvgPrice2: 6.66,
        IsTop: "1",
      },
      formRules: [
        // 两列的表单,formRules数据格式为:[[{},{}]]
        [
          {
            title: "商品类型",
            dataKey: "age",
            // 如果这里绑定了data数据,后台不会加载此数据源
            data: [],
            field: "Variety",
            readonly: true,
            type: "select",
          },
          {
            dataKey: "city",
            title: "所在城市",
            field: "City",
            readonly: true,
            type: "select",
            data: [],
          },
          {
            title: "成交均价",
            field: "AvgPrice",
          },
        ],
        [
          {
            dataKey: "city",
            title: "所在地区",
            field: "City1",
            readonly: true,
            type: "select",
            data: [],
          },
          {
            title: "生产价格",
            field: "AvgPrice1",
            readonly: true,
          },
          {
            title: "审核日期",
            field: "DateRange",
            type: "date",
            readonly: true,
          },
        ],
        [
          {
            dataKey: "city",
            title: "详细地址",
            field: "City2",
            readonly: true,
            type: "select",
            data: [],
          },
          {
            title: "平均重量",
            field: "AvgPrice2",
            type: "number",
            readonly: true,
          },
          {
            type: "date",
            title: "生产日期",
            field: "DateRange2",
            readonly: true,
          },
        ],
      ],
      formRules2: [
        [
          {
            title: "商品类型",
            dataKey: "age",
            data: [],
            field: "Variety",
            type: "label",
          },
          {
            dataKey: "city",
            title: "所在城市",
            field: "City",
            type: "label",
            data: [],
            type: "label",
          },
          {
            title: "成交均价",
            field: "AvgPrice",
            type: "label",
          },
        ],
        [
          {
            dataKey: "city",
            title: "所在地区",
            field: "City1",
            type: "label",
            data: [],
          },
          {
            title: "生产价格",
            field: "AvgPrice1",
            type: "label",
          },
          {
            title: "审核日期",
            field: "DateRange",
            type: "label",
          },
        ],
        [
          {
            title: "详细地址",
            field: "City2",
            type: "label",
          },
          {
            title: "平均重量",
            field: "AvgPrice2",
            type: "label",
          },
          {
            type: "label",
            title: "生产日期",
            field: "DateRange2",
          },
        ],
      ],
    };
  },
};
</script>
<style lang="less" scoped>
.t-dis1,.t-dis2 {
  margin-bottom: 15px;
  background: white;
  border: 1px solid #f5f5f5;
  padding: 5px;
  border-radius: 5px;
  margin: 15px 20px 0 20px;
}
.t-dis1 ::v-deep(.el-form-item){
  margin-bottom: 5px;
}
</style>