Browse Source

项目详情优化

songxy 1 year ago
parent
commit
6f37dfdffa

+ 3 - 3
client/src/service/project.ts

@@ -135,11 +135,11 @@ export const getProjectMileStone = async (projectId: ProjectId) => {
  * @param id
  * @param projectId
  */
-export const finishProjectMileStone = async (params: { id: string; projectId: ProjectId }) => {
-  return await request.get(
+export const finishProjectMileStone = async (data: { id: string; projectId: ProjectId }) => {
+  return await request.post(
     {
       url: '/project-milestone/finish',
-      params: params
+      data: data
     },
     '/business'
   )

+ 12 - 0
client/src/utils/index.ts

@@ -233,3 +233,15 @@ export const yuanToFen = (amount: string | number): number => {
 export const fenToYuan = (amount: string | number): number => {
   return Number((Number(amount) / 100).toFixed(2))
 }
+
+/***
+ * 复制对象值
+ */
+export const copyObject = (target: object, source: object) => {
+  const tKeys = Object.keys(target)
+  for (let i = 0; i < tKeys.length; i++) {
+    if (source[tKeys[i]]) {
+      target[tKeys[i]] = source[tKeys[i]]
+    }
+  }
+}

+ 1 - 1
client/src/views/OaSystem/projectCenter/projectBook/projectBook.vue

@@ -173,7 +173,7 @@ const handleCurrentChange = (pageNo: number) => {
 const operateClick = (row: any) => {
   router.push({
     path: '/projectDetail',
-    query: { [row.flowStatus === 99 ? 'subId' : 'id']: row.id }
+    query: { id: row.id }
   })
 }
 const tableData = ref<Array<any>>([])

+ 32 - 3
client/src/views/OaSystem/projectCenter/projectDetail/components/xmht/index.vue

@@ -166,8 +166,24 @@
               <td>
                 <UserOrgTree v-model="mContractDetail.areaManagerId" :disabled="!editor" />
               </td>
-              <td class="th"></td>
-              <td></td>
+              <td class="th">签订方式:</td>
+              <td>
+                <span v-if="!editor && !mContractDetail.signWay"></span>
+                <el-select
+                  v-else
+                  style="width: 100%"
+                  placeholder="请选择签订方式"
+                  v-model="mContractDetail.signWay"
+                  :disabled="!editor"
+                >
+                  <el-option
+                    v-for="item in signWayList"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value"
+                  />
+                </el-select>
+              </td>
             </tr>
             <tr>
               <td class="th">付款条件:</td>
@@ -513,6 +529,20 @@ const mContractDetail = ref<Contract>({} as Contract)
 const cContractDetail = ref<any>()
 const mContractDetails = ref<any[]>([])
 const childrenContracts = ref<any[]>([])
+const signWayList = reactive<any[]>([
+  {
+    label: '跟单',
+    value: 1
+  },
+  {
+    label: '半开拓',
+    value: 2
+  },
+  {
+    label: '开拓',
+    value: 3
+  }
+])
 /***
  * 查询主合同和子合同详情数据: 存在多个主合同(兼容之前项目合同),一般来说子合同只存在最新主合同
  * **/
@@ -524,7 +554,6 @@ const { refetch } = useQuery(
       for (const contract of tData) {
         if (contract.children && contract.children.length > 0) {
           childrenContracts.value = contract.children.filter((child) => {
-            child['contractType'] = 2 //模拟子合同
             return child?.contractType !== 4
           })
           for (let i = 0; i < childrenContracts.value.length; i++) {

+ 18 - 5
client/src/views/OaSystem/projectCenter/projectDetail/components/xmxx/AddSubProject.vue

@@ -4,7 +4,7 @@ import { ProjectId } from '@/interface/project'
 import { useMutation } from '@tanstack/vue-query'
 import { ElMessageBox } from 'element-plus'
 import type { Action } from 'element-plus'
-import { postSubProject } from '@/service/project'
+import { addMember, postSubProject } from '@/service/project'
 import UserOrgTree from '@/views/OaSystem/components/UserOrgTree/index.vue'
 import DeptTree from '@/views/OaSystem/components/DeptTree/index.vue'
 
@@ -50,15 +50,24 @@ const rules = reactive({
   xmjlId: [{ required: true, message: '请选择项目经理', trigger: 'change' }],
   zrbmId: [{ required: true, message: '请选择责任部门', trigger: 'change' }]
 })
-const ruleFormRef = ref<FormInstance>()
+const ruleFormRef = ref()
 const projectChildForm = ref(_projectChildFormSource)
 const { mutate: addSubProject } = useMutation(postSubProject, {
-  onSuccess: () => {
+  onSuccess: (data) => {
     onSuccessCallBack()
     projectChildForm.value = _projectChildFormSource
+    if (data) {
+      //新增项目成员
+      addMember({
+        projectId: data,
+        responsibility: '',
+        workerId: xmjlId.value as string
+      })
+    }
   }
 })
 const message = useMessage() // 消息弹窗
+const xmjlId = ref<string>()
 const submitProjectChild = () => {
   projectChildForm.value.xmbh = projectNo.value
   projectChildForm.value.shareRatio = props.parentData.shareRatio
@@ -82,9 +91,13 @@ const submitProjectChild = () => {
     return
   }
   ElMessageBox.alert('添加子项目后将无法撤销,确认是否添加子项目?', '提交确认', {
-    confirmButtonText: 'OK',
+    showCancelButton: true,
+    confirmButtonText: '确认',
     callback: (action: Action) => {
-      if (action === 'confirm') addSubProject(sendData)
+      if (action === 'confirm') {
+        xmjlId.value = sendData.xmjlId
+        addSubProject(sendData)
+      }
     }
   })
 }

+ 67 - 40
client/src/views/OaSystem/projectCenter/projectDetail/components/xmxx/ProjectMileStone.vue

@@ -1,7 +1,10 @@
 <script setup lang="ts">
 import { useMutation, useQuery } from '@tanstack/vue-query'
+import { copyObject } from '@/utils'
+import request from '@/config/axios'
 import { finishProjectMileStone, getProjectMileStone } from '@/service/project'
 
+const message = useMessage() // 消息弹窗
 /**
  * 项目里程碑
  */
@@ -14,17 +17,54 @@ const { refetch } = useQuery(
   async () => await getProjectMileStone(props.projectId),
   {
     onSuccess: (data) => {
-      projectMilestoneList.value = data
+      projectMilestoneList.value = data.map((item) => {
+        item['is_edit'] = false
+        return item
+      })
     }
   }
 )
+//新增项目里程碑
+const addProjectMilestone = async (item) => {
+  const url = '/project-milestone'
+  const sendData = {
+    name: '',
+    planFinishTime: '',
+    actualFinishTime: '',
+    projectId: props.projectId
+  }
+  copyObject(sendData, item)
+  const result = await request.post({ url, data: sendData }, '/business')
+  if (result) {
+    message.success('项目里程碑新增成功!')
+    refetch()
+  }
+}
+//编辑项目里程碑
+const updateProjectMilestone = async (item) => {
+  const url = '/project-milestone'
+  const sendData = {
+    ...item
+  }
+  const result = await request.put({ url, data: sendData }, '/business')
+  if (result) {
+    message.success('项目里程碑编辑成功!')
+  }
+}
+//删除项目里程碑
+const deleteProjectMilestone = async (id: string) => {
+  const url = `/project-milestone?id=${id}`
+  const result = await request.delete({ url }, '/business')
+  console.log('result-----------------')
+  console.log(result)
+}
 watch(
   () => props.projectId,
   () => {
     refetch()
   }
 )
-const { mutate: handleFinish } = useMutation(finishProjectMileStone, {
+const { mutate: handleFinishMutate } = useMutation(finishProjectMileStone, {
   onSuccess: () => {
     refetch()
     ElMessage({
@@ -33,37 +73,33 @@ const { mutate: handleFinish } = useMutation(finishProjectMileStone, {
     })
   }
 })
+const handleFinish = (item) => {
+  if (item.is_edit) {
+    if (!item.id) {
+      //新增保存
+      addProjectMilestone(item)
+      return
+    }
+    updateProjectMilestone(item)
+    if (item.actualFinishTime) {
+      handleFinishMutate({ id: item.id, projectId: item.projectId })
+    }
+  }
+  item.is_edit = !item.is_edit
+}
 const pMileStoneAddHandle = () => {
   projectMilestoneList.value.push({
-    id: '',
     name: '',
     planFinishTime: '',
     actualFinishTime: '',
-    state: 2,
-    sortnum: 1,
-    projectId: ''
+    is_edit: true
   })
 }
-interface StateTypeInterface {
-  value: number
-  label: string
-}
-const stateTypes: StateTypeInterface[] = [
-  {
-    value: 0,
-    label: '未开始'
-  },
-  {
-    value: 1,
-    label: '进行中'
-  },
-  {
-    value: 2,
-    label: '已完成'
-  }
-]
 const confirmHandle = (id: string, index: number) => {
   projectMilestoneList.value.splice(index, 1)
+  if (id) {
+    deleteProjectMilestone(id)
+  }
 }
 </script>
 
@@ -76,13 +112,13 @@ const confirmHandle = (id: string, index: number) => {
       <el-table :data="projectMilestoneList" border style="width: 100%" header-align="center">
         <el-table-column label="里程碑名称">
           <template #default="scope">
-            <el-input :disabled="scope.row.id !== ''" v-model="scope.row.name" />
+            <el-input :disabled="!scope.row.is_edit" v-model="scope.row.name" />
           </template>
         </el-table-column>
         <el-table-column prop="planFinishTime" label="计划完成时间" width="260">
           <template #default="scope">
             <el-date-picker
-              :disabled="scope.row.id !== ''"
+              :disabled="!scope.row.is_edit"
               style="width: 100%"
               v-model="scope.row.planFinishTime"
               value-format="YYYY-MM-DD"
@@ -93,32 +129,23 @@ const confirmHandle = (id: string, index: number) => {
         <el-table-column label="实际完成时间" prop="actualFinishTime" width="260">
           <template #default="scope">
             <el-date-picker
-              :disabled="scope.row.id !== ''"
+              :disabled="!scope.row.is_edit"
               style="width: 100%"
               v-model="scope.row.actualFinishTime"
               value-format="YYYY-MM-DD"
             />
           </template>
         </el-table-column>
-        <el-table-column label="状态" width="200">
+        <el-table-column label="项目进度" width="200">
           <template #default="scope">
-            <el-select :disabled="scope.row.id !== ''" v-model="scope.row.state">
-              <el-option
-                v-for="(item, index) in stateTypes"
-                :key="index"
-                :label="item.label"
-                :value="item.value"
-              />
-            </el-select>
+            <el-input :disabled="!scope.row.is_edit" v-model="scope.row.name" />
           </template>
         </el-table-column>
         >
         <el-table-column label="操作" width="200">
           <template #default="scope">
-            <el-button
-              @click="handleFinish({ id: scope.row.id, projectId: scope.row.projectId })"
-              type="text"
-              >完成
+            <el-button @click="handleFinish(scope.row)" type="text"
+              >{{ !scope.row.is_edit ? '编辑' : '保存' }}
             </el-button>
             <el-popconfirm title="确定删除?" @confirm="confirmHandle(scope.row.id, scope.$index)">
               <template #reference>

+ 1 - 1
client/src/views/OaSystem/projectCenter/projectDetail/components/xmxx/index.vue

@@ -176,7 +176,7 @@
                 <td class="th">是否签合同:</td>
                 <td>{{ projectDetail['isSign'] === 0 ? '否' : '是' }}</td>
                 <td class="th">本项目成本(元):</td>
-                <td>{{ projectDetail['xmcbys'] }}</td>
+                <td>{{ projectDetail['xmcbys'] ?? 0 }}</td>
               </tr>
               <tr>
                 <td class="th">本项目产值(元):</td>

+ 3 - 0
client_h5/index.html

@@ -4,6 +4,9 @@
     <meta charset="UTF-8" />
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1">
+    <!-- <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.10.3/dingtalk.open.js"></script> -->
+    <script src="eruda.js"></script>
+    <script>eruda.init()</script>
     <title></title>
   </head>
   <body>

+ 21 - 13
client_h5/src/App.vue

@@ -12,14 +12,22 @@ const initUserInfoHandler = async (type: number) => {
     if (res && res.data) {
         const map = getUrlParams(res.data);
         const state: string = map?.get("state") as string
+        console.log("state--------------")
+        console.log(state)
         const code: string = await getDDAuthCode() as string
+        console.log("code--------")
+        console.log(code)
         const userIdResult = await getUserIdByDD({
             type,
             code,
             state
         })
+        console.log("userIdResult----------------")
+        console.log(userIdResult)
         if (userIdResult && userIdResult.data) { 
-            getUserInfoById(userIdResult.data)
+            const userInfo = await getUserInfoById(userIdResult.data)
+            console.log("userInfo----------------")
+            console.log(userInfo) 
         }
     }
 }
@@ -28,13 +36,17 @@ function getDDAuthCode() {
     return new Promise((resolve, reject) => {
         getAuthCode({
             corpId: 'ding65143abf9aeea2ec',
-            success: (res) => {
-                const { authCode } = res;
-                if (authCode) {
-                    resolve(authCode);
+            success: (res: any) => {
+                const { code } = res;
+                console.log("authCode---------------")
+                console.log(res)
+                if (code) {
+                    resolve(code);
                 }
             },
             fail: (ex: any) => {
+                console.log("ex---------------")
+                console.log(ex)
                 reject(ex);
             },
             complete: () => {},
@@ -47,16 +59,12 @@ interface UserIdParam {
     state: string
 }
 const getUserIdByDD = async (data: Required<UserIdParam>) => {
-    return reqest.post({
-        url: '/system/auth/social-login',
-        data: data
-    })
+  return reqest.post('/system/auth/social-login', data)
 }
 const getUserInfoById = async (idStr: Required<string>) => {
-    return reqest.get({
-        url: '/system/user/get',
-        params: {id: idStr}
-    })
+  return reqest.get('/system/user/get', {
+      params: {id: idStr}
+  })
 }
 </script>
 

+ 1 - 1
client_h5/src/stores/modules/user.ts

@@ -21,7 +21,7 @@ const UserStore = defineStore("UserStore", {
             mobile: "",
             sex: "",
             avatar: ""
-        }
+        } as UserInterface
     }),
     getters: {
         getUser(state) {

+ 1 - 1
zjugis-business/src/main/java/com/zjugis/business/controller/ProjectMilestoneController.java

@@ -73,7 +73,7 @@ public class ProjectMilestoneController {
 
     @PostMapping("/project-milestone/finish")
     public CommonResult finish(@Valid  @RequestBody ProjectMilestoneRequest projectMilestone) {
-        return CommonResult.success(projectMilestoneService.finish(projectMilestone));
+        return CommonResult.success(projectMilestoneService.e/project-milestone(projectMilestone));
     }
 
     /**