<template>
|
<a-spin :spinning="confirmLoading">
|
<j-form-container :disabled="formDisabled" class="andon-button-form">
|
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
|
<!-- 第一行:安灯名称 + 安灯编码 -->
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item label="安灯名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="buttonName">
|
<a-input v-model="model.buttonName" placeholder="请输入" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="安灯编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="buttonCode">
|
<a-input v-model="model.buttonCode" placeholder="请输入" />
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<!-- 第二行:升级响应时长 + 升级处理时长 -->
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item label="升级响应" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="upgradeResponseDuration">
|
<a-input-number v-model="model.upgradeResponseDuration" placeholder="请输入" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="升级处理" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="upgradeProcessDuration">
|
<a-input-number v-model="model.upgradeProcessDuration" placeholder="请输入" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<!-- 第三行:二次升级响应时长 + 二次升级处理时长 -->
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item label="二次升级响应" :labelCol="labelColWide" :wrapperCol="wrapperColNarrow" prop="secondUpgradeResponseDuration">
|
<a-input-number v-model="model.secondUpgradeResponseDuration" placeholder="请输入" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="二次升级处理" :labelCol="labelColWide" :wrapperCol="wrapperColNarrow" prop="secondUpgradeProcessDuration">
|
<a-input-number v-model="model.secondUpgradeProcessDuration" placeholder="请输入" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<!-- 第四行:安灯按钮状态 + 备注 -->
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item label="按钮状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="buttonStatus">
|
<j-dict-select-tag type="list" v-model="model.buttonStatus" dictCode="button_status" placeholder="请选择" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
|
<a-input v-model="model.remark" placeholder="请输入" />
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</j-form-container>
|
</a-spin>
|
</template>
|
|
<script>
|
import { httpAction, getAction } from '@/api/manage'
|
import { validateDuplicateValue } from '@/utils/util'
|
|
export default {
|
name: 'AndonButtonConfigForm',
|
components: {},
|
props: {
|
disabled: {
|
type: Boolean,
|
default: false,
|
required: false
|
}
|
},
|
data() {
|
return {
|
model: {},
|
// 普通标签列宽度
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 6 },
|
},
|
// 宽标签列(用于“二次升级响应”等长标签)
|
labelColWide: {
|
xs: { span: 24 },
|
sm: { span: 8 }, // 增加标签宽度
|
},
|
// 窄输入框列(配合宽标签,保持布局平衡)
|
wrapperColNarrow: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 18 },
|
},
|
confirmLoading: false,
|
validatorRules: {
|
buttonName: [
|
{ required: true, message: '安灯名称是必选项', trigger: 'change' }
|
],
|
buttonCode: [
|
{ required: true, message: '安灯编码是必选项', trigger: 'change' }
|
],
|
upgradeResponseDuration: [
|
{ required: true, message: '升级响应时长是必选项', trigger: 'change' }
|
],
|
upgradeProcessDuration: [
|
{ required: true, message: '升级处理时长是必选项', trigger: 'change' }
|
],
|
secondUpgradeResponseDuration: [
|
{ required: true, message: '二次升级响应时长是必选项', trigger: 'change' }
|
],
|
secondUpgradeProcessDuration: [
|
{ required: true, message: '二次升级处理时长是必选项', trigger: 'change' }
|
],
|
buttonStatus: [
|
{ required: true, message: '安灯按钮状态是必选项', trigger: 'change' }
|
],
|
},
|
url: {
|
add: '/andonbuttonconfig/andonButtonConfig/add',
|
edit: '/andonbuttonconfig/andonButtonConfig/edit',
|
queryById: '/andonbuttonconfig/andonButtonConfig/queryById'
|
}
|
}
|
},
|
computed: {
|
formDisabled() {
|
return this.disabled
|
},
|
},
|
created() {
|
this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
},
|
methods: {
|
add() {
|
this.edit(this.modelDefault);
|
},
|
edit(record) {
|
this.model = Object.assign({}, record);
|
this.visible = true;
|
},
|
submitForm() {
|
const that = this;
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true;
|
let httpurl = '';
|
let method = '';
|
if (!this.model.id) {
|
httpurl += this.url.add;
|
method = 'post';
|
} else {
|
httpurl += this.url.edit;
|
method = 'put';
|
}
|
httpAction(httpurl, this.model, method).then((res) => {
|
if (res.success) {
|
that.$message.success(res.message);
|
that.$emit('ok');
|
} else {
|
that.$message.warning(res.message);
|
}
|
}).finally(() => {
|
that.confirmLoading = false;
|
})
|
}
|
})
|
},
|
}
|
}
|
</script>
|
|
<style scoped>
|
.andon-button-form {
|
padding: 24px;
|
background-color: #fff;
|
border-radius: 8px;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
}
|
|
/* 统一表单项垂直间距 */
|
.a-form-model-item {
|
margin-bottom: 16px !important;
|
}
|
|
/* 标签与输入框水平间距(解决文字拥挤) */
|
.a-form-model-item-label {
|
margin-right: 12px !important;
|
}
|
|
/* 输入框 & 数字输入框 占位符样式优化 */
|
.a-input::placeholder,
|
.a-input-number::placeholder {
|
color: #ccc;
|
font-style: italic;
|
}
|
|
/* 必选标签的红色星号强调 */
|
.a-form-model-item-label > span:first-child {
|
color: #f5222d;
|
margin-right: 2px;
|
}
|
|
/* 按钮区域右对齐 & 按钮样式优化 */
|
.a-form-footer {
|
text-align: right;
|
margin-top: 32px;
|
}
|
|
.a-button-primary {
|
background-color: #1890ff;
|
border-color: #1890ff;
|
transition: all 0.3s ease;
|
}
|
|
.a-button-primary:hover {
|
background-color: #40a9ff;
|
border-color: #40a9ff;
|
}
|
|
.a-button-default {
|
border-color: #d9d9d9;
|
transition: all 0.3s ease;
|
}
|
|
.a-button-default:hover {
|
border-color: #bfbfbf;
|
}
|
</style>
|