Commit cddedae720b4ae48c7b59a5114aff5d55dcf1c88

Authored by 刘汉宸
1 parent 7d0bbda6

feat: 优化表单必填判断

Showing 1 changed file with 29 additions and 26 deletions   Show diff stats
packages/schema-page/index.vue
... ... @@ -99,33 +99,37 @@
99 99 <template v-else>
100 100 <!-- 新增/修改弹出框内容 -->
101 101 <template v-if="['new', 'edit'].includes(modalType)">
102   - <z-schema-form
103   - :key="`form-${modalType}`"
104   - ref="form"
105   - :value="valueForm"
106   - @input="e => $emit('update:value-form', e)"
107   - :schema="schema.form"
108   - @submit="onFormSubmit"
109   - @cancel="closeDialog"
110   - >
111   - <template v-for="item in getSlotKeys('form-')" #[item.name]="slotScope">
112   - <slot :name="item.slot" v-bind="{ ..._slotScope, ...slotScope }"></slot>
113   - </template>
114   - <template #footer="{ submit, cancel }">
115   - <div style="text-align: center; width: 100%">
116   - <el-button :size="_size" type="primary" @click="submit" :loading="submitting">确定</el-button>
117   - <el-button :size="_size" plain @click="cancel">取消</el-button>
118   - </div>
119   - </template>
120   - </z-schema-form>
  102 + <template v-if="schema.form">
  103 + <z-schema-form
  104 + :key="`form-${modalType}`"
  105 + ref="form"
  106 + :value="valueForm"
  107 + @input="e => $emit('update:value-form', e)"
  108 + :schema="schema.form"
  109 + @submit="onFormSubmit"
  110 + @cancel="closeDialog"
  111 + >
  112 + <template v-for="item in getSlotKeys('form-')" #[item.name]="slotScope">
  113 + <slot :name="item.slot" v-bind="{ ..._slotScope, ...slotScope }"></slot>
  114 + </template>
  115 + <template #footer="{ submit, cancel }">
  116 + <div style="text-align: center; width: 100%">
  117 + <el-button :size="_size" type="primary" @click="submit" :loading="submitting">确定</el-button>
  118 + <el-button :size="_size" plain @click="cancel">取消</el-button>
  119 + </div>
  120 + </template>
  121 + </z-schema-form>
  122 + </template>
121 123 </template>
122 124 <!-- 详情弹出框内容 -->
123 125 <template v-else-if="modalType === 'detail'">
124   - <z-schema-form key="form-detail" ref="form" v-model="detail" :schema="schema.detail || detailSchema">
125   - <template v-for="item in getSlotKeys('detail-')" #[item.name]="slotScope">
126   - <slot :name="item.slot" v-bind="{ ..._slotScope, ...slotScope }"></slot>
127   - </template>
128   - </z-schema-form>
  126 + <template v-if="schema.form || schema.detail">
  127 + <z-schema-form key="form-detail" ref="form" v-model="detail" :schema="schema.detail || detailSchema">
  128 + <template v-for="item in getSlotKeys('detail-')" #[item.name]="slotScope">
  129 + <slot :name="item.slot" v-bind="{ ..._slotScope, ...slotScope }"></slot>
  130 + </template>
  131 + </z-schema-form>
  132 + </template>
129 133 </template>
130 134 </template>
131 135 </div>
... ... @@ -189,7 +193,7 @@ export default {
189 193 modalType: this.dialogType || 'none',
190 194 modalTitle: this.dialogTitle || '',
191 195 modalProps: {},
192   - detailSchema: filterout(cloneDeep(this.schema.form), ['is', 'rules']),
  196 + detailSchema: filterout(cloneDeep(this.schema.form || {}), ['is', 'rules']),
193 197 detail: this.valueDetail || {},
194 198 tableData: this.valueTable || [],
195 199 loading: false,
... ... @@ -201,7 +205,6 @@ export default {
201 205 if (this.auto || this.schema.auto) {
202 206 this.onSearch();
203 207 }
204   - console.log(this);
205 208 },
206 209 watch: {
207 210 valueDetail(val) {
... ...