|
@@ -22,14 +22,16 @@
|
|
|
<a-button style="margin-left: 8px" :disabled="disabled" @click="close">取消</a-button>
|
|
|
</a-form-item>
|
|
|
</a-form>-->
|
|
|
- <k-form-build :value="jsonData" :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" @click="close">取消</a-button>
|
|
|
+ <a-button style="margin-left: 8px;" :disabled="disabled" @click="close">取消</a-button>
|
|
|
+ </div>
|
|
|
</a-card>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -63,7 +65,8 @@ export default {
|
|
|
url: {
|
|
|
getForm: '/actBusiness/getForm',
|
|
|
addApply: '/actBusiness/add',
|
|
|
- editForm: '/actBusiness/editForm'
|
|
|
+ editForm: '/actBusiness/editForm',
|
|
|
+ leaveType: '/sys/dict/getDictItems'
|
|
|
},
|
|
|
description: '流程表单demo,按例开发表单。需在 activitiMixin.js 中加入写好的表单',
|
|
|
// form
|
|
@@ -73,21 +76,16 @@ export default {
|
|
|
btndisabled: false,
|
|
|
ceshi_file: null,
|
|
|
dynamicData: {
|
|
|
- aa: [
|
|
|
- {
|
|
|
- value: '1',
|
|
|
- label: '男'
|
|
|
- },
|
|
|
- {
|
|
|
- value: '2',
|
|
|
- label: '女'
|
|
|
- }
|
|
|
- ]
|
|
|
+ typeData: [],//请假类型下拉数据
|
|
|
+ reimbursementTypeList:[],//报销类型下拉数据
|
|
|
+ invoiceTypeList:[],//发票类型下拉数据
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
console.log('流程数据', this.processData)
|
|
|
+ //加载一些下拉选择数据等
|
|
|
+ this.getDataList();
|
|
|
let businessTable = ''
|
|
|
//如果没有值则在另一个属性上有值
|
|
|
if (!this.processData.businessTable) {
|
|
@@ -106,6 +104,33 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
methods: {
|
|
|
+ //获取获取下拉数据等
|
|
|
+ getDataList(){
|
|
|
+ //获取请假类型下拉数据
|
|
|
+ this.getAction(this.url.leaveType + '/leave_type').then(res => {
|
|
|
+ if (res.success) {
|
|
|
+ this.dynamicData.typeData = res.result
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //获取报销类型下拉数据
|
|
|
+ this.getAction(this.url.leaveType + '/reimbursement_type').then(res => {
|
|
|
+ if (res.success) {
|
|
|
+ this.dynamicData.reimbursementTypeList = res.result
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //获取发票类型下拉数据
|
|
|
+ this.getAction(this.url.leaveType + '/invoice_type').then(res => {
|
|
|
+ if (res.success) {
|
|
|
+ this.dynamicData.invoiceTypeList = res.result
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
/*回显数据*/
|
|
|
init() {
|
|
|
this.btndisabled = true
|
|
@@ -131,6 +156,44 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ //表单字段数值发生改变事件
|
|
|
+ handleChange(value, key) {
|
|
|
+ // 数据变化时触发
|
|
|
+ //如果开始时间发生变化
|
|
|
+ if(key=="start_time"){
|
|
|
+ //判断结束时间是否存在
|
|
|
+ if (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({
|
|
|
+ duration: duration
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果结束时间发生变化
|
|
|
+ if(key=="end_time"){
|
|
|
+ //判断结束时间是否存在
|
|
|
+ if (this.$refs.KFB.form.getFieldValue('start_time')) {
|
|
|
+ //获取时间差
|
|
|
+ let duration = startEndFun(
|
|
|
+ this.$refs.KFB.form.getFieldValue('start_time'),
|
|
|
+ value
|
|
|
+ )
|
|
|
+ if (duration) {
|
|
|
+ // 使用k-form-design组件的form属性修改表单数据
|
|
|
+ this.$refs.KFB.setData({
|
|
|
+ duration: duration
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
// handler
|
|
|
handleSubmit(e) {
|
|
|
// 通过函数获取数据
|
|
@@ -238,6 +301,44 @@ function getFiledNames(formData) {
|
|
|
})
|
|
|
return filedNames;
|
|
|
}
|
|
|
+
|
|
|
+//根据开始时间 结束时间计算天数
|
|
|
+function startEndFun(start, end) {
|
|
|
+ if (start && end) {
|
|
|
+ let startTime = new Date(start) // 开始时间
|
|
|
+ let endTime = new Date(end) // 结束时间
|
|
|
+ let usedTime = endTime - startTime // 相差的毫秒数
|
|
|
+ let days = (usedTime / 1000 / 60 / 60).toFixed(2) // 计算出天数
|
|
|
+ return days
|
|
|
+ } else {
|
|
|
+ return null
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//格式化时间
|
|
|
+function formatDate(date, fmt) {
|
|
|
+ if (/(y+)/.test(fmt)) {
|
|
|
+ fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
|
|
|
+ }
|
|
|
+ let o = {
|
|
|
+ 'M+': date.getMonth() + 1,
|
|
|
+ 'd+': date.getDate(),
|
|
|
+ 'h+': date.getHours(),
|
|
|
+ 'm+': date.getMinutes(),
|
|
|
+ 's+': date.getSeconds()
|
|
|
+ }
|
|
|
+ for (let k in o) {
|
|
|
+ if (new RegExp(`(${k})`).test(fmt)) {
|
|
|
+ let str = o[k] + ''
|
|
|
+ fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return fmt
|
|
|
+}
|
|
|
+
|
|
|
+function padLeftZero(str) {
|
|
|
+ return ('00' + str).substr(str.length)
|
|
|
+}
|
|
|
</script>
|
|
|
<style lang="less" scoped>
|
|
|
.form-main {
|