Houjie
2 天以前 28f1104e32c40273778eed24392bbf14ce03e7fe
src/views/andon/modules/AndonButtonConfigForm.vue
@@ -1,46 +1,59 @@
<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
    <j-form-container :disabled="formDisabled" class="andon-button-form">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
        <!-- 第一行:安灯名称 + 安灯编码 -->
        <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-input>
              <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-input>
              <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="upgradeResponseDuration">
              <a-input-number v-model="model.upgradeResponseDuration" placeholder="请输入升级响应时长(分钟)" style="width: 100%" />
            <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="labelCol" :wrapperCol="wrapperCol" prop="upgradeProcessDuration">
              <a-input-number v-model="model.upgradeProcessDuration" placeholder="请输入升级处理时长(分钟)" style="width: 100%" />
            <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="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="labelCol" :wrapperCol="wrapperCol" prop="secondUpgradeProcessDuration">
              <a-input-number v-model="model.secondUpgradeProcessDuration" placeholder="请输入二次升级处理时长(分钟)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <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 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-input>
              <a-input v-model="model.remark" placeholder="请输入" />
            </a-form-model-item>
          </a-col>
        </a-row>
@@ -50,16 +63,13 @@
</template>
<script>
  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  export default {
    name: 'AndonButtonConfigForm',
    components: {
    },
  components: {},
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
@@ -68,15 +78,25 @@
    },
    data () {
      return {
        model:{
         },
      model: {},
      // 普通标签列宽度
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        sm: { span: 6 },
      },
      // 宽标签列(用于“二次升级响应”等长标签)
      labelColWide: {
        xs: { span: 24 },
        sm: { span: 8 }, // 增加标签宽度
      },
      // 窄输入框列(配合宽标签,保持布局平衡)
      wrapperColNarrow: {
        xs: { span: 24 },
        sm: { span: 16 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        sm: { span: 18 },
        },
        confirmLoading: false,
        validatorRules: {
@@ -103,9 +123,9 @@
          ],
        },
        url: {
          add: "/andonbuttonconfig/andonButtonConfig/add",
          edit: "/andonbuttonconfig/andonButtonConfig/edit",
          queryById: "/andonbuttonconfig/andonButtonConfig/queryById"
        add: '/andonbuttonconfig/andonButtonConfig/add',
        edit: '/andonbuttonconfig/andonButtonConfig/edit',
        queryById: '/andonbuttonconfig/andonButtonConfig/queryById'
        }
      }
    },
@@ -115,7 +135,6 @@
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
@@ -128,7 +147,6 @@
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
@@ -152,9 +170,66 @@
              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>