scorpio 3 years ago
parent
commit
d69fff72b4
1 changed files with 36 additions and 11 deletions
  1. 36 11
      src/components/basic-form/sub.vue

+ 36 - 11
src/components/basic-form/sub.vue

@@ -101,12 +101,33 @@
           <template v-slot:label>
             <div :style='`height:` + item.rows * 35 + `px`'
                  class='label white-bg full-width text-left padding-left bold'>
-              {{ item.label }}
+              {{ item.label }}{{item.type}}
             </div>
           </template>
           <div class='full-width flex flex-align-start full-height text-left full-width'
                style='white-space: pre-wrap;text-overflow: ellipsis;'>
-            <el-cascader :options="item.data" class="m-2" :placeholder="`请选择${item.label}`" @change='change'>
+            <el-cascader :options="item.dict" class="m-2" :placeholder="`请选择${item.label}`" @change='change'>
+            </el-cascader>
+            <el-icon v-if='!disable' class="padding-right padding-top">
+              <edit/>
+            </el-icon>
+          </div>
+        </el-form-item>
+      </div>
+    </el-col>
+<!--    -->
+    <el-col v-if='item.type ==="daterange" ' :style='`height:` + item.rows * 35 + `px`' class='full-width'>
+      <div class='flex item full-width'>
+        <el-form-item class='full-width '>
+          <template v-slot:label>
+            <div :style='`height:` + item.rows * 35 + `px`'
+                 class='label white-bg full-width text-left padding-left bold'>
+              {{ item.label }}{{item.type}}
+            </div>
+          </template>
+          <div class='full-width flex flex-align-start full-height text-left full-width'
+               style='white-space: pre-wrap;text-overflow: ellipsis;'>
+            <el-cascader :options="item.dict" class="m-2" :placeholder="`请选择${item.label}`" @change='change'>
             </el-cascader>
             <el-icon v-if='!disable' class="padding-right padding-top">
               <edit/>
@@ -154,10 +175,10 @@ export default {
           console.log(val.dict)
         } else if (val.type === 'area') {
           const tmp = {
-            dict: '/blade-system/region/lazy-tree?parentCode=00',
+            dict: '/blade-system/region/lazy-list',
             props: {
-              label: 'title',
-              value: 'key'
+              label: 'name',
+              value: 'id'
             }
           }
           val.expand = JSON.stringify(tmp, null, 4)
@@ -165,7 +186,6 @@ export default {
           this.getDic(val.expand).then(res => {
             val.dict = res
           })
-          console.log(val.dict)
         }
       },
       immediate: true
@@ -180,11 +200,16 @@ export default {
   methods: {
     async getDic (expand) {
       const tmp = await this.$api.common.basicFormRequest(expand.dict)
-      return tmp.data.map(item => {
-        item.label = item[expand.props.label]
-        item.value = item[expand.props.value]
-        return item
-      })
+      return tmp.data.map(item => this.mapTree(item, expand))
+    },
+    mapTree (item, expand) {
+      const haveChildren = Array.isArray(item.children) && item.children.length > 0
+      return {
+        key: item.id,
+        value: item[expand.props.value],
+        label: item[expand.props.label],
+        children: haveChildren ? item.children.map(i => this.mapTree(i, expand)) : []
+      }
     },
     change (res) {
       console.log(res)