readonly、disabled、display、visible的区别

本文详细对比了CSS属性display:none与visibility:hidden的区别,包括SEO影响与JS交互的不同;并介绍了HTML属性readonly与disabled的差异,涉及表单提交行为、用户交互等方面。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

display和visible的区别:

(1)首先说明的是display:none和visible:hidden都能够实现将网页上某个元素隐藏起来。

(2)如果在样式文件或页面文件代码中直接用display:none对元素进行了隐藏,载入页面后,在没有通过js设置样式使元素显示的前提下,使用js代码会无法正确获得该元素的一些属性,比如offSetTop,offSetLeft等,返回的值会为0,通过js设置style.display来使元素显示后才能正确获得这些值。

(3)使用display:none隐藏的元素不会被百度等搜索网站检索,会影响到网站的SEO,某些情况下可以使用left:-100000px来达到同样效果。

(4)如果是通过样式文件或方式来设置元素的display:none样式,用js设置style.display=”“并不能使元素显示,可以使用block或inline等值来代替。通过style=”display:none”直接在元素上进行的设置不会有这个问题。

(5)将元素设置为display:none将不为被隐藏的对象保留其物理空间,即该对象在页面上彻底消失,通俗来说就是看不见也摸不到。而将元素设置为visibility:hidden则仅使对象在网页上不可见,但该对象在网页上所占的空间没有改变,通俗来说就是看不见但摸得到。

Readonly和Disabled的区别:

(1)Readonly和Disabled它们都能够做到使用户不能够更改表单域中的内容。

(2)在disabled和readonly这两个属性都设置为true的情况下,form属性将不能被编辑。

(3)如果一个输入项的disabled设为true,则该表单输入项不能获取焦点,用户的所有操作(鼠标点击和键盘输入等)对该输入项都无效。而readonly只是针对文本输入框这类可以输入文本的输入项,如果设为true,用户只是不能编辑对应的文本,但是仍然可以聚焦焦点。

(4)Readonly只针对input(text / password)和textarea有效,而disabled对于html中所有的表单元素都有效,但是在表单元素在使用了disabled后,当我们将表单以POST或GET的方式提交之后,这个元素的值不会被提交,而被设置为readonly的表单元素的值还是会被提交的。 一般比较常用的情况是:

(1)在某个表单中为用户预填了某个唯一识别代码,不允许用户改动,但是在提交时需要传递该值,此时应该将它的属性设置为readonly 。

(2)经常遇到当用户正式提交了表单后需要等待管理员的信息验证,这就不允许用户再更改表单中的数据,而是只能够查看,由于disabled的作用元素范围大,所以此时应该使用disabled,但同时应该注意的是要将submit button也disabled掉,否则只要用户按了这个按钮,如果在数据库操作页面中没有做完整性检测的话,数据库中的值就会被清除。如果说在这种情况下用readonly来代替disabled的话,若表单中只有input(text / password)和textarea元素,那还是可以的,如果存在其他发元素,比如select,用户可以在重新改写值后按回车键进行提交(回车是默认的submit触发按键) 。

(3)我们常常在用户按了提交按钮后,利用JavaScript将提交按钮disabled掉,这样可以防止网络条件比较差的环境下,用户反复点提交按钮导致数据冗余地存入数据库。

本文转载:http://blog.youkuaiyun.com/u014012083/article/details/45481225

<template> <el-dialog :title="!dataForm.id ? '新增电池信息' : '修改电池信息'" :close-on-click-modal="false" :visible.sync="visible" width="80%" top="5vh" custom-class="battery-form-dialog" > <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="180px" label-position="top" > <el-collapse v-model="activePanels" accordion> <!-- 电池基本信息 --> <el-collapse-item title="电池基本信息" name="1"> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="电池ID" prop="batteryId"> <el-input :disabled="true" v-model="dataForm.batteryId" placeholder="请输入电池唯一标识"> <i slot="prefix" class="el-icon-files"></i> </el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="电池电压(V)" prop="batteryVoltage"> <el-input :disabled="true" v-model="dataForm.batteryVoltage" type="number"> <i slot="prefix" class="el-icon-data-line"></i> </el-input> </el-form-item> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="电池电流(A)" prop="batteryCurrent"> <el-input :disabled="true" v-model="dataForm.batteryCurrent" type="number"> <i slot="prefix" class="el-icon-sort"></i> </el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="电池SOC(%)" prop="batterySoc"> <el-input :disabled="true" v-model="dataForm.batterySoc" type="number" min="0" max="100"> <i slot="prefix" class="el-icon-pie-chart"></i> </el-input> </el-form-item> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="硬件版本" prop="batteryHardVersion"> <el-input :disabled="true" v-model="dataForm.batteryHardVersion"> <i slot="prefix" class="el-icon-cpu"></i> </el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="软件版本" prop="batterySoftVersion"> <el-input :disabled="true" v-model="dataForm.batterySoftVersion"> <i slot="prefix" class="el-icon-setting"></i> </el-input> </el-form-item> </el-col> </el-row> </el-collapse-item> <!-- 电池状态信息 --> <el-collapse-item title="电池状态信息" name="2"> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="工作模式" prop="batteryWorkMode"> <el-select :disabled="true" v-model="dataForm.batteryWorkMode" placeholder="请选择工作模式"> <el-option label="放电模式 (0x01)" value="1"></el-option> <el-option label="充电模式 (0x10)" value="16"></el-option> <el-option label="保护模式 (0x21)" value="33"></el-option> <el-option label="待机无输出模式 (0x30)" value="48"></el-option> <el-option label="待机预放电模式 (0x31)" value="49"></el-option> <el-option label="故障需返厂 (0xFF)" value="255"></el-option> </el-select> </el-form-item> </el-col> <el-col span="12"> <el-form-item label="电池类型" prop="batteryKind"> <el-select v-model="dataForm.batteryKind" placeholder="请选择电池类型"> <el-option label="运营" value="0"></el-option> <el-option label="售后" value="1"></el-option> <el-option label="内测" value="2"></el-option> <el-option label="报废" value="3"></el-option> </el-select> </el-form-item> </el-col> </el-row> <el-form-item label="保护状态码" prop="batteryProtectCode"> <el-tooltip effect="dark" placement="top"> <div slot="content"> bit0: 放电低温 | bit1: 放电高温 | bit2: 充电高温<br> bit3: 充电低温 | bit4: 放电过流 | bit5: 放电欠压<br> bit6: 充电过流 | bit7: 充电过压 | bit8: 短路<br> bit9: 温差过大 | bit10: 压差过大 | bit11: 智能充电通信超时<br> bit12: IC保护 | bit13: 预放电失败 | bit14: BMS与Tracker通讯超时<br> bit15: Gsensor故障 | bit16~31: 保留 </div> <el-input :disabled="true" v-model="dataForm.batteryProtectCode" placeholder="请输入保护状态码"> <i slot="prefix" class="el-icon-warning"></i> </el-input> </el-tooltip> </el-form-item> <el-form-item label="错误状态码" prop="batteryErrorCode"> <el-tooltip effect="dark" placement="top"> <div slot="content"> 低8位故障状态码:<br> bit0: 保留 | bit1: 采样线故障 | bit2: 温度传感器损坏<br> bit3: IC损坏 | bit4: 充电MOS损坏 | bit5: 放电MOS损坏<br> bit6: 失衡 | bit7: 失效<br> 高8位工作状态:<br> bit8: G sensor损坏 | bit9: BMS与Tracker通讯故障 </div> <el-input :disabled="true" v-model="dataForm.batteryErrorCode" placeholder="请输入错误状态码"> <i slot="prefix" class="el-icon-warning-outline"></i> </el-input> </el-tooltip> </el-form-item> </el-collapse-item> <!-- 温度电压信息 --> <el-collapse-item title="温度与电压信息" name="3"> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="最高温度(℃)" prop="batteryTemperatureMax"> <el-input :disabled="true" v-model="dataForm.batteryTemperatureMax" type="number"> <i slot="prefix" class="el-icon-sunny"></i> </el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="最低温度(℃)" prop="batteryTemperatureMin"> <el-input :disabled="true" v-model="dataForm.batteryTemperatureMin" type="number"> <i slot="prefix" class="el-icon-cold-drink"></i> </el-input> </el-form-item> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="最高电压(V)" prop="batteryVoltageMax"> <el-input :disabled="true" v-model="dataForm.batteryVoltageMax" type="number"> <i slot="prefix" class="el-icon-top"></i> </el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="最低电压(V)" prop="batteryVoltageMin"> <el-input :disabled="true" v-model="dataForm.batteryVoltageMin" type="number"> <i slot="prefix" class="el-icon-bottom"></i> </el-input> </el-form-item> </el-col> </el-row> </el-collapse-item> <!-- 设备信息 --> <el-collapse-item title="设备信息" name="4"> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="设备型号" prop="model"> <el-input :disabled="true" v-model="dataForm.model"> <i slot="prefix" class="el-icon-mobile"></i> </el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="制造商" prop="manufacture"> <el-input :disabled="true" v-model="dataForm.manufacture"> <i slot="prefix" class="el-icon-office-building"></i> </el-input> </el-form-item> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="8"> <el-form-item label="IMEI" prop="imei"> <el-input :disabled="true" v-model="dataForm.imei"> <i slot="prefix" class="el-icon-phone"></i> </el-input> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="IMSI" prop="imsi"> <el-input :disabled="true" v-model="dataForm.imsi"> <i slot="prefix" class="el-icon-sim-card"></i> </el-input> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="ICCID" prop="iccid"> <el-input :disabled="true" v-model="dataForm.iccid"> <i slot="prefix" class="el-icon-credit-card"></i> </el-input> </el-form-item> </el-col> </el-row> </el-collapse-item> <!-- GPS定位信息 --> <el-collapse-item title="GPS定位信息" name="5"> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="经度" prop="longitude"> <el-input :disabled="true" v-model="dataForm.longitude" type="number"> <i slot="prefix" class="el-icon-place"></i> </el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="经度方向" prop="longitudeDirection"> <el-select :disabled="true" v-model="dataForm.longitudeDirection"> <el-option label="东经" value="E"></el-option> <el-option label="西经" value="W"></el-option> </el-select> </el-form-item> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="纬度" prop="latitude"> <el-input :disabled="true" v-model="dataForm.latitude" type="number"> <i slot="prefix" class="el-icon-place"></i> </el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="纬度方向" prop="latitudeDirection"> <el-select :disabled="true" v-model="dataForm.latitudeDirection"> <el-option label="北纬" value="N"></el-option> <el-option label="南纬" value="S"></el-option> </el-select> </el-form-item> </el-col> </el-row> </el-collapse-item> <!-- 业务信息 --> <el-collapse-item title="业务信息" name="6"> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="业务模式" prop="businessmode"> <el-select :disabled="true" v-model="dataForm.businessmode"> <el-option v-for="mode in businessModes" :key="mode.value" :label="mode.label" :value="mode.value" ></el-option> </el-select> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="处理状态" prop="handled"> <el-select :disabled="true" v-model="dataForm.handled"> <el-option label="已处理" :value="1"></el-option> <el-option label="待处理" :value="0"></el-option> </el-select> </el-form-item> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="执行方式" prop="todoNow"> <el-select :disabled="true" v-model="dataForm.todoNow"> <el-option label="立即执行" :value="1"></el-option> <el-option label="等待执行" :value="0"></el-option> </el-select> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="需要回复" prop="needack"> <el-select :disabled="true" v-model="dataForm.needack"> <el-option label="是" :value="1"></el-option> <el-option label="否" :value="0"></el-option> </el-select> </el-form-item> </el-col> </el-row> <!-- 消息类型 --> <el-form-item label="消息类型" prop="flag"> <el-select :disabled="true" v-model="dataForm.flag"> <el-option label="设备主动请求或上报" :value="1"></el-option> <el-option label="平台主动推送或下指令" :value="2"></el-option> <el-option label="平台指令反馈的结果" :value="3"></el-option> </el-select> </el-form-item> </el-collapse-item> <!-- 其他信息 --> <el-collapse-item title="其他信息" name="7"> <el-form-item label="原始数据" prop="payload"> <el-input v-model="dataForm.payload" type="textarea" :rows="3" placeholder="请输入原始数据" :disabled="true" ></el-input> </el-form-item> </el-collapse-item> </el-collapse> </el-form> <span slot="footer" class="dialog-footer"> <el-button @click="visible = false">取消</el-button> <el-button type="primary" @click="dataFormSubmit()">确定</el-button> </span> </el-dialog> </template> <script> export default { data() { return { visible: false, activePanels: ['1'], dataForm: { id: 0, batteryId: '', batteryVoltage: '', batteryCurrent: '', batterySoc: '', batteryHardVersion: '', batterySoftVersion: '', batteryWorkMode: '', batteryKind: "0", batteryProtectCode: '', batteryErrorCode: '', batteryTemperatureMax: '', batteryTemperatureMin: '', batteryVoltageMax: '', batteryVoltageMin: '', mosStatus: '', mosTemp: '', batteryCycleTimes: '', steadyStatus: '', cellVoltage: '', model: '', manufacture: '', imei: '', imsi: '', iccid: '', trackerHardwareVersion: '', trackerSoftwareVersion: '', csq: '', networkType: '', locationMode: '', longitude: '', longitudeDirection: '', latitude: '', latitudeDirection: '', gpsSpeed: '', gpsSignal: '', satelliteNum: '', accuracy: '', flag: '', clientId: '', topic: '', productKey: '', handled: '', todoNow: '', needack: '', businessmode: '', uploadTime: '', createTime: '', updateTime: '', payload: '' }, businessModes: [ { value: 1, label: "关机模式" }, { value: 2, label: "运营模式" }, { value: 3, label: "运输模式" }, { value: 4, label: "通讯充电模式" }, { value: 5, label: "盲充模式" }, { value: 6, label: "存储模式" }, { value: 7, label: "搜寻模式" }, { value: 8, label: "返厂模式" } ], /* dataRule: { batteryId: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryVoltage: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryCurrent: [ { required: true, message: '不能为空', trigger: 'blur' } ], batterySoc: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryHardVersion: [ { required: true, message: '不能为空', trigger: 'blur' } ], batterySoftVersion: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryWorkMode: [ { required: true, message: '0x01(1):放电模式 0x10(16):充电模式 0x21(33):保护模式 0x30(48):待机无输出模式 0x31(49):待机预放电模式 0xFF(255):故障需返厂不能为空', trigger: 'blur' } ], batteryProtectCode: [ { required: true, message: '保护状态 bit16~bit 31 保留 bit15:Gsensor 故障 bit14:BMS 与 Tracker通讯超时 bit13: 预放电失败 bit12: IC保护 bit11: 智能充电通信超时 bit10:压差过大 bit9:温差过大 bit8:短路 bit7:充电过压 bit6:充电过流 bit5:放电欠压 bit4:放电过流 bit3:充电低温 bit2:充电高温 bit1:放电高温 bit0:放电低温不能为空', trigger: 'blur' } ], batteryErrorCode: [ { required: true, message: '转成2进制, 总共为16位,高8位为电池包工作状态,低8位为故障状态码 bit9BMS 与 Tracker通讯故障,bit8BMS 板 G sensor损坏,(8/9无效)bit7:失效,bit6:失衡,bit5:放电 MOS 损坏,bit4:充电 MOS 损坏,bit3IC 损坏,bit2:温度传感器损坏,bit1:采样线断线,虚焊等故障 保留,置 0,bit0:保留不能为空', trigger: 'blur' } ], batteryTemperatureMax: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryTemperatureMin: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryVoltageMax: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryVoltageMin: [ { required: true, message: '不能为空', trigger: 'blur' } ], mosStatus: [ { required: true, message: '不能为空', trigger: 'blur' } ], mosTemp: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryCycleTimes: [ { required: true, message: '不能为空', trigger: 'blur' } ], steadyStatus: [ { required: true, message: '不能为空', trigger: 'blur' } ], cellVoltage: [ { required: true, message: '不能为空', trigger: 'blur' } ], model: [ { required: true, message: '不能为空', trigger: 'blur' } ], manufacture: [ { required: true, message: '不能为空', trigger: 'blur' } ], imei: [ { required: true, message: '不能为空', trigger: 'blur' } ], imsi: [ { required: true, message: '不能为空', trigger: 'blur' } ], iccid: [ { required: true, message: '不能为空', trigger: 'blur' } ], trackerHardwareVersion: [ { required: true, message: '不能为空', trigger: 'blur' } ], trackerSoftwareVersion: [ { required: true, message: '不能为空', trigger: 'blur' } ], csq: [ { required: true, message: '不能为空', trigger: 'blur' } ], networkType: [ { required: true, message: '不能为空', trigger: 'blur' } ], locationMode: [ { required: true, message: '不能为空', trigger: 'blur' } ], longitude: [ { required: true, message: '不能为空', trigger: 'blur' } ], longitudeDirection: [ { required: true, message: '不能为空', trigger: 'blur' } ], latitude: [ { required: true, message: '不能为空', trigger: 'blur' } ], latitudeDirection: [ { required: true, message: '不能为空', trigger: 'blur' } ], gpsSpeed: [ { required: true, message: '不能为空', trigger: 'blur' } ], gpsSignal: [ { required: true, message: '不能为空', trigger: 'blur' } ], satelliteNum: [ { required: true, message: '不能为空', trigger: 'blur' } ], accuracy: [ { required: true, message: '不能为空', trigger: 'blur' } ], flag: [ { required: true, message: '1:设备主动请求或上报 2:平台主动推送或下指令 3:平台指令反馈的结果不能为空', trigger: 'blur' } ], clientId: [ { required: true, message: 'MQTT发布消息所需的clientId不能为空', trigger: 'blur' } ], topic: [ { required: true, message: 'MQTT主题不能为空', trigger: 'blur' } ], productKey: [ { required: true, message: '主题名称中需要的productKey不能为空', trigger: 'blur' } ], handled: [ { required: true, message: '配置是否处理 1:已处理 0:待处理不能为空', trigger: 'blur' } ], todoNow: [ { required: true, message: '是否立即执行 0:等待执行 1:立即执行不能为空', trigger: 'blur' } ], needack: [ { required: true, message: '是否回复不能为空', trigger: 'blur' } ], businessmode: [ { required: true, message: '业务模式 1:关机模式 2:运营模式 3:运输模式 4:通讯充电模式 5:盲充模式 6:存储模式 7:搜寻模式 8:返厂模式不能为空', trigger: 'blur' } ], uploadTime: [ { required: true, message: '不能为空', trigger: 'blur' } ], createTime: [ { required: true, message: '不能为空', trigger: 'blur' } ], updateTime: [ { required: true, message: '更新时间不能为空', trigger: 'blur' } ], payload: [ { required: true, message: '原始数据不能为空', trigger: 'blur' } ] } */ } }, computed: { // 处理状态标签 handledLabel() { return this.dataForm.handled === 1 ? "已处理" : this.dataForm.handled === 0 ? "待处理" : ""; }, // 执行方式标签 todoNowLabel() { return this.dataForm.todoNow === 1 ? "立即执行" : this.dataForm.todoNow === 0 ? "等待执行" : ""; }, // 需要回复标签 needackLabel() { return this.dataForm.needack === 1 ? "是" : this.dataForm.needack === 0 ? "否" : ""; }, // 业务模式标签 businessModeLabel() { const mode = this.businessModes.find(m => m.value == this.dataForm.businessmode); return mode ? mode.label : ""; }, // 消息类型标签 flagLabel() { switch (this.dataForm.flag) { case 1: return "设备主动请求或上报"; case 2: return "平台主动推送或下指令"; case 3: return "平台指令反馈的结果"; default: return ""; } } }, methods: { init (id) { this.dataForm.id = id || 0 this.visible = true this.$nextTick(() => { this.$refs['dataForm'].resetFields() if (this.dataForm.id) { this.$http({ url: this.$http.adornUrl(`/maya/mybatteryinfo/info/${this.dataForm.id}`), method: 'get', params: this.$http.adornParams() }).then(({data}) => { if (data && data.code === 0) { this.dataForm.batteryId = data.myBatteryInfo.batteryId this.dataForm.batteryVoltage = data.myBatteryInfo.batteryVoltage this.dataForm.batteryCurrent = data.myBatteryInfo.batteryCurrent this.dataForm.batterySoc = data.myBatteryInfo.batterySoc this.dataForm.batteryHardVersion = data.myBatteryInfo.batteryHardVersion this.dataForm.batterySoftVersion = data.myBatteryInfo.batterySoftVersion this.dataForm.batteryWorkMode = data.myBatteryInfo.batteryWorkMode this.dataForm.batteryKind = String(data.myBatteryInfo.batteryKind); this.dataForm.batteryProtectCode = data.myBatteryInfo.batteryProtectCode this.dataForm.batteryErrorCode = data.myBatteryInfo.batteryErrorCode this.dataForm.batteryTemperatureMax = data.myBatteryInfo.batteryTemperatureMax this.dataForm.batteryTemperatureMin = data.myBatteryInfo.batteryTemperatureMin this.dataForm.batteryVoltageMax = data.myBatteryInfo.batteryVoltageMax this.dataForm.batteryVoltageMin = data.myBatteryInfo.batteryVoltageMin this.dataForm.mosStatus = data.myBatteryInfo.mosStatus this.dataForm.mosTemp = data.myBatteryInfo.mosTemp this.dataForm.batteryCycleTimes = data.myBatteryInfo.batteryCycleTimes this.dataForm.steadyStatus = data.myBatteryInfo.steadyStatus this.dataForm.cellVoltage = data.myBatteryInfo.cellVoltage this.dataForm.model = data.myBatteryInfo.model this.dataForm.manufacture = data.myBatteryInfo.manufacture this.dataForm.imei = data.myBatteryInfo.imei this.dataForm.imsi = data.myBatteryInfo.imsi this.dataForm.iccid = data.myBatteryInfo.iccid this.dataForm.trackerHardwareVersion = data.myBatteryInfo.trackerHardwareVersion this.dataForm.trackerSoftwareVersion = data.myBatteryInfo.trackerSoftwareVersion this.dataForm.csq = data.myBatteryInfo.csq this.dataForm.networkType = data.myBatteryInfo.networkType this.dataForm.locationMode = data.myBatteryInfo.locationMode this.dataForm.longitude = data.myBatteryInfo.longitude this.dataForm.longitudeDirection = data.myBatteryInfo.longitudeDirection this.dataForm.latitude = data.myBatteryInfo.latitude this.dataForm.latitudeDirection = data.myBatteryInfo.latitudeDirection this.dataForm.gpsSpeed = data.myBatteryInfo.gpsSpeed this.dataForm.gpsSignal = data.myBatteryInfo.gpsSignal this.dataForm.satelliteNum = data.myBatteryInfo.satelliteNum this.dataForm.accuracy = data.myBatteryInfo.accuracy this.dataForm.flag = data.myBatteryInfo.flag this.dataForm.clientId = data.myBatteryInfo.clientId this.dataForm.topic = data.myBatteryInfo.topic this.dataForm.productKey = data.myBatteryInfo.productKey this.dataForm.handled = data.myBatteryInfo.handled this.dataForm.todoNow = data.myBatteryInfo.todoNow this.dataForm.needack = data.myBatteryInfo.needack this.dataForm.businessmode = data.myBatteryInfo.businessmode this.dataForm.uploadTime = data.myBatteryInfo.uploadTime this.dataForm.createTime = data.myBatteryInfo.createTime this.dataForm.updateTime = data.myBatteryInfo.updateTime this.dataForm.payload = data.myBatteryInfo.payload } }) } }) }, // 表单提交 dataFormSubmit () { this.$refs['dataForm'].validate((valid) => { if (valid) { this.$http({ url: this.$http.adornUrl(`/maya/mybatteryinfo/${!this.dataForm.id ? 'save' : 'update'}`), method: 'post', data: this.$http.adornData({ 'id': this.dataForm.id || undefined, 'batteryId': this.dataForm.batteryId, 'batteryVoltage': this.dataForm.batteryVoltage, 'batteryCurrent': this.dataForm.batteryCurrent, 'batterySoc': this.dataForm.batterySoc, 'batteryHardVersion': this.dataForm.batteryHardVersion, 'batterySoftVersion': this.dataForm.batterySoftVersion, 'batteryWorkMode': this.dataForm.batteryWorkMode, 'batteryKind': Number(this.dataForm.batteryKind), 'batteryProtectCode': this.dataForm.batteryProtectCode, 'batteryErrorCode': this.dataForm.batteryErrorCode, 'batteryTemperatureMax': this.dataForm.batteryTemperatureMax, 'batteryTemperatureMin': this.dataForm.batteryTemperatureMin, 'batteryVoltageMax': this.dataForm.batteryVoltageMax, 'batteryVoltageMin': this.dataForm.batteryVoltageMin, 'mosStatus': this.dataForm.mosStatus, 'mosTemp': this.dataForm.mosTemp, 'batteryCycleTimes': this.dataForm.batteryCycleTimes, 'steadyStatus': this.dataForm.steadyStatus, 'cellVoltage': this.dataForm.cellVoltage, 'model': this.dataForm.model, 'manufacture': this.dataForm.manufacture, 'imei': this.dataForm.imei, 'imsi': this.dataForm.imsi, 'iccid': this.dataForm.iccid, 'trackerHardwareVersion': this.dataForm.trackerHardwareVersion, 'trackerSoftwareVersion': this.dataForm.trackerSoftwareVersion, 'csq': this.dataForm.csq, 'networkType': this.dataForm.networkType, 'locationMode': this.dataForm.locationMode, 'longitude': this.dataForm.longitude, 'longitudeDirection': this.dataForm.longitudeDirection, 'latitude': this.dataForm.latitude, 'latitudeDirection': this.dataForm.latitudeDirection, 'gpsSpeed': this.dataForm.gpsSpeed, 'gpsSignal': this.dataForm.gpsSignal, 'satelliteNum': this.dataForm.satelliteNum, 'accuracy': this.dataForm.accuracy, 'flag': this.dataForm.flag, 'clientId': this.dataForm.clientId, 'topic': this.dataForm.topic, 'productKey': this.dataForm.productKey, 'handled': this.dataForm.handled, 'todoNow': this.dataForm.todoNow, 'needack': this.dataForm.needack, 'businessmode': this.dataForm.businessmode, 'uploadTime': this.dataForm.uploadTime, 'createTime': this.dataForm.createTime, 'updateTime': this.dataForm.updateTime, 'payload': this.dataForm.payload }) }).then(({data}) => { if (data && data.code === 0) { this.$message({ message: '操作成功', type: 'success', duration: 1500, onClose: () => { this.visible = false this.$emit('refreshDataList') } }) } else { this.$message.error(data.msg) } }) } }) } } } </script> <style scoped> /* 添加状态显示样式 */ .status-display { margin-top: 8px; padding: 6px 12px; background-color: #f5f7fa; border-radius: 4px; border: 1px solid #dcdfe6; font-size: 14px; color:rgb(226, 228, 233); } /* 在查看模式下隐藏选择框,显示纯文本 */ .view-mode .el-select { display: none; } .view-mode .status-display { display: block; } </style>优化此页面输入框颜色,白底黑字
07-22
<%@page import="com.haitaiinc.inpordnurse.ylz.dto.common.Bm_ygxx00DTO"%> <%@page import="com.haitaiinc.common.CommUtil"%> <%@ page import="com.haitaiinc.servlet.JSP,com.haitaiinc.util.Dict,com.haitaiinc.htdb.sd_haitai2.dto.*"%> <%@page import="com.haitaiinc.htdb.sd_haitai2.dto.Inpatient"%> <%@page import="com.haitaiinc.common.CommonAction"%> <%@page import="com.haitaiinc.htcpoe.InpordSystemConfig"%> <%@page import="com.haitaiinc.util.Dict"%> <%@page import="com.haitaiinc.Util"%> <%@page import="java.text.SimpleDateFormat"%> <%@page import="java.util.Calendar"%> <%@page import="java.util.Date"%> <%@page import="java.util.List"%> <%@page import="java.util.ArrayList"%> <%@page import="com.haitaiinc.servlet.JSP"%> <%@page import="com.haitaiinc.common.Const"%> <%@page import="com.haitaiinc.util.Dict"%> <%@page import="com.haitaiinc.inpordnurse.ylz.dto.yrqd.Bm_bqks00DTO"%> <jsp:useBean id="token" class="java.lang.String" scope="request"></jsp:useBean> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=7" ></meta> <%=JSP.getHtCSSDef(request)%> <%=JSP.getPageCSSDef(request) %> <%=JSP.getHtJSDef(request)%> <script src="ht-5.0/ht-core.js" type="text/javascript"></script> <script src="<%=request.getContextPath() %>/js/jquery-1.8.3.js"></script> <script src="<%=request.getContextPath() %>/js/jquery-ui-1.11.4/jquery-ui.js"></script> <link href="<%=request.getContextPath() %>/js/jquery-ui-1.11.4/jquery-ui.css" rel="stylesheet" type="text/css" /> <script src="<%=request.getContextPath() %>/js/showLoading.js"></script> <script src="<%=request.getContextPath() %>/js/orderdrug/common-edit-drug.js"></script> <script src="/nurse-business-extend/extendforylz/commjs/nurse-synthetical-oprate.js"></script> <% String titleName = "病区收入统计"; String currentTime = Util.getCurrentDate("yyyy-MM-dd"); SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar=Calendar.getInstance(); String currentday = simpleDateFormat.format(calendar.getTime()); calendar.add(Calendar.MONTH,-1); String lastmonth = simpleDateFormat.format(calendar.getTime()); //医嘱检索结果区下方增加空白区域显示医嘱的特殊说明 String showDesc = "false"; showDesc = "true"; List<Bm_bqks00DTO> bqksList = (ArrayList)request.getAttribute("bqksList"); List<Bm_ygxx00DTO> yhryList = (ArrayList)request.getAttribute("yshsList"); String[] monthsList = {"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"}; %> <title><%=titleName%></title> <script type="text/javascript" src="js/json2.js"></script> <script type="text/javascript"> </script> <style> html{height:100%;overflow:hidden;} .div-radio { margin: 0px 0px 0px 0px; } .div-inline1{ margin-top: 5px; margin-left: -6px; padding-left: 10px; height: 25px; } </style> </head> <body style="height:100%"> <div id="qrDiv" style="height:100%;"> <form name="searchForm" id="searchForm" method="post"> <table cellpadding="1" cellspacing="1" style="table-layout: fixed;width: 100%; height:100%;"> <colgroup> <col id="colId" width="100%"> </colgroup> <tr> <td class="main_bg_search" style="width: 100%;" colspan="2"> <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td> <div class="div-inline">  科室: <select id="bqks" name="bqks" style="width: 120px;height: 23px;" onchange="changeYhry(this);"> <option selected="selected" value="">全部</option> <% for(int j=0; bqksList!=null&&j<bqksList.size();j++){ Bm_bqks00DTO sd = bqksList.get(j); %> <option value="<%=Util.toString(sd.getKsh000()) %>"><%=Util.toString(sd.getBmmc00()) %></option> <%} %> </select> </div>  <div class="div-inline"> <span> <label><input type="radio" style="margin-left: -10px;" name="itemStatus" value="xmlb" checked="checked" onclick="checkYhry(this);searchList();"/>按项目类别</label> <label><input type="radio" name="itemStatus" value="jtxm" onclick="checkYhry(this);searchList();" />按具体项目</label> <label><input type="radio" name="itemStatus" value="yhry" onclick="checkYhry(this);searchList();" /> 按医护人员: <select id="yhry" name="yhry" disabled="disabled" style="width: 120px;height: 23px;"> <option selected="selected" value="">全部</option> <% for(int j=0; yhryList!=null&&j<yhryList.size();j++){ Bm_ygxx00DTO sd = yhryList.get(j); %> <option value="<%=Util.toString(sd.getYgbh00()) %>"><%=Util.toString(sd.getZwxm00()) %></option> <%} %> </select> </label> </span> </div>  </td> </tr> <tr> <td>    <div class="div-inline div-checkbox-or-radio div-inline1"> <span> <label><input type="radio" checked="checked" style="margin-left: -10px;" name="timeTypes" value="0" onclick="checkTime(this);"/> 月份: <select id="months" name="months" style="width: 120px;height: 22px;margin-top: 1px;"> <option selected="selected" value="0">当前月份</option> <% for(int j=0; monthsList!=null&&j<monthsList.length;j++){ %> <option value="<%=j+1 %>"><%=monthsList[j] %></option> <%} %> </select> </label> </span> </div>   <div class="div-inline div-checkbox-or-radio div-inline1" style="margin-bottom: 3px;"> <span> <label><input type="radio" style="margin-left: -10px;" name="timeTypes" value="1" onclick="checkTime(this);"/> 时间: <input type="text" readonly name="startTime" id="startTime" style="width: 100px;" disabled="disabled" onclick="fPopUpCalendarDlg(startTime);searchList();" value="<%=Util.format(lastmonth, "yyyy-MM-dd")%>" /> - <input type="text" readonly name="endTime" id="endTime" style="width: 100px;" disabled="disabled" onclick="fPopUpCalendarDlg(endTime);searchList();" value="<%=Util.format(currentday, "yyyy-MM-dd")%>" /> </label> </span> </div> <div class="div-inline" style="margin-bottom: 5px;"> <input type="button" class="order_button" value="查  询" id='queryBtn' onclick="searchList();"/>   <input type="button" class="order_button" value="导出Excel" id='exportExcelBtn' onclick="exportExcel();"/>   </div> </td> </tr> </table> </td> </tr> <tr id="listTr"> <td id="dataTd" height="84.5%" width="100%" align="left" valign="top"> <table cellpadding="1" cellspacing="1" style="table-layout: fixed;width: 100%; height:100%;"> <tr> <td height="100%" width="100%" ><!-- 医嘱信息展示列表区 --> <div id="listshow" style="overflow:hidden;height:100%;width:100%;" ></div> </td> </tr> </table> </td> </tr> </table> </form> </div> <div id="swElement" style="display: none;"> </div> </body> <script type="text/javascript"> var token = "<%=token%>"; var menu = "<%=titleName%>"; searchList(); //展示统计列表 function searchList(){ showLoading(); var url = "do?module=inpordnurse&action=YlzBqsrtj&method=searchIncomeStatisticsList"; $("#listshow").html(""); Haitai.Ajax.request({ url : url, params:{ token:token }, form : searchForm, callback : function(text){ closeLoading(); ht("listshow").html(text,false); } }); } function checkYhry(obj){ if(obj.value=="xmlb"&&obj.checked){ $("#yhry").attr("disabled",true); }else if(obj.value=="jtxm"&&obj.checked){ $("#yhry").attr("disabled",true); }else{ $("#yhry").attr("disabled",false); } } function checkTime(obj){ if(obj.value=="0"&&obj.checked){ $("#startTime").attr("disabled",true); $("#endTime").attr("disabled",true); $("#months").attr("disabled",false); }else{ $("#startTime").attr("disabled",false); $("#endTime").attr("disabled",false); $("#months").attr("disabled",true); } searchList(); } function checkIsNull(str){ if(str==null||str==""||str==undefined){ return true; }else{ return false; } } //选择科室联动变化医护人员下拉框数据,护士不变,医生随科室切换变化 function changeYhry(obj){ var xzks00 = obj.value; if(xzks00!=""){ var url = "do?module=inpordnurse&action=YlzBqsrtj&method=searchYhryByXzks"; Haitai.Ajax.request({ url : url, params:{ token:token, xzks00:xzks00 }, form : searchForm, callback : function(text){ if(checkIsNull(text)){ var yhryObj = $("#yhry"); yhryObj.html(""); yhryObj.append($("<option selected=\"selected\" value=\"\">全部</option>")); }else{ var retJson = eval("("+text+")"); var yhryObj = $("#yhry"); yhryObj.html(""); yhryObj.append($("<option selected=\"selected\" value=\"\">全部</option>")); for(var i=0;i<retJson.length;i++){ yhryObj.append($("<option value=\""+retJson[i].ygbh00+"\">"+retJson[i].zwxm00+"</option>")); } } } }); } } function exportExcel(){ } </script> </html>exportExcel帮我导出excel
07-16
<template> <div> <el-dialog :title="!dataForm.id ? '指令生成' : '修改'" :close-on-click-modal="false" v-dialogDrag :visible.sync="visible" id="myOrder"> <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px" style="margin-top: -0.275rem;background-color: #fff;border: 0px solid #DCDFE6;"> <!-- 升级类型 1-BMS升级 2-Tracker通讯板升级 --> <el-form-item label="升级类型" size="mini" prop="type"> <el-radio-group v-model="dataForm.type" :disabled="dataForm.id ? 'disabled' : null"> <el-radio :label="1">BMS升级</el-radio> <el-radio :label="2">Tracker通讯板升级</el-radio> <!-- <el-radio :label="2">参数设置</el-radio> --> </el-radio-group> </el-form-item> <el-form-item label="项目" prop="projectParameter"> <el-select v-model="dataForm.projectParameter" placeholder="请选择项目" @change="blurSelect" style="width:6rem" clearable> <el-option v-for="item in projectIds" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select> </el-form-item> <el-form-item label="项目名称" prop="projectRef"> <el-input v-model="dataForm.projectRef" placeholder="项目简称" style="width:6rem" readonly></el-input> </el-form-item> <el-form-item label="升级模式" size="mini" prop="orderType"> <el-radio-group v-model="dataForm.orderType" :disabled="dataForm.id ? 'disabled' : null"> <el-radio :label="1" @change="typeChange(1)">指定设备升级</el-radio> <el-radio :label="0" @change="typeChange(0)">所有设备升级</el-radio> </el-radio-group> </el-form-item> <el-form-item label="设备导入" v-if="showotaall"> <!-- <el-button v-if="isAuth('maya:myotarequest:batchUpgrade')" type="success" @click="otaBatchUpgradeHandle()" :disabled="dataListSelections.length != 2">批量升级</el-button> --> <el-button type="success" @click="otaBatchUpgradeHandle()" >Excel导入</el-button> </el-form-item> <el-form-item label="设备编号" prop="deviceCodes" v-if="showotaall"> <!-- <el-input v-model="dataForm.deviceCodes" placeholder="设备编号。多个用“;”隔开,如下224042102999025;411219000005615;411219000005617"></el-input> --> <el-autocomplete style="width:10rem" size="normal" v-model="dataForm.deviceCodes" :popper-append-to-body="false" :fetch-suggestions="querySearchAsync" @select="handleSelect" placeholder="请输入设备编号。多个用“;”隔开,如下224042102999025;411219000005615;411219000005617"> </el-autocomplete> </el-form-item> <el-form-item label="Topic" prop="topic"> <el-select v-model="dataForm.topic" placeholder="请选择topic" style="width:6rem" > <el-option v-for="item in topics" :key="item.value" :label="item.label" :value="item.value" :disabled="item.disabled" > </el-option> </el-select> </el-form-item> <!-- <el-form-item label="通讯方式" prop="communicationMode"> <el-input v-model="dataForm.communicationMode" placeholder="通讯方式 0:暂无 1:串口 2:can 3:i2c"></el-input> </el-form-item> --> <!-- <el-form-item label="通讯类型" size="mini" prop="communicationMode"> <el-radio-group v-model="dataForm.communicationMode" :disabled="dataForm.id ? 'disabled' : null"> <el-radio :label="1">串口</el-radio> <el-radio :label="2">can</el-radio> <el-radio :label="3">i2c</el-radio> </el-radio-group> </el-form-item> --> <!-- <el-form-item label="can通讯的帧id" prop="frameIdCan"> <el-input v-model="dataForm.frameIdCan" placeholder="can通讯的帧id"></el-input> </el-form-item> <el-form-item label="通讯数据" prop="payload"> <el-input v-model="dataForm.payload" placeholder="通讯的数据"></el-input> </el-form-item> --> <!-- <el-form-item label="升级固件地址" prop="url"> <el-input v-model="dataForm.url" placeholder="升级时的固件地址"></el-input> </el-form-item> --> <!-- <el-form-item label="*固件地址" prop="url" v-if="showota"> --> <el-form-item label="*固件地址" prop="url"> <el-select v-model="dataForm.url" placeholder="升级固件地址" style="width:10rem"> <el-option v-for="item in uploadurls" :key="item.value" :label="item.label" :value="item.value" :disabled="item.disabled" > </el-option> </el-select> </el-form-item> <el-form-item label="硬件版本" prop="hardwareversion"> <el-input v-model="dataForm.hardwareversion" placeholder="要升级的目标电池硬件版本" style="width:6rem;padding-left:0.0rem;"></el-input> <br/><span style="color:blue;font-size:13px">✸ 可不填写,若指定要升级的目标电池硬件版本,填写请在前面请带上“V”,如V1.00,V1.02</span> </el-form-item> <el-form-item label="*软件版本" prop="softwareversion"> <el-input v-model="dataForm.softwareversion" placeholder="当前升级的固件的软件版本" style="width:6rem"></el-input> </el-form-item> <el-form-item label="是否执行" size="mini" prop="todoNow"> <el-radio-group v-model="dataForm.todoNow"> <el-radio :label="0">等待</el-radio> <el-radio :label="1">立即执行</el-radio> </el-radio-group> </el-form-item> <!-- <el-form-item label="固件MD5" prop="md5"> <el-input v-model="dataForm.md5" placeholder="固件MD5"></el-input> </el-form-item> <el-form-item label="固件大小" prop="size"> <el-input v-model="dataForm.size" placeholder="固件大小"></el-input> </el-form-item> <el-form-item label="配置是否处理 " prop="handled"> <el-input v-model="dataForm.handled" placeholder="配置是否处理 1:已处理 0:待处理"></el-input> </el-form-item> <el-form-item label="是否立即执行" prop="todoNow"> <el-input v-model="dataForm.todoNow" placeholder="是否立即执行 0:等待执行 1:立即执行"></el-input> </el-form-item>--> <!-- <el-form-item label="是否执行" size="mini" prop="todoNow"> <el-radio-group v-model="dataForm.todoNow"> <el-radio :label="0">等待</el-radio> <el-radio :label="1">执行</el-radio> </el-radio-group> </el-form-item> --> </el-form> <span slot="footer" class="dialog-footer"> <el-button @click="visible = false">取消</el-button> <el-button type="primary" @click="dataFormSubmit()">生成指令</el-button> </span> </el-dialog> <!-- 弹窗, Excel导入--> <ota-batch-upgrade v-if="otaBatchUpgradeVisible" ref="otaBatchUpgrade" @refreshDataList="onSubmit(1)"></ota-batch-upgrade> </div> </template> <script> import OtaBatchUpgrade from './myotabatchupgrade' export default { data () { return { visible: false, showotaall: true, otaBatchUpgradeVisible: false, projectIds:[], uploadurls:[], topics: [{ value: '/{productKey}/{deviceId}/maya7026/ota/upgrade/push', label: '固件升级(ota/upgrade/push)' } // , { // value: '/{productKey}/{deviceId}/upgradebox/{projectRef}/property/get', // label: '电池数据获取(property/get)' // } ], dataForm: { id: 0, type: 1, orderType: 1, projectParameter: '', deviceCodes: '', projectRef: '', topic: '', // communicationMode: 1, // frameIdCan: '', payload: '', url: '', hardwareversion: '', softwareversion: '', md5: '', size: '', handled: '', todoNow: 0, createTime: '', updateTime: '' }, dataRule: { type: [ { required: true, message: '升级类型 1-BMS升级 2-Tracker通讯板升级 不能为空', trigger: 'blur' } ], orderType: [ { required: true, message: '升级模式勾选 不能为空', trigger: 'blur' } ], projectParameter: [ { required: true, message: '不能为空', trigger: 'blur' } ], // deviceCodes: [ // { required: true, message: '设备编号不能为空', trigger: 'blur' } // ], // projectRef: [ // { required: true, message: '项目简称(用于topic)不能为空', trigger: 'blur' } // ], topic: [ { required: true, message: 'mqtt发送主题,如:battery/{batteryCode}/down/upgrade不能为空', trigger: 'blur' } ], // communicationMode: [ // { required: true, message: '通讯方式 0:暂无 1:串口 2:can 3:i2c不能为空', trigger: 'blur' } // ], // frameIdCan: [ // { required: true, message: 'can通讯的帧id不能为空', trigger: 'blur' } // ], // payload: [ // { required: true, message: '通讯的数据不能为空', trigger: 'blur' } // ], // url: [ // { required: true, message: '升级时的固件地址不能为空', trigger: 'blur' } // ], // md5: [ // { required: true, message: '固件MD5不能为空', trigger: 'blur' } // ], // size: [ // { required: true, message: '固件大小不能为空', trigger: 'blur' } // ], // handled: [ // { required: true, message: '配置是否处理 1:已处理 0:待处理不能为空', trigger: 'blur' } // ], todoNow: [ { required: true, message: '是否立即执行 0:等待执行 1:立即执行不能为空', trigger: 'blur' } ], // createTime: [ // { required: true, message: '不能为空', trigger: 'blur' } // ], // updateTime: [ // { required: true, message: '更新时间不能为空', trigger: 'blur' } // ] } } }, components: { OtaBatchUpgrade, }, methods: { typeChange(val){ // alert('packageChange') if(val=='1'){ // 指定电池升级,打开电池编号输入框 this.showotaall = true }else if(val=='0'){ // ota升级项目下所有电池 this.showotaall = false } }, // el-select失去焦点必填校验 blurSelect() { var project_name = this.dataForm.projectParameter.substring(this.dataForm.projectParameter.lastIndexOf("::")+2) this.$set(this.dataForm,'projectRef', project_name) }, querySearchAsync(queryString, cb) { clearTimeout(1000); var results = [] // alert('queryString='+queryString) if (queryString == '') { cb(results); } else { //掉接口需要的参数 this.$http({ url: this.$http.adornUrl('/mqtt/mqtttriad/getDeviceIds'), method: 'get', params: this.$http.adornParams({ 'deviceId': queryString, 'projectParameter': this.dataForm.projectParameter }) }).then(({data}) => { if (data && data.code === 0) { // alert(data.data.length) var result = data.data //循环放到一个远程搜索需要的数组 for (let i = 0; i < result.length; i++) { const element = result[i]; // alert(element) results.push({ value: element, id: i }) } cb(results); } else { console.log('没有数据的显示') results = [] cb(results); } }) } }, //点击出现搜索后点击的每一项 handleSelect(item) { this.id = item.id this.name = item.value }, init (id) { this.dataForm.id = id || 0 this.showotaall = true this.visible = true this.$nextTick(() => { this.$refs['dataForm'].resetFields() if (this.dataForm.id) { this.$http({ url: this.$http.adornUrl(`/maya/myotarequest/info/${this.dataForm.id}`), method: 'get', params: this.$http.adornParams() }).then(({data}) => { if (data && data.code === 0) { this.projectIds = data.data.projectMenus.projectIds this.uploadurls = data.data.OtaUrlMenus.uploads const socitem = data.data.mqttSends this.dataForm.type = socitem.type this.dataForm.projectParameter = socitem.projectParameter this.dataForm.deviceCodes = socitem.deviceCodes this.dataForm.projectRef = socitem.projectRef this.dataForm.topic = socitem.topic // this.dataForm.communicationMode = socitem.communicationMode // this.dataForm.frameIdCan = socitem.frameIdCan // this.dataForm.payload = socitem.payload this.dataForm.url = socitem.url this.dataForm.md5 = socitem.md5 this.dataForm.size = socitem.size this.dataForm.handled = socitem.handled this.dataForm.todoNow = socitem.todoNow this.dataForm.createTime = socitem.createTime this.dataForm.updateTime = socitem.updateTime } }) }else{ this.$http({ url: this.$http.adornUrl(`/maya/myotarequest/getOtaAndProjectMenus`), method: 'get', params: this.$http.adornParams() }).then(({data}) => { if (data && data.code === 0) { this.projectIds = data.data.projectMenus.projectIds this.uploadurls = data.data.OtaUrlMenus.uploads } }) } }) }, /** * 设备导入弹窗触发方法 */ otaBatchUpgradeHandle(){ this.otaBatchUpgradeVisible=true this.$nextTick(()=>{ this.$refs.otaBatchUpgrade.init() }) }, // 表单提交 dataFormSubmit () { if(this.dataForm.orderType==='1' || this.dataForm.orderType===1){ if(this.dataForm.deviceCodes === '' || this.dataForm.deviceCodes === undefined || this.dataForm.deviceCodes === null){ this.$message.warning('选择指定电池升级的,设备编号不能为空!') return } } // if(this.dataForm.type==='0' || this.dataForm.type===0){ if(this.dataForm.url === '' || this.dataForm.url === undefined || this.dataForm.url === null){ this.$message.warning('升级固件地址不能为空!') return } // if(this.dataForm.hardwareversion === '' || this.dataForm.hardwareversion === undefined || this.dataForm.hardwareversion === null){ // this.$message.warning('升级硬件版本不能为空!') // return // } if(this.dataForm.softwareversion === '' || this.dataForm.softwareversion === undefined || this.dataForm.softwareversion === null){ this.$message.warning('升级软件版本不能为空!') return } // } this.$refs['dataForm'].validate((valid) => { if (valid) { this.$http({ url: this.$http.adornUrl(`/maya/myotarequest/create`), method: 'post', data: this.$http.adornData({ 'id': this.dataForm.id || undefined, 'type': this.dataForm.type, 'orderType': this.dataForm.orderType, 'projectParameter': this.dataForm.projectParameter, 'deviceCodes': this.dataForm.deviceCodes, 'projectRef': this.dataForm.projectRef, 'topic': this.dataForm.topic, // 'communicationMode': this.dataForm.communicationMode, // 'frameIdCan': this.dataForm.frameIdCan, // 'payload': this.dataForm.payload, 'url': this.dataForm.url, 'hardwareversion': this.dataForm.hardwareversion, 'softwareversion': this.dataForm.softwareversion, 'md5': this.dataForm.md5, 'size': this.dataForm.size, 'handled': this.dataForm.handled, 'todoNow': this.dataForm.todoNow, 'createTime': this.dataForm.createTime, 'updateTime': this.dataForm.updateTime }) }).then(({data}) => { if (data && data.code === 0) { this.$message({ message: '操作成功', type: 'success', duration: 1500, onClose: () => { this.visible = false this.$emit('refreshDataList') // this.$emit('refreshDataList', this.dataForm.type,this.dataForm.communicationMode,this.dataForm.deviceCodes); } }) } else { this.$message.error(data.msg) } }) } }) } } } </script> <style> #myOrder element.style { width: 150px; } </style>父组件是这样的
07-12
<template> <div> <header class="ant-layout-header header_sd-header_common"> <div class="left_sd-header_common"> <div class="logo_sd-webflow_webflow"> <h3>激励考核指下发</h3> </div> </div> <div class="right_sd-header_common"> <a-button v-if="!readonly" type="link" icon="save" class="button_sd-webflow-button_webflow" @click="save" > 保存 </a-button> <a-button v-if="!readonly" type="link" icon="save" class="button_sd-webflow-button_webflow" @click="xfClick" > 下发 </a-button> <a-button type="link" icon="close-circle" class="button_sd-webflow-button_webflow" @click="btnClose" > 退出 </a-button> </div> </header> <div class="budget-record"> <div class="budget-record-table"> <h2 class="budget-record-table-title">激励考核指下发</h2> <a-form-model ref="ruleForm" :rules="rules" :model="project" class="sitd-apply" layout="horizontal" > <table> <colgroup> <col width="170px" /> <col /> <col width="170px" /> <col /> </colgroup> <tr> <td class="ant-form-item-label cell_sd-form-item-td-label_common"> <label title="指标编号">指标编号</label> </td> <td class="ant-form-item-control-wrapper" :colspan="3"> <a-form-model-item prop="zbbh"> <template>{{ project['zbbh'] }}</template> </a-form-model-item> </td> </tr> <tr> <td class="ant-form-item-label cell_sd-form-item-td-label_common"> <label title="指标年度" class="ant-form-item-required">指标年度</label> </td> <td class="ant-form-item-control-wrapper"> <a-form-model-item prop="zbnd"> <!-- 修改为下拉选择框 --> <a-select v-if="!readonly" v-model="project['zbnd']" placeholder="请选择年份" style="width: 100%" > <!-- 生成年份选项 --> <a-select-option v-for="year in yearOptions" :key="year" :value="year"> {{ year }} </a-select-option> </a-select> <template v-else> {{ project['zbnd'] }} </template> </a-form-model-item> </td> <td class="ant-form-item-label cell_sd-form-item-td-label_common"> <label title="考核周期">考核周期</label> </td> <td class="ant-form-item-control-wrapper"> <a-form-model-item prop="khzq"> <a-input v-if="!readonly" v-model="project['khzq']" placeholder="考核周期" /> <template v-else>{{ project['khzq'] }}</template> </a-form-model-item> </td> </tr> <tr> <td class="ant-form-item-label cell_sd-form-item-td-label_common"> <label title="考核对象">考核对象</label> </td> <td class="ant-form-item-control-wrapper"> <a-form-model-item prop="khdx"> <a-select v-if="!readonly" v-model="selectedKhdxIds" mode="multiple" style="width: 100%" placeholder="请选择被考核对象" @change="handleKhdxChange" > <template v-for="(item, _i) in khdxList"> <a-select-option :key="item.code" :value="item.code">{{ item.value }}</a-select-option> </template> </a-select> <template v-else>{{ project['khdx'] }}</template> </a-form-model-item> </td> <td class="ant-form-item-label cell_sd-form-item-td-label_common"> <label title="创建日期" class="ant-form-item-required">创建日期</label> </td> <td class="ant-form-item-control-wrapper"> <a-form-model-item prop="cjrq"> <template>{{ project['cjrq'] ? refreshTime(project['cjrq']) : '' }}</template> </a-form-model-item> </td> </tr> <tr> <td class="ant-form-item-label cell_sd-form-item-td-label_common upload-td"> <label title="说明">说明</label> </td> <td class="ant-form-item-control-wrapper" colspan="3"> <a-form-model-item prop="sm"> <div v-if="!readonly" class="textarea-wrapper"> <a-textarea v-model="project['sm']" placeholder="请输入内容" :max-length="300" class="m-textarea" :auto-size="{ minRows: 3, maxRows: 5 }" /> <span class="m-count">{{ `${project['sm']?.length || 0}/300` }}</span> </div> <template v-else>{{ project['sm'] }}</template> </a-form-model-item> </td> </tr> </table> </a-form-model> <!-- 这里暂时去掉,根据客户描述,一年只进行一次年度考核和激励考核,因此根据年度和单位关联即可 --> <!-- <h3 class="budget-record-table-title">关联年度考核</h3> <a-button v-if="!readonly" type="primary" :style="{ marginLeft: '88px' }" class="button_sd-webflow-button_webflow" @click="openDialogGl" > 关联年度考核 </a-button> <a-button v-if="!readonly" :style="{ marginLeft: '8px' }" class="button_sd-webflow-button_webflow" :disabled="!ndkhSelectedRowKeys.length" @click="ndkhBeforDelete" > 删除 </a-button> <a-modal title="选择年度考核" :visible="dialogVisibleGl" width="80%" @ok="handleDialogConfirm" @cancel="dialogVisibleGl = false" > <div class="apply-search"> <a-form-model :form="searchForm" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"> <a-row :gutter="24"> <a-col :span="8" class="chd"> <a-form-model-item label="考核年度"> <a-input v-model="searchForm['khnd']" allow-clear placeholder="请输入指标年度" /> </a-form-model-item> </a-col> <a-col :span="8" class="chd"> <a-form-model-item label="考核周期"> <a-input v-model="searchForm['khzq']" allow-clear placeholder="请输入考核周期" /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="24" class="chd" :style="{ textAlign: 'right', lineHeight: '45px' }"> <a-button :style="{ marginRight: '8px' }" @click="reset"> 重置 </a-button> <a-button type="primary" html-type="submit" @click="btnSearchBusinessList"> 查询 </a-button> </a-col> </a-row> </a-form-model> </div> <a-divider style="margin: 12px 0" /> <SdTable ref="ndkh" row-key="id" :columns="ndkhColumns" :data-source.sync="dialogResult" :pagination="paginationOpt" :loading="dialogLoading" :scroll="{ x: 1500 }" :row-selection="{ selectedRowKeys: selectedRowKeysAdd, onChange: btnSelectProjectAdd, }" > </SdTable> </a-modal> <SdTable ref="ndkhTable" row-key="id" :columns="ndkhColumns" :data-source.sync="ndkhResult" :loading="ndkhLoading" :pagination="false" class="ant-table" :row-selection="{ selectedRowKeys: ndkhSelectedRowKeys, onChange: btnSelectProjectNdkh, }" > </SdTable> --> <h3 class="budget-record-table-title" style="margin-top: 18px">激励考核指标</h3> <a-button v-if="!readonly" type="primary" :style="{ marginLeft: '88px' }" class="button_sd-webflow-button_webflow" @click="openDialog" > 新增 </a-button> <a-button v-if="!readonly" :style="{ marginLeft: '8px' }" class="button_sd-webflow-button_webflow" :disabled="!selectedRowKeys.length" @click="btnBeforDelete" > 删除 </a-button> <SdTable ref="jlkhzbxf" row-key="id" :columns="jlkhzbxfColumns" :data-source.sync="jlkhzbxfResult" :loading="loading" :pagination="false" class="ant-table" bordered :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: btnSelectProject, }" > <!-- 指标内容列自定义渲染 --> <template slot="指标内容" slot-scope="text, record, index"> <div style="white-space: pre-line; text-align: left; padding: 8px 0"> {{ text }} </div> </template> <template slot="分值" slot-scope="text, record, index"> <div style="white-space: pre-line; text-align: left; padding: 8px 0"> {{ text }} </div> </template> <!-- 操作列 --> <template v-if="!readonly" slot="操作" slot-scope="text, record"> <a-button class="action-button" type="link" size="small" @click="btnOpenProjectDetails(record)" > 编辑 </a-button> </template> </SdTable> <a-modal title="激励考核指标" :visible="dialogVisible" width="35%" @ok="handleConfirm" @cancel="handleCancel" > <div class="apply-search"> <a-form-model ref="subFormRef" :rules="jlkhzbxfSubRules" :form="jlkhzbxfSubForm" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" > <a-row> <a-col :span="18"> <a-form-model-item label="指标类别"> <a-input v-model="jlkhzbxfSubForm['zblb']" allow-clear placeholder="请输入指标类别" /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="18"> <a-form-model-item label="指标内容"> <a-textarea v-model="jlkhzbxfSubForm['zbnr']" placeholder="请输入指标内容(按Enter换行)" :max-length="300" class="m-textarea" :auto-size="{ minRows: 3, maxRows: 6 }" /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="18"> <a-form-model-item label="分值"> <a-textarea v-model="jlkhzbxfSubForm['fz']" placeholder="请输入分值(按Enter换行)" :max-length="300" class="m-textarea" :auto-size="{ minRows: 2, maxRows: 4 }" /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="18"> <a-form-model-item label="分值上限"> <a-input v-model="jlkhzbxfSubForm['fzsx']" allow-clear placeholder='例如:"+1分"、"-1.5分"或"不设上限"' /> </a-form-model-item> </a-col> </a-row> </a-form-model> </div> </a-modal> </div> </div> </div> </template> <script> import { Message, Modal } from 'ant-design-vue' import moment from 'moment' import components from './_import-components/zk-jlkh-zbxf-import' import KhypjService from './khypj-service' import crossWindowWatcher from '@/common/services/cross-window-watcher' import SdTable from '@/common/components/sd-table.vue' export default { name: 'ZkJlkhZbxf', metaInfo: { title: '激励考核指标下发', }, components: { ...components, SdTable, }, props: { id: { type: String, default: undefined, }, }, data() { // 添加校验规则 const validateFzsx = (rule, value, callback) => { if (!value) { callback() return } // 允许"不设上限" if (value === '不设上限') { callback() return } // 验证格式: ±数字(可含小数) + 单位(非数字字符) const regex = /^[+-]\d+(\.\d+)?[^\d]+$/ if (!regex.test(value)) { callback(new Error('格式错误,请填写"不设上限"或类似"+1分"、"-1.5分"的格式')) } else { callback() } } return { loading: false, ndkhLoading: false, dialogLoading: false, readonly: true, yearOptions: this.generateYearOptions(), rules: { zbnd: [{ required: true, message: '请选择指标年度', trigger: 'blur' }], }, jlkhzbxfSubRules: { fzsx: [{ validator: validateFzsx, trigger: 'blur' }], }, // 新增搜索表单数据 searchForm: { khnd: undefined, // 考核年度 khzq: undefined, // 考核周期 }, project: { id: undefined, // 主键id zbbh: undefined, // 指标编号 cjrq: undefined, // 创建日期 zbnd: undefined, // 指标年度 khzq: undefined, // 考核周期 khdx: undefined, // 考核对象 khdxId: undefined, // 考核对象id sm: undefined, // 说明 status: undefined, // 指标状态:0暂存,1下发(不可修改) ndkhId: undefined, // 关联的年度考核id }, jlkhzbxfResult: [], jlkhzbxfSubForm: { id: undefined, // id mainId: undefined, // 主表id zblb: undefined, // 指标类别 zbnr: undefined, // 指标内容 fz: undefined, // 分值 fzsx: undefined, // 分值上限 }, ndkhResult: [], khdxList: [], selectedKhdxIds: [], // 用于多选绑定的临时ID数组 dialogVisible: false, dialogVisibleGl: false, selectedKeys: [], selectedRows: [], selectedRowKeys: [], ndkhSelectedRowKeys: [], // 年度考核表格的选中项 ndkhSelectedRows: [], // 年度考核表格选中的行数据 selectedKeysAdd: [], selectedRowKeysAdd: [], // 年度考核表格的选中项 selectedRowsAdd: [], // 年度考核表格选中的行数据 isUpdateJlkhzbxfSub: false, isXf: false, ndkhColumns: [ { title: '考核编号', dataIndex: 'khbh', scopedSlots: { customRender: '考核编号', }, width: '200px', align: 'center', }, { title: '考核年度', dataIndex: 'khnd', scopedSlots: { customRender: '指标年度', }, width: '70px', align: 'center', }, { title: '考核对象', dataIndex: 'khdx', scopedSlots: { customRender: '责任主体', }, width: '200px', align: 'center', }, { title: '考核周期', dataIndex: 'khzq', scopedSlots: { customRender: '考核周期', }, width: '100px', align: 'center', }, ], dialogResult: [], dialogColumns: [], paginationOpt: { current: 1, // 当前页码 pageSize: 10, // 当前每页大小 total: 0, // 总数 showSizeChanger: true, showQuickJumper: false, pageSizeOptions: ['10', '20', '40', '60', '80', '100'], showTotal: (total) => `共 ${total} 条`, onShowSizeChange: (current, pageSize) => { this.paginationOpt.current = 1 this.paginationOpt.pageSize = pageSize this.btnSearchBusinessList() }, onChange: (current, size) => { this.paginationOpt.current = current this.paginationOpt.pageSize = size this.btnSearchBusinessList() }, }, } }, computed: { // 动态计算列配置 jlkhzbxfColumns() { const baseColumns = [ { title: '序号', customRender: (text, record, index) => { return index + 1 }, align: 'center', width: '10%', }, { title: '指标类别', dataIndex: 'zblb', customRender: (text, record) => { // 只有显示行才渲染内容 if (record.rowSpan > 0) { return { children: text, attrs: { rowSpan: record.rowSpan }, } } return { attrs: { rowSpan: 0 } } }, align: 'center', width: '10%', }, { title: '指标内容', dataIndex: 'zbnr', scopedSlots: { customRender: '指标内容', }, align: 'center', width: '40%', }, { title: '分值', dataIndex: 'fz', scopedSlots: { customRender: '分值', }, align: 'center', width: '20%', }, { title: '分值上限', dataIndex: 'fzsx', scopedSlots: { customRender: '分值上限', }, align: 'center', width: '10%', }, ] // 非只读模式下添加操作列 if (!this.readonly) { baseColumns.push({ title: '操作', dataIndex: 'action', scopedSlots: { customRender: '操作' }, width: '10%', align: 'center', }) } return baseColumns }, }, watch: { jlkhzbxfResult: { handler(newVal) { this.calculateRowSpans(newVal) }, immediate: true, // 初始化时立即执行 deep: true, // 深度监听 }, }, created() { this.getKhdxList() this.jlkhzbxfResult = this.calculateRowSpans(this.jlkhzbxfResult) this.initJlkhzbxfInfo() }, mounted() { if (!this.$route.query.id) { this.project.zbbh = this.getZBbh() this.project.cjrq = moment(new Date()).format('YYYY-MM-DD') this.readonly = false } }, methods: { // 年度考核表格选中处理 btnSelectProjectNdkh(selectedRowKeys, selectedRows) { this.ndkhSelectedRowKeys = selectedRowKeys this.ndkhSelectedRows = [...selectedRows] }, btnSelectProjectAdd(selectedRowKeys, selectedRows) { this.selectedRowKeysAdd = selectedRowKeys this.selectedRowsAdd = [...selectedRows] }, // 重置搜索表单 reset() { this.searchForm = { khnd: undefined, // 考核年度 khzq: undefined, // 考核周期 } this.paginationOpt.current = 1 this.paginationOpt.pageSize = 10 this.btnSearchBusinessList() }, getKhzbxfInfo() { console.log('1111111----------', this.project) console.log('22222222----------', this.project.ndkhId) if (this.project.ndkhId) { KhypjService.getKhzbxfById(this.project.ndkhId).then((res) => { if (res.data.code === 200) { if (res.data.data) { this.ndkhResult.push(res.data.data) } else { this.ndkhResult = [] } } else { Message.error('获取考核指标下发信息失败!') } }) } }, ndkhBeforDelete() { const _this = this if (_this.ndkhSelectedRowKeys.length === 0) { Message.warning('请选择要删除的数据!') return } Modal.confirm({ content: '是否确认删除?', onOk() { _this.project.ndkhId = '-1' _this.saveJlkhzbxf() _this.ndkhResult = [] _this.ndkhSelectedRowKeys = [] // 清空选中状态 }, onCancel() {}, }) }, openDialogGl() { console.log('3333----------', this.ndkhResult) if (this.ndkhResult.length > 0) { Message.warning('只能关联一条年度考核!') return } this.dialogVisibleGl = true this.selectedKeysAdd = [] this.selectedRowsAdd = [] this.btnSearchBusinessList() }, handleDialogConfirm() { if (this.selectedRowsAdd.length === 0) { Message.warning('请选择一条年度考核!') return } if (this.selectedRowsAdd.length > 1) { Message.warning('只能关联一条年度考核!') return } this.project.ndkhId = this.selectedRowsAdd[0].id this.saveJlkhzbxf() this.getKhzbxfInfo() this.dialogVisibleGl = false }, btnSearchBusinessList() { this.dialogLoading = true const khzbxfSearchVo = { khnd: this.searchForm.khnd, khzq: this.searchForm.khzq, } const params = { current: this.paginationOpt.current, // 直接使用当前页码 pageSize: this.paginationOpt.pageSize, // 直接使用当前每页大小 searchVo: khzbxfSearchVo, } KhypjService.getNdkhList(params) .then((res) => { if (res.data.code === 200) { this.paginationOpt.total = res.data.data.total this.dialogResult = res.data.data.records } else { Message.error('查询失败!') } }) .catch((err) => { Message.error(err.message || err.data) this.paginationOpt.total = 0 this.dialogResult = [] }) .finally(() => { this.dialogLoading = false }) }, getKhdxList() { KhypjService.getCodeList('khdx').then((res) => { if (res.data.code === 200) { this.khdxList = res.data.data } else { Message.error('查询失败!') } }) }, // 处理考核对象选择变化 handleKhdxChange(selectedIds) { // 1. 拼接ID字符串 this.project.khdxId = selectedIds.join(';') // 2. 拼接名称字符串 const selectedNames = [] selectedIds.forEach((code) => { const item = this.khdxList.find((d) => d.code === code) if (item) { selectedNames.push(item.value) } }) this.project.khdx = selectedNames.join(';') }, btnBeforDelete() { const _this = this if (this.selectedRowKeys.length === 0) { Message.warning('请选择要删除的数据!') return } Modal.confirm({ content: '是否确认删除?', onOk() { _this.deleteJlkhzbxfSub() _this.selectedRowKeys = [] }, onCancel() {}, }) }, deleteJlkhzbxfSub() { KhypjService.removeJlkhzbxfSubByIds(this.selectedRowKeys).then((res) => { if (res.data.code === 200) { Message.success('删除成功!') this.getJlkhzbxfSubList() } else { Message.error('查询失败!') } }) }, btnSelectProject(selectedRowKeys, selectedRows) { this.selectedRowKeys = selectedRowKeys this.selectedRows = [...selectedRows] }, openDialog() { this.dialogVisible = true this.selectedKeys = [] this.selectedRows = [] this.jlkhzbxfSubForm = { id: undefined, // id mainId: this.$route.query.id, // 主表id zblb: undefined, // 指标类别 zbnr: undefined, // 指标内容 fz: undefined, // 分值 fzsx: undefined, // 分值上限 } // 新增子数据自动保存主数据 if (!this.$route.query.id) { this.saveJlkhzbxf() } }, btnOpenProjectDetails(record) { this.dialogVisible = true this.jlkhzbxfSubForm = { id: record.id, // id mainId: record.mainId, // 主表id zblb: record.zblb, // 指标类别 zbnr: record.zbnr, // 指标内容 fz: record.fz, // 分值 fzsx: record.fzsx, // 分值上限 } this.isUpdateJlkhzbxfSub = true console.log('121212------', record) console.log('33333222------', this.jlkhzbSubxfForm) }, handleCancel() { this.dialogVisible = false }, // 弹窗确认 handleConfirm() { // 添加表单校验 this.$refs.subFormRef.validate((valid) => { if (!valid) { return false } // 原有的保存逻辑... if (!this.isUpdateJlkhzbxfSub) { this.jlkhzbxfSubForm.mainId = this.$route.query.id // 保存子表数据 KhypjService.saveJlkhzbxfSub(this.jlkhzbxfSubForm).then((res) => { if (res.data.code === 200) { Message.success(`添加成功!`) this.getJlkhzbxfSubList() } else { Message.error('添加失败!') } }) } else { // 保存子表数据 KhypjService.updateJlkhzbxfSub(this.jlkhzbxfSubForm).then((res) => { if (res.data.code === 200) { Message.success(`修改成功!`) this.getJlkhzbxfSubList() } else { Message.error('修改失败!') } }) this.isUpdateJlkhzbxfSub = false } this.dialogVisible = false }) }, // handleConfirm() { // if (!this.isUpdateJlkhzbxfSub) { // this.jlkhzbxfSubForm.mainId = this.$route.query.id // // 保存子表数据 // KhypjService.saveJlkhzbxfSub(this.jlkhzbxfSubForm).then((res) => { // if (res.data.code === 200) { // Message.success(`添加成功!`) // this.getJlkhzbxfSubList() // } else { // Message.error('添加失败!') // } // }) // } else { // // 保存子表数据 // KhypjService.updateJlkhzbxfSub(this.jlkhzbxfSubForm).then((res) => { // if (res.data.code === 200) { // Message.success(`修改成功!`) // this.getJlkhzbxfSubList() // } else { // Message.error('修改失败!') // } // }) // this.isUpdateJlkhzbxfSub = false // } // this.dialogVisible = false // }, // 计算行合并 calculateRowSpans(data) { if (!data || data.length === 0) return data const categoryMap = {} // 第一步:统计每个类别的行数 data.forEach((item) => { categoryMap[item.zblb] = (categoryMap[item.zblb] || 0) + 1 }) // 第二步:设置行合并属性 let lastCategory = null return data.map((item) => { // 重置rowSpan属性 item.rowSpan = undefined if (item.zblb !== lastCategory) { lastCategory = item.zblb // 只有每个类别的第一行设置rowSpan item.rowSpan = categoryMap[item.zblb] return item } // 同类别的后续行设置rowSpan为0 item.rowSpan = 0 return item }) }, // 生成年份选项 generateYearOptions() { const currentYear = new Date().getFullYear() const years = [] // 添加年份:当前年后1年、本年、前1年、前2年 years.push(currentYear + 1) // 后1年 years.push(currentYear) // 本年 years.push(currentYear - 1) // 前1年 years.push(currentYear - 2) // 前2年 return years }, btnClose() { window.close() }, initJlkhzbxfInfo() { if (this.$route.query.id) { KhypjService.getJlkhzbxfById(this.$route.query.id).then((res) => { if (res.data.code === 200) { this.project = res.data.data this.project.cjrq = this.project.cjrq ? moment(new Date(this.project.cjrq)).format('YYYY-MM-DD') : null this.readonly = this.project.status === 1 // 初始化选中项 if (this.project.khdxId) { this.selectedKhdxIds = this.project.khdxId.split(';').filter(Boolean) } this.getJlkhzbxfSubList() this.getKhzbxfInfo() } else { Message.error('获取考核指标库信息失败!') } }) } }, save() { const _this = this this.$refs.ruleForm.validate((valid, obj) => { if (!valid) { Message.warning('请输入必填项!') return false } else { _this.saveJlkhzbxf() } }) }, xfClick() { this.readonly = true this.isXf = true this.save() KhypjService.jlkhzbzpXfStart(this.$route.query.id).then((res) => { if (res.data.code === 200) { Message.success('下发成功!') } else { Message.error('下发失败!') } }) }, // 修改 saveJlkhzbxf 方法返回 Promise saveJlkhzbxf() { const _this = this if (this.isXf) { this.project.status = 1 } else { this.project.status = 0 } // 创建数据副本,避免污染原始数据 const postData = { ...this.project } // 仅在值是字符串时才进行转换 if (postData.cjrq && typeof postData.cjrq === 'string') { postData.cjrq = this.strToTimestamp(postData.cjrq) } // 返回一个 Promise return new Promise((resolve, reject) => { // 判断是新增还是更新 const apiCall = !this.$route.query.id ? KhypjService.saveJlkhzbxf(postData) : KhypjService.updateJlkhzbxf(postData) apiCall .then((res) => { if (res.data.code === 200) { // 处理新增保存成功 if (!_this.$route.query.id) { Message.success('保存成功!') if (res.data.data) { const currentUrl = window.location.href const newUrl = currentUrl.replace('zbxf', `zbxf?id=${res.data.data}`) // 直接跳转页面,不需要等待初始化 window.location.href = newUrl } resolve() // 解析 Promise } // 处理更新保存成功 else { if (_this.project.status === 1) { Message.success('提交成功!') } else { Message.success('保存成功!') } resolve() // 解析 Promise } } else { // 处理失败情况 const errorMessage = !_this.project.id ? '保存失败!' : _this.project.status === 1 ? '提交失败!' : '保存失败!' Message.error(errorMessage) reject(new Error(res.data.message || errorMessage)) } }) .catch((error) => { // 处理 API 错误 const errorMessage = !_this.project.id ? '保存失败!' : _this.project.status === 1 ? '提交失败!' : '保存失败!' console.error('API 错误:', error) Message.error(errorMessage) reject(error) }) }) }, getJlkhzbxfSubList() { KhypjService.getJlkhzbxfSubList(this.$route.query.id).then((res) => { if (res.data.code === 200) { this.jlkhzbxfResult = res.data.data } else { Message.error('获取子表信息失败!') } }) }, // 获取唯一指标编号 getZBbh() { // 获取当前时间 const now = new Date() // 获取当前时间的年、月、日、时、分、秒、毫秒 const year = now.getFullYear() const month = String(now.getMonth() + 1).padStart(2, '0') const day = String(now.getDate()).padStart(2, '0') const hour = String(now.getHours()).padStart(2, '0') const minute = String(now.getMinutes()).padStart(2, '0') const second = String(now.getSeconds()).padStart(2, '0') const millisecond = String(now.getMilliseconds()).padStart(3, '0') // 生成唯一标识 const uniqueId = `${year}${month}${day}${hour}${minute}${second}${millisecond}` return 'JLKHZBXF-' + uniqueId }, strToTimestamp(dateStr) { const date = moment(dateStr, 'YYYY-MM-DD') return date.valueOf() }, refreshTime(item) { return moment(item).format('YYYY-MM-DD') }, }, } </script> <style lang="scss" scoped> /* 设置表格宽度 */ .ant-table { width: 90%; margin: auto; /* 居中显示 */ } .sitd-collapse-block { width: 90%; margin: auto; &::v-deep(.ant-collapse-content-box) { padding: unset !important; } } table { width: 90%; margin: auto; border-top: 1px solid #e8e8e8; margin-bottom: 16px; table-layout: fixed; tr td { border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; min-height: 100px; &:first-child { border-left: unset; } &:nth-child(2n + 1) { background: #fafafa; width: 170px; } &.upload-td { background: #fafafa; width: 170px !important; } &.upload-time-td { background: #fafafa; width: 200px !important; } &.ant-form-item-check { width: 194px !important; } .ant-form-item { margin-bottom: unset !important; padding: 5px; .ant-form-item-label { width: 170px; padding-bottom: 1px; text-align: center; background-color: #fafafa; } } &::v-deep(label) { display: block; margin: 0 auto; text-align: right; white-space: normal; line-height: 20px; padding: 0 5px; } .ant-form-item-prompt { display: block; margin: 0 auto; text-align: right; white-space: normal; line-height: 20px; padding: 0 14px 0 5px; font-size: 16px; color: rgba(0, 0, 0, 0.85); } .prompt-red { color: #f5222d !important; } .ant-form-item-radio { &::v-deep(label) { display: inline !important; } } &::v-deep(.ant-checkbox + span) { padding-right: 0 !important; } } ::v-deep(.ant-form-item-control-wrapper) { min-height: 40px; } } .ant-form-long-label { tr td { &:nth-child(2n + 1) { // width: 200px !important; } } } .ant-collapse { border-top: 1px solid #d9d9d9; border-bottom: unset; border-left: unset; border-right: unset; width: 90%; margin: auto; & > .ant-collapse-item { border-bottom: unset; /*& > .ant-collapse-content{*/ /* border-top: 1px solid #d9d9d9;*/ /* border-bottom: 1px solid #d9d9d9;*/ /* border-radius: 4px;*/ /*}*/ &::v-deep(.ant-collapse-content) { border-top: unset; } } } .textarea-wrapper { position: relative; display: block; .m-textarea { padding: 8px 12px; height: 100%; } .m-count { color: #808080; background: #fff; position: absolute; font-size: 12px; bottom: 12px; right: 12px; line-height: 16px; } } .ant-spin-loading { width: 100vw; height: 100vh; display: block; background-color: rgba(0, 0, 0, 0.5); position: fixed; top: 0; left: 0; z-index: 99; } .apply-block { display: flex; align-items: center; .dynamic-delete-button { cursor: pointer; position: relative; font-size: 24px; color: #999; transition: all 0.3s; } .dynamic-delete-button:hover { color: #777; } .dynamic-delete-button[disabled] { cursor: not-allowed; opacity: 0.5; } div { flex: 1; } } .btn-group { display: flex; align-items: center; justify-content: right; width: 90%; margin: 0 auto 20px; button { margin-left: 10px; } } .ant-form-budget-border { border-bottom: 1px solid #d9d9d9; margin-left: -1px; } .budget-box { height: 100%; overflow: hidden; display: flex; flex: 1; flex-direction: column; } .budget-record { width: 100%; height: 100%; overflow: auto; display: flex; justify-content: center; background: #fff; } .budget-record-table { width: 90%; //调整页面表格宽度 // min-width: 840px; padding: 16px; } .budget-record-table-title { margin-bottom: 20px; text-align: center; white-space: pre-wrap; } .header_sd-header_common.ant-layout-header { padding: 0 20px 0 20px; color: #fff; background-image: linear-gradient(90deg, #1890ff 0%, #0162eb 100%); height: 64px; line-height: 64px; } .header_sd-header_common { z-index: 1; } .ant-layout-header { background: #001529; } .ant-layout-header, .ant-layout-footer { flex: 0 0 auto; } header { display: block; } .ant-layout, .ant-layout * { box-sizing: border-box; } .left_sd-header_common { float: left; height: 100%; } .right_sd-header_common { float: right; height: 100%; } .logo_sd-webflow_webflow h3 { color: #fff; } .header_sd-header_common .ant-btn-link { color: #fff; } .button_sd-webflow-button_webflow { max-width: 100%; } </style> 检查代码,针对分值上限设置的校验规则并未生效,请检查代码并修改
最新发布
07-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值