当前位置: 首页 > news >正文

图解asp.net网站开发实战价格对比网站开发

图解asp.net网站开发实战,价格对比网站开发,深圳市住房和建设局官网站,政务微网站建设方案项目为vue3elementPlus开发的项目 业务要求:table表格展示数据,其中有一行是ip地址可展示可修改,此处要求增加自定义校验规则 先看一下效果: 此处先描述一下,问题出在了哪里,我将el-table的data,使用一个…

项目为vue3+elementPlus开发的项目

业务要求:table表格展示数据,其中有一行是ip地址可展示可修改,此处要求增加自定义校验规则

先看一下效果:

此处先描述一下,问题出在了哪里,我将el-table的data,使用一个ref数组存储,表格校验使用了一个对象存储,导致,校验的时候拿不到数据,代码如下

<template>
<el-form ref="ruleFormRef" :model="form" :rules="probeIpFormRules">
<el-table:data="tableData"empty-text="暂无数据"height="calc(100% - 40px)":border="true"style="width: 100%"v-loading="loading"element-loading-background="rgba(255, 255, 255, 0.5)"><el-table-column type="index" label="序号" width="60" /><el-table-column prop="portName" min-width="190" label="端口号" /><el-table-column prop="probeIp" min-width="160" label="探针IP"><template #default="{ row, $index }"><el-form-item :prop="`tableData[${$index}].probeIp`" :rules="probeIpFormRules.probeIp"><el-input class="probeIp-style" v-model.trim="row.probeIp" autocomplete="off" clearable /></el-form-item></template></el-table-column></el-table></el-form>
</template>
<script setup lang="ts">const  probeIpFormRules= {probeIp: [{ required: false, message: '请输入ip地址', trigger: 'change' }, { validator: checkIp }],}
const tableData=ref([])
</script>

以下是正确代码,就是将tableData和probeIpFormRules放到同一个对象里

<template><el-dialogtitle="设置交换机端口"v-model="dialogVisible":close-on-click-modal="false":close-on-press-escape="false"draggablewidth="90%"@closed="handleClose"><el-form ref="ruleFormRef" :model="form" :rules="form.probeIpFormRules"><div class="box-warp"><div class="hd-header"><span>交换机ip: {{ switchIp }}</span><div class="hd-btn"><el-button type="primary" @click="handleSave(ruleFormRef)" :loading="btnLoading">保存</el-button><el-button @click="handleClose">关闭</el-button></div></div><el-table:data="form.tableData"empty-text="暂无数据"height="calc(100% - 40px)":border="true"style="width: 100%"v-loading="loading"element-loading-background="rgba(255, 255, 255, 0.5)"><el-table-column type="index" label="序号" width="60" /><el-table-column prop="portName" min-width="190" label="端口号" /><el-table-column prop="portDes" min-width="200" label="端口描述" /><el-table-column prop="portRunningStatus" min-width="90"><template #header><el-tooltip :visible="tooltipVisible" placement="top"><template #content><span>端口状态改变后请等待1分钟刷新查看</span></template><div class="status-style" @mouseenter="tooltipVisible = true" @mouseleave="tooltipVisible = false"><span>当前端口状态</span><el-icon><QuestionFilled /></el-icon></div></el-tooltip></template><template #default="{ row }"><el-tag :type="showStatus(row.portRunningStatus)">{{ filterStatus(row.portRunningStatus) }}</el-tag></template></el-table-column><el-table-column prop="nominalBandwidth" min-width="100" label="额定带宽(Mb)"><template #default="{ row }"><el-input-numberv-model="row.nominalBandwidth":controls="false":step="1":min="0":max="9999":precision="0"style="width: 100%"/></template></el-table-column><el-table-column prop="probeName" min-width="190" label="探针名称"><template #default="{ row }"><el-input v-model.trim="row.probeName" maxlength="30" autocomplete="off" /></template></el-table-column><el-table-column prop="probeIp" min-width="160" label="探针IP"><template #default="{ row, $index }"><el-form-item :prop="`tableData[${$index}].probeIp`" :rules="form.probeIpFormRules.probeIp"><el-input class="probeIp-style" v-model.trim="row.probeIp" autocomplete="off" clearable /></el-form-item></template></el-table-column><el-table-column label="端口操作" fixed="right" width="140"><template #default="{ row }"><el-switchv-model="row.portChangeStatus":active-value="1":inactive-value="2"active-text="ON"inactive-text="OFF"inline-promptstyle="--el-switch-on-color: #13ce66; --el-switch-off-color: #f56c6c"@change="changevisible"/></template></el-table-column></el-table></div></el-form></el-dialog>
</template>
<script setup lang="ts">
import { getPortByIp, savePort } from '@/api/switchModule'
import { validIpC } from '@/utils/validate.js'
const tooltipVisible = ref(false)
const ruleFormRef = ref()
/*** 状态显示*/
const changevisible = () => {tooltipVisible.value = trueconst timer = setTimeout(() => {tooltipVisible.value = falseclearTimeout(timer)}, 1000)
}
//校验子网地址格式
const checkIp = (rule: any, value: any, callback: any) => {if (value?.trim().length === 0) {callback(new Error('请输入ip地址'))} else if (value && !validIpC(value?.trim())) {callback(new Error('请输入正确格式的ip地址'))} else {callback()}
}const dialogVisible = ref(false)
/*** 关闭弹窗*/
const handleClose = () => {dialogVisible.value = false
}
const portStatus: Record<string, { label: string; color: 'success' | 'danger' }> = {'1': {label: '开启',color: 'success',},'2': {label: '关闭',color: 'danger',},
}
const filterStatus = (status: number) => {return portStatus[String(status)].label
}
const showStatus = (status: number) => {return portStatus[String(status)].color
}const switchIp = ref('')
const btnLoading = ref(false)
const form = ref({tableData: [],probeIpFormRules: {probeIp: [{ required: false, message: '请输入ip地址', trigger: 'change' }, { validator: checkIp }],},
})const handleSave = async (formEl: any) => {if (!formEl) returnformEl.validate(async (valid: any) => {if (!valid) returnElMessageBox.confirm('确定提交端口信息吗?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning',}).then(async () => {btnLoading.value = truetry {const params = {switchIp: switchIp.value,resSwitchPortEntities: form.value.tableData,}console.log('请求保存的参数是==》', params)const { code, data } = await savePort(params)console.log('保存的数值为=》', code, data)dialogVisible.value = false} catch (error) {console.log('保存失败==》', error)} finally {btnLoading.value = false}})})
}
/*** 查询数据* @param switchIp*/
const queryList = async (switchIp: string) => {loading.value = truetry {const { code, data } = await getPortByIp({ switchIp })if (code !== 200 || data.resSwitchPortEntities.length === 0) returnform.value.tableData = data.resSwitchPortEntities} catch (error) {console.log('错误==》', error)} finally {loading.value = false}
}const openDialog = (ip: string) => {switchIp.value = ip//通过ip请求数据queryList(ip)dialogVisible.value = true
}
defineExpose({openDialog,
})
// 搜索对象
const searchForm = reactive({pageNum: 1,pageSize: 100,total: 0,
})
// 表格数据
const loading: Ref<boolean> = ref(false)
</script><style lang="scss" scoped>
.box-warp {height: 70vh;:deep(.el-input__wrapper) {box-shadow: 0 0 0 0px;}.hd-header {display: flex;justify-content: space-between;// margin-top: -20px;margin-bottom: 20px;}.probeIp-style{margin-top: 18px ;}.status-style {display: flex;align-items: center;justify-content: center;}
}
</style>

最终样式如下

Ï

http://www.sczhlp.com/news/150985/

相关文章:

  • 旅游网站哪个做的好全栈网站开发者
  • 网站建设如何建百度收录什么网站
  • 长春建站怎么做动漫设计专升本
  • 天津企航网络技术有限公司自学网站建设和seo
  • 域名备案需要哪些资料宁波seo关键词优化案例
  • 旅游海外推广网站建设方案用网站模板建站
  • 2025广州1688代运营服务商推荐排行榜,阿里巴巴全店,实力商家,店铺装修,产品推广,流量优化,国际站,新店起量,数据分析,爆款打造代运营公司推荐
  • 2025 海南财税公司最新推荐榜:三亚海口代理记账 / 税务合规服务机构权威解析海南代理财税/海南财税代理/海南注册公司财税/海南代理记账财税公司推荐
  • 2025 年 TM 芯片经销商最新推荐榜:聚焦规模化采购与敏捷物流, 实力解析
  • 2025 天微芯片经销商最新推荐榜:品牌实力测评与采购指南 —— 权威揭秘优质服务商选择标准
  • 新余做网站公司wordpress适配熊掌号
  • 宿迁商城网站建设手机端h5
  • 手机网站活动策划方案百度风云排行榜官网
  • 基本的网站开发技术路线做网站学哪种代码好
  • 浙江建设信息港网站查询贵州建筑人才网
  • 上海易雅达网站建设公司管理手机网站
  • 自已建网站徐州网站建设哪家好
  • 建立网站需要多少人网络服务机构的域名
  • 中山外贸营销网站建设哪些网做网站比较好
  • 自己做网站能赚钱吗app下载导航
  • 网站建设图片流程图创意设计是什么
  • 读人形机器人27太空中
  • 2025 年酒店一次性用品源头厂家最新推荐榜单:含牙签牙线筷子套杯盖等全品类及采购选择指南酒店一次性牙签/牙线/筷子套/杯盖/杯垫/杯套用品 厂家推荐
  • 2025 年餐饮一次性用品实力厂家最新推荐榜单:覆盖牙签 / 牙线 / 筷子套 / 杯盖 / 杯垫多品类且资质口碑双优的标杆企业权威甄选
  • 龙之向导免费网站英语机构网站建设方案
  • 安康做网站的公司电话电脑网页打不开
  • ps做游戏下载网站有哪些内容做网站与网店运营
  • 品牌创意网站建设网站怎样做推广
  • 一个营业执照可以做两个网站设计开发计划书
  • 学校网站建设的意义如何开网站详细步骤图