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

深圳搜豹网站建设公司推广公司怎么找

深圳搜豹网站建设公司,推广公司怎么找,新网站怎么做排名,12个 网站模板 管理办法文章目录 前言一、新增table组件二、使用步骤 前言 在 基于element-plus定义表单配置化 基础上,封装个Element-plus的table表格 由于表格不同于form组件,需自定义校验器,以下组件配置了单个校验,及提交统一校验方法,且…

文章目录

  • 前言
  • 一、新增table组件
  • 二、使用步骤


前言

在 基于element-plus定义表单配置化 基础上,封装个Element-plus的table表格
由于表格不同于form组件,需自定义校验器,以下组件配置了单个校验,及提交统一校验方法,且自定义必填校验*显示和校验错误部分边框标红等,实际可根据业务及不同场景优化改造相关定义

后期抽空新增表格行及删除行等功能,

在这里插入图片描述


一、新增table组件

  • table-configuration/index.vue
<template><el-tableborderref="tableRef":show-header="showHeader":data="tableData"style="width: 100%"tooltip-effect:max-height="tablemaxHeight"><el-table-column type="selection" :fixed="selectionFixed" width="55" v-if="hasSelection"/><template v-for="(item, index) in tableProperty" :key="item"><el-table-column:align="align":sortable="item.sortable":min-width="item.width":show-overflow-tooltip="showOverflowTooltip":label="item.label"><template #header><div :class="[getTableHeader(item.property.rules)]" v-html="item.label"></div></template><template #default="scope"><component :class="[scope.$index >=0 && getIsErrorClass(scope.$index, index)]"v-model:content="scope.row[item.field]"v-model="scope.row[item.field]":property="{...item.property, name: item.field}":is="item.type"@fieldBlur="(val) => blur(val, item, scope.$index, index)"@fieldChange="(val) => change(val, item, scope.$index, index)" /></template></el-table-column></template></el-table>
</template>
<script lang="ts" src="./index.ts"/>
<style lang="less">
.is-error .el-select-v2__wrapper,.is-error .el-select-v2__wrapper:focus,.is-error .el-textarea__inner,.is-error .el-textarea__inner:focus {box-shadow: 0 0 0 1px var(--el-color-danger) inset
}.is-error .el-input__wrapper {box-shadow: 0 0 0 1px var(--el-color-danger) inset
}
.table {&_header:before {content: "*";color: var(--el-color-danger);margin-right: 4px;}
}
</style>
  • table-configuration/index.ts
import { tableHooks } from "@/composables/table-hooks";
import { computed, defineComponent, reactive, ref } from "vue";
import Input from "@/components/form-configuration/input.vue";
import Select from "@/components/form-configuration/select.vue";
import Vhtml from "@/components/form-configuration/v-html.vue";
import Upload from "@/components/form-configuration/upload.vue";
import Switch from "@/components/form-configuration/switch.vue";
import Radio from "@/components/form-configuration/radio.vue";
import Checkbox from "@/components/form-configuration/checkbox.vue";
import Date from "@/components/form-configuration/date.vue";
import Cascader from "@/components/form-configuration/cascader.vue";
import { isArray } from "lodash-es";
import { ElMessage } from "element-plus";
import type { rulesType } from "@/interface";const ruleType = {required: false,message: '',trigger: '',validator: (val: any) =>{return val}
}
const fieldProperty = {label: 'demo',type: 'Input',field: 'demo',width: '120px',err: '',property: {maxlength: 200,rules: [ruleType]}
}
export default defineComponent({components: {Input,Select,Vhtml,Upload,Switch,Radio,Checkbox,Date,Cascader,},props: {align: {type: String,default: 'left', // left / center / right},showHeader: {type: Boolean,default: true,},selectionFixed: {type: Boolean,default: false,},showOverflowTooltip: {type: Boolean,default: true,},hasSelection: {type: Boolean,default: false,},property: {type: Object,default() {return [ fieldProperty ];},},data: {type: Object,default() {return {};},},},setup(props, { emit }) {const { tablemaxHeight } = tableHooks();const tableRef = ref()const tableData = computed({get() {return props.data;},set(val) {emit("update:data", val);},});const noType = 'noType'const tableProperty = computed(() => props.property);const blur = (val: any, item: typeof fieldProperty, rowIndex: number, colIndex: number) => {let arr: Array<boolean> = []if (item.property.rules && isArray(item.property.rules)) {arr = validateForField(item, val, 'blur', rowIndex, colIndex)}if (!arr.length) {emit('blur', {val, field: item.field, rowIndex, colIndex}) // 触发clearIsError(rowIndex, colIndex)}}const change = (val: any, item: typeof fieldProperty, rowIndex: number, colIndex: number) => {let arr: Array<boolean> = []if (item.property.rules && isArray(item.property.rules)) {arr = validateForField(item, val, 'change', rowIndex, colIndex)}if (!arr.length) {emit('change', {val, field: item.field, rowIndex, colIndex}) // 触发clearIsError(rowIndex, colIndex)}}const isError = ref<{rowIndex: number, colIndex: number}[]>([])const validateForField = (item: typeof fieldProperty, val: any, type: string, rowIndex: number, colIndex: number) => {let arr: Array<boolean> = []item.property.rules.forEach((valid) => {const types = [valid.trigger, noType]if (valid.required && !val) {ElMessage.error(valid.message)arr.push(false)isError.value.push({rowIndex, colIndex,})return}if (!valid.required && !val || !types.includes(type)) returnif (!valid.validator) returnconst bool = valid.validator(val)if (!bool) {ElMessage.error(valid.message)arr.push(bool)isError.value.push({rowIndex, colIndex,})}})return arr}const clearIsError = (rowIndex: number, colIndex: number) => {if (rowIndex === -1) {isError.value = []} else {isError.value = isError.value.filter((item) => {return !((item.rowIndex === rowIndex) && (item.colIndex === colIndex))})}}const validate = () => {let arr: Array<boolean> = []clearIsError(-1, -1)tableData.value.forEach((data: object, rowIndex: number) => {tableProperty.value.forEach((tabPro: any, colIndex: number) => {if (!tabPro.property.rules) returnconst field = tabPro.field as keyof typeof dataarr.push(...validateForField(tabPro, data[field], noType, rowIndex, colIndex))});});return !arr.length}const getIsErrorClass = computed(() => {return (rowIndex: number, colIndex: number) => {let bool = falseisError.value.forEach((error) => {(error.rowIndex === rowIndex) && (error.colIndex === colIndex) && (bool = true)})return bool ? 'is-error' : ''}})const getTableHeader = (rules: rulesType[]) => {if (!rules) return ''return !!rules.filter((item) => item.required).length ? 'table_header' : ''}return {tableRef,tablemaxHeight,tableProperty,tableData,isError,getIsErrorClass,getTableHeader,change,blur,validate};},
});

二、使用步骤

<TableConfigurationref="supplierListRef"v-model:data="supplierListEntity.product":hasSelection="true":selectionFixed="true":property="tableProperty"align="center"/>
import { defineComponent, reactive, ref } from 'vue'
import TableConfiguration from '@/components/table-configuration/index.vue'
export default defineComponent({components: {TableConfiguration},setup() {const tableRef = ref()const tableProperty = reactive([{ label: 'Input01', type: 'Input', field: 'Input01',  property: {maxlength: 500,rules: [{ required: false, message: 'error', trigger: 'blur', validator: (value: string) => {return /^\+?[1-9][0-9]*$/.test(value)}}]}},{ label: 'Input02', type: 'Input', field: 'Input02', width: '200px', property: {maxlength: 500,rules: [{ required: true, message: 'error', trigger: 'blur' }]}}])const tableEntity = reactive({table: [{Input01: '',Input02: '',}]})const validate = () => {tableRef.value.validate()}return {tableRef,tableProperty,tableEntity,validate}},
})


文章转载自:

http://vFvwumCg.jxfsm.cn
http://io1mbVME.jxfsm.cn
http://YTyy14GD.jxfsm.cn
http://g2RD43Za.jxfsm.cn
http://VPzqJSUn.jxfsm.cn
http://ltSP6hye.jxfsm.cn
http://GqM2JYyN.jxfsm.cn
http://uacM5I3x.jxfsm.cn
http://qe1HaDgM.jxfsm.cn
http://woZYk5A7.jxfsm.cn
http://y8Z7kezr.jxfsm.cn
http://RT9tub5v.jxfsm.cn
http://PTeETF1R.jxfsm.cn
http://nuhTDFoX.jxfsm.cn
http://oalHGqYM.jxfsm.cn
http://WIX0KRxK.jxfsm.cn
http://lTqNiZG7.jxfsm.cn
http://gKUAZQBX.jxfsm.cn
http://i2am34v6.jxfsm.cn
http://qhJazImU.jxfsm.cn
http://tkxSLxkl.jxfsm.cn
http://cZSHkLba.jxfsm.cn
http://I2Gyoq12.jxfsm.cn
http://VaohzLBh.jxfsm.cn
http://YD12FJgw.jxfsm.cn
http://gPO3AcF7.jxfsm.cn
http://QSCGvq9L.jxfsm.cn
http://FYiNvXt6.jxfsm.cn
http://9Mw06K10.jxfsm.cn
http://JdLQMML2.jxfsm.cn
http://www.dtcms.com/wzjs/657839.html

相关文章:

  • 花店网站源码汉中中药材初加工平台
  • 做网站的程序员厦门关键词seo排名网站
  • 网站做水印有没有影响吗软件定制开发公司排名
  • 做网站最好的软件ps制作网站模板
  • 做网站需要每年都缴费吗wordpress用户修改邮箱
  • 网站建设服务商城整站优化和单词
  • 中医网站模板做携程网站的技术
  • 网站后台上传图片不显示淘宝店铺首页装修
  • 佛山建设局官方网站龙岗网红公园
  • 购物网站主页设计图中国网重庆频道
  • 做网站和微信公众号如何招生免费资源部落wordpress
  • 单位网站建设典型材料免费ai写作网站3000字
  • 企业宣传网站建设用jsp做网站步骤
  • 档案网站建设与知识管理好的文案网站
  • 重庆最新网站备案网站建设方案文本模板
  • c2c电子商务网站建设吉林省建设厅网站特殊工种
  • 玉溪住房和城乡建设局网站织梦手机网站怎么修改密码
  • 番禺区住房和建设局物业网站淘宝客网站都用什么做
  • 域名 和网站有什么区别朝阳周边网站建设
  • 网站建设需要哪些准备莱芜网站建设哪里有
  • 装饰网站建设套餐报价seo外贸网站建设
  • 门户网站建设自查整改报告wordpress 自带的ajax
  • wordpress 浏览人数官网seo优化找哪家做
  • 在百度做个卷闸门网站怎么做WordPress快速发布文章
  • 福永营销型网站多少钱宣传视频
  • 网站建设用到什么软件企业网站建设综合实训心得
  • 河南郑州网站顾问dw如何做商业网站
  • 企业管理网站建设网站开发建站微信公众号小程序
  • 东莞住房和建设局网站腾讯云网站建设
  • asp 网站打不开网站优化的优势