Commit c8754394 authored by renjintao's avatar renjintao

mesplan

parent 62757512
......@@ -169,38 +169,37 @@ henq.findRoots = (arr1, id) => {
//省市县pacc转为list
henq.treeToList1 = (tree) => {
let list = [];
function treeToList1(data) {
data.map(u => {
if (u.children&&u.level!=1) {
if (u.children && u.level != 1) {
treeToList1(u.children, u)
}
else if(u.children&&u.level==1)
{
list=list.concat(u.children);
} else if (u.children && u.level == 1) {
list = list.concat(u.children);
}
})
}
treeToList1(tree, null)
return list;
}
//根据departId返出上级所有name
henq.getDepartAllName = (list,id) => {
henq.getDepartAllName = (list, id) => {
let names = '';
function getDepartAllName(list,id) {
function getDepartAllName(list, id) {
list.map(u => {
if(id==u.id)
{
names=u.name+"/"+names
if (u.parent_Id>0) {
getDepartAllName(list, u.parent_Id)
if (id == u.id) {
names = u.name + "/" + names
if (u.parent_Id > 0) {
getDepartAllName(list, u.parent_Id)
}
}
}
})
}
getDepartAllName(list,id)
return names.slice(0,names.length-1);
getDepartAllName(list, id)
return names.slice(0, names.length - 1);
}
//导出pdf
henq.outPdf = (ele, fileName) => {
......@@ -343,4 +342,106 @@ henq.dirCode = (code, v) => {
}
return items
}
henq.makeRules = (list, api) => {
list = [{
columnDescription: "测试列1", // 中文名称
dbColumnName: "colums1", // 字段名称
dataType: "varchar", // 数据库中字段类型
propertyName: "colums1", //程序中的字段名称
propertyType: "String", // 程序中的字段类型
code: "", // 数据字典编码
isNullable: false, // 是否可空
isKey: false, // 是否主键
unit: "", // 单位
length: 50, //
decimalDigits: 0, // 精度
link: 0, //外键 表的
defaultValue: "", // 默认值
control: 0,
uniqueness: 0, // 唯一性 0 不限制 1 表内唯一 2 表内某条件下唯一
ruleType: "", // 邮箱 ,电话,等
},
{
columnDescription: "测试列2", // 中文名称
dbColumnName: "colums2", // 字段名称
dataType: "int32", // 数据库中字段类型
propertyName: "colums2", //程序中的字段名称
propertyType: "int", // 程序中的字段类型
code: "aps.plan.status", // 数据字典编码
isNullable: false, // 是否可空
isKey: false, // 是否主键
unit: "", // 单位
length: 50, //
decimalDigits: 0, // 精度
link: 0, //外键 表的
defaultValue: "", // 默认值
control: 0,
uniqueness: 0, // 唯一性 0 不限制 1 表内唯一 2 表内某条件下唯一
ruleType: "", // 邮箱 ,电话,等
},
{
columnDescription: "测试列3", // 中文名称
dbColumnName: "colums3", // 字段名称
dataType: "varchar", // 数据库中字段类型
propertyName: "colums3", //程序中的字段名称
propertyType: "String", // 程序中的字段类型
code: "", // 数据字典编码
isNullable: false, // 是否可空
isKey: false, // 是否主键
unit: "", // 单位
length: 50, //
decimalDigits: 0, // 精度
link: 0, //外键 表的
defaultValue: "", // 默认值
control: 0,
uniqueness: 0, // 唯一性 0 不限制 1 表内唯一 2 表内某条件下唯一
ruleType: "email", // 邮箱 ,电话,等
}
]
let rules = {}
list.forEach(el => {
if (!el.isNullable) {
let objInfo = {}
//不能为空,必填文本或数字类型
if (el.code == '' && (el.propertyType == 'String' || el.propertyType == 'int')) {
objInfo = {
required: true,
message: el.columnDescription + "必填",
trigger: "blur"
}
}
//不能为空,根据数据字典,必选
else if (el.code != '' && el.propertyType == 'int') {
objInfo = {
required: true,
message: el.columnDescription + "必选",
trigger: "change",
type: "number",
}
}
rules[el.propertyName] = []
rules[el.propertyName].push(objInfo)
if (el.ruleType == "email") {
let valInfoEmail = {
validator: function (rule, value, callback) {
if (
/^\w{1,64}@[a-z0-9\-]{1,256}(\.[a-z]{2,6}){1,2}$/i.test(
value
) == false
) {
callback(new Error("邮箱格式错误"));
} else {
callback();
}
},
trigger: "blur"
}
rules[el.propertyName].push(valInfoEmail)
}
}
})
return rules
}
export default henq;
......@@ -32,6 +32,7 @@
</FormItem>
<FormItem>
<Button type="primary" @click="search">查询</Button>
<Button type="primary" @click="getRules" v-if="false">getRules</Button>
</FormItem>
</Form>
</template>
......@@ -549,6 +550,10 @@ export default {
}
},
methods: {
getRules() {
let ruleInfos = this.$u.makeRules()
alert(JSON.stringify(ruleInfos))
},
addOk() {
this.$refs.grid.load();
this.addModal = false;
......
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