|
@@ -22,15 +22,30 @@
|
|
|
<a-button style="margin-left: 8px" :disabled="disabled" @click="close">取消</a-button>
|
|
|
</a-form-item>
|
|
|
</a-form>-->
|
|
|
- <k-form-build :value="jsonData" @change="handleChange" :dynamicData="dynamicData" ref="KFB" @submit="handleSubmit" />
|
|
|
+ <k-form-build
|
|
|
+ :value="jsonData"
|
|
|
+ @change="handleChange"
|
|
|
+ :dynamicData="dynamicData"
|
|
|
+ ref="KFB"
|
|
|
+ @submit="handleSubmit"
|
|
|
+ />
|
|
|
<div style="text-align:center">
|
|
|
- <a-button
|
|
|
- htmlType="submit"
|
|
|
- type="primary"
|
|
|
- :disabled="disabled||btndisabled"
|
|
|
- @click="handleSubmit"
|
|
|
- >保存</a-button>
|
|
|
- <a-button style="margin-left: 8px;" :disabled="disabled||disabled2" @click="close">取消</a-button>
|
|
|
+ <a-button
|
|
|
+ htmlType="submit"
|
|
|
+ type="primary"
|
|
|
+ :disabled="disabled||btndisabled"
|
|
|
+ @click="handleSubmit"
|
|
|
+ >保存</a-button>
|
|
|
+ <todoManageOperation
|
|
|
+ v-if="processData.operationType&&processData.operationType=='1'"
|
|
|
+ :processData="processData"
|
|
|
+ :todoManageOperationObject="todoManageOperationObject"
|
|
|
+ :disabled="disabled"
|
|
|
+ :btndisabled="btndisabled"
|
|
|
+ @refreshToDo="refreshToDo"
|
|
|
+ @handleSubmit2="handleSubmit2"
|
|
|
+ ></todoManageOperation>
|
|
|
+ <a-button style="margin-left: 8px;" :disabled="disabled||disabled2" @click="close">取消</a-button>
|
|
|
</div>
|
|
|
</a-card>
|
|
|
</div>
|
|
@@ -38,6 +53,7 @@
|
|
|
|
|
|
<script>
|
|
|
import pick from 'lodash.pick'
|
|
|
+import todoManageOperation from '../operation/todoManageOperation'
|
|
|
|
|
|
export default {
|
|
|
name: 'demoForm',
|
|
@@ -59,9 +75,16 @@ export default {
|
|
|
/*是否新增*/
|
|
|
isNew: { type: Boolean, default: false, required: false }
|
|
|
},
|
|
|
+ components: {
|
|
|
+ todoManageOperation
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- disabled2:false,//用来取决于表单时不同流程节点填写不同表单信息使用
|
|
|
+ todoManageOperationObject: {
|
|
|
+ isSave: false,
|
|
|
+ formData: {}
|
|
|
+ },
|
|
|
+ disabled2: false, //用来取决于表单时不同流程节点填写不同表单信息使用
|
|
|
jsonData: {},
|
|
|
url: {
|
|
|
getForm: '/actBusiness/getForm',
|
|
@@ -77,31 +100,34 @@ export default {
|
|
|
btndisabled: false,
|
|
|
ceshi_file: null,
|
|
|
dynamicData: {
|
|
|
- typeData: [],//请假类型下拉数据
|
|
|
- reimbursementTypeList:[],//报销类型下拉数据
|
|
|
- invoiceTypeList:[],//发票类型下拉数据
|
|
|
+ typeData: [], //请假类型下拉数据
|
|
|
+ reimbursementTypeList: [], //报销类型下拉数据
|
|
|
+ invoiceTypeList: [] //发票类型下拉数据
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
console.log('流程数据', this.processData)
|
|
|
//加载一些下拉选择数据等
|
|
|
- this.getDataList();
|
|
|
+ this.getDataList()
|
|
|
let businessTable = ''
|
|
|
//如果没有值则在另一个属性上有值
|
|
|
if (!this.processData.businessTable) {
|
|
|
this.processData.businessTable = this.processData.tableName
|
|
|
}
|
|
|
- this.getAction('/tbTableInfo/query', { businessTable: this.processData.businessTable ,taskNodeId:this.processData.key}).then(res => {
|
|
|
+ this.getAction('/tbTableInfo/query', {
|
|
|
+ businessTable: this.processData.businessTable,
|
|
|
+ taskNodeId: this.processData.key
|
|
|
+ }).then(res => {
|
|
|
this.jsonData = res.result.jsonContent
|
|
|
// this.$refs.KFB.setData({aaa:null,bbb:null,name:"123"})
|
|
|
// this.$refs.KFB.getData().then(res => {
|
|
|
// console.log('aaa',res)
|
|
|
// })
|
|
|
//后台检测到流程节点有关联表单且前台处于我的待办界面打开表单详情
|
|
|
- if(res.result.isSave&&this.processData.isSuspended!=undefined){
|
|
|
- this.disabled=false;
|
|
|
- this.btndisabled=false;
|
|
|
+ if (res.result.isSave && this.processData.isSuspended != undefined) {
|
|
|
+ this.disabled = false
|
|
|
+ this.btndisabled = false
|
|
|
}
|
|
|
if (!this.isNew) {
|
|
|
this.init()
|
|
@@ -110,7 +136,7 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
//获取获取下拉数据等
|
|
|
- getDataList(){
|
|
|
+ getDataList() {
|
|
|
//获取请假类型下拉数据
|
|
|
this.getAction(this.url.leaveType + '/leave_type').then(res => {
|
|
|
if (res.success) {
|
|
@@ -165,14 +191,11 @@ export default {
|
|
|
handleChange(value, key) {
|
|
|
// 数据变化时触发
|
|
|
//如果开始时间发生变化
|
|
|
- if(key=="start_time"){
|
|
|
+ if (key == 'start_time') {
|
|
|
//判断结束时间是否存在
|
|
|
if (this.$refs.KFB.form.getFieldValue('end_time')) {
|
|
|
//获取时间差
|
|
|
- let duration = startEndFun(
|
|
|
- value,
|
|
|
- this.$refs.KFB.form.getFieldValue('end_time')
|
|
|
- )
|
|
|
+ let duration = startEndFun(value, this.$refs.KFB.form.getFieldValue('end_time'))
|
|
|
if (duration) {
|
|
|
// 使用k-form-design组件的form属性修改表单数据
|
|
|
this.$refs.KFB.setData({
|
|
@@ -182,14 +205,11 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
//如果结束时间发生变化
|
|
|
- if(key=="end_time"){
|
|
|
+ if (key == 'end_time') {
|
|
|
//判断结束时间是否存在
|
|
|
if (this.$refs.KFB.form.getFieldValue('start_time')) {
|
|
|
//获取时间差
|
|
|
- let duration = startEndFun(
|
|
|
- this.$refs.KFB.form.getFieldValue('start_time'),
|
|
|
- value
|
|
|
- )
|
|
|
+ let duration = startEndFun(this.$refs.KFB.form.getFieldValue('start_time'), value)
|
|
|
if (duration) {
|
|
|
// 使用k-form-design组件的form属性修改表单数据
|
|
|
this.$refs.KFB.setData({
|
|
@@ -201,7 +221,8 @@ export default {
|
|
|
},
|
|
|
// handler
|
|
|
handleSubmit(e) {
|
|
|
- // 通过函数获取数据
|
|
|
+ // return new Promise((resolve)=>{
|
|
|
+ //通过函数获取数据
|
|
|
this.$refs.KFB.getData()
|
|
|
.then(res => {
|
|
|
// 获取数据成功
|
|
@@ -211,70 +232,155 @@ export default {
|
|
|
formData.procDefId = this.processData.id
|
|
|
formData.procDeTitle = this.processData.name
|
|
|
if (!formData.tableName) formData.tableName = this.processData.businessTable
|
|
|
- formData.filedNames = _.keys(res).join(',');
|
|
|
- formData.filedNames=getFiledNames(formData);//获取主表字段,排除子表标识
|
|
|
+ formData.filedNames = _.keys(res).join(',')
|
|
|
+ formData.filedNames = getFiledNames(formData) //获取主表字段,排除子表标识
|
|
|
var url = this.url.addApply
|
|
|
if (!this.isNew) {
|
|
|
url = this.url.editForm
|
|
|
}
|
|
|
//是否存在子表
|
|
|
- let ischild=false;
|
|
|
+ let ischild = false
|
|
|
//循环表单字段属性判断是否属性中包含数组对象
|
|
|
- let i=0;//子表数量
|
|
|
- _.keys(res).join(',').split(',').forEach(element => {
|
|
|
- if (formData[element] instanceof Array) {
|
|
|
- //判断是否符合子表命名规则
|
|
|
- if (element.indexOf('&') != -1) {
|
|
|
- let tableChildNameList = element.split('&')
|
|
|
- //判断是否能拆分两个字符,子表标识和子表数据库名称
|
|
|
- if (tableChildNameList.length == 2) {
|
|
|
- i++;
|
|
|
- let childName = tableChildNameList[1] //子表数据库名称
|
|
|
- if(!formData.table_name_children){
|
|
|
- //第一次拼接
|
|
|
- formData.table_name_children = childName //表名
|
|
|
- }else{//后面的表明拼接用“,”隔开
|
|
|
- formData.table_name_children = formData.table_name_children+","+childName //表名
|
|
|
+ let i = 0 //子表数量
|
|
|
+ _.keys(res)
|
|
|
+ .join(',')
|
|
|
+ .split(',')
|
|
|
+ .forEach(element => {
|
|
|
+ if (formData[element] instanceof Array) {
|
|
|
+ //判断是否符合子表命名规则
|
|
|
+ if (element.indexOf('&') != -1) {
|
|
|
+ let tableChildNameList = element.split('&')
|
|
|
+ //判断是否能拆分两个字符,子表标识和子表数据库名称
|
|
|
+ if (tableChildNameList.length == 2) {
|
|
|
+ i++
|
|
|
+ let childName = tableChildNameList[1] //子表数据库名称
|
|
|
+ if (!formData.table_name_children) {
|
|
|
+ //第一次拼接
|
|
|
+ formData.table_name_children = childName //表名
|
|
|
+ } else {
|
|
|
+ //后面的表明拼接用“,”隔开
|
|
|
+ formData.table_name_children = formData.table_name_children + ',' + childName //表名
|
|
|
+ }
|
|
|
+ //定义属性名和值
|
|
|
+ formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') //子表字段名
|
|
|
+ formData['childList' + i] = JSON.stringify(formData[element]) //子表数据
|
|
|
+ ischild = true
|
|
|
}
|
|
|
- //定义属性名和值
|
|
|
- formData["childFiledNames"+i] = _.keys(formData[element][0]).join(',') //子表字段名
|
|
|
- formData["childList"+i] = JSON.stringify(formData[element]) //子表数据
|
|
|
- ischild=true;
|
|
|
+ } else {
|
|
|
+ //如果不是子表则是上传文件,则转字符串
|
|
|
+ formData[element] = JSON.stringify(formData[element])
|
|
|
}
|
|
|
- } else {
|
|
|
- //如果不是子表则是上传文件,则转字符串
|
|
|
- formData[element] = JSON.stringify(formData[element])
|
|
|
}
|
|
|
- }
|
|
|
- // formData[element];
|
|
|
- })
|
|
|
+ // formData[element];
|
|
|
+ })
|
|
|
//判断需不需要存子表
|
|
|
- if(ischild){
|
|
|
- formData.filedNames=formData.filedNames+",table_name_children";
|
|
|
+ if (ischild) {
|
|
|
+ formData.filedNames = formData.filedNames + ',table_name_children'
|
|
|
}
|
|
|
|
|
|
console.log(formData)
|
|
|
//子表数据
|
|
|
-
|
|
|
//调用保存接口
|
|
|
this.btndisabled = true
|
|
|
+ this.todoManageOperationObject.formData = formData
|
|
|
+ this.todoManageOperationObject.url = url
|
|
|
+ //非我的待办节点打卡表单界面
|
|
|
this.postFormAction(url, formData)
|
|
|
.then(res => {
|
|
|
if (res.success) {
|
|
|
+ this.todoManageOperationObject.isSave = true
|
|
|
this.$message.success('保存成功!')
|
|
|
+ console.log('123')
|
|
|
this.$emit('afterSubmit', formData)
|
|
|
this.$emit('close')
|
|
|
+ // resolve(true);
|
|
|
} else {
|
|
|
this.$message.error(res.message)
|
|
|
+ // resolve(false);
|
|
|
}
|
|
|
})
|
|
|
.finally(() => {
|
|
|
this.btndisabled = false
|
|
|
+ // resolve(false);
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log(err, '校验失败')
|
|
|
+ // resolve(false);
|
|
|
+ })
|
|
|
+ // })
|
|
|
+ },
|
|
|
+ //我的待办点击通过保存专用
|
|
|
+ handleSubmit2(e) {
|
|
|
+ // return new Promise((resolve)=>{
|
|
|
+ //通过函数获取数据
|
|
|
+ this.$refs.KFB.getData()
|
|
|
+ .then(res => {
|
|
|
+ // 获取数据成功
|
|
|
+ let formData = JSON.parse(JSON.stringify(res))
|
|
|
+ console.log(formData)
|
|
|
+ formData.id = this.data.id
|
|
|
+ formData.procDefId = this.processData.id
|
|
|
+ formData.procDeTitle = this.processData.name
|
|
|
+ if (!formData.tableName) formData.tableName = this.processData.businessTable
|
|
|
+ formData.filedNames = _.keys(res).join(',')
|
|
|
+ formData.filedNames = getFiledNames(formData) //获取主表字段,排除子表标识
|
|
|
+ var url = this.url.addApply
|
|
|
+ if (!this.isNew) {
|
|
|
+ url = this.url.editForm
|
|
|
+ }
|
|
|
+ //是否存在子表
|
|
|
+ let ischild = false
|
|
|
+ //循环表单字段属性判断是否属性中包含数组对象
|
|
|
+ let i = 0 //子表数量
|
|
|
+ _.keys(res)
|
|
|
+ .join(',')
|
|
|
+ .split(',')
|
|
|
+ .forEach(element => {
|
|
|
+ if (formData[element] instanceof Array) {
|
|
|
+ //判断是否符合子表命名规则
|
|
|
+ if (element.indexOf('&') != -1) {
|
|
|
+ let tableChildNameList = element.split('&')
|
|
|
+ //判断是否能拆分两个字符,子表标识和子表数据库名称
|
|
|
+ if (tableChildNameList.length == 2) {
|
|
|
+ i++
|
|
|
+ let childName = tableChildNameList[1] //子表数据库名称
|
|
|
+ if (!formData.table_name_children) {
|
|
|
+ //第一次拼接
|
|
|
+ formData.table_name_children = childName //表名
|
|
|
+ } else {
|
|
|
+ //后面的表明拼接用“,”隔开
|
|
|
+ formData.table_name_children = formData.table_name_children + ',' + childName //表名
|
|
|
+ }
|
|
|
+ //定义属性名和值
|
|
|
+ formData['childFiledNames' + i] = _.keys(formData[element][0]).join(',') //子表字段名
|
|
|
+ formData['childList' + i] = JSON.stringify(formData[element]) //子表数据
|
|
|
+ ischild = true
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //如果不是子表则是上传文件,则转字符串
|
|
|
+ formData[element] = JSON.stringify(formData[element])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // formData[element];
|
|
|
})
|
|
|
+ //判断需不需要存子表
|
|
|
+ if (ischild) {
|
|
|
+ formData.filedNames = formData.filedNames + ',table_name_children'
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(formData)
|
|
|
+ //子表数据
|
|
|
+ //调用保存接口
|
|
|
+ this.btndisabled = true
|
|
|
+ this.todoManageOperationObject.formData = formData
|
|
|
+ this.todoManageOperationObject.url = url
|
|
|
})
|
|
|
.catch(err => {
|
|
|
console.log(err, '校验失败')
|
|
|
+ // resolve(false);
|
|
|
})
|
|
|
+ // })
|
|
|
},
|
|
|
close() {
|
|
|
this.$emit('close')
|
|
@@ -289,23 +395,31 @@ export default {
|
|
|
.catch(err => {
|
|
|
console.log(err, '校验失败')
|
|
|
})
|
|
|
+ },
|
|
|
+ //刷新待办列表
|
|
|
+ refreshToDo() {
|
|
|
+ this.close()
|
|
|
+ this.$emit('getDataList')
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//获取主表字段,排除子表标识
|
|
|
function getFiledNames(formData) {
|
|
|
- let filedNames="";
|
|
|
- let list = formData.filedNames.split(',');//获取表单属性名集合
|
|
|
+ let filedNames = ''
|
|
|
+ let list = formData.filedNames.split(',') //获取表单属性名集合
|
|
|
list.forEach(element => {
|
|
|
- if (element.indexOf('&')==-1) {//查询是否有这个字段
|
|
|
- if(filedNames==""){//第一次则直接等于
|
|
|
- filedNames=element;
|
|
|
- }else{//后面用逗号隔开
|
|
|
- filedNames=filedNames+","+element
|
|
|
+ if (element.indexOf('&') == -1) {
|
|
|
+ //查询是否有这个字段
|
|
|
+ if (filedNames == '') {
|
|
|
+ //第一次则直接等于
|
|
|
+ filedNames = element
|
|
|
+ } else {
|
|
|
+ //后面用逗号隔开
|
|
|
+ filedNames = filedNames + ',' + element
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- return filedNames;
|
|
|
+ return filedNames
|
|
|
}
|
|
|
|
|
|
//根据开始时间 结束时间计算天数
|