Browse Source

工作流

chenc 3 years ago
parent
commit
f5865728c2
6 changed files with 188 additions and 48 deletions
  1. 1 0
      src/main.js
  2. 6 0
      src/main.less
  3. 3 2
      src/router/index.js
  4. 114 13
      src/views/activiti/form/demoForm2.vue
  5. 34 30
      src/views/activiti/mixins/activitiMixin.js
  6. 30 3
      vue.config.js

+ 1 - 0
src/main.js

@@ -9,6 +9,7 @@ import { getAction,postFormAction ,postAction} from "@/api/manage"
 
 import Antd from 'ant-design-vue'
 import Viser from 'viser-vue'
+import 'k-form-design/lib/k-form-design.css'
 import 'ant-design-vue/dist/antd.less';  // or 'ant-design-vue/dist/antd.less'
 
 import '@/permission' // permission control

+ 6 - 0
src/main.less

@@ -0,0 +1,6 @@
+@primary-color: red; // 主色
+@layout-color: red; // 布局色
+@title-text-color: red; // 标题文字颜色
+@header-height: 56px; // 头部高度
+@left-right-width: 270px; // 左右栏宽度
+@border-color: red; // 边框颜色

+ 3 - 2
src/router/index.js

@@ -15,8 +15,9 @@ try {
 Vue.use(Router)
 
 export default new Router({
-  mode: 'history',
+  // mode: 'history',
   base: process.env.BASE_URL,
   scrollBehavior: () => ({ y: 0 }),
   routes: constantRouterMap
-})
+})
+

+ 114 - 13
src/views/activiti/form/demoForm2.vue

@@ -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 {

+ 34 - 30
src/views/activiti/mixins/activitiMixin.js

@@ -12,18 +12,20 @@ export const activitiMixin = {
     return {
       //token header
       tokenHeader: {'X-Access-Token': Vue.ls.get(ACCESS_TOKEN)},
-      tableListAll:[{
-        text:'请假申请',
-          routeName:'@/views/activiti/form/cdLeaveForm',
-        component:() => import(`@/views/activiti/form/cdLeaveForm`),
-        businessTable:'cd_leave'
-      },
-      {
-        text:'报销申请',
-        routeName:'@/views/activiti/form/cdReimbursementForm',
-        component:() => import(`@/views/activiti/form/cdReimbursementForm`),
-        businessTable:'cd_reimbursement'
-      }]
+      tableListAll:[
+      //   {
+      //   text:'请假申请',
+      //     routeName:'@/views/activiti/form/cdLeaveForm',
+      //   component:() => import(`@/views/activiti/form/cdLeaveForm`),
+      //   businessTable:'cd_leave'
+      // },
+      // {
+      //   text:'报销申请',
+      //   routeName:'@/views/activiti/form/cdReimbursementForm',
+      //   component:() => import(`@/views/activiti/form/cdReimbursementForm`),
+      //   businessTable:'cd_reimbursement'
+      // }
+    ]
     }
   },
   computed:{
@@ -63,24 +65,26 @@ export const activitiMixin = {
           //获取其他项目表单
           tableList=res.result
           //获取固定表单
-          let nowTableList=[{
-            text:'请假申请',
-              routeName:'@/views/activiti/form/cdLeaveForm',
-            component:() => import(`@/views/activiti/form/cdLeaveForm`),
-            businessTable:'cd_leave'
-          },
-          {
-            text:'报销申请',
-            routeName:'@/views/activiti/form/cdReimbursementForm',
-            component:() => import(`@/views/activiti/form/cdReimbursementForm`),
-            businessTable:'cd_reimbursement'
-          },
-          {
-            text:'报销申请2',
-            routeName:'@/views/activiti/form/demoForm2',
-            component:() => import(`@/views/activiti/form/demoForm2`),
-            businessTable:'test_demo2'
-          }];
+          let nowTableList=[
+          //   {
+          //   text:'请假申请',
+          //     routeName:'@/views/activiti/form/cdLeaveForm',
+          //   component:() => import(`@/views/activiti/form/cdLeaveForm`),
+          //   businessTable:'cd_leave'
+          // },
+          // {
+          //   text:'报销申请',
+          //   routeName:'@/views/activiti/form/cdReimbursementForm',
+          //   component:() => import(`@/views/activiti/form/cdReimbursementForm`),
+          //   businessTable:'cd_reimbursement'
+          // },
+          // {
+          //   text:'报销申请2',
+          //   routeName:'@/views/activiti/form/demoForm2',
+          //   component:() => import(`@/views/activiti/form/demoForm2`),
+          //   businessTable:'test_demo2'
+          // }
+        ];
           //把其他表单中的表数据添加到原有的下拉数据中合并
           if(tableList!=null&&tableList.length>0){
             tableList.forEach(element => {

+ 30 - 3
vue.config.js

@@ -53,8 +53,28 @@ module.exports = {
       }
     }
   },
-
+  // devServer: {
+  //   port: 3000,
+  //   proxy: {
+  //     /* '/api': {
+  //       target: 'https://mock.ihx.me/mock/5baf3052f7da7e07e04a5116/antd-pro', //mock API接口系统
+  //       ws: false,
+  //       changeOrigin: true,
+  //       pathRewrite: {
+  //         '/jeecg-boot': ''  //默认所有请求都加了jeecg-boot前缀,需要去掉
+  //       }
+  //     }, */
+  //     '/jeecg-boot': {
+  //       target: 'http://127.0.0.1:8090', // 请求本地 需要jeecg-boot后台项目
+  //       // target: 'http://106.15.206.14:8087', // 测试环境
+  //       // ws: false,
+  //       changeOrigin: true
+  //     }
+  //   }
+  // },
   devServer: {
+    assetsSubDirectory:'static',
+    assetsPublicPath:'./',
     port: 3000,
     proxy: {
       /* '/api': {
@@ -67,11 +87,18 @@ module.exports = {
       }, */
       '/jeecg-boot': {
         target: 'http://127.0.0.1:8090', // 请求本地 需要jeecg-boot后台项目
-        ws: false,
+        // target: 'http://106.15.206.14:8087', // 测试环境
+        // ws: false,
         changeOrigin: true
       }
     }
   },
 
-  lintOnSave: undefined
+  lintOnSave: undefined,
+  // build:{
+  //   index:path.resolve(__dirname,'../dist/index.html'),
+  //   assetsRoot:path.resolve(__dirname,'../dist'),
+  //   assetsSubDirectory:'static',
+  //   assetsPublicPath:'./'
+  // }
 }