Skip to content

Commit

Permalink
完善主从表维护例子
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTong committed Apr 14, 2016
1 parent 76eefe3 commit 28205c3
Show file tree
Hide file tree
Showing 8 changed files with 443 additions and 222 deletions.
3 changes: 3 additions & 0 deletions public/common/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@ html {
padding-top: 0.6em;
}
}
.ui.form .field > label {
font-weight: initial;
}
113 changes: 57 additions & 56 deletions public/example/crud.coffee
Original file line number Diff line number Diff line change
@@ -1,27 +1,67 @@
cola((model)->
$(".ui.accordion").accordion({exclusive: false})

model.describe("items", {
model.describe("products", {
dataType:
name: "Product",
properties:
id:
validators: ["required"]
name:
validators: ["required"]
price:
dataType: "number"
provider:
url: "/service/products"
url: "/service/shoes"
pageSize: 4
})
model.set("customItem", {})
beforeSend:(self,arg)->
data=arg.options.data
condition=model.get("condition")
if condition
condition=condition.toJSON()
for key,value of condition
if value
data[key]=value


})
model.set("condition",{})
model.describe("editItem", "Product");
model.action({
getColor: (status)->
if status is "完成"
return "positive-text"
else
return "negative-text"
add: ()->
newItem = model.get("items").insert()
search:()->
model.get("products").flush()

add: ()->
model.set("editItem", {})
cola.widget("editLayer").show()
edit: ()->
item = model.get("products").current;
model.set("editItem", item.toJSON());
cola.widget("editLayer").show()
back:()->
cancel: ()->
cola.widget("editLayer").hide()
ok: ()->
editItem = model.get("editItem")
if editItem.validate()
id = editItem.get("id")
data = editItem.toJSON()
# NProgress.start()
# $.ajax("./service/product/", {
# data: JSON.stringify(data),
# type: if data.id then "PUT" else "POST",
# contentType: "application/json",
# complete: ()->
# cola.widget("editLayer").hide();
# NProgress.done()
# })
del: (item)->
item.remove();
# 此处编写调用后台直接删除
})
model.widgetConfig({
editLayer: {
Expand All @@ -33,61 +73,22 @@ cola((model)->
$("#mainView").show()
}
productTable: {
$type: "table",
bind: "item in items",
showHeader: true,
height: 500
$type: "table", showHeader: true,
bind: "item in products",
highlightCurrentItem: true,
currentPageOnly: true,
columns: [{
$type: "select"
}, {
caption: "已跟次数",
template: "ygCount"
}, {
caption: "催收状态",
template: "csStatus"
}, {
caption: "待跟进日",
template: "dgDate"
}, {
caption: "委托方",
template: "wtf"
}, {
caption: "受理方",

template: "slf"
}, {
caption: "委案日期",
template: "waDate"
}, {
caption: "剩余天数",
template: "syDay"
}, {
caption: "委案金额",
template: "waje"
}, {
caption: "已还金额",
template: "yhje"
}, {
caption: "期数",
template: "qs"
}, {
caption: "姓名",
template: "name"
bind: ".id", caption: "产品编号"
}, {
caption: "证件号",
template: "id"
bind: ".name", caption: "产品名称"
}, {
caption: "卡号",
template: "cardNo"
bind: "formatNumber(item.originalPrice, '¥#,##0.00')", caption: "原价", align: "right"
}, {
caption: "地区",
template: "region"
bind: "formatNumber(item.price, '¥#,##0.00')", caption: "价格", align: "right"
}, {
caption: "催收组",
template: "csz"
bind: ".shop", caption: "经营商"
}, {
caption: "催收员",
template: "csy"
caption: "操作", align: "center", template: "operations"
}]
}
});
Expand Down
41 changes: 0 additions & 41 deletions public/example/crud.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,9 @@ body {
padding: 0.8em;
}

.ui.panel {
background-color: #fff;
> .header {
> .content {
background-color: transparent;
font-size: 0.9em;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
}
> .content {
padding: 0.6em;
}
}

.ui.form .field > label {
font-weight: initial;
}

.ui.form {
.ui.input {
input {
border-radius: 0;
}
}
}

.ui.segment {
//padding: 0px;
border-radius: 0px;
> .ui.menu {
margin: 0px;
}
}

.ui.menu {
border-radius: 0px;
}

.form.ui.cn {
list-style: none;
padding: 1em;
Expand All @@ -60,15 +25,9 @@ body {
}
}
}

.ui.items-view.widget-table {
font-size: @fontSize;
}

.ui.button:not(.circular) {
border-radius: 0px !important;
}

.ui.data-pilot {
> .control.item {
padding: 0;
Expand Down
3 changes: 3 additions & 0 deletions public/example/master-detail.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ cola((model)->
# })
})
model.widgetConfig({
productLayer:{
$type:"Layer"
}
categoryList: {
$type: "table",
bind: "item in categorys",
Expand Down
Loading

0 comments on commit 28205c3

Please sign in to comment.