forked from mt-fe-group/mt-yd-ui
		
	update
This commit is contained in:
		@@ -11,20 +11,10 @@
 | 
				
			|||||||
						:label="getLabel(n, c)"
 | 
											:label="getLabel(n, c)"
 | 
				
			||||||
					>
 | 
										>
 | 
				
			||||||
						<!-- 暂时先不实现部分输入方式 -->
 | 
											<!-- 暂时先不实现部分输入方式 -->
 | 
				
			||||||
						<el-input
 | 
											<el-input v-if="getType(n, c) === 'input'" :placeholder="getPlaceholder(n, c)" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]" clearable />
 | 
				
			||||||
							v-if="getType(n, c) === 'input'"
 | 
					 | 
				
			||||||
							:placeholder="configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].placeholder || '...'"
 | 
					 | 
				
			||||||
							v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"
 | 
					 | 
				
			||||||
							clearable
 | 
					 | 
				
			||||||
						/>
 | 
					 | 
				
			||||||
						<el-radio v-if="getType(n, c) === 'radio'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-radio>
 | 
											<el-radio v-if="getType(n, c) === 'radio'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-radio>
 | 
				
			||||||
						<el-checkbox v-if="getType(n, c) === 'check'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-checkbox>
 | 
											<el-checkbox v-if="getType(n, c) === 'check'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-checkbox>
 | 
				
			||||||
						<el-select
 | 
											<el-select v-if="getType(n, c) === 'select'" :placeholder="getPlaceholder(n, c)" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]" clearable>
 | 
				
			||||||
							v-if="getType(n, c) === 'select'"
 | 
					 | 
				
			||||||
							:placeholder="configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].placeholder || ''"
 | 
					 | 
				
			||||||
							v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"
 | 
					 | 
				
			||||||
							clearable
 | 
					 | 
				
			||||||
						>
 | 
					 | 
				
			||||||
							<el-option v-for="opt in configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].options" :key="opt.label" :label="opt.label" :value="opt.value" />
 | 
												<el-option v-for="opt in configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].options" :key="opt.label" :label="opt.label" :value="opt.value" />
 | 
				
			||||||
						</el-select>
 | 
											</el-select>
 | 
				
			||||||
						<el-switch v-if="getType(n, c) === 'switch'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-switch>
 | 
											<el-switch v-if="getType(n, c) === 'switch'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-switch>
 | 
				
			||||||
@@ -129,7 +119,8 @@ export default {
 | 
				
			|||||||
				remark: '备注',
 | 
									remark: '备注',
 | 
				
			||||||
				specifications: '规格'
 | 
									specifications: '规格'
 | 
				
			||||||
				// add more...
 | 
									// add more...
 | 
				
			||||||
			}
 | 
								},
 | 
				
			||||||
 | 
								defaultPlaceholders: {} // 自动根据 defaultNames 计算得来
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	computed: {
 | 
						computed: {
 | 
				
			||||||
@@ -139,8 +130,14 @@ export default {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	mounted() {
 | 
						mounted() {
 | 
				
			||||||
		this.$nextTick(() => {
 | 
							/** 计算 defaultPlaceholders */
 | 
				
			||||||
 | 
							const prefix = '请输入'
 | 
				
			||||||
 | 
							Object.entries(this.defaultNames).map(([key, value]) => {
 | 
				
			||||||
 | 
								this.defaultPlaceholders[key] = prefix + value
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/** 转换 configs.fields 的结构,把纯字符串转为对象 */
 | 
							/** 转换 configs.fields 的结构,把纯字符串转为对象 */
 | 
				
			||||||
 | 
							this.$nextTick(() => {
 | 
				
			||||||
			this.configs.fields = this.configs.fields.map(item => {
 | 
								this.configs.fields = this.configs.fields.map(item => {
 | 
				
			||||||
				if (typeof item === 'string') {
 | 
									if (typeof item === 'string') {
 | 
				
			||||||
					return { name: item }
 | 
										return { name: item }
 | 
				
			||||||
@@ -234,6 +231,13 @@ export default {
 | 
				
			|||||||
				return opt.label ? opt.label : this.defaultNames[opt.name]
 | 
									return opt.label ? opt.label : this.defaultNames[opt.name]
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							getPlaceholder(n, c) {
 | 
				
			||||||
 | 
								const opt = this.configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)]
 | 
				
			||||||
 | 
								if (opt) {
 | 
				
			||||||
 | 
									// if opt is valid
 | 
				
			||||||
 | 
									return opt.placeholder ? opt.placeholder : this.defaultPlaceholders[opt.name]
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		getType(n, c) {
 | 
							getType(n, c) {
 | 
				
			||||||
			const opt = this.configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)]
 | 
								const opt = this.configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)]
 | 
				
			||||||
			if (opt) {
 | 
								if (opt) {
 | 
				
			||||||
@@ -251,8 +255,6 @@ export default {
 | 
				
			|||||||
			this.visible = true
 | 
								this.visible = true
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		handleClick(btn) {
 | 
							handleClick(btn) {
 | 
				
			||||||
			this.$refs['dataForm'].validate(valid => {
 | 
					 | 
				
			||||||
				if (valid) {
 | 
					 | 
				
			||||||
			/** 提取url */
 | 
								/** 提取url */
 | 
				
			||||||
			const urls = {}
 | 
								const urls = {}
 | 
				
			||||||
			this.configs.operations.map(item => {
 | 
								this.configs.operations.map(item => {
 | 
				
			||||||
@@ -262,6 +264,9 @@ export default {
 | 
				
			|||||||
			switch (btn.name) {
 | 
								switch (btn.name) {
 | 
				
			||||||
				case 'save':
 | 
									case 'save':
 | 
				
			||||||
				case 'update':
 | 
									case 'update':
 | 
				
			||||||
 | 
										/** 需要验证表单的操作 */
 | 
				
			||||||
 | 
										this.$refs['dataForm'].validate(valid => {
 | 
				
			||||||
 | 
											if (valid) {
 | 
				
			||||||
							this.$http({
 | 
												this.$http({
 | 
				
			||||||
								url: this.$http.adornUrl(urls[btn.name]),
 | 
													url: this.$http.adornUrl(urls[btn.name]),
 | 
				
			||||||
								method: btn.name === 'save' ? 'POST' : 'PUT',
 | 
													method: btn.name === 'save' ? 'POST' : 'PUT',
 | 
				
			||||||
@@ -279,6 +284,8 @@ export default {
 | 
				
			|||||||
									})
 | 
														})
 | 
				
			||||||
								}
 | 
													}
 | 
				
			||||||
							})
 | 
												})
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										})
 | 
				
			||||||
					return
 | 
										return
 | 
				
			||||||
				case 'reset':
 | 
									case 'reset':
 | 
				
			||||||
					for (const key of Object.keys(this.dataForm)) {
 | 
										for (const key of Object.keys(this.dataForm)) {
 | 
				
			||||||
@@ -294,8 +301,6 @@ export default {
 | 
				
			|||||||
					break
 | 
										break
 | 
				
			||||||
				// add more..
 | 
									// add more..
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			})
 | 
					 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		handleClose() {
 | 
							handleClose() {
 | 
				
			||||||
			if (this.isAdd || this.isUpdated) this.$emit('refreshDataList')
 | 
								if (this.isAdd || this.isUpdated) this.$emit('refreshDataList')
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -97,6 +97,7 @@ http.adornData = (data = {}, openDefaultdata = true, contentType = 'json') => {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  data = openDefaultdata ? merge(defaults, data) : data
 | 
					  data = openDefaultdata ? merge(defaults, data) : data
 | 
				
			||||||
  return contentType === 'json' ? JSON.stringify(data) : qs.stringify(data)
 | 
					  return contentType === 'json' ? JSON.stringify(data) : qs.stringify(data)
 | 
				
			||||||
 | 
					  // return contentType === 'json' ? JSON.stringify(data, (_, v) => typeof v === 'bigint' ? v.toString() : v) : qs.stringify(data)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -141,6 +141,7 @@ const addOrUpdateConfigs = {
 | 
				
			|||||||
			name: 'unitDictValue',
 | 
								name: 'unitDictValue',
 | 
				
			||||||
			label: '单位',
 | 
								label: '单位',
 | 
				
			||||||
			type: 'select',
 | 
								type: 'select',
 | 
				
			||||||
 | 
								// placeholder: '请选择单位',
 | 
				
			||||||
			options: [
 | 
								options: [
 | 
				
			||||||
				// 动态获取
 | 
									// 动态获取
 | 
				
			||||||
			]
 | 
								]
 | 
				
			||||||
@@ -265,6 +266,7 @@ export default {
 | 
				
			|||||||
		deleteHandle(id) {
 | 
							deleteHandle(id) {
 | 
				
			||||||
			var ids = id
 | 
								var ids = id
 | 
				
			||||||
				? [id]
 | 
									? [id]
 | 
				
			||||||
 | 
									// ? [1556817256347828335]
 | 
				
			||||||
				: this.dataListSelections.map(item => {
 | 
									: this.dataListSelections.map(item => {
 | 
				
			||||||
						return item.id
 | 
											return item.id
 | 
				
			||||||
				  })
 | 
									  })
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user