mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-23 21:36:37 +08:00
优化代码
This commit is contained in:
parent
b059ecca13
commit
0a4d6c9916
@ -74,13 +74,17 @@
|
||||
<button class="btn-white btn btn-xs"
|
||||
v-on:click="_openAuditNewOaWorkflowUndoDetail(undo)">办理
|
||||
</button>
|
||||
<button class="btn-white btn btn-xs"
|
||||
v-on:click="_openEditNewOaWorkflow(undo)">编辑
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button class="btn-white btn btn-xs"
|
||||
v-on:click="_openNewOaWorkflowUndoDetail(undo)">详情
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button class="btn-white btn btn-xs" v-if="_isMe(undo)"
|
||||
v-on:click="_openEditNewOaWorkflow(undo)">编辑
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
total: 0,
|
||||
records: 1,
|
||||
formJson: [],
|
||||
userId: vc.getData('/nav/getUserInfo').userId,
|
||||
conditions: {
|
||||
createUserName: '',
|
||||
startTime: '',
|
||||
@ -34,7 +35,7 @@
|
||||
$that._listOaWorkFlowUndoForm();
|
||||
vc.component._listOaWorkflowUndos(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
})
|
||||
vc.on('newOaWorkflowUndo','paginationPlus', 'page_event', function (_currentPage) {
|
||||
vc.on('newOaWorkflowUndo', 'paginationPlus', 'page_event', function (_currentPage) {
|
||||
vc.component._listOaWorkflowUndos(_currentPage, DEFAULT_ROWS);
|
||||
});
|
||||
},
|
||||
@ -73,7 +74,7 @@
|
||||
vc.component.newOaWorkflowUndoInfo.total = _newOaWorkflowUndoInfo.total;
|
||||
vc.component.newOaWorkflowUndoInfo.records = _newOaWorkflowUndoInfo.records;
|
||||
vc.component.newOaWorkflowUndoInfo.undos = _newOaWorkflowUndoInfo.data;
|
||||
vc.emit('newOaWorkflowUndo','paginationPlus', 'init', {
|
||||
vc.emit('newOaWorkflowUndo', 'paginationPlus', 'init', {
|
||||
total: vc.component.newOaWorkflowUndoInfo.records,
|
||||
dataCount: vc.component.newOaWorkflowUndoInfo.total,
|
||||
currentPage: _page
|
||||
@ -86,14 +87,14 @@
|
||||
_openNewOaWorkflowUndoDetail: function (_undo) {
|
||||
vc.jumpToPage("/admin.html#/pages/property/newOaWorkflowDetail?id=" + _undo.id + "&flowId=" + $that.newOaWorkflowUndoInfo.conditions.flowId);
|
||||
},
|
||||
_openAuditNewOaWorkflowUndoDetail:function(_undo){
|
||||
vc.jumpToPage("/admin.html#/pages/property/newOaWorkflowDetail?id=" + _undo.id
|
||||
+ "&flowId=" + $that.newOaWorkflowUndoInfo.conditions.flowId
|
||||
+ "&action=Audit"
|
||||
+ "&taskId="+_undo.taskId);
|
||||
_openAuditNewOaWorkflowUndoDetail: function (_undo) {
|
||||
vc.jumpToPage("/admin.html#/pages/property/newOaWorkflowDetail?id=" + _undo.id
|
||||
+ "&flowId=" + $that.newOaWorkflowUndoInfo.conditions.flowId
|
||||
+ "&action=Audit"
|
||||
+ "&taskId=" + _undo.taskId);
|
||||
},
|
||||
_openEditNewOaWorkflow:function(_undo){
|
||||
vc.jumpToPage("/admin.html#/pages/property/newOaWorkflowFormEdit?id=" + _undo.id + "&flowId=" + $that.newOaWorkflowUndoInfo.conditions.flowId);
|
||||
_openEditNewOaWorkflow: function (_undo) {
|
||||
vc.jumpToPage("/form.html#/pages/property/newOaWorkflowFormEdit?id=" + _undo.id + "&flowId=" + $that.newOaWorkflowUndoInfo.conditions.flowId);
|
||||
},
|
||||
_queryOaWorkflowUndoMethod: function () {
|
||||
vc.component._listOaWorkflowUndos(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
@ -120,6 +121,15 @@
|
||||
}
|
||||
|
||||
return "未知"
|
||||
},
|
||||
_isMe:function(undo){
|
||||
|
||||
let userId = $that.newOaWorkflowUndoInfo.userId;
|
||||
if(undo.create_user_id == userId){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,3 +1,72 @@
|
||||
<div class="bg-white padding" >
|
||||
<div id="form"></div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="ibox">
|
||||
<div class="ibox-title">
|
||||
<h5>编辑</h5>
|
||||
<div class="ibox-tools" style="top:10px;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div v-for="(item,index) in newOaWorkflowFormEditInfo.components">
|
||||
<div class="form-group row" v-if="item.type== 'textfield'">
|
||||
<label class="col-sm-2 col-form-label">{{item.label}}</label>
|
||||
<div class="col-sm-10">
|
||||
<input v-model="item.value" type="text" :placeholder="item.description"
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row" v-if="item.type== 'number'">
|
||||
<label class="col-sm-2 col-form-label">{{item.label}}</label>
|
||||
<div class="col-sm-10">
|
||||
<input v-model="item.value" type="number" :placeholder="item.description"
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row" v-if="item.type== 'textarea'">
|
||||
<label class="col-sm-2 col-form-label">{{item.label}}</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea v-model="item.value" :placeholder="item.description"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row" v-if="item.type== 'textdate'">
|
||||
<label class="col-sm-2 col-form-label">{{item.label}}</label>
|
||||
<div class="col-sm-10">
|
||||
<input v-model="item.value" type="date" :placeholder="item.description"
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row" v-if="item.type== 'textdatetime'">
|
||||
<label class="col-sm-2 col-form-label">{{item.label}}</label>
|
||||
<div class="col-sm-10">
|
||||
<input v-model="item.value" type="time" :placeholder="item.description"
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row" v-if="item.type== 'checkbox'">
|
||||
<label class="col-sm-2 col-form-label">{{item.label}}</label>
|
||||
<div class="col-sm-10">
|
||||
<div class="checkbox custom-control-inline">
|
||||
<label>
|
||||
<input type="checkbox" v-model="item.value"
|
||||
:value="item.value">{{item.label}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ibox-content">
|
||||
<button class="btn btn-primary float-right" type="button" v-on:click="_submitFormData()"><i
|
||||
class="fa fa-check"></i> 提交
|
||||
</button>
|
||||
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
|
||||
v-on:click="closeEditInfo()">取消
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -6,29 +6,30 @@
|
||||
var DEFAULT_ROWS = 100;
|
||||
vc.extends({
|
||||
data: {
|
||||
newOaWorkflowFormInfo: {
|
||||
newOaWorkflowFormEditInfo: {
|
||||
formJson: {},
|
||||
components: [],
|
||||
conditions: {
|
||||
},
|
||||
flowId: '',
|
||||
id:'',
|
||||
id: '',
|
||||
}
|
||||
},
|
||||
_initMethod: function () {
|
||||
$that.newOaWorkflowFormInfo.flowId = vc.getParam('flowId');
|
||||
$that.newOaWorkflowFormInfo.id = vc.getParam('id');
|
||||
vc.component._listOaWorkflowForm(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
$that.newOaWorkflowFormEditInfo.flowId = vc.getParam('flowId');
|
||||
$that.newOaWorkflowFormEditInfo.id = vc.getParam('id');
|
||||
vc.component._listOaWorkflowFormEdit(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
},
|
||||
_initEvent: function () {
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
_listOaWorkflowForm: function (_page, _rows) {
|
||||
_listOaWorkflowFormEdit: function (_page, _rows) {
|
||||
var param = {
|
||||
params: {
|
||||
page: 1,
|
||||
row: 1,
|
||||
flowId: $that.newOaWorkflowFormInfo.flowId
|
||||
flowId: $that.newOaWorkflowFormEditInfo.flowId
|
||||
}
|
||||
};
|
||||
|
||||
@ -36,36 +37,64 @@
|
||||
vc.http.apiGet('/oaWorkflow/queryOaWorkflowForm',
|
||||
param,
|
||||
function (json, res) {
|
||||
let _newOaWorkflowFormInfo = JSON.parse(json);
|
||||
$that.newOaWorkflowFormInfo.formJson = JSON.parse(_newOaWorkflowFormInfo.data[0].formJson);
|
||||
$that._initForm();
|
||||
let _newOaWorkflowFormEditInfo = JSON.parse(json);
|
||||
$that.newOaWorkflowFormEditInfo.formJson = JSON.parse(_newOaWorkflowFormEditInfo.data[0].formJson);
|
||||
$that.newOaWorkflowFormEditInfo.components = $that.newOaWorkflowFormEditInfo.formJson.components;
|
||||
$that._listOaWorkflowDetails();
|
||||
|
||||
}, function (errInfo, error) {
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
},
|
||||
_initForm: function () {
|
||||
const container = document.querySelector('#form');
|
||||
const form = FormViewer.createForm({
|
||||
container,
|
||||
schema: $that.newOaWorkflowFormInfo.formJson
|
||||
});
|
||||
console.log(form);
|
||||
form.then((_from) => {
|
||||
_from.on('submit', (event) => {
|
||||
$that._submitFormData(event.data, event.errors);
|
||||
})
|
||||
})
|
||||
_listOaWorkflowDetails: function () {
|
||||
var param = {
|
||||
params: {
|
||||
page: 1,
|
||||
row: 1,
|
||||
id: $that.newOaWorkflowFormEditInfo.id,
|
||||
flowId: $that.newOaWorkflowFormEditInfo.flowId
|
||||
}
|
||||
};
|
||||
|
||||
//发送get请求
|
||||
vc.http.apiGet('/oaWorkflow/queryOaWorkflowFormData',
|
||||
param,
|
||||
function (json, res) {
|
||||
var _newOaWorkflowDetailInfo = JSON.parse(json);
|
||||
let _data = _newOaWorkflowDetailInfo.data[0];
|
||||
$that.newOaWorkflowFormEditInfo.components.forEach(item => {
|
||||
item.value = _data[item.key];
|
||||
})
|
||||
$that.$forceUpdate();
|
||||
}, function (errInfo, error) {
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
},
|
||||
_submitFormData(_data, _err) {
|
||||
if (Object.keys(_err).length != 0) {
|
||||
return;
|
||||
}
|
||||
console.log('我要的数据', _data);
|
||||
_data.flowId = $that.newOaWorkflowFormInfo.flowId;
|
||||
_submitFormData() {
|
||||
//做数据校验
|
||||
let _components = $that.newOaWorkflowFormEditInfo.components;
|
||||
let _data = {
|
||||
id: $that.newOaWorkflowFormEditInfo.id,
|
||||
flowId: $that.newOaWorkflowFormEditInfo.flowId
|
||||
};
|
||||
|
||||
_components.forEach(item => {
|
||||
if (item.validate && item.validate.required == true && !item.value) {
|
||||
vc.toast(item.label + "不能为空")
|
||||
throw Error(item.label + "不能为空");
|
||||
}
|
||||
if (item.type != 'button' && item.type != 'text') {
|
||||
_data[item.key] = item.value;
|
||||
if (item.type == 'checkbox') {
|
||||
_data[item.key] = item.value.length > 0 ? item.value[0] : '';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vc.http.apiPost(
|
||||
'/oaWorkflow/saveOaWorkflowFormData',
|
||||
'/oaWorkflow/updateOaWorkflowFormData',
|
||||
JSON.stringify(_data),
|
||||
{
|
||||
emulateJSON: true
|
||||
@ -75,7 +104,7 @@
|
||||
if (_json.code == 0) {
|
||||
//关闭model
|
||||
vc.toast('提交成功');
|
||||
vc.emit('newOaWorkflow', 'switch', 'newOaWorkflowPool')
|
||||
$that.closeEditInfo();
|
||||
return;
|
||||
}
|
||||
vc.toast(_json.msg);
|
||||
@ -86,6 +115,9 @@
|
||||
vc.toast(errInfo);
|
||||
|
||||
});
|
||||
},
|
||||
closeEditInfo: function () {
|
||||
vc.goBack();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user