|
|
|
import { MessageBox, Message } from 'element-ui';
|
|
|
|
import { addOperation, getOperation } from '@/api/http';
|
|
|
|
|
|
|
|
const phoneListen = function(val, form, prop) {
|
|
|
|
if(/^[0-9]*$/.test(val)) {
|
|
|
|
form[prop] = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const mailBoxListen = function(val, form, prop) {
|
|
|
|
if(/^[\u4E00-\u9FA5A-Za-z0-9_]+$/.test(val) || val==='') {
|
|
|
|
form[prop] = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 校验中文
|
|
|
|
const checkHanzi = function(val, form, prop) {
|
|
|
|
// 检查符号
|
|
|
|
const charReg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、]/im;
|
|
|
|
// 检查空格
|
|
|
|
const tmpCheck = val.substr(val.length-1, 1);
|
|
|
|
if(tmpCheck === ' ' || charReg.test(val) || /[\u4E00-\u9FA5]/i.test(val)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
form[prop] = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
const checkName = function(val, form, prop) {
|
|
|
|
// 检查符号
|
|
|
|
const charReg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、]/im;
|
|
|
|
// // 检查数字
|
|
|
|
const charReg2 = /^[0-9]*$/;
|
|
|
|
const tmpCheck = val.substr(val.length-1, 1);
|
|
|
|
if(val.length<form[prop].length) {
|
|
|
|
form[prop] = val;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(charReg.test(val) || charReg2.test(tmpCheck)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
form[prop] = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 监听年利率
|
|
|
|
const rateListen = function(val, form, prop) {
|
|
|
|
|
|
|
|
// 检查符号 允许%
|
|
|
|
// const charReg = /[`~!@#$^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥……&*()——\-+={}|《》?:“”【】、;‘',。、]/im;
|
|
|
|
const charReg =/^\\d+(\\.\\d)?\\d{0,1}%$/
|
|
|
|
// 检查空格
|
|
|
|
if(charReg.test(val) || /[\u4E00-\u9FA5]/i.test(val)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
form[prop] = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 监听数字
|
|
|
|
const inputListen = function(val, row, prop) {
|
|
|
|
// 检查空格
|
|
|
|
const tmpCheck = val.substr(val.length-1, 1);
|
|
|
|
if(tmpCheck === ' ') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(val === '') {
|
|
|
|
row[prop] = val;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
row[prop] = Number(val.replace(/\D+/, ''))
|
|
|
|
}
|
|
|
|
|
|
|
|
const inputListen2 = function(val, row, prop) {
|
|
|
|
// 检查空格
|
|
|
|
const tmpCheck = val.substr(val.length-1, 1);
|
|
|
|
if(tmpCheck === ' ') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 可以删光
|
|
|
|
if(val === '') {
|
|
|
|
row[prop] = val;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(Number(val) || Number(val)===0) {
|
|
|
|
console.log(val)
|
|
|
|
row[prop] = val
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const ismoney = function(val, row, prop) {
|
|
|
|
// 检查空格
|
|
|
|
const tmpCheck = val.substr(val.length-1, 1);
|
|
|
|
if(tmpCheck === ' ') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(val.length === 15) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// const reg = /([1-9]\d{0,9}|0)(\.\d{1,2})?$/ // 不用保留
|
|
|
|
const reg2 = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/; // 保留小数点后两位
|
|
|
|
if (reg2.test(Number(val)) || val==='') {
|
|
|
|
row[prop] = val
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const checkRequired = function(form, obj) {
|
|
|
|
for(const prop in obj) {
|
|
|
|
if(form[prop] === '') {
|
|
|
|
MessageBox.alert('请填写' + obj[prop], '提示', {
|
|
|
|
type: 'info',
|
|
|
|
confirmButtonText: '确定'
|
|
|
|
});
|
|
|
|
return prop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
const myValidate = (callback, refs) => {
|
|
|
|
return (valid, obj) => {
|
|
|
|
if (valid) {
|
|
|
|
callback()
|
|
|
|
} else {
|
|
|
|
let tmpObj = {};
|
|
|
|
for(const key in obj) {
|
|
|
|
tmpObj = obj[key][0]
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
const { message, field } = tmpObj
|
|
|
|
try {
|
|
|
|
refs[field].focus();
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
}
|
|
|
|
Message.info({
|
|
|
|
center: true,
|
|
|
|
message
|
|
|
|
})
|
|
|
|
// Message.message(message + '', '提示', {
|
|
|
|
// type: 'info',
|
|
|
|
// confirmButtonText: message
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const autoPlay = (parentId, form, myTable2, myTable, cards=[]) => {
|
|
|
|
let projectId = sessionStorage.getItem('projectId') || 11 // 默认11吧?
|
|
|
|
let startTime = sessionStorage.getItem('startTime')
|
|
|
|
let formList = [];
|
|
|
|
// let tmpIndex = 100;
|
|
|
|
for(const key in myTable2) {
|
|
|
|
const { prop, type, subjectId='' } = myTable2[key]
|
|
|
|
if(form[prop]){
|
|
|
|
formList.push({ "answerId": key + '', "emptyOne": '' + subjectId, "emptyTwo": form[prop], "operationIds": parentId + ',' + key, "type":type })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(const key in myTable) {
|
|
|
|
const { prop, type, subjectId='' } = myTable[key]
|
|
|
|
formList.push({ "answerId": key + '', "emptyOne": '' + subjectId, "emptyTwo": form[prop], "operationIds": parentId + ',' + key, "type":type })
|
|
|
|
}
|
|
|
|
|
|
|
|
for(let i=0; i<cards.length; i++ ) {
|
|
|
|
let myKey = ''
|
|
|
|
let tmpJson = null
|
|
|
|
let subjectId = ''
|
|
|
|
for(const key in cards[i]) {
|
|
|
|
if(key!=='subjectId') {
|
|
|
|
myKey = key
|
|
|
|
tmpJson = JSON.stringify(cards[i][key])
|
|
|
|
}else {
|
|
|
|
subjectId = cards[i]['subjectId']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
formList.push({ "answerId": myKey + '', "emptyOne": '' + subjectId, "emptyTwo": tmpJson, "operationIds": parentId + ',' + myKey, "type":5 })
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let params= {
|
|
|
|
parentId,
|
|
|
|
lcJudgmentRuleReq:formList,
|
|
|
|
projectId: projectId,
|
|
|
|
// projectId:+projectId,
|
|
|
|
startTime:startTime,
|
|
|
|
}
|
|
|
|
console.log('---提交的')
|
|
|
|
console.log(formList)
|
|
|
|
addOperation(params).then((data)=>{
|
|
|
|
// Message.success({
|
|
|
|
// center: true,
|
|
|
|
// message: '提交成功'
|
|
|
|
// })
|
|
|
|
}).catch((error)=>{
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const autoPlay2 = (parentId=11, form, myTable2, myTable, cardArr, callback) => {
|
|
|
|
// 默认11吧?
|
|
|
|
let param= {
|
|
|
|
parentId
|
|
|
|
}
|
|
|
|
getOperation(param).then((data)=>{
|
|
|
|
console.log('---拿到的data')
|
|
|
|
console.log(data)
|
|
|
|
if(data.status == 200) {
|
|
|
|
var list = data.data.judgmentRuleReqs
|
|
|
|
const tmpObj = Object.assign(myTable, myTable2)
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
const { answerId, emptyTwo } = list[i]
|
|
|
|
if(!cardArr) {
|
|
|
|
form[tmpObj[answerId].prop] = emptyTwo
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if(cardArr[answerId]) {
|
|
|
|
try{
|
|
|
|
console.log(answerId)
|
|
|
|
sessionStorage.setItem(cardArr[answerId], JSON.parse(list[i].emptyTwo))
|
|
|
|
}catch(e) {
|
|
|
|
// sessionStorage.setItem(cardArr[answerId], list[i].emptyTwo)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
form[tmpObj[answerId].prop] = emptyTwo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// form[tmpObj[answerId].prop] = emptyTwo
|
|
|
|
}
|
|
|
|
callback()
|
|
|
|
}
|
|
|
|
}).catch((error)=>{
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const autoPlay3 = (name, allName, arr) => { // 要接收的, 所有的, 要接收的属性
|
|
|
|
for(let key of arr) {
|
|
|
|
name[key] = allName[key]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const getNowDate = () => {
|
|
|
|
const date = new Date()
|
|
|
|
var y = date.getFullYear();
|
|
|
|
var m = date.getMonth() + 1;
|
|
|
|
m = m < 10 ? '0' + m : m;
|
|
|
|
var d = date.getDate();
|
|
|
|
d = d < 10 ? ('0' + d) : d;
|
|
|
|
return y + '-' + m + '-' + d;
|
|
|
|
}
|
|
|
|
|
|
|
|
const messageIdCard = () => {
|
|
|
|
Message.warning({
|
|
|
|
center: true,
|
|
|
|
message: '请刷身份证',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const messageCard = () => {
|
|
|
|
Message.warning({
|
|
|
|
center: true,
|
|
|
|
message: '请刷银行卡',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const randomPeopleNumber = () => {
|
|
|
|
const $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
|
|
const $chars2 = '1234567890'
|
|
|
|
const maxPos = $chars2.length;
|
|
|
|
let str = '';
|
|
|
|
str += $chars.charAt(Math.floor(Math.random() * maxPos))
|
|
|
|
for (let i = 0; i < 9; i++) {
|
|
|
|
str += $chars2.charAt(Math.floor(Math.random() * maxPos));
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
randomPeopleNumber,
|
|
|
|
phoneListen,
|
|
|
|
mailBoxListen,
|
|
|
|
checkRequired,
|
|
|
|
inputListen,
|
|
|
|
ismoney,
|
|
|
|
checkHanzi,
|
|
|
|
myValidate,
|
|
|
|
checkName,
|
|
|
|
rateListen,
|
|
|
|
autoPlay,
|
|
|
|
autoPlay2,
|
|
|
|
autoPlay3,
|
|
|
|
getNowDate,
|
|
|
|
inputListen2,
|
|
|
|
messageIdCard,
|
|
|
|
messageCard
|
|
|
|
}
|