whj 1 год назад
Родитель
Сommit
d5d50497d5

+ 4 - 1
src/views/test/Test1.vue

@@ -54,7 +54,7 @@
       </a-card>
     </a-col>
     <a-col :span="4">
-      <Detail :config="config" ref="detail"/>
+      <Detail :config="config" ref="detail" @delete="handleDelete"/>
     </a-col>
   </a-row>
 </template>
@@ -98,6 +98,9 @@ export default {
     update (val) {
       console.log(val)
     },
+    handleDelete (val) {
+      this.list2 = this.list2.filter(v => v.id !== val.id)
+    },
     handleSelect (item) {
       this.$refs.detail.base(item, this.config)
     }

+ 1 - 1
src/views/test/modules/Component.vue

@@ -14,7 +14,7 @@
         </a-select-option> -->
       </a-select>
       <!-- 日期时间 -->
-      <a-date-picker v-if="detail.type==='date'" v-bind="detail.attrs" v-decorator="[detail.value, { rules: [{ required: detail.required, message: detail.attrs.placeholder}] }]" />
+      <a-date-picker style="width:100%" v-if="detail.type==='date'" v-bind="detail.attrs" v-decorator="[detail.value, { rules: [{ required: detail.required, message: detail.attrs.placeholder}] }]" />
       <!-- 单选框 -->
       <!-- 文件上传 -->
       <!-- 图片上传 -->

+ 13 - 3
src/views/test/modules/Detail.vue

@@ -76,6 +76,15 @@
           <a-button @click="addOption" style="width:100%"><a-icon type="plus" /></a-button>
         </a-form-item>
       </template>
+      <!-- 日期选择 -->
+      <template v-if="model.type === 'date'">
+        <a-form-item label="是否显示时间">
+          <a-switch v-model="model.attrs.showTime" />
+        </a-form-item>
+        <a-form-item label="时间格式">
+          <a-input placeholder="YYYY-MM-DD HH:mm:ss" v-model="model.attrs.format" ></a-input>
+        </a-form-item>
+      </template>
       <a-popconfirm
         title="确定删除该组件?"
         ok-text="确定"
@@ -84,7 +93,6 @@
       >
         <a-button type="danger" style="width:100%">删除</a-button>
       </a-popconfirm>
-
     </a-form>
     <a-form
       size="small"
@@ -119,7 +127,9 @@ export default {
   data () {
     return {
       model: {
-        attrs: {}
+        attrs: {
+          placeholder: ''
+        }
       },
       config: {},
       selectKey: '0',
@@ -152,7 +162,7 @@ export default {
       this.model.attrs.options.splice(i, 1)
     },
     deleteModel () {
-
+      this.$emit('delete', this.model)
     },
     onTabChange (key) {
       this.selectKey = key

+ 3 - 1
src/views/test/modules/components.js

@@ -73,7 +73,9 @@ export const componentList = [
     required: true,
     label: '日期时间',
     attrs: {
-      placeholder: '请输入'
+      placeholder: '请输入',
+      format: 'YYYY-MM-DD HH:mm:ss',
+      showTime: false
     }
   },
   {