Commit 29349b94 authored by renjintao's avatar renjintao

test

parent 17a01eb8
import XLSX from 'xlsx'; import XLSX from 'xlsx';
import Api from '@/plugins/request'
let henq = {}; let henq = {};
let pdfInfo = '' let pdfInfo = ''
henq.clone = (obj) => { henq.clone = (obj) => {
...@@ -434,18 +435,44 @@ henq.makeRules = (list, apiUrl) => { ...@@ -434,18 +435,44 @@ henq.makeRules = (list, apiUrl) => {
link: 0, link: 0,
defaultValue: "", defaultValue: "",
control: 0, control: 0,
uniqueness: 1,//表内唯一验证 uniqueness: 1, //表内唯一验证
ruleType: "", ruleType: "",
},
{ //日期校验
columnDescription: "测试列6",
dbColumnName: "colums6",
dataType: "datetime",
propertyName: "colums6",
propertyType: "String",
code: "",
isNullable: false,
isKey: false,
unit: "",
length: 50,
decimalDigits: 0,
link: 0,
defaultValue: "",
control: 0,
uniqueness: 0, //表内唯一验证
ruleType: "datetime",
} }
] ]
apiUrl = `${resourceUrl}/mesparttaskplansimulate/get` apiUrl = `${systemUrl}/user/list`
//测试数据end //测试数据end
//唯一性校验 //唯一性校验
const validateCol = (rule, value, callback) => { const validateCol = (rule, value, callback) => {
if (!value) { if (!value) {
return callback(new Error("输入不能为空")); return callback(new Error("输入不能为空"));
} }
this.$api.post(apiUrl, value).then((r) => { var params1 = {
"conditions": [{
"fieldName": "cardNo",
"fieldValue": value,
"conditionalType": "Equal"
}],
"pageSize": 3
}
Api.post(apiUrl, params1).then((r) => {
if (r.result.length > 0) { if (r.result.length > 0) {
return callback(new Error("输入数据已经存在")); return callback(new Error("输入数据已经存在"));
} else { } else {
...@@ -467,7 +494,6 @@ henq.makeRules = (list, apiUrl) => { ...@@ -467,7 +494,6 @@ henq.makeRules = (list, apiUrl) => {
} }
} }
let rules = {} let rules = {}
list.forEach(el => { list.forEach(el => {
if (!el.isNullable) { if (!el.isNullable) {
let objInfo = {} let objInfo = {}
...@@ -479,13 +505,11 @@ henq.makeRules = (list, apiUrl) => { ...@@ -479,13 +505,11 @@ henq.makeRules = (list, apiUrl) => {
message: "必填", message: "必填",
trigger: "blur" trigger: "blur"
} }
if(el.uniqueness!=0) if (el.uniqueness != 0) {
{ var objUniqueness = {
let objUniqueness = {
validator: validateCol, validator: validateCol,
trigger: "blur" trigger: "blur"
} }
rules[el.propertyName].push(objUniqueness)
} }
} else if (el.ruleType == 'email') { } else if (el.ruleType == 'email') {
objInfo = { objInfo = {
...@@ -501,6 +525,14 @@ henq.makeRules = (list, apiUrl) => { ...@@ -501,6 +525,14 @@ henq.makeRules = (list, apiUrl) => {
trigger: "blur" trigger: "blur"
} }
} }
else if (el.ruleType == 'datetime')
{
objInfo = {
required: true,
message: "请选择时间",
trigger: "change"
}
}
} else { //数据字典 } else { //数据字典
objInfo = { objInfo = {
...@@ -511,6 +543,9 @@ henq.makeRules = (list, apiUrl) => { ...@@ -511,6 +543,9 @@ henq.makeRules = (list, apiUrl) => {
} }
} }
rules[el.propertyName].push(objInfo) rules[el.propertyName].push(objInfo)
if (el.uniqueness != 0) {
rules[el.propertyName].push(objUniqueness)
}
} }
}) })
......
...@@ -79,7 +79,6 @@ ...@@ -79,7 +79,6 @@
</div> </div>
</template> </template>
<script> <script>
var myDate = new Date(); var myDate = new Date();
var dayTomorrow = new Date(); var dayTomorrow = new Date();
...@@ -138,6 +137,7 @@ export default { ...@@ -138,6 +137,7 @@ export default {
trigger: "change", trigger: "change",
}, ], }, ],
}, },
wfstatu: 1, wfstatu: 1,
}; };
}, },
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
</FormItem> </FormItem>
<FormItem> <FormItem>
<Button type="primary" @click="search">查询</Button> <Button type="primary" @click="search">查询</Button>
<Button type="primary" @click="getRules">getRules</Button>
</FormItem> </FormItem>
</Form> </Form>
</template> </template>
...@@ -550,11 +549,6 @@ export default { ...@@ -550,11 +549,6 @@ export default {
} }
}, },
methods: { methods: {
getRules() {
let ruleInfos = this.$u.makeRules()
// console.log(ruleInfos)
//alert(JSON.stringify(ruleInfos))
},
addOk() { addOk() {
this.$refs.grid.load(); this.$refs.grid.load();
this.addModal = false; this.addModal = false;
......
<style lang="less"> <style lang="less">
.test_layout { .test_layout {
height: 100%; height: 100%;
.bg1 { .bg1 {
background: #fefefe; background: #fefefe;
} }
// &.fg { // &.fg {
// // overflow: auto; // // overflow: auto;
// } // }
} }
.layout-copy { .layout-copy {
text-align: center; text-align: center;
padding: 10px 0 20px; padding: 10px 0 20px;
...@@ -15,7 +18,7 @@ ...@@ -15,7 +18,7 @@
} }
</style> </style>
<template> <template>
<div class="flex fd test_layout"> <div class="flex fd test_layout">
<div> <div>
<Menu mode="horizontal" theme="light" active-name="0"> <Menu mode="horizontal" theme="light" active-name="0">
<div class="layout-assistant"> <div class="layout-assistant">
...@@ -24,18 +27,23 @@ ...@@ -24,18 +27,23 @@
<MenuItem name="2" to="/test/com">异步组件</MenuItem> <MenuItem name="2" to="/test/com">异步组件</MenuItem>
<MenuItem name="4" to="/test/resource">资源选择</MenuItem> <MenuItem name="4" to="/test/resource">资源选择</MenuItem>
<MenuItem name="3" to="/test/view">详情拖拽排版</MenuItem> <MenuItem name="3" to="/test/view">详情拖拽排版</MenuItem>
<MenuItem name="5" to="/test/test1">colum验证</MenuItem>
</div> </div>
</Menu> </Menu>
</div> </div>
<div class="fg"> <div class="fg">
<nuxt-child></nuxt-child> <nuxt-child></nuxt-child>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
layout: "empty", layout: "empty",
async fetch({ store, params }) { async fetch({
store,
params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典 await store.dispatch("loadDictionary"); // 加载数据字典
} }
}; };
......
<template>
<div style="width:100%;">
<Form :model="orderSearchForm" :label-width="120" :rules="ruleValidate" ref="formValidate">
<Row>
<Col span="8">
<FormItem label="输入校验" style="width:100%" prop="colums1">
<Input v-model="orderSearchForm.colums1" style="width:240px" />
</FormItem>
</Col>
<Col span="8">
<FormItem label="数据字典" style="width:100%" prop="colums2">
<dictionary code="plan.order.taskType" v-model="orderSearchForm.colums2" style="width:240px"></dictionary>
</FormItem>
</Col>
<Col span="8">
<FormItem label="电话校验" style="width:100%" prop="colums3">
<Input v-model="orderSearchForm.colums3" style="width:240px" />
</FormItem>
</Col>
<Col span="8">
<FormItem label="email校验" style="width:100%" prop="colums4">
<Input v-model="orderSearchForm.colums4" style="width:240px" />
</FormItem>
</Col>
<Col span="8">
<FormItem label="唯一性校验(用户编号)" style="width:100%" prop="colums5">
<Input v-model="orderSearchForm.colums5" style="width:240px" />
</FormItem>
</Col>
<Col span="8">
<FormItem label="时间校验" style="width:100%" prop="colums6">
<DatePicker v-model="orderSearchForm.colums6" type="date" placeholder="请选择日期" @on-change="getTime"></DatePicker>
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem>
<Button type="primary" @click="handleSubmit" v-noClick>保存</Button>
</FormItem>
</Col>
</Row>
</Form>
</div>
</template>
<script>
export default {
layout: 'empty',
name: "Test1",
data() {
return {
orderSearchForm: {
colums6: ""
},
ruleValidate: this.$u.makeRules(),
};
},
mounted() {
},
methods: {
handleSubmit() {
this.$refs.formValidate.validate((v) => {
if (v) {
this.$Message.success('验证通过')
}
});
},
getTime(value) {
if (value != '') {
this.orderSearchForm.colums6 = this.getFormatDateEnd(value);
}
},
getFormatDateEnd(dates) {
const d = new Date(dates);
const resDate =
d.getFullYear() +
"-" +
this.p(d.getMonth() + 1) +
"-" +
this.p(d.getDate()) +
" 23:59:59";
return resDate;
},
p(s) {
return s < 10 ? "0" + s : s;
},
},
};
</script>
<template> <template>
<div class="flex"> <div class="flex">
<div class="fg1"> <div class="fg1">
<Form ref="form" :model="entity" :rules="rules" :label-width="110"> <Form ref="form" :model="entity" :rules="rules" :label-width="110">
<Row class="view"> <Row class="view">
...@@ -27,8 +27,9 @@ ...@@ -27,8 +27,9 @@
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: "", name: "",
...@@ -65,14 +66,16 @@ export default { ...@@ -65,14 +66,16 @@ export default {
}; };
</script> </script>
<style lang="less" > <style lang="less">
@line-height: 40px; @line-height: 40px;
@item-width: 12.5%; @item-width: 12.5%;
.view { .view {
margin: 30px; margin: 30px;
border: 1px solid #ddd; border: 1px solid #ddd;
line-height: @line-height; line-height: @line-height;
background-color: white; background-color: white;
.item { .item {
border-right: 1px solid #ddd; border-right: 1px solid #ddd;
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment