diff --git a/.env.development b/.env.development index 17b3bbde2..78976cddd 100644 --- a/.env.development +++ b/.env.development @@ -32,3 +32,6 @@ VITE_OUT_DIR=dist # 自定义接口路径 VITE_INTERFACE_URL='http://localhost:12080/magic/web/index.html' + +# 积木报表请求路径 +VITE_JMREPORT_BASE_URL='http://localhost:12080' \ No newline at end of file diff --git a/.env.production b/.env.production index 9937520a0..8e25d2385 100644 --- a/.env.production +++ b/.env.production @@ -29,3 +29,6 @@ VITE_BASE_PATH=/ # 输出路径 VITE_OUT_DIR=dist-pro + +# 积木报表请求路径 +VITE_JMREPORT_BASE_URL='http://dev.ccwin-in.com:25110' diff --git a/.env.test b/.env.test index 3d5028e29..84edcdfe7 100644 --- a/.env.test +++ b/.env.test @@ -4,10 +4,10 @@ NODE_ENV=test VITE_DEV=false # 请求路径 -VITE_BASE_URL='http://dev.ccwin-in.com:25110' +VITE_BASE_URL='http://dev.ccwin-in.com:25100/api' # 上传路径 -VITE_UPLOAD_URL='http://dev.ccwin-in.com:25110/admin-api/infra/file/upload' +VITE_UPLOAD_URL='http://dev.ccwin-in.com:25100/api/admin-api/infra/file/upload' # 接口前缀 VITE_API_BASEPATH= @@ -32,3 +32,6 @@ VITE_OUT_DIR=dist-test # 自定义接口路径 VITE_INTERFACE_URL='http://dev.ccwin-in.com:25110/magic/web/index.html' + +# 积木报表请求路径 +VITE_JMREPORT_BASE_URL='http://dev.ccwin-in.com:25110' diff --git a/src/components/BasicForm/src/BasicForm.vue b/src/components/BasicForm/src/BasicForm.vue index 3c81d3812..92820031e 100644 --- a/src/components/BasicForm/src/BasicForm.vue +++ b/src/components/BasicForm/src/BasicForm.vue @@ -1,6 +1,22 @@ @@ -295,11 +320,10 @@ const emit = defineEmits([ 'extendedButtonsClick', 'formSelectChange', 'tableSortChange', - 'showDrawer', 'selectCallback', 'handleTableSelect', - 'handleDelete', - 'handleAdd', + 'handleDeleteTable', + 'handleAddTable', 'inpuFocus' ]) // 获取下拉列表 | type = radio | type = select @@ -319,9 +343,9 @@ const tableSortChange = (column, prop, order) => { emit('tableSortChange', column, prop, order) } //下拉框回显方法 -const showSelect = (val, statusID) => { - return getDictForStatusID(val, statusID) -} +// const showSelect = (val, statusID) => { +// return getDictForStatusID(val, statusID) +// } // 行点击 const handleTableSelect = (row, column, event) => { @@ -342,33 +366,27 @@ const TableBaseForm_Ref = ref() * @param {*} error 如果验证【不成功】走的方法 */ -const $baseMessage = inject('$baseMessage') -const validateForm = (success, error) => { +const validateForm = async () => { let _lists = TableBaseForm_Ref.value.map(v => v.validate()) - Promise.all(_lists).then(res => { - if (success) success() + return Promise.all(_lists).then(res => { + return true }).catch(err => { - if (error) { - error() - return - } - $baseMessage('验证未通过,请按规则填写', 'error', 'vab-hey-message-error') + return false }) } // 删除数据 -const handleDelete = (row, index) => { - console.log(row); - console.log(index); - emit('handleDelete', row) +const handleDeleteTable = (row, index) => { + emit('handleDeleteTable', row) } // 添加数据 -const handleAdd = () => { - emit('handleAdd') +const handleAddTable = () => { + emit('handleAddTable') } // 输入框聚焦 const inpuFocus = (headerItem)=>{ - if(headerItem.isInpuFocusShow){ - emit('inpuFocus') + + if(headerItem?.tableForm?.isInpuFocusShow){ + emit('inpuFocus') } } // setup 语法糖 抛出方法 @@ -376,6 +394,7 @@ defineExpose({ TableBaseComponents_Ref, validateForm }) + @@ -388,10 +407,12 @@ defineExpose({ border: none; } -::v-deep(.el-table td.el-table__cell div) { +::v-deep(.el-table td.el-table__cell .el-form-item__content) { display: flex !important; align-items: center !important; justify-content: center !important; +} +::v-deep(.el-table td.el-table__cell div) { overflow: visible; } diff --git a/src/utils/disposition/tableColumns.ts b/src/utils/disposition/tableColumns.ts index 5b9cf5061..797925f82 100644 --- a/src/utils/disposition/tableColumns.ts +++ b/src/utils/disposition/tableColumns.ts @@ -1,5 +1,6 @@ import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' +import { validateTwoNum } from "@/utils/validator"; /** * @returns {Array} 基础物料信息 */ @@ -3280,10 +3281,10 @@ export const Owner = useCrudSchemas(reactive([ //表单校验 export const OwnerRules = reactive({ code: [ - { required: true, message: '请选择代码', trigger: 'blur' } + { required: true, message: '请输入代码', trigger: 'blur' } ], shortName: [ - { required: true, message: '请选择简称', trigger: 'blur' } + { required: true, message: '请输入简称', trigger: 'blur' } ], available: [ { required: true, message: '请选择是否可用', trigger: 'change' } @@ -3415,10 +3416,10 @@ export const Carrier = useCrudSchemas(reactive([ //表单校验 export const CarrierRules = reactive({ code: [ - { required: true, message: '请选择代码', trigger: 'blur' } + { required: true, message: '请输入代码', trigger: 'blur' } ], shortName: [ - { required: true, message: '请选择简称', trigger: 'blur' } + { required: true, message: '请输入简称', trigger: 'blur' } ], available: [ { required: true, message: '请选择是否可用', trigger: 'change' } @@ -3460,7 +3461,8 @@ export const Shift = useCrudSchemas(reactive([ field: 'endAtNextDay', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', - isTable: true + isTable: true, + isSearch: true }, { label: '是否可用', @@ -3519,13 +3521,13 @@ export const Shift = useCrudSchemas(reactive([ //表单校验 export const ShiftRules = reactive({ code: [ - { required: true, message: '请选择代码', trigger: 'blur' } + { required: true, message: '请输入代码', trigger: 'blur' } ], beginTime: [ - { required: true, message: '请选择开始时间', trigger: 'blur' } + { required: true, message: '请输入开始时间', trigger: 'blur' } ], entTime: [ - { required: true, message: '请选择结束时间', trigger: 'blur' } + { required: true, message: '请输入结束时间', trigger: 'blur' } ], endAtNextDay: [ { required: true, message: '请选择是否跨天', trigger: 'change' } @@ -3608,7 +3610,7 @@ export const Team = useCrudSchemas(reactive([ //表单校验 export const TeamRules = reactive({ code: [ - { required: true, message: '请选择代码', trigger: 'blur' } + { required: true, message: '请输入代码', trigger: 'blur' } ], available: [ { required: true, message: '请选择是否可用', trigger: 'change' } @@ -3666,9 +3668,31 @@ export const Strategy = useCrudSchemas(reactive([ { label: '创建者', field: 'creator' + }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } } ])) +//表单校验 +export const StrategyRules = reactive({ + code: [ + { required: true, message: '请输入代码', trigger: 'blur' } + ], + priority: [ + { required: true, message: '请输入优先级', trigger: 'blur' } + ], + type: [ + { required: true, message: '请选择类型', trigger: 'change' } + ], +}) + /** * @returns {Array} 规则 */ @@ -3696,9 +3720,34 @@ export const Rule = useCrudSchemas(reactive([ { label: '配置', field: 'configuration' + }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } } ])) +//表单校验 +export const RuleRules = reactive({ + strategyCode: [ + { required: true, message: '请输入策略代码', trigger: 'blur' } + ], + priority: [ + { required: true, message: '请输入优先级', trigger: 'blur' } + ], + code: [ + { required: true, message: '请输入代码', trigger: 'blur' } + ], + configuration: [ + { required: true, message: '请输入配置', trigger: 'blur' } + ], +}) + /** * @returns {Array} 条件 */ @@ -3730,9 +3779,37 @@ export const Condition = useCrudSchemas(reactive([ { label: '条件分组', field: 'groupCode' + }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } } ])) +//表单校验 +export const ConditionRules = reactive({ + strategyCode: [ + { required: true, message: '请输入策略代码', trigger: 'blur' } + ], + ruleCode: [ + { required: true, message: '请输入规则代码', trigger: 'blur' } + ], + paramCode: [ + { required: true, message: '请输入参数', trigger: 'blur' } + ], + operator: [ + { required: true, message: '请选择操作符', trigger: 'change' } + ], + value: [ + { required: true, message: '请输入值', trigger: 'blur' } + ], +}) + /** * @returns {Array} 配置 */ @@ -3761,8 +3838,33 @@ export const Configuration = useCrudSchemas(reactive([ label: '配置分组', field: 'groupCode' }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } + } ])) +//表单校验 +export const ConfigurationRules = reactive({ + strategyCode: [ + { required: true, message: '请输入策略代码', trigger: 'blur' } + ], + ruleCode: [ + { required: true, message: '请输入规则代码', trigger: 'blur' } + ], + configurationCode: [ + { required: true, message: '请输入配置名称', trigger: 'blur' } + ], + configurationValue: [ + { required: true, message: '请输入配置值', trigger: 'blur' } + ], +}) + /** * @returns {Array} 配置设置 */ @@ -3811,14 +3913,45 @@ export const Configurationsetting = useCrudSchemas(reactive([ isSearch: true, isTable: true }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } + } ])) +//表单校验 +export const ConfigurationsettingRules = reactive({ + strategyType: [ + { required: true, message: '请选择策略类型', trigger: 'change' } + ], + configurationCode: [ + { required: true, message: '请输入配置代码', trigger: 'blur' } + ], + configurationName: [ + { required: true, message: '请输入配置名称', trigger: 'blur' } + ], + isRequired: [ + { required: true, message: '请选择必填', trigger: 'change' } + ], + dataType: [ + { required: true, message: '请选择数据类型', trigger: 'change' } + ], + valueScope: [ + { required: true, message: '请输入值范围', trigger: 'blur' } + ], +}) + /** * @returns {Array} 参数设置 */ export const Paramsetting = useCrudSchemas(reactive([ { - label: '策略代码', + label: '策略类型', field: 'strategyType', dictType: DICT_TYPE.STRATEGY_TYPE, dictClass: 'string', @@ -3869,8 +4002,39 @@ export const Paramsetting = useCrudSchemas(reactive([ isSearch: true, isTable: true }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } + } ])) +//表单校验 +export const ParamsettingRules = reactive({ + strategyType: [ + { required: true, message: '请选择策略类型', trigger: 'change' } + ], + paramCode: [ + { required: true, message: '请输入参数代码', trigger: 'blur' } + ], + usableOpeartors: [ + { required: true, message: '请选择可用操作符', trigger: 'change' } + ], + isRequired: [ + { required: true, message: '请选择必填', trigger: 'change' } + ], + dataType: [ + { required: true, message: '请选择数据类型', trigger: 'change' } + ], + valueScope: [ + { required: true, message: '请输入值范围', trigger: 'blur' } + ], +}) + /** * @returns {Array} 事务类型 */ @@ -3958,8 +4122,33 @@ export const Transactiontype = useCrudSchemas(reactive([ isTable: false, isForm: false }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } + } ])) +//表单校验 +export const TransactiontypeRules = reactive({ + code: [ + { required: true, message: '请输入代码', trigger: 'blur' } + ], + name: [ + { required: true, message: '请输入名称', trigger: 'blur' } + ], + inventoryAction: [ + { required: true, message: '请选择库存动作', trigger: 'change' } + ], + allowNegative: [ + { required: true, message: '请选择允许复数', trigger: 'change' } + ], +}) + /** * @returns {Array} 业务类型 */ @@ -4107,8 +4296,42 @@ export const Businesstype = useCrudSchemas(reactive([ isTable: true, isSearch: true }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } + } ])) +//表单校验 +export const BusinesstypeRules = reactive({ + code: [ + { required: true, message: '请输入代码', trigger: 'blur' } + ], + name: [ + { required: true, message: '请输入名称', trigger: 'blur' } + ], + itemTypes: [ + { required: true, message: '请选择可用物品类型范围', trigger: 'change' } + ], + itemStatuses: [ + { required: true, message: '请选择可用物品状态范围', trigger: 'change' } + ], + outTransactionType: [ + { required: true, message: '请输入出库事务类型', trigger: 'blur' } + ], + inTransactionType: [ + { required: true, message: '请输入入库事务类型', trigger: 'blur' } + ], + useOnTheWay: [ + { required: true, message: '请输入代码', trigger: 'blur' } + ], +}) + /** * @returns {Array} 单据设置 */ @@ -4216,8 +4439,45 @@ export const Documentsetting = useCrudSchemas(reactive([ isTable: true, isSearch: true }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } + } ])) +//表单校验 +export const DocumentsettingRules = reactive({ + code: [ + { required: true, message: '请输入代码', trigger: 'blur' } + ], + name: [ + { required: true, message: '请输入名称', trigger: 'blur' } + ], + type: [ + { required: true, message: '请选择单据类型', trigger: 'change' } + ], + businessType: [ + { required: true, message: '请输入业务类型', trigger: 'blur' } + ], + numberPrefix: [ + { required: true, message: '请输入号码前缀', trigger: 'blur' } + ], + dateFormat: [ + { required: true, message: '请输入号码时间格式', trigger: 'blur' } + ], + serialLength: [ + { required: true, message: '请输入号码流水长度', trigger: 'blur' } + ], + resetPeriod: [ + { required: true, message: '请选择流水重置周期', trigger: 'change' } + ], +}) + /** * @returns {Array} 申请设置 */ @@ -4321,8 +4581,39 @@ export const Requestsetting = useCrudSchemas(reactive([ isTable: false, isForm: false }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } + } ])) +//表单校验 +export const RequestsettingRules = reactive({ + code: [ + { required: true, message: '请输入代码', trigger: 'blur' } + ], + requestMode: [ + { required: true, message: '请选择申请模式', trigger: 'change' } + ], + autoCommit: [ + { required: true, message: '请选择是否自动提交', trigger: 'change' } + ], + autoAgree: [ + { required: true, message: '请选择是否自动通过', trigger: 'change' } + ], + autoExecute: [ + { required: true, message: '请选择是否自动执行', trigger: 'change' } + ], + directCreateRecord: [ + { required: true, message: '请选择是否跳过任务直接生成记录', trigger: 'change' } + ], +}) + /** * @returns {Array} 任务设置 */ @@ -4470,8 +4761,57 @@ export const Jobsetting = useCrudSchemas(reactive([ isTable: false, isForm: false }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } + } ])) +//表单校验 +export const JobsettingRules = reactive({ + code: [ + { required: true, message: '请输入代码', trigger: 'blur' } + ], + validMinutes: [ + { required: true, message: '请输入有效分钟', trigger: 'blur' } + ], + autoComplete: [ + { required: true, message: '请选择是否自动完成', trigger: 'change' } + ], + allowModifyLocation: [ + { required: true, message: '请选择是否允许修改库位', trigger: 'change' } + ], + allowModifyQty: [ + { required: true, message: '请选择是否允许修改数量', trigger: 'change' } + ], + allowBiggerQty: [ + { required: true, message: '请选择是否允许大于推荐数量', trigger: 'change' } + ], + allowSmallerQty: [ + { required: true, message: '请选择是否允许小于推荐数量', trigger: 'change' } + ], + allowModifyInventoryStatus: [ + { required: true, message: '请选择是否允许修改库存状态', trigger: 'change' } + ], + allowContinuousScanning: [ + { required: true, message: '请选择是否允许连续扫描', trigger: 'change' } + ], + allowPartialComplete: [ + { required: true, message: '请选择是否允许部分完成', trigger: 'change' } + ], + allowModifyBach: [ + { required: true, message: '请选择是否允许修改批次', trigger: 'change' } + ], + allowModifyPackingNumber: [ + { required: true, message: '请选择是否允许修改包装号', trigger: 'change' } + ], +}) + /** * @returns {Array} 记录设置 */ @@ -4543,8 +4883,27 @@ export const Recordsetting = useCrudSchemas(reactive([ isTable: true, isSearch: true }, + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false , + table: { + width: 150 + } + } ])) +//表单校验 +export const RecordsettingRules = reactive({ + code: [ + { required: true, message: '请输入代码', trigger: 'blur' } + ], + interfaceType: [ + { required: true, message: '请选择接口类型', trigger: 'change' } + ], +}) + /** * @returns {Array} 库位容量 */ diff --git a/src/utils/validator.ts b/src/utils/validator.ts new file mode 100644 index 000000000..0b805cb9b --- /dev/null +++ b/src/utils/validator.ts @@ -0,0 +1,760 @@ +//校验学校编码 只能为数字 +export function validateCode(rule, value, callback) { + if (!value) { + return callback(new Error('学校编码不能为空')) + } else { + const codeReg = /^[0-9]+$/ + const codeMax = /^\d{0,5}$/ + if (codeReg.test(value)) { + if (codeMax.test(value)) { + callback() + } else { + callback(new Error('学校编码不能大于5位')) + } + + } else { + callback(new Error('请输入正确的学校编码,只能是数字')) + } + } +} + +//校验邮箱 +export function validateEmail(rule, value, callback) { + if (value) { + const mailReg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/ + if (mailReg.test(value)) { + callback() + } else { + callback(new Error('请输入正确的邮箱格式')) + } + } else { + callback() + } +} + +//校验英文 +export function validateEng(rule, value, callback) { + if (value) { + const mailReg = /^[A-Za-z\-\&\(\)\Ⅰ\Ⅱ\Ⅲ\Ⅳ\Ⅴ\Ⅵ\Ⅶ\Ⅷ\Ⅸ\Ⅹ\s]+$/; + if (mailReg.test(value)) { + callback() + } else { + callback(new Error('请输入正确的英文名字')) + } + } else { + callback() + } +} + +//校验姓名拼音 +export function validateEngName(rule, value, callback) { + if (value) { + const EngNameReg = /^[A-Za-z \(\)\s]+$/ + if (EngNameReg.test(value)) { + callback() + } else { + callback(new Error('请输入正确的姓名拼音')) + } + } else { + callback() + } +} + +//校验手机号码 +export function validateHanset(rule, value, callback) { + if (value) { + // const regs =/^[1][3,4,5,6,7,8,9][0-9]{9}$/; + // const regs = /^1[3|4|5|7|8][0-9]\d{8}$/ + const regs = /^1[3-9]\d{9}$/ + if (regs.test(value)) { + callback() + } else { + return callback(new Error('请输入正确的手机号')) + } + } else { + callback() + } +} + +//校验座机电话 +export function validatePhone(rule, value, callback) { + if (value) { + //const reg = /^1[3|4|5|7|8][0-9]\d{8}$/ + // const regs = /^([0-9]{3,4}-)?[0-9]{7,8}$/; + const regs = /^((0\d{2,3}-\d{7,8}))$/; + if (regs.test(value)) { + callback() + } else { + return callback(new Error('请输入正确的座机号')) + } + } else { + callback() + } +} + +//校验家庭电话 手机或者座机 +export function validateFamilyPhone(rule, value, callback) { + if (value) { + const isPhone = /^([0-9]{3,4}-)?[0-9]{7,8}$/; + // const isMob = /^((\+?86)|(\+86))?(13[0123456789][0-9]{8}|15[0123456789][0-9]{8}|17[0123456789][0-9]{8}|18[0123456789][0-9]{8}|147[0-9]{8}|1349[0-9]{7})$/; + const isMob = /^1[3-9]\d{9}$/ + if (isPhone.test(value) || isMob.test(value)) { + callback() + } else { + return callback(new Error('请输入正确的手机或者座机电话')) + } + } else { + callback() + } +} + +// 校验只能为中文 +export function validateChinese(rule, value, callback) { + if (value) { + const chineseReg = /^[\u4E00-\u9FA5]+$/ + if (chineseReg.test(value)) { + callback() + } else { + callback(new Error('请输入简介,只能为中文')) + } + } else { + callback() + } +} + +// 校验名称既能为中文也可以为英文 +export function validateName(rule, value, callback) { + if (value) { + const chineseReg = /^[\u4E00-\u9FA5]+$/ + const engLish = /^[A-Za-z]+$/ + if (chineseReg.test(value) || engLish.test(value)) { + callback() + } else { + callback(new Error('请输入正确的中文或者英文名称')) + } + } else { + callback() + } +} + +// 校验负责人既能为中文也可以为英文 +export function validateChargeperson(rule, value, callback) { + if (value) { + const chineseReg = /^[\u4E00-\u9FA5]+$/ + const engLish = /^[A-Za-z]+$/ + if (chineseReg.test(value) || engLish.test(value)) { + callback() + } else { + callback(new Error('请输入正确的负责人(中英文都可以)')) + } + } else { + callback() + } +} + +//校验学校名称不能为空 +export function validateXXMC(rule, value, callback) { + if (!value) { + return callback(new Error('案例名称不能为空')) + } else { + const chineseReg = /^[\u4E00-\u9FA5]+$/ + if (chineseReg.test(value)) { + callback() + } else { + callback(new Error('请输入正确的案例名称,只能是汉字')) + } + } +} + +//校验中英文数字和下划线都可以 +export function validateZYS(rule, value, callback) { + if (value) { + //const postReg =/^[\u4e00-\u9fa5_a-zA-Z0-9_]{4,10}+$/ + const Reg = /^[\u4e00-\u9fa5a-zA-Z0-9]+$/ + if (Reg.test(value)) { + callback() + } else { + callback(new Error('请输入正确的名称')) + } + } else { + callback() + } +} + +// 校验邮政编码 +export function validatePostCode(rule, value, callback) { + if (value) { + const postReg = /^[1-9]\d{5}$/ + if (postReg.test(value)) { + callback() + } else { + callback(new Error('请输入正确的邮政编码')) + } + } else { + callback() + } +} + +// 数字 +export function validateNum(rule, value, callback) { + if (value) { + const numReg = /^[\d]+$/ + if (numReg.test(value)) { + callback() + } else { + callback(new Error('请输入数字')) + } + } else { + callback() + } +} + +//数字和小数点 +export function validateNumDot(rule, value, callback) { + if (value) { + const numReg = /^\d+$|^\d+\.\d+$/g + if (numReg.test(value)) { + callback() + } else { + callback(new Error('请输入数字或小数点')) + } + } else { + callback() + } +} + +// 组织机构代码 +export function validateOrganization(rule, value, callback) { + if (value) { + const orgReg = /^[A-Za-z0-9]\w{14}$/g + if (orgReg.test(value)) { + callback() + } else { + callback(new Error('请输入组织机构代码')) + } + } else { + callback() + } + +} + +// 传真 +export function validateFax(rule, value, callback) { + if (value) { + const faxReg = /^(\d{3,4}-)?\d{7,8}$/ + if (faxReg.test(value)) { + callback() + } else { + callback(new Error('请输入正确的传真')) + } + } else { + callback() + } +} + +// 主页地址 +export function validateHome(rule, value, callback) { + if (value) { + const homeReg = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\*\+,;=.]+$/ + if (homeReg.test(value)) { + callback() + } else { + return callback(new Error('请输入正确的主页地址')) + } + } else { + callback() + } +} + +// 学分 小数,且保留最多三位小数 +export function validateXf(rule, value, callback) { + if (!value) { + return callback(new Error('学分不能为空')) + } else { + const numReg = /^[0-9]+\.[0-9]{0,3}$/ + if (numReg.test(value)) { + callback() + } else { + callback(new Error('请输入小数,且小数点后最多三位')) + } + } +} + +// 数字格式 小数点后一位 +export function validateOneNum(rule, value, callback) { + if (value) { + const numReg = /^\d+(\.\d+)?$/ + const numOneReg = /^\d*\.{0,1}\d{0,1}$/ + if (numReg.test(value)) { + if (numOneReg.test(value)) { + callback() + } else { + callback(new Error('小数点后最多1位')) + } + } else { + callback(new Error('请输入数字')) + } + } + callback() +} + +// 数字格式 小数点后两位 +export function validateTwoNum(rule, value, callback) { + if (value) { + const numReg = /^\d+(\.\d+)?$/ + const numTwoReg = /^\d*\.{0,2}\d{0,2}$/ + if (numReg.test(value)) { + if (numTwoReg.test(value)) { + callback() + } else { + callback(new Error('小数点后最多2位')) + } + } else { + callback(new Error('请输入数字')) + } + } + callback() +} + + +// 数字格式 小数点后两位 小数点前保留五位 +export function validateTwoNumThree(rule, value, callback) { + if (value) { + if (Number(value) > 10000) {// 校验value值不能大于10000 + callback(new Error('数值过大,请重新输入')) + } + + const numReg = /^\d+(\.\d+)?$/ + const numTwoReg = /^\d*\.{0,2}\d{0,2}$/ + if (numReg.test(value)) { + if (numTwoReg.test(value)) { + callback() + } else { + callback(new Error('小数点后最多2位')) + } + } else { + callback(new Error('请输入数字')) + } + } + + callback() +} + +// 数字格式 小数点后三位 +export function validateThreeNum(rule, value, callback) { + if (value) { + const numReg = /^\d+(\.\d+)?$/ + const numTwoReg = /^\d*\.{0,3}\d{0,3}$/ + if (numReg.test(value)) { + if (numTwoReg.test(value)) { + callback() + } else { + callback(new Error('小数点后最多3位')) + } + } else { + callback(new Error('请输入数字')) + } + } + callback() + // if (!value) { + // return callback(new Error('字段不能为空')) + // } else { + // const numReg = /^\d+(\.\d+)?$/ + // const numTwoReg = /^\d*\.{0,3}\d{0,3}$/ + // if (numReg.test(value)) { + // if (numTwoReg.test(value)) { + // callback() + // } else { + // callback(new Error('小数点后最多3位')) + // } + // } else { + // callback(new Error('请输入数字')) + // } + // } +} + +//校验年份必须为4位数字 +export function validateNF(rule, value, callback) { + if (value) { + const NFReg = /^\d{4}$/ + if (NFReg.test(value)) { + callback() + } else { + callback(new Error('请输入4位数字')) + } + } else { + callback() + } +} + +//校验年份必须为4位数字 +export function validateXQ(rule, value, callback) { + if (value) { + const NFReg = /^\d{5}$/ + if (NFReg.test(value)) { + callback() + } else { + callback(new Error('请输入5位数字')) + } + } else { + callback() + } +} + +//校验分数最大值 +export function validateMaxNumber(rule, value, callback) { + if (parseInt(value) <= 200) { + callback() + } else { + callback(new Error('分数不能大于200')) + } + +} + +//校验正整数 +export function validateInteger(rule, value, callback) { + if (value) { + const integerReg = /^[+]{0,1}(\d+)$/ + if (integerReg.test(value)) { + callback() + } else { + callback(new Error('请输入正确的整数')) + } + } else { + callback() + } +} + +//校验整数 +export function validateroundNumber(rule, value, callback) { + if (value) { + const numReg = /^[1-9]\d*$/ + if (numReg.test(value)) { + callback() + } else { + callback(new Error('请输入正确的整数')) + } + } else { + callback() + } +} +//校验身份证号 +export function validateCard(rule, value, callback) { + if (value) { + const cardBoolean = IdCardValidate(value); + // const cardReg =/(^\d{18}$)|(^\d{17}(\d|X|x)$)/ + // if (cardReg.test(value)) { + if (cardBoolean) { + callback() + } else { + callback(new Error('请输入正确的身份证号')) + } + } else { + callback() + } +} + +//身份证:身份证校验 +function IdCardValidate(code) { + let tip = ""; + if (code != "") { + const city = { + 11: "北京", + 12: "天津", + 13: "河北", + 14: "山西", + 15: "内蒙古", + 21: "辽宁", + 22: "吉林", + 23: "黑龙江 ", + 31: "上海", + 32: "江苏", + 33: "浙江", + 34: "安徽", + 35: "福建", + 36: "江西", + 37: "山东", + 41: "河南", + 42: "湖北 ", + 43: "湖南", + 44: "广东", + 45: "广西", + 46: "海南", + 50: "重庆", + 51: "四川", + 52: "贵州", + 53: "云南", + 54: "西藏 ", + 61: "陕西", + 62: "甘肃", + 63: "青海", + 64: "宁夏", + 65: "新疆", + 71: "台湾", + 81: "香港", + 82: "澳门", + 91: "国外 " + }; + + let pass = true; + + //是否为空 + if (code === '') { + tip = "请输入身份证号,身份证号不能为空"; + pass = false; + } + //校验长度,类型 + else if (isCardNo(code) === false) { + tip = "您输入的身份证号码不正确,请重新输入"; + pass = false; + } + //检查省份 + else if (checkProvince(code, city) === false) { + tip = "您输入的身份证号码不正确,请重新输入"; + pass = false; + } + //校验生日 + else if (checkBirthday(code) === false) { + tip = "您输入的身份证号码生日不正确,请重新输入"; + pass = false; + } else { + //18位身份证需要验证最后一位校验位 + if (code.length == 18) { + code = code.split(''); + //∑(ai×Wi)(mod 11) + //加权因子 + const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]; + //校验位 + const parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2]; + let sum = 0; + let ai = 0; + let wi = 0; + for (let i = 0; i < 17; i++) { + ai = code[i]; + wi = factor[i]; + sum += ai * wi; + } + const last = parity[sum % 11]; + if (parity[sum % 11] != code[17]) { + tip = "身份证格式错误"; + pass = false; + } + } + } + return pass; + } +} + +//身份证:检查身份证号码是否符合规范,包括长度,类型 +function isCardNo(card) { + //身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X + const reg = /(^\d{15}$)|(^\d{17}(\d|X)$)/; + if (reg.test(card) === false) { + return false; + } + return true; +}; + +//身份证:取身份证前两位,校验省份 +function checkProvince(card, city) { + const province = card.substr(0, 2); + if (city[province] == undefined) { + return false; + } + return true; +}; + +//身份证:检查生日是否正确 +function checkBirthday(card) { + const len = card.length; + //身份证15位时,次序为省(3位)市(3位)年(2位)月(2位)日(2位)校验位(3位),皆为数字 + if (len == '15') { + const re_fifteen = /^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/; + const arr_data = card.match(re_fifteen); + const year = arr_data[2]; + const month = arr_data[3]; + const day = arr_data[4]; + const birthday = new Date('19' + year + '/' + month + '/' + day); + return verifyBirthday('19' + year, month, day, birthday); + } + //身份证18位时,次序为省(3位)市(3位)年(4位)月(2位)日(2位)校验位(4位),校验位末尾可能为X + if (len == '18') { + const re_eighteen = /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/; + const arr_data = card.match(re_eighteen); + const year = arr_data[2]; + const month = arr_data[3]; + const day = arr_data[4]; + const birthday = new Date(year + '/' + month + '/' + day); + return verifyBirthday(year, month, day, birthday); + } + return false; +}; + +//身份证:校验日期 +function verifyBirthday(year, month, day, birthday) { + const now = new Date(); + const now_year = now.getFullYear(); + //年月日是否合理 + if (birthday.getFullYear() == year && (birthday.getMonth() + 1) == month && birthday.getDate() == day) { + //判断年份的范围(3岁到100岁之间) + const time = now_year - year; + if (time >= 3 && time <= 100) { + return true; + } + return false; + } + return false;By18Val +}; + +/** + * 判断身份证号码为18位时最后的验证位是否正确 + * @param a_idCard 身份证号码数组 + * @return + */ +function isTrueValidateCodeBy18IdCard(a_idCard) { + const By18Val = a_idCard[17].toLowerCase(); // 获取第十八位值 + const numReg = /^[1-9]\d*$/ + let numVal = false; // 校验第十八位是否为整数 + if (numReg.test(Number(By18Val))) { + numVal = true + } else { + numVal = false + } + if (By18Val == 'x' || By18Val == 'X' || numVal) { + return true + } else { + return false + } +} + +/** + * 验证身份证号码前两位,省级编码的准确性 + * @param AddressNum + * @constructor + */ +function IdCardValidateAddress(AddressNum) { + const city = { + 11: "北京", + 12: "天津", + 13: "河北", + 14: "山西", + 15: "内蒙古", + 21: "辽宁", + 22: "吉林", + 23: "黑龙江 ", + 31: "上海", + 32: "江苏", + 33: "浙江", + 34: "安徽", + 35: "福建", + 36: "江西", + 37: "山东", + 41: "河南", + 42: "湖北 ", + 43: "湖南", + 44: "广东", + 45: "广西", + 46: "海南", + 50: "重庆", + 51: "四川", + 52: "贵州", + 53: "云南", + 54: "西藏 ", + 61: "陕西", + 62: "甘肃", + 63: "青海", + 64: "宁夏", + 65: "新疆", + 71: "台湾", + 81: "香港", + 82: "澳门", + 91: "国外 " + }; + if (city[AddressNum.substr(0, 2)]) { + return true + } else { + return false + } +} + +/** + * 验证18位数身份证号码中的生日是否是有效生日 + * @param idCard 18位书身份证字符串 + * @return + */ +function isValidityBrithBy18IdCard(idCard18) { + const year = idCard18.substring(6, 10); + const month = idCard18.substring(10, 12); + const day = idCard18.substring(12, 14); + const temp_date = new Date(year, parseFloat(month) - 1, parseFloat(day)); + // 这里用getFullYear()获取年份,避免千年虫问题 + if (temp_date.getFullYear() != parseFloat(year) + || temp_date.getMonth() != parseFloat(month) - 1 + || temp_date.getDate() != parseFloat(day)) { + return false; + } else { + return true; + } +} + +/** + * 验证15位数身份证号码中的生日是否是有效生日 + * @param idCard15 15位书身份证字符串 + * @return + */ +function isValidityBrithBy15IdCard(idCard15) { + const year = idCard15.substring(6, 8); + const month = idCard15.substring(8, 10); + const day = idCard15.substring(10, 12); + const temp_date = new Date(year, parseFloat(month) - 1, parseFloat(day)); + // 对于老身份证中的你年龄则不需考虑千年虫问题而使用getYear()方法 + if (temp_date.getYear() != parseFloat(year) + || temp_date.getMonth() != parseFloat(month) - 1 + || temp_date.getDate() != parseFloat(day)) { + return false; + } else { + return true; + } +} + +/** + * 去掉字符串头尾空格 + * @param str + * @returns {*} + */ +function trim(str) { + return str.replace(/(^\s*)|(\s*$)/g, ""); +} + + +export default { + validateCode, + validateEmail, + validateEng, + validatePhone, + validateChinese, + validatePostCode, + validateNum, + validateNumDot, + validateZYS, + validateOrganization, + validateFax, + validateHome, + validateXXMC, + validateXf, + validateOneNum, + validateMaxNumber, + validateTwoNum, + validateTwoNumThree, + validateThreeNum, + validateInteger, + validateNF, + validateXQ, + validateroundNumber, + validateEngName, + validateCard, + validateHanset, + validateFamilyPhone, + validateName, + validateChargeperson, +} diff --git a/src/views/report/jmreport/index.vue b/src/views/report/jmreport/index.vue index 0bac35192..e05bb51f5 100644 --- a/src/views/report/jmreport/index.vue +++ b/src/views/report/jmreport/index.vue @@ -8,6 +8,6 @@ import { getAccessToken } from '@/utils/auth' defineOptions({ name: 'JimuReport' }) -const BASE_URL = import.meta.env.VITE_BASE_URL +const BASE_URL = import.meta.env.VITE_JMREPORT_BASE_URL const src = ref(BASE_URL + '/jmreport/list?token=' + getAccessToken()) diff --git a/src/views/wms/itembasic/ItembasicForm.vue b/src/views/wms/itembasic/ItembasicForm.vue index 975eabc44..9fb4d4153 100644 --- a/src/views/wms/itembasic/ItembasicForm.vue +++ b/src/views/wms/itembasic/ItembasicForm.vue @@ -4,7 +4,7 @@
- +