update attr-form 的逻辑,TODO:检查产品池和设备信息的编辑子表单
This commit is contained in:
		@@ -66,8 +66,14 @@ export default {
 | 
			
		||||
			default: () => []
 | 
			
		||||
		},
 | 
			
		||||
		/** 表单提交需要的属性 */
 | 
			
		||||
		pId: {
 | 
			
		||||
		relatedId: {
 | 
			
		||||
			type: String,
 | 
			
		||||
			required: true,
 | 
			
		||||
			default: null
 | 
			
		||||
		},
 | 
			
		||||
		relatedField: {
 | 
			
		||||
			type: String,
 | 
			
		||||
			required: true,
 | 
			
		||||
			default: null
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
@@ -96,12 +102,12 @@ export default {
 | 
			
		||||
	},
 | 
			
		||||
	mounted() {
 | 
			
		||||
		this.getDataList()
 | 
			
		||||
    /** 设置 AttrForm 的 rules */
 | 
			
		||||
    for(const config of this.tableConfigs) {
 | 
			
		||||
      if (config.rules) {
 | 
			
		||||
        this.$set(this.AttrFormRules, [config.prop], config.rules)
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
		/** 设置 AttrForm 的 rules */
 | 
			
		||||
		for (const config of this.tableConfigs) {
 | 
			
		||||
			if (config.rules) {
 | 
			
		||||
				this.$set(this.AttrFormRules, [config.prop], config.rules)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	methods: {
 | 
			
		||||
		/** init dataform */
 | 
			
		||||
@@ -127,7 +133,7 @@ export default {
 | 
			
		||||
				params: this.$http.adornParams({
 | 
			
		||||
					page: this.pageIndex,
 | 
			
		||||
					limit: this.pageSize,
 | 
			
		||||
					productId: this.pId
 | 
			
		||||
					[this.relatedField]: this.relatedId
 | 
			
		||||
					// order: 'asc/desc',
 | 
			
		||||
					// orderField: 'name'
 | 
			
		||||
				})
 | 
			
		||||
@@ -210,7 +216,7 @@ export default {
 | 
			
		||||
						headers: {
 | 
			
		||||
							'Content-Type': 'application/json'
 | 
			
		||||
						},
 | 
			
		||||
						data: JSON.stringify({ ...this.AttrForm, productId: this.pId })
 | 
			
		||||
						data: JSON.stringify({ ...this.AttrForm, [this.relatedField]: this.relatedId })
 | 
			
		||||
					}).then(({ data }) => {
 | 
			
		||||
						if (data && data.code === 0) {
 | 
			
		||||
							this.$message({
 | 
			
		||||
 
 | 
			
		||||
@@ -66,7 +66,7 @@
 | 
			
		||||
			</el-form>
 | 
			
		||||
 | 
			
		||||
			<template v-if="dataForm.id && configs.subtable">
 | 
			
		||||
				<attr-form :pId="dataForm.id" v-bind="configs.subtable" />
 | 
			
		||||
				<attr-form :related-id="dataForm.id" v-bind="configs.subtable" />
 | 
			
		||||
			</template>
 | 
			
		||||
		</div>
 | 
			
		||||
		<span slot="footer" class="dialog-footer">
 | 
			
		||||
 
 | 
			
		||||
@@ -154,6 +154,18 @@ const addOrUpdateConfigs = {
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	],
 | 
			
		||||
	subtable: {
 | 
			
		||||
		title: '查看设备属性',
 | 
			
		||||
		url: '/monitoring/equipmentAttr',
 | 
			
		||||
		relatedField: 'equipmentId',
 | 
			
		||||
		tableConfigs: [
 | 
			
		||||
			{ type: 'index', name: '序号' },
 | 
			
		||||
			{ prop: 'createTime', name: '创建时间' },
 | 
			
		||||
			{ prop: 'attrName', name: '属性名称', formField: true },
 | 
			
		||||
			{ prop: 'attrValue', name: '属性值', formField: true },
 | 
			
		||||
			{ prop: 'operate', name: '操作', options: ['edit', 'delete'] }
 | 
			
		||||
		]
 | 
			
		||||
	},
 | 
			
		||||
	operations: [
 | 
			
		||||
		{ name: 'cancel', showAlways: true },
 | 
			
		||||
		{ name: 'save', url: '/monitoring/equipment', permission: '', showOnEdit: false },
 | 
			
		||||
 
 | 
			
		||||
@@ -140,6 +140,7 @@ const addOrUpdateConfigs = {
 | 
			
		||||
		// for i18n
 | 
			
		||||
		title: '动态属性',
 | 
			
		||||
		url: '/monitoring/productArrt',
 | 
			
		||||
		relatedField: 'productId',
 | 
			
		||||
		tableConfigs: [
 | 
			
		||||
			{ type: 'index', name: '序号' },
 | 
			
		||||
			{ prop: 'createTime', name: '添加时间', filter: val => (val ? moment(val).format('YYYY-MM-DD hh:mm:ss') : '-') },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user