update 设备类型

This commit is contained in:
g7hoo 2022-08-12 14:26:46 +08:00
parent 04f19e82e3
commit d1dd52fe90
2 changed files with 33 additions and 5 deletions

View File

@ -30,7 +30,12 @@
<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>
<el-cascader v-if="getType(n, c) === 'tree'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-cascader> <el-cascader
v-if="getType(n, c) === 'cascader'"
v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"
:options="configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].options"
:props="configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].props"
></el-cascader>
<el-time-select v-if="getType(n, c) === 'time'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-time-select> <el-time-select v-if="getType(n, c) === 'time'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-time-select>
<el-date-picker v-if="getType(n, c) === 'date'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-date-picker> <el-date-picker v-if="getType(n, c) === 'date'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-date-picker>
</el-form-item> </el-form-item>
@ -275,6 +280,8 @@ export default {
return 'input' return 'input'
} else if (['select' /** add more.. */].includes(opt.type)) { } else if (['select' /** add more.. */].includes(opt.type)) {
return 'select' return 'select'
} else if (['cascader'].includes(opt.type)) {
return 'cascader'
} }
// add more... // add more...
} else { } else {
@ -329,7 +336,7 @@ export default {
this.$http({ this.$http({
url: this.$http.adornUrl(urls[btn.name].url), url: this.$http.adornUrl(urls[btn.name].url),
method: btn.name === 'save' ? 'POST' : 'PUT', method: btn.name === 'save' ? 'POST' : 'PUT',
data: { ...this.dataForm, ...urls[btn.name].extraFields} data: { ...this.dataForm, ...urls[btn.name].extraFields }
}) })
.then(({ data: res }) => { .then(({ data: res }) => {
if (res && res.code === 0) { if (res && res.code === 0) {
@ -382,7 +389,8 @@ export default {
</script> </script>
<style scoped> <style scoped>
.super-flexible-dialog >>> .el-select { .super-flexible-dialog >>> .el-select,
.super-flexible-dialog >>> .el-cascader {
width: 100%; width: 100%;
} }

View File

@ -71,10 +71,14 @@ const addOrUpdateConfigs = {
fields: [ fields: [
{ name: 'name', label: '设备类型名称' }, { name: 'name', label: '设备类型名称' },
{ name: 'code', label: '设备类型编码', api: '/monitoring/equipmentType/getCode' }, { name: 'code', label: '设备类型编码', api: '/monitoring/equipmentType/getCode' },
{ name: 'parentId', label: '父类', type: 'tree' }, { name: 'parentId', label: '父类', type: 'cascader', props: { label: 'name', value: 'id', checkStrictly: true, emitPath: false }, options: [] },
'remark' 'remark'
], ],
operations: [], operations: [
{ name: 'cancel', showAlways: true },
{ name: 'save', url: '/monitoring/equipmentType', permission: '', showOnEdit: false },
{ name: 'update', url: '/monitoring/equipmentType', permission: '', showOnEdit: true }
],
extraComponents: null extraComponents: null
} }
@ -100,9 +104,23 @@ export default {
BaseTable BaseTable
}, },
activated() { activated() {
this.getTreeEquipmentType()
this.getDataList() this.getDataList()
}, },
methods: { methods: {
//
getTreeEquipmentType() {
this.$http({
url: this.$http.adornUrl('/monitoring/equipmentType/getTree'),
method: 'post'
}).then(({ data: res }) => {
if (res && res.code === 0 && res.data.length) {
this.addOrUpdateConfigs.fields.find(item => item.name === 'parentId').options = res.data
} else {
this.addOrUpdateConfigs.fields.find(item => item.name === 'parentId').options.splice(0)
}
})
},
// //
getDataList() { getDataList() {
this.addOrUpdateVisible = false this.addOrUpdateVisible = false
@ -151,6 +169,8 @@ export default {
}, },
// / // /
addOrUpdateHandle(id) { addOrUpdateHandle(id) {
//
this.getTreeEquipmentType()
this.addOrUpdateVisible = true this.addOrUpdateVisible = true
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.addOrUpdate.init(id) this.$refs.addOrUpdate.init(id)