表格组件
This commit is contained in:
		| @@ -396,6 +396,7 @@ export default { | ||||
|       }) | ||||
|     }, | ||||
|     clone(e) { | ||||
|       console.log(this.deepClone(e)) | ||||
|       this.componentList.push(this.deepClone(e)) | ||||
|     }, | ||||
|  | ||||
| @@ -405,31 +406,42 @@ export default { | ||||
|       } | ||||
|     }, | ||||
|  | ||||
|     deepClone(data, hash = new WeakMap()) { | ||||
|       if (typeof data !== 'object' || data === null) { | ||||
|         throw new TypeError('传入参数不是对象') | ||||
|       } | ||||
|       if (hash.has(data)) { | ||||
|         return hash.get(data) | ||||
|       } | ||||
|       let newData = {} | ||||
|       const dataKeys = Object.keys(data) | ||||
|       dataKeys.forEach(value => { | ||||
|         const currentDataValue = data[value] | ||||
|         if (typeof currentDataValue !== "object" || currentDataValue === null) { | ||||
|           newData[value] = currentDataValue | ||||
|         } else if (Array.isArray(currentDataValue)) { | ||||
|           newData[value] = [...currentDataValue] | ||||
|         } else if (currentDataValue instanceof Set) { | ||||
|           newData[value] = new Set([...currentDataValue]) | ||||
|         } else if (currentDataValue instanceof Map) { | ||||
|           newData[value] = new Map([...currentDataValue]) | ||||
|     deepClone(obj) { | ||||
|       if (obj instanceof Object) { | ||||
|         let newObj = {} | ||||
|  | ||||
|         if (Array.isArray(obj)) { | ||||
|           let arr = [] | ||||
|           obj.forEach(item => { | ||||
|             arr.push(this.deepClone(item)) | ||||
|           }) | ||||
|           return arr | ||||
|         } else if (typeof obj == 'function') { | ||||
|           newObj = obj.bind(newObj) | ||||
|         } else { | ||||
|           hash.set(data, data) | ||||
|           newData[value] = this.deepClone(currentDataValue, hash) | ||||
|           for (let key in obj) { | ||||
|             let value = obj[key] | ||||
|             if (typeof value == 'function') { | ||||
|               newObj[key] = value.bind(newObj) | ||||
|             } else if (typeof value == 'object') { | ||||
|               if (Array.isArray(value)) { | ||||
|                 newObj[key] = [] | ||||
|                 value.forEach(item => { | ||||
|                   newObj[key].push(this.deepClone(item)) | ||||
|                 }) | ||||
|               } else { | ||||
|                 newObj[key] = this.deepClone(value) | ||||
|               } | ||||
|             } else { | ||||
|               newObj[key] = value | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       }) | ||||
|       return newData | ||||
|  | ||||
|         return newObj | ||||
|       } else { | ||||
|         return obj | ||||
|       } | ||||
|     }, | ||||
|  | ||||
|     onContextmenu(e, index) { | ||||
|   | ||||
| @@ -110,7 +110,7 @@ | ||||
|               <el-input-number size="mini" style="width: 232px" :min="0" v-model="config.rowNum" controls-position="right"></el-input-number> | ||||
|             </div> | ||||
|           </div> | ||||
|           <div class="layout-config__item table-config" v-if="config.type === 'AiDvTable'" v-for="(item, index) in data" :key="index"> | ||||
|           <div class="layout-config__item table-config" v-if="config.type === 'AiDvTable'" v-for="(item, index) in config.config" :key="index"> | ||||
|             <label>第{{ index + 1 }}列</label> | ||||
|             <div class="layout-config__item--right"> | ||||
|               <el-select size="mini" style="width: 80px;" v-model="item.align" placeholder="请选择" clearable> | ||||
| @@ -119,7 +119,7 @@ | ||||
|                 <el-option label="居右" value="right"></el-option> | ||||
|               </el-select> | ||||
|               <el-color-picker v-model="item.color" style="margin: 0 10px;"></el-color-picker> | ||||
|               <el-input-number v-model="item.width" :min="1" label="描述文字" controls-position="right"></el-input-number> | ||||
|               <el-input-number v-model="item.width" label="描述文字" controls-position="right"></el-input-number> | ||||
|             </div> | ||||
|           </div> | ||||
|         </template> | ||||
| @@ -213,23 +213,8 @@ export default { | ||||
|       tableStatus: [ | ||||
|         {label: '是', value: '1'}, | ||||
|         {label: '否', value: '0'} | ||||
|       ], | ||||
|       data: [] | ||||
|       ] | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   watch: { | ||||
|     config: { | ||||
|       handler (v) { | ||||
|         this.data = v[v.dataType] | ||||
|       }, | ||||
|       deep: true, | ||||
|       immediate: true | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   created() { | ||||
|  | ||||
|   } | ||||
| } | ||||
| </script> | ||||
|   | ||||
| @@ -505,7 +505,23 @@ const components = [ | ||||
|             isShowIndex: '1', | ||||
|             sourceDataId: '', | ||||
|             api: '', | ||||
|             config: [], | ||||
|             config: [ | ||||
|               { | ||||
|                 width: '', | ||||
|                 color: '', | ||||
|                 align: '' | ||||
|               }, | ||||
|               { | ||||
|                 width: '', | ||||
|                 color: '', | ||||
|                 align: '' | ||||
|               }, | ||||
|               { | ||||
|                 width: '', | ||||
|                 color: '', | ||||
|                 align: '' | ||||
|               } | ||||
|             ], | ||||
|             apiData: [], | ||||
|             dataType: 'staticData', | ||||
|             dynamicData: [], | ||||
|   | ||||
		Reference in New Issue
	
	Block a user