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) => {
...@@ -416,7 +417,7 @@ henq.makeRules = (list, apiUrl) => { ...@@ -416,7 +417,7 @@ henq.makeRules = (list, apiUrl) => {
link: 0, link: 0,
defaultValue: "", defaultValue: "",
control: 0, control: 0,
uniqueness: 0, uniqueness: 0,
ruleType: "email", ruleType: "email",
}, },
{ //唯一性api接口校验 { //唯一性api接口校验
...@@ -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 {
background: #fefefe; .bg1 {
} background: #fefefe;
// &.fg { }
// // overflow: auto;
// } // &.fg {
// // overflow: auto;
// }
} }
.layout-copy { .layout-copy {
text-align: center; text-align: center;
padding: 10px 0 20px; padding: 10px 0 20px;
color: #9ea7b4; color: #9ea7b4;
} }
</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">
<MenuItem name="0" to="/test/example">基础组件</MenuItem> <MenuItem name="0" to="/test/example">基础组件</MenuItem>
<MenuItem name="1" to="/test/user">人员选择</MenuItem> <MenuItem name="1" to="/test/user">人员选择</MenuItem>
<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>
</div> <MenuItem name="5" to="/test/test1">colum验证</MenuItem>
</Menu> </div>
</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({
await store.dispatch("loadDictionary"); // 加载数据字典 store,
} params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典
}
}; };
</script> </script>
\ No newline at end of file
<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">
<Col :span="12" class="item" v-for="(li,i) in items" :key="i" v-dragging="{ item: li, list: items}"> <Col :span="12" class="item" v-for="(li,i) in items" :key="i" v-dragging="{ item: li, list: items}">
<FormItem :label="li.key" :prop="li.key"> <FormItem :label="li.key" :prop="li.key">
<component :is="li.control" :value="entity[li.key]" /> <component :is="li.control" :value="entity[li.key]" />
</FormItem> </FormItem>
</Col> </Col>
</Row> </Row>
<div> <div>
{{ {{
entity entity
}} }}
<Button type="primary" @click="con">conso</Button> <Button type="primary" @click="con">conso</Button>
</div> </div>
</Form> </Form>
</div> </div>
<div v-width="25"> <div v-width="25">
<ul> <ul>
...@@ -27,60 +27,63 @@ ...@@ -27,60 +27,63 @@
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: "", name: "",
data() { data() {
return { return {
items: [], items: [],
entity: {}, entity: {},
rules: null rules: null
}; };
}, },
created() { created() {
this.init(); this.init();
},
methods: {
con() {
console.warn("entity", this.entity);
}, },
init() { methods: {
let items = []; con() {
let controls = ["Input", "InputNumber", "Dictionary", "DatePicker"]; console.warn("entity", this.entity);
for (let i = 0; i < 5; i++) { },
this.entity["I" + i] = i; init() {
items.push({ let items = [];
key: "I" + i, let controls = ["Input", "InputNumber", "Dictionary", "DatePicker"];
name: "Item" + i, for (let i = 0; i < 5; i++) {
width: 4, this.entity["I" + i] = i;
control: controls[i % 4], items.push({
height: 1 key: "I" + i,
}); name: "Item" + i,
} width: 4,
this.items = items; control: controls[i % 4],
height: 1
});
}
this.items = items;
}
} }
}
}; };
</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 {
border-right: 1px solid #ddd; .item {
border-top: 1px solid #ddd; border-right: 1px solid #ddd;
margin-right: -1px; border-top: 1px solid #ddd;
margin-top: -1px; margin-right: -1px;
border-bottom: 1px solid #ddd; margin-top: -1px;
text-align: center; border-bottom: 1px solid #ddd;
box-sizing: border-box; text-align: center;
} box-sizing: border-box;
}
} }
</style> </style>
\ No newline at end of file
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