优化OA编辑完成

This commit is contained in:
java110 2021-09-15 00:15:13 +08:00
parent 8ef908aa00
commit 4462dd0b3e
5 changed files with 306 additions and 4 deletions

View File

@ -87,6 +87,31 @@ export function saveOaWorkflowFormData(_that,_data){
});
}
/**
* 编辑申请
* @param {Object} _that
* @param {Object} _data
*/
export function updateOaWorkflowFormData(_that,_data){
return new Promise(function(reslove,reject){
_that.context.post({
url: url.updateOaWorkflowFormData,
data:_data,
success: function(res) {
reslove(res);
},
fail: function(e) {
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
})
}
})
});
}
/**
* 审核
* @param {Object} _that

View File

@ -140,7 +140,7 @@ export default {
getNextTask: baseUrl + "app/oaWorkflow/getNextTask",
auditOaWorkflow: baseUrl + "app/oaWorkflow/auditOaWorkflow",
updateOaWorkflowFormData: baseUrl +"app/oaWorkflow.updateOaWorkflowFormData",

View File

@ -490,7 +490,16 @@
"path" : "pages/newOaWorkflowUndoAudit/newOaWorkflowUndoAudit",
"style" :
{
"navigationBarTitleText": "",
"navigationBarTitleText": "流程审核",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/newOaWorkflowFormEdit/newOaWorkflowFormEdit",
"style" :
{
"navigationBarTitleText": "表单修改",
"enablePullDownRefresh": false
}

View File

@ -14,8 +14,10 @@
<view class="text-gray">{{item.label}}</view>
<view class="text-gray">{{oaWorkflowData[item.key]}}</view>
</view>
<view class="solid-top flex justify-end margin-top padding-top-sm " v-if="action=='Audit'">
<button class="cu-btn sm bg-green margin-left" @click="doDealOaWorkflow()">处理</button>
<view class="solid-top flex justify-end margin-top padding-top-sm " >
<button class="cu-btn sm bg-orange margin-left" @click="doEditOaWorkflow()" v-if="isMe()">编辑</button>
<button class="cu-btn sm bg-green margin-left" @click="doDealOaWorkflow()" v-if="action=='Audit'">处理</button>
</view>
</view>
@ -50,6 +52,7 @@
queryOaWorkflowUser,
listRunWorkflowImage
} from '../../api/oa/oa.js'
import {getUserInfo} from '../../lib/java110/api/Java110SessionApi.js'
export default {
data() {
return {
@ -87,6 +90,13 @@
_that.components = _that.formJson.components;
})
},
isMe:function(){
let _userId = getUserInfo().userId;
if(this.oaWorkflowData.create_user_id == _userId){
return true;
}
return false;
},
_loadOaWorkflowDetail: function() {
let _that = this;
queryOaWorkflowFormData(this, {
@ -123,6 +133,11 @@
url:'/pages/newOaWorkflowUndoAudit/newOaWorkflowUndoAudit?flowId='+this.flowId+"&id="+this.id+"&taskId="+this.taskId
})
},
doEditOaWorkflow:function(){
this.context.navigateTo({
url:'/pages/newOaWorkflowFormEdit/newOaWorkflowFormEdit?flowId='+this.flowId+"&id="+this.id
})
},
_getNewOaWorkflowDetailState: function(_finish) {
/**

View File

@ -0,0 +1,253 @@
<template>
<view>
<view v-for="(item,index) in components">
<!-- 标题 -->
<view class="block__title" v-if="item.type=='text'">{{item.text}}</view>
<!--文本框-->
<view class="cu-form-group margin-top-xs" v-if="item.type== 'textfield'">
<view class="title">{{item.label}}</view>
<input v-model="item.value" type="text" :placeholder="item.description" class="text-right"></input>
</view>
<!--数字框-->
<view class="cu-form-group margin-top-xs" v-if="item.type== 'number'">
<view class="title">{{item.label}}</view>
<input v-model="item.value" type="number" :placeholder="item.description" class="text-right"></input>
</view>
<view class="cu-form-group margin-top" v-if="item.type== 'textarea'">
<textarea v-model="item.value" :placeholder="item.description"></textarea>
</view>
<!--日期选择-->
<view class="cu-form-group arrow margin-top-xs" v-if="item.type== 'textdate'">
<view class="title">{{item.label}}</view>
<picker mode="date" :value="item.value" start="2010-09-01" end="2050-09-01"
@change="dateChange($event,item)">
<view class="picker">
{{item.value}}
</view>
</picker>
</view>
<view class="cu-form-group arrow margin-top-xs" v-if="item.type== 'textdatetime'">
<view class="title">{{item.label}}</view>
<picker mode="time" :value="item.value" start="00:00" end="23:59" @change="timeChange($event,item)">
<view class="picker">
{{item.value}}
</view>
</picker>
</view>
<view class="cu-form-group arrow margin-top-xs" v-if="item.type== 'radio' ">
<view class="title">{{item.label}}</view>
<picker bindchange="PickerChange" :value="item.valueIndex" :range-key="'label'" :range="item.values"
@change="selectChange($event,item)">
<view class="picker">
{{item.values.length==0 ? "请选择" : item.values[item.valueIndex].label}}
</view>
</picker>
</view>
<view class="cu-form-group arrow margin-top-xs" v-if="item.type== 'select' ">
<view class="title">{{item.label}}</view>
<picker bindchange="PickerChange" :value="item.valueIndex" :range-key="'label'" :range="item.values"
@change="selectChange($event,item)">
<view class="picker">
{{item.values.length==0 ? "请选择" : item.values[item.valueIndex].label}}
</view>
</picker>
</view>
<checkbox-group class="block" @change="checkboxChange($event,item)" v-if="item.type== 'checkbox' ">
<view class="cu-form-group margin-top-xs">
<view class="title">{{item.label}}</view>
<checkbox :class="item.value == item.label?'checked':''"
:checked="item.value == item.label?true:false" :value="item.label"></checkbox>
</view>
</checkbox-group>
<!--提交框-->
<view v-if="item.type== 'button' && item.action == 'submit'">
<view class="button_up_blank"></view>
<view class="flex flex-direction">
<button class="cu-btn bg-green margin-tb-sm lg" @click="_doSubmit()">{{item.label}}</button>
</view>
</view>
<!--重置框-->
<view v-if="item.type== 'button' && item.action == 'reset'">
<view class="button_up_blank"></view>
<view class="flex flex-direction">
<button class="cu-btn bg-white margin-tb-sm lg" @click="_doReset()">{{item.label}}</button>
</view>
</view>
</view>
</view>
</template>
<script>
import {
queryOaWorkflowForm,
updateOaWorkflowFormData,
queryOaWorkflowFormData
} from '../../api/oa/oa.js'
import {
isEmpty
} from '../../lib/java110/utils/StringUtil.js'
export default {
data() {
return {
formJson: {},
components: [],
flowId: '',
flowName: '',
id:''
}
},
onLoad(options) {
this.java110Context.onLoad();
this.flowId = options.flowId;
this.id = options.id;
this.flowName = options.flowName;
this._loadForm();
},
methods: {
_loadForm: function() {
let _that = this;
queryOaWorkflowForm(this, {
page: 1,
row: 1,
flowId: this.flowId
}).then(_data => {
_that.formJson = JSON.parse(_data.data[0].formJson);
console.log(_that.formJson);
_that.components = _that.formJson.components;
_that.components.forEach(item => {
item.value = "";
if (item.type == 'textdate' || item.type == 'textdatetime') {
item.value = "请选择";
}
if (item.type == "radio" || item.type == "select") {
item.valueIndex = 0;
}
})
}).then(_data=>{
return queryOaWorkflowFormData(this, {
page: 1,
row: 1,
flowId: this.flowId,
id: this.id
})
}).then(_data => {
let _oaData = _data.data[0];
_that.components.forEach(item => {
item.value = _oaData[item.key];
})
console.log(_that.components);
_that.$forceUpdate();
})
},
dateChange: function(e, obj) {
obj.value = e.detail.value;
this.$forceUpdate();
},
timeChange: function(e, obj) {
obj.value = e.detail.value;
this.$forceUpdate();
},
checkboxChange: function(e, obj) {
obj.value = e.detail.value;
console.log(obj, e.detail)
this.$forceUpdate();
},
selectChange: function(e, obj) {
obj.valueIndex = e.target.value //
let selected = obj.values[obj.valueIndex] //
if (selected == undefined) {
return;
}
obj.value = selected.value //id
this.$forceUpdate();
},
_doSubmit: function() {
//
let _components = this.components;
let _data = {};
_components.forEach(item => {
if (item.validate && item.validate.required == true && isEmpty(item.value)) {
uni.showToast({
title: item.label + "不能为空",
icon: 'none',
duration: 2000
})
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] : '';
}
}
});
_data.flowId = this.flowId;
_data.id = this.id;
updateOaWorkflowFormData(this, _data)
.then(_data => {
if (_data.data.code == 0) {
uni.showToast({
title: "提交成功",
icon: 'none',
duration: 2000
})
uni.navigateBack({
delta: 1
})
return;
}
uni.showToast({
title: _data.data.msg,
icon: 'none',
duration: 2000
})
}, _err => {
uni.showToast({
title: '网络异常',
icon: 'none',
duration: 2000
})
})
},
_doReset: function() {
let _that = this;
_that.components.forEach(item => {
item.value = "";
if (item.type == 'textdate' || item.type == 'textdatetime') {
item.value = "请选择";
}
if (item.type == "radio" || item.type == "select") {
item.valueIndex = 0;
}
});
this.$forceUpdate();
}
}
}
</script>
<style>
.block__title {
margin: 0;
font-weight: 400;
font-size: 14px;
color: rgba(69, 90, 100, .6);
padding: 40rpx 30rpx 20rpx;
}
.button_up_blank {
height: 40rpx;
}
</style>