1、新增 “业务预览-数据保存”功能逻辑

2、修改保存数据解析sql的bug
This commit is contained in:
2019-06-13 17:45:17 +08:00
parent 60566a69c9
commit d40676f724
5 changed files with 54 additions and 28 deletions

View File

@@ -105,8 +105,12 @@ const meta = {
}
},
del({name, id}) {
dataDel({name, id}) {
return red.postX('/data/del', {name, data: JSON.stringify({id})})
},
dataSave({name, data}) {
return red.postX('/data/save', {name, data: JSON.stringify(data)})
}
}

View File

@@ -76,7 +76,7 @@
<tr>
<!-- 'sort':field.order>0 -->
<th v-for="field in cfg.shows"
v-if="field.fmt != 'HIDDEN'"
v-if="field.inType != 'HIDDEN'"
v-text="field.label || getFieldLabel(field.col)"
:class="{'sort':1, 'sort-up':field.col==order.col && order.desc==1, 'sort-down':field.col==order.col && order.desc!=1}"
@click="sortEvent(field.col)"></th>
@@ -89,7 +89,7 @@
<td v-for="field in cfg.shows" v-title="dealFieldFmt(row, field.col)" v-text="dealFieldFmt(row, field.col)"></td>
-->
<td v-for="field in cfg.shows"
v-if="field.fmt != 'HIDDEN'"
v-if="field.inType != 'HIDDEN'"
v-title="dealFieldFmt(row, field)"
v-html="dealFieldFmt(row, field)"></td>
<td>
@@ -184,15 +184,15 @@
<div class="modal-body" style="padding-right: 50px">
<form class="form-horizontal">
<div class="col-sm-6" v-for="item in cfg.edits">
<div class="form-group">
<div v-show="item.inType != 'HIDDEN'" class="form-group">
<label class="col-sm-5" v-text="item.label"></label>
<div class="col-sm-7">
<input v-if="item.inType == 'INPUT' || item.inType == '' || !item.inType" v-model="detailData[item.col]" class="form-control" :placeholder="`请输入 ${item.label}`">
<input v-if="!item.inType || item.inType == 'INPUT' || item.inType == '' || !item.inType" v-model="detailData[item.col]" class="form-control" :placeholder="`请输入 ${item.label}`">
<input v-if="item.inType == 'INPUT_DT'" v-model="detailData[item.col]" class="form-control" :placeholder="`请输入 ${item.label}`">
<select v-if="item.inType == 'SELECT_EXT'" v-model="detailData[item.col]" class="form-control">
<option value="选项一">选项一</option>
<option value="选项二">选项二</option>
<option value="山东省">山东省</option>
<select v-if="item.inType == 'DICT'" v-model="detailData[item.col]" class="form-control">
<option value="1">选项一</option>
<option value="2">选项二</option>
<option value="3">山东省</option>
<!--
<option v-for="x in inTypes" :value="x">{{x}}</option>
-->
@@ -206,7 +206,7 @@
<div class="clearfix"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button @click="" type="button" class="btn btn-primary">确定</button>
<button @click="save()" type="button" class="btn btn-primary">确定</button>
</div>
</div>
</div>
@@ -229,7 +229,7 @@
return {1:"男",2:"女"}[v] || "未知性别"
}
let {getServiceList, getCfg, getDataList, exportData, del} = meta
let {getServiceList, getCfg, getDataList, exportData, dataDel, dataSave} = meta
let {showOk} = red
var vm = new Vue({
el:".data-list",
@@ -320,7 +320,12 @@
else {
v = bean[colFmt["col"]]
}
return v + " -> "+colFmt.inType
if (colFmt.inType && colFmt.inType != "INPUT") {
v += " -> "+colFmt.inType
}
return v
/*if (colFmt["fmt"]) {
let fmt = colFmt["fmt"]
@@ -454,7 +459,23 @@
let name = this.service
let pk = this.detailData[this.cfg.pk]
del({name, id: pk}).then(res => showOk)
dataDel({name, id: pk}).then(res => showOk())
},
save() {
// 表单保存
let row = this.detailData
let edits = this.cfg.edits
let name = this.service
let data = {}
for (let i in edits) {
data[edits[i].col] = row[edits[i].col]
}
dataSave({name, data}).then(res => {
showOk()
$('#edit').modal('hide')
})
},
showInfo() {
$('#f-info').modal({moveable: true})