2021-09-13 14:56:28 +08:00
|
|
|
<!--
|
|
|
|
* @Author: zwq
|
|
|
|
* @Date: 2020-12-29 16:37:56
|
2022-03-05 19:43:42 +08:00
|
|
|
* @LastEditors: fzq
|
|
|
|
* @LastEditTime: 2022-03-05 14:08:41
|
2021-09-13 14:56:28 +08:00
|
|
|
* @Description:
|
|
|
|
-->
|
|
|
|
<template>
|
|
|
|
<el-drawer
|
|
|
|
:append-to-body="true"
|
|
|
|
:show-close="false"
|
|
|
|
:visible.sync="visible"
|
|
|
|
size="40%"
|
|
|
|
>
|
|
|
|
<div slot="title" style=" background-color:#02BCFF;font-size:1.5em;color:white;padding:5px 20px">
|
|
|
|
{{ !dataForm.id ? 'btn.add' : 'btn.edit' | i18nFilter }}
|
|
|
|
</div>
|
|
|
|
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="130px" @keyup.enter.native="dataFormSubmit()">
|
|
|
|
<el-form-item :label="$t('module.basicData.visual.AttributeName')" prop="attrName">
|
|
|
|
<el-input v-model="dataForm.attrName" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.visual.AttributeName')])" clearable />
|
|
|
|
</el-form-item>
|
2022-03-05 19:43:42 +08:00
|
|
|
<el-form-item :label="$t('module.basicData.visual.AttributeValue')" prop="attrContent">
|
|
|
|
<el-input v-model="dataForm.attrContent" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.visual.AttributeValue')])" clearable />
|
2021-09-13 14:56:28 +08:00
|
|
|
</el-form-item>
|
2022-03-05 19:43:42 +08:00
|
|
|
<!-- <el-form-item :label="$t('module.basicData.visual.Remarks')" prop="remark">
|
2021-09-13 14:56:28 +08:00
|
|
|
<el-input v-model="dataForm.remark" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.visual.Remarks')])" clearable />
|
2022-03-05 19:43:42 +08:00
|
|
|
</el-form-item> -->
|
2021-09-13 14:56:28 +08:00
|
|
|
</el-form>
|
|
|
|
<div class="drawer-footer">
|
|
|
|
<el-button @click="visible = false">{{ 'btn.cancel' | i18nFilter }}</el-button>
|
|
|
|
<el-button type="primary" :loading="btnLoading" @click="dataFormSubmit()">{{ 'btn.confirm' | i18nFilter }}</el-button>
|
|
|
|
</div>
|
|
|
|
</el-drawer>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { equipmentInfoAttrDetail, equipmentInfoAttrUpdate, equipmentInfoAttrAdd } from '@/api/basicData/Equipment/equipmentInfoAttr'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
equipmentId: {
|
|
|
|
type: String,
|
|
|
|
default: () => {
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
visible: false,
|
|
|
|
btnLoading: false,
|
|
|
|
dataForm: {
|
|
|
|
id: 0,
|
|
|
|
attrName: '',
|
2022-03-05 19:43:42 +08:00
|
|
|
attrContent: '',
|
2021-09-13 14:56:28 +08:00
|
|
|
remark: ''
|
|
|
|
},
|
|
|
|
dataRule: {
|
|
|
|
attrName: [
|
|
|
|
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.visual.AttributeName')]), trigger: 'blur' }
|
|
|
|
],
|
2022-03-05 19:43:42 +08:00
|
|
|
attrContent: [
|
2021-09-13 14:56:28 +08:00
|
|
|
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.visual.AttributeValue')]), trigger: 'blur' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
init(id) {
|
|
|
|
this.dataForm.id = id || ''
|
|
|
|
this.btnLoading = false
|
|
|
|
this.visible = true
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$refs['dataForm'].resetFields()
|
|
|
|
if (this.dataForm.id) {
|
|
|
|
equipmentInfoAttrDetail(this.dataForm.id).then(res => {
|
2022-03-05 19:43:42 +08:00
|
|
|
console.log(res)
|
2021-09-13 14:56:28 +08:00
|
|
|
this.dataForm = res.data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 表单提交
|
|
|
|
dataFormSubmit() {
|
|
|
|
this.btnLoading = true
|
|
|
|
this.$refs['dataForm'].validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
const data = {
|
|
|
|
'attrName': this.dataForm.attrName,
|
2022-03-05 19:43:42 +08:00
|
|
|
'attrContent': this.dataForm.attrContent,
|
2021-09-13 14:56:28 +08:00
|
|
|
'remark': this.dataForm.remark,
|
|
|
|
'equipmentId': this.equipmentId,
|
|
|
|
'id': this.dataForm.id
|
|
|
|
}
|
|
|
|
if (this.dataForm.id) {
|
|
|
|
equipmentInfoAttrUpdate(data).then(res => {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('module.basicData.visual.success'),
|
|
|
|
type: 'success',
|
|
|
|
duration: 1500,
|
|
|
|
onClose: () => {
|
|
|
|
this.visible = false
|
|
|
|
this.$emit('refreshDataList')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
equipmentInfoAttrAdd(data).then(res => {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('module.basicData.visual.success'),
|
|
|
|
type: 'success',
|
|
|
|
duration: 1500,
|
|
|
|
onClose: () => {
|
|
|
|
this.visible = false
|
|
|
|
this.$emit('refreshDataList')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.drawer-footer {
|
|
|
|
width: 100%;
|
|
|
|
margin-top: 50px;
|
|
|
|
border-top: 1px solid #e8e8e8;
|
|
|
|
padding: 10px 50px;
|
|
|
|
text-align: left;
|
|
|
|
background: #fff;
|
|
|
|
}
|
|
|
|
</style>
|