chenc 2 lat temu
rodzic
commit
2d5b770432
3 zmienionych plików z 242 dodań i 65 usunięć
  1. 56 35
      src/views/activiti/form/demoForm2.vue
  2. 184 28
      src/views/user/Login.vue
  3. 2 2
      vue.config.js

+ 56 - 35
src/views/activiti/form/demoForm2.vue

@@ -55,7 +55,7 @@
 import pick from 'lodash.pick'
 import todoManageOperation from '../operation/todoManageOperation'
 import { postAction, postFormDataAction } from '@/api/manage'
-import {getTotal,leaveTime} from './js/leave-date'
+import { getTotal, leaveTime } from './js/leave-date'
 export default {
   name: 'demoForm',
   props: {
@@ -89,6 +89,7 @@ export default {
       },
       disabled2: false, //用来取决于表单时不同流程节点填写不同表单信息使用
       jsonData: {},
+      jsonDataSave: {}, //保存到数据库的json
       url: {
         getForm: '/actBusiness/getForm',
         addApply: '/actBusiness/add',
@@ -139,7 +140,8 @@ export default {
     this.getAction('/tbTableInfo/query', {
       businessTable: this.processData.businessTable,
       taskNodeId: this.processData.key,
-      tableId: this.processData.tableId
+      tableId: this.processData.tableId,
+      type: '2'
     }).then(res => {
       // this.$refs.KFB.setData({aaa:null,bbb:null,name:"123"})
       // this.$refs.KFB.getData().then(res => {
@@ -192,6 +194,7 @@ export default {
                 this.dynamicData.add = this.add //新增按钮
                 //获取json
                 this.jsonData = res.result.jsonContent
+                this.jsonDataSave = JSON.parse(JSON.stringify(res.result.jsonContent))
                 //如果是手机端子表初始化子表model
                 this.listUpdateModel()
                 if (!this.isNew) {
@@ -266,41 +269,57 @@ export default {
     init() {
       this.btndisabled = true
       var r = this.processData
-
       this.getAction(this.url.getForm, {
         tableId: r.tableId,
         tableName: r.tableName
       }).then(res => {
-        if (res.success) {
-          let formData = res.result
-          formData.tableName = r.tableName
-          this.data = formData
-          //如果表单是手机端的子表则
-          if (this.isSJ) {
-            var formModelList = _.keys(this.data)
-              .join(',')
-              .split(',')
-            var itemList = []
-            formModelList.forEach(element => {
-              if (element.indexOf('child&') != -1) {
-                itemList = JSON.parse(JSON.stringify(this.data[element]))
-                delete this.data[element]
+        //第一次调接口根据子表数据渲染子表前台效果
+        //只有手机端才执行
+        if (this.isSJ) {
+          _.keys(res.result).forEach((e, i) => {
+            if (e.indexOf('child&') != -1) {
+              if (i > 0) {
+                this.add()
               }
-            })
-            //子表字段名
-            //子表数据model和值组装
-            itemList.forEach((item, index) => {
-              this.itemModelNameList.forEach(itemModelName => {
-                this.data[itemModelName + '@' + (index + 1)] = item[itemModelName]
+            }
+          })
+        }
+
+        this.getAction(this.url.getForm, {
+          tableId: r.tableId,
+          tableName: r.tableName
+        }).then(res => {
+          if (res.success) {
+            let formData = res.result
+            formData.tableName = r.tableName
+            this.data = formData
+            //如果表单是手机端的子表则
+            if (this.isSJ) {
+              var formModelList = _.keys(this.data)
+                .join(',')
+                .split(',')
+              var itemList = []
+              formModelList.forEach(element => {
+                if (element.indexOf('child&') != -1) {
+                  itemList = JSON.parse(JSON.stringify(this.data[element]))
+                  delete this.data[element]
+                }
               })
-            })
+              //子表字段名
+              //子表数据model和值组装
+              itemList.forEach((item, index) => {
+                this.itemModelNameList.forEach(itemModelName => {
+                  this.data[itemModelName + '@' + (index + 1)] = item[itemModelName]
+                })
+              })
+            }
+            //赋值
+            this.$refs.KFB.setData(this.data)
+            this.btndisabled = false
+          } else {
+            this.$message.error(res.message)
           }
-          //赋值
-          this.$refs.KFB.setData(this.data)
-          this.btndisabled = false
-        } else {
-          this.$message.error(res.message)
-        }
+        })
       })
     },
     //表单字段数值发生改变事件
@@ -312,8 +331,8 @@ export default {
         if (this.$refs.KFB.form.getFieldValue('end_time')) {
           //获取时间差
           // let duration = startEndFun(value, this.$refs.KFB.form.getFieldValue('end_time'))
-          let duration =leaveTime(value,this.$refs.KFB.form.getFieldValue('end_time'));
-          
+          let duration = leaveTime(value, this.$refs.KFB.form.getFieldValue('end_time'))
+
           if (duration) {
             // 使用k-form-design组件的form属性修改表单数据
             this.$refs.KFB.setData({
@@ -328,7 +347,7 @@ export default {
         if (this.$refs.KFB.form.getFieldValue('start_time')) {
           //获取时间差
           // let duration = startEndFun(this.$refs.KFB.form.getFieldValue('start_time'), value)
-          let duration =leaveTime(this.$refs.KFB.form.getFieldValue('start_time'),value);
+          let duration = leaveTime(this.$refs.KFB.form.getFieldValue('start_time'), value)
           // alert(JSON.stringify(duration))
           if (duration) {
             // 使用k-form-design组件的form属性修改表单数据
@@ -426,7 +445,8 @@ export default {
             }
           })
           //如果手机端子表得则需要修改json
-          var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
+          // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
+          var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
           if (!this.isSJ && this.isNew) {
             jsonPamats = null
           }
@@ -543,7 +563,8 @@ export default {
             }
           })
           //如果手机端子表得则需要修改json
-          var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
+          // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
+          var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
           if (!this.isSJ && this.isNew) {
             jsonPamats = null
           }

+ 184 - 28
src/views/user/Login.vue

@@ -23,7 +23,7 @@
               <img src="@assets/haveSomething.png" alt="?????" class="haveSomethingImg" />
               <p>
                 我的待办
-                <a-badge class="numTips"> {{ todoList.length }} </a-badge>
+                <a-badge class="numTips">{{ todoList.length }}</a-badge>
               </p>
             </div>
           </span>
@@ -34,7 +34,12 @@
       <div class="oaContain">
         <a-card title="OA工作台" style="width: 100%" class="oaTitle">
           <div class="oaButton">
-            <a class="oaItem" v-for="(item, index) in activeKeyAll" :key="index.id" @click.prevent="aClick(item)">
+            <a
+              class="oaItem"
+              v-for="(item, index) in activeKeyAll"
+              :key="index.id"
+              @click.prevent="aClick(item)"
+            >
               <span>
                 <img :src="item.iconAddress" />
               </span>
@@ -46,7 +51,12 @@
 
       <!-- 其他弹框 -->
 
-      <a-modal v-model="lcModal.visible" :title="lcModal.Title" :footer="null" :maskClosable="false">
+      <a-modal
+        v-model="lcModal.visible"
+        :title="lcModal.Title"
+        :footer="null"
+        :maskClosable="false"
+      >
         <component
           :disabled="lcModal.disabled"
           v-if="lcModal.visible"
@@ -55,14 +65,69 @@
           :isNew="lcModal.isNew"
           @afterSubmit="afterSub"
           @close=";(lcModal.visible = false), (lcModal.disabled = false)"
-        >
-        </component>
+        ></component>
       </a-modal>
     </div>
+
+    <a-modal
+      title="登录公司选择"
+      :width="450"
+      :visible="departVisible"
+      :closable="false"
+      :maskClosable="false"
+    >
+      <template slot="footer">
+        <a-button type="primary" @click="departOk">确认</a-button>
+      </template>
+
+      <a-form>
+        <!-- <a-form-item
+          :labelCol="{span:4}"
+          :wrapperCol="{span:20}"
+          style="margin-bottom:10px"
+          :validate-status="validate_status">
+          <a-tooltip placement="topLeft" >
+            <template slot="title">
+              <span>您隶属于多部门,请选择登录部门</span>
+            </template>
+            <a-avatar style="backgroundColor:#87d068" icon="gold" />
+          </a-tooltip>
+          <a-select @change="departChange" :class="{'valid-error':validate_status=='error'}" placeholder="请选择登录部门" style="margin-left:10px;width: 80%">
+            <a-icon slot="suffixIcon" type="gold" />
+            <a-select-option
+              v-for="d in departList"
+              :key="d.id"
+              :value="d.orgCode">
+              {{ d.departName }}
+            </a-select-option>
+          </a-select>
+        </a-form-item>-->
+        <a-form-item
+          :labelCol="{span:4}"
+          :wrapperCol="{span:20}"
+          style="margin-bottom:10px"
+          :validate-status="validate_status"
+        >
+          <a-tooltip placement="topLeft">
+            <template slot="title">
+              <span>您隶属于多公司,请选择登录公司</span>
+            </template>
+            <a-avatar style="backgroundColor:#87d068" icon="gold" />
+          </a-tooltip>
+          <a-select
+            @change="departChange"
+            :class="{'valid-error':validate_status=='error'}"
+            placeholder="请选择登录公司"
+            style="margin-left:10px;width: 80%"
+          >
+            <a-icon slot="suffixIcon" type="gold" />
+            <a-select-option v-for="d in orgList" :key="d.id" :value="d.id">{{ d.departName }}</a-select-option>
+          </a-select>
+        </a-form-item>
+      </a-form>
+    </a-modal>
     <!-- 底部 -->
-    <a-layout-footer class="footer">
-      上海萃颠信息科技有限公司出品
-    </a-layout-footer>
+    <a-layout-footer class="footer">上海萃颠信息科技有限公司出品</a-layout-footer>
   </div>
 </template>
 
@@ -76,6 +141,8 @@ import { JeecgListMixin } from '@/mixins/JeecgListMixin'
 import { activitiMixin } from '@/views/activiti/mixins/activitiMixin'
 import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
 import { getCode } from '../../utils/dingding'
+import { putAction, postAction, getAction } from '@/api/manage'
+import store from '@/store/'
 
 export default {
   loading: true,
@@ -83,6 +150,9 @@ export default {
   components: {},
   data() {
     return {
+      orgList: [],
+      validate_status: '',
+      departVisible: false,
       todoList: [],
       activeKeyAll: [],
       url: {
@@ -105,26 +175,31 @@ export default {
     Vue.ls.remove(ACCESS_TOKEN)
     //钉钉免登录
     //获取临时授权码
-    //  getCode(code=>{
-    //    //登录
-    //   // 异步操作
-    //   this.dingLogin({code:code})
-    //     .then(res => {
-    //       this.getDataList() // 待办、已办 列表
-    //       this.getActiveKeyAll() // OA 4个按钮
-    //     })
-    //     .catch(err => {
-    //       console.log(err)
-    //     })
-    // })
+    getCode(code => {
+      //登录
+      // 异步操作
+      this.dingLogin({ code: code })
+        .then(res => {
+          const userInfo = res.result.userInfo
+          Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
+          store.commit('SET_INFO', userInfo)
+          if (userInfo) {
+            this.getDataList() // 待办、已办 列表
+            this.getActiveKeyAll() // OA 4个按钮
+          }
+        })
+        .catch(err => {
+          console.log(err)
+        })
+    })
     // 进入页面自动登录
-    this.autoLogin()
-      .then(res => {
-        this.getDataList() // 待办、已办 列表
-      })
-      .then(res => {
-        this.getActiveKeyAll() // OA 4个按钮
-      })
+    // this.autoLogin()
+    //   .then(res => {
+    //     this.getDataList() // 待办、已办 列表
+    //   })
+    //   .then(res => {
+    //     this.getActiveKeyAll() // OA 4个按钮
+    //   })
   },
 
   methods: {
@@ -145,6 +220,7 @@ export default {
       await that
         .Login(loginParams)
         .then(res => {
+          // this.departConfirm(res)
           console.log('Login拿到token | 登录上啦!')
         })
         .catch(err => {
@@ -223,6 +299,86 @@ export default {
     //提交后
     afterSub(formData) {
       this.lcModal.visible = false
+    },
+    departConfirm(res) {
+      if (res.success) {
+        console.log('用户信息', res)
+        let multi_depart = res.result.multi_depart
+        //0:无部门 1:一个部门 2:多个部门
+        if (multi_depart == 0) {
+          this.loginSuccess()
+          this.$notification.warn({
+            message: '提示',
+            // description: `您尚未归属部门,请确认账号信息`,
+            description: `您尚未归属公司,请确认账号信息`,
+            duration: 3
+          })
+        } else if (multi_depart == 2) {
+          this.departVisible = true
+          // this.currentUsername = this.form.getFieldValue('username')
+          this.currentUsername = res.result.userInfo.username
+          this.departList = res.result.departs
+          this.orgList = res.result.orgList
+          console.log('公司', this.orgList)
+        } else {
+          console.log('登录')
+          const userInfo = res.result.userInfo
+          Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
+          store.commit('SET_INFO', userInfo)
+          this.loginSuccess()
+        }
+      } else {
+        this.requestFailed(res)
+        this.Logout()
+      }
+    },
+    requestFailed(err) {
+      this.$notification['error']({
+        message: '登录失败',
+        description: ((err.response || {}).data || {}).message || err.message || '请求出现错误,请稍后再试',
+        duration: 4
+      })
+      this.loginBtn = false
+    },
+
+    departOk() {
+      if (!this.departSelected) {
+        this.validate_status = 'error'
+        return false
+      }
+      let obj = {
+        orgCode: this.departSelected,
+        // username: this.form.getFieldValue('username')
+        username: this.currentUsername
+      }
+      putAction('/sys/selectDepart', obj).then(res => {
+        if (res.success) {
+          const userInfo = res.result.userInfo
+          Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
+          store.commit('SET_INFO', userInfo)
+          //console.log("---切换组织机构---userInfo-------",store.getters.userInfo.orgCode);
+          this.departClear()
+          // this.loginSuccess()
+        } else {
+          this.requestFailed(res)
+          this.Logout().then(() => {
+            this.departClear()
+          })
+        }
+      })
+    },
+
+    departChange(value) {
+      this.validate_status = 'success'
+      this.departSelected = value
+    },
+    departClear() {
+      this.departList = []
+      this.departSelected = ''
+      this.currentUsername = ''
+      this.departVisible = false
+      this.validate_status = ''
+      this.orgList = []
     }
   }
 }
@@ -263,7 +419,7 @@ export default {
         padding: 10px 20px;
         border-radius: 999em;
         border: transparent;
-        background-color: rgba(37, 104, 239,.8);
+        background-color: rgba(37, 104, 239, 0.8);
         box-shadow: 10px 1px 10px rgba(0, 0, 0, 0.8);
         -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
         -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);

+ 2 - 2
vue.config.js

@@ -66,8 +66,8 @@ module.exports = {
         }
       }, */
             '/jeecg-boot': {
-                // target: 'http://127.0.0.1:8090', // 请求本地 需要jeecg-boot后台项目
-                target: 'http://106.15.206.14:8087', // 测试环境
+                target: 'http://127.0.0.1:8090', // 请求本地 需要jeecg-boot后台项目
+                // target: 'http://106.15.206.14:8087', // 测试环境
                 // ws: false,
                 changeOrigin: true
             }