songxy преди 1 година
родител
ревизия
fb581c4d95

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

@@ -245,3 +245,16 @@ export const copyObject = (target: object, source: object) => {
     }
   }
 }
+
+/***
+ * 刪除对象某个Key
+ */
+export const deleteKey = (target: object, key: string): object => {
+  const nObj = {}
+  for (const k in target) {
+    if (k !== key) {
+      nObj[k] = target[k]
+    }
+  }
+  return nObj
+}

+ 69 - 0
client/src/views/OaSystem/projectCenter/projectBook/common.ts

@@ -0,0 +1,69 @@
+import moment from 'moment'
+
+interface QueryParam {
+  xmbh: string
+  xmmc: string
+  xmlbId: string
+  lxsjOn: string
+  lxsjOff: string
+  pageNo: number
+  xzqdm: number | string
+  pageSize: number
+  isSign: any
+  xmzt: any
+  hyId: any
+}
+export const useMixins = () => {
+  const xmztMap: any = { 0: '立项申请中', 1: '进行中', 2: '已结项', 3: '中止' }
+  const queryParams = reactive<QueryParam>({
+    xmbh: '',
+    xmmc: '',
+    xmlbId: '15',
+    lxsjOn: '',
+    lxsjOff: '',
+    pageNo: 1,
+    xzqdm: '',
+    pageSize: 15,
+    isSign: '',
+    xmzt: '',
+    hyId: 0
+  })
+  const lxsjObj = ref()
+  const setSearchParams = (): void => {
+    if (lxsjObj.value && lxsjObj.value.length > 0) {
+      queryParams.lxsjOn = moment(lxsjObj.value[0]).format('YYYY-MM-DD')
+      queryParams.lxsjOff = moment(lxsjObj.value[1]).format('YYYY-MM-DD')
+    } else {
+      queryParams.lxsjOn = ''
+      queryParams.lxsjOff = ''
+    }
+    if (queryParams.hyId == 0) {
+      queryParams.hyId = null
+    }
+  }
+
+  return {
+    xmztMap,
+    queryParams,
+    lxsjObj,
+    setSearchParams
+  }
+}
+
+export const infoList: any = reactive([
+  {
+    icon: 'xmzx/xmzcz',
+    name: '项目总产值(元)',
+    num: 0
+  },
+  {
+    icon: 'xmzx/xmzcb',
+    name: '项目总成本(元)',
+    num: 0
+  },
+  {
+    icon: 'xmzx/xmzlr',
+    name: '项目总利润(元)',
+    num: 0
+  }
+])

+ 13 - 78
client/src/views/OaSystem/projectCenter/projectBook/deptProject.vue

@@ -59,7 +59,7 @@
           <el-radio :label="1">进行中({{ process }})</el-radio>
           <el-radio :label="4">已验收({{ accepted }})</el-radio>
           <el-radio :label="2">已结项({{ finished }})</el-radio>
-          <el-radio :label="9">已终止({{ terminated }})</el-radio>
+          <el-radio :label="3">已终止({{ terminated }})</el-radio>
           <el-radio>全部({{ totalNum }})</el-radio>
         </el-radio-group>
       </div>
@@ -143,67 +143,23 @@
   </div>
 </template>
 <script setup lang="ts">
-import moment from 'moment'
 import { useRouter } from 'vue-router'
+import { useMixins, infoList } from './common'
 import request from '@/config/axios'
+import { deleteKey } from '@/utils'
 import { getAssetURL } from '@/utils/auth'
 import { industryListAll } from '@/utils/business'
 import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
 import district from '@/components/Area/district.js'
 
 defineOptions({ name: 'ProjectBook' })
-const xmztMap: any = { 0: '立项申请中', 1: '进行中', 2: '已结项', 3: '中止' }
 const router = useRouter()
 const { wsCache } = useCache()
 const user = wsCache.get(CACHE_KEY.USER)
 const deptId = user.user.deptId ? user.user.deptId : ''
 const tableRef: any = ref(null)
 const tableHeight: any = ref(0)
-const queryParams = reactive<{
-  xmbh: string
-  xmmc: string
-  xmlbId: string
-  lxsjOn: string
-  lxsjOff: string
-  pageNo: number
-  xzqdm: number | string
-  pageSize: number
-  isSign: any
-  xmzt: any
-  hyId: any
-  deptId: string
-}>({
-  xmbh: '',
-  xmmc: '',
-  xmlbId: '15',
-  lxsjOn: '',
-  lxsjOff: '',
-  pageNo: 1,
-  xzqdm: '',
-  pageSize: 15,
-  isSign: '',
-  xmzt: '',
-  hyId: 0,
-  deptId: deptId
-})
-const lxsjObj = ref()
-const infoList: any = reactive([
-  {
-    icon: 'xmzx/xmzcz',
-    name: '项目总产值(元)',
-    num: 0
-  },
-  {
-    icon: 'xmzx/xmzcb',
-    name: '项目总成本(元)',
-    num: 0
-  },
-  {
-    icon: 'xmzx/xmzlr',
-    name: '项目总利润(元)',
-    num: 0
-  }
-])
+const { xmztMap, queryParams, lxsjObj, setSearchParams } = useMixins()
 
 const handleCurrentChange = (pageNo: number) => {
   queryParams.pageNo = pageNo
@@ -224,20 +180,15 @@ const searchHandle: () => void = () => {
 }
 const queryProjectListAjax = async (): Promise<void> => {
   const urlApi = `/project/page`
-  if (lxsjObj.value && lxsjObj.value.length > 0) {
-    queryParams.lxsjOn = moment(lxsjObj.value[0]).format('YYYY-MM-DD')
-    queryParams.lxsjOff = moment(lxsjObj.value[1]).format('YYYY-MM-DD')
-  } else {
-    queryParams.lxsjOn = ''
-    queryParams.lxsjOff = ''
+  setSearchParams()
+  if (queryParams.hyId == 0) {
+    queryParams.hyId = null
   }
   const sendData = {
     ...queryParams,
+    deptId: deptId,
     pageSize: 15
   }
-  if (sendData['hyId'] == 0) {
-    sendData['hyId'] = null
-  }
   const result = await request.get({ url: urlApi, params: sendData }, '/business')
   tableData.value = result['records']
   total.value = result['total']
@@ -249,20 +200,12 @@ queryProjectListAjax()
  */
 const queryProjectCalculate = async (): Promise<void> => {
   const urlApi = `/project/calculate`
-  if (lxsjObj.value && lxsjObj.value.length > 0) {
-    queryParams.lxsjOn = moment(lxsjObj.value[0]).format('YYYY-MM-DD')
-    queryParams.lxsjOff = moment(lxsjObj.value[1]).format('YYYY-MM-DD')
-  } else {
-    queryParams.lxsjOn = ''
-    queryParams.lxsjOff = ''
-  }
+  setSearchParams()
   const sendData = {
     ...queryParams,
+    deptId: deptId,
     pageSize: 15
   }
-  if (sendData['hyId'] == 0) {
-    sendData['hyId'] = null
-  }
   const result = await request.get({ url: urlApi, params: sendData }, '/business')
   if (result) {
     infoList[0]['num'] = result.output ?? 0
@@ -282,18 +225,10 @@ const accepted = ref<number>(0)
 
 const queryXmztCount = async (): Promise<void> => {
   const urlApi = `/project/xmzt/count`
-  if (lxsjObj.value && lxsjObj.value.length > 0) {
-    queryParams.lxsjOn = moment(lxsjObj.value[0]).format('YYYY-MM-DD')
-    queryParams.lxsjOff = moment(lxsjObj.value[1]).format('YYYY-MM-DD')
-  } else {
-    queryParams.lxsjOn = ''
-    queryParams.lxsjOff = ''
-  }
+  setSearchParams()
   const sendData = {
-    ...queryParams
-  }
-  if (sendData['hyId'] == 0) {
-    sendData['hyId'] = null
+    ...deleteKey(queryParams, 'xmzt'),
+    deptId: deptId
   }
   const result = await request.get({ url: urlApi, params: sendData }, '/business')
   if (result) {

+ 13 - 80
client/src/views/OaSystem/projectCenter/projectBook/myProject.vue

@@ -47,7 +47,7 @@
       </div>
       <div class="form" style="width: unset">
         <span class="formSpan">合同:</span>
-        <el-radio-group v-model="queryParams.isSign">
+        <el-radio-group v-model="queryParams.isSign" @change="searchHandle">
           <el-radio>全部</el-radio>
           <el-radio label="1">已签订</el-radio>
           <el-radio label="0">未签订</el-radio>
@@ -55,11 +55,11 @@
       </div>
       <div class="form" style="width: unset">
         <span class="formSpan">项目状态:</span>
-        <el-radio-group v-model="queryParams.xmzt">
+        <el-radio-group v-model="queryParams.xmzt" @change="searchHandle">
           <el-radio :label="1">进行中({{ process }})</el-radio>
           <el-radio :label="4">已验收({{ accepted }})</el-radio>
           <el-radio :label="2">已结项({{ finished }})</el-radio>
-          <el-radio :label="9">已终止({{ terminated }})</el-radio>
+          <el-radio :label="3">已终止({{ terminated }})</el-radio>
           <el-radio>全部({{ totalNum }})</el-radio>
         </el-radio-group>
       </div>
@@ -143,67 +143,24 @@
   </div>
 </template>
 <script setup lang="ts">
-import moment from 'moment'
 import { useRouter } from 'vue-router'
+import { useMixins, infoList } from './common'
 import request from '@/config/axios'
+import { deleteKey } from '@/utils'
 import { getAssetURL } from '@/utils/auth'
 import { industryListAll } from '@/utils/business'
 import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
 import district from '@/components/Area/district.js'
 
 defineOptions({ name: 'ProjectBook' })
-const xmztMap: any = { 0: '立项申请中', 1: '进行中', 2: '已结项', 3: '中止' }
 const router = useRouter()
 const { wsCache } = useCache()
 const user = wsCache.get(CACHE_KEY.USER)
 const userId = user.user.id ? user.user.id : ''
 const tableRef: any = ref(null)
 const tableHeight: any = ref(0)
-const queryParams = reactive<{
-  xmbh: string
-  xmmc: string
-  xmlbId: string
-  lxsjOn: string
-  lxsjOff: string
-  pageNo: number
-  xzqdm: number | string
-  pageSize: number
-  isSign: any
-  xmzt: any
-  hyId: any
-  userId: string
-}>({
-  xmbh: '',
-  xmmc: '',
-  xmlbId: '15',
-  lxsjOn: '',
-  lxsjOff: '',
-  pageNo: 1,
-  xzqdm: '',
-  pageSize: 15,
-  isSign: '',
-  xmzt: '',
-  hyId: 0,
-  userId: userId
-})
+const { xmztMap, queryParams, setSearchParams } = useMixins()
 const lxsjObj = ref()
-const infoList: any = reactive([
-  {
-    icon: 'xmzx/xmzcz',
-    name: '项目总产值(元)',
-    num: 0
-  },
-  {
-    icon: 'xmzx/xmzcb',
-    name: '项目总成本(元)',
-    num: 0
-  },
-  {
-    icon: 'xmzx/xmzlr',
-    name: '项目总利润(元)',
-    num: 0
-  }
-])
 
 const handleCurrentChange = (pageNo: number) => {
   queryParams.pageNo = pageNo
@@ -224,20 +181,12 @@ const searchHandle: () => void = () => {
 }
 const queryProjectListAjax = async (): Promise<void> => {
   const urlApi = `/project/page`
-  if (lxsjObj.value && lxsjObj.value.length > 0) {
-    queryParams.lxsjOn = moment(lxsjObj.value[0]).format('YYYY-MM-DD')
-    queryParams.lxsjOff = moment(lxsjObj.value[1]).format('YYYY-MM-DD')
-  } else {
-    queryParams.lxsjOn = ''
-    queryParams.lxsjOff = ''
-  }
+  setSearchParams()
   const sendData = {
     ...queryParams,
+    userId,
     pageSize: 15
   }
-  if (sendData['hyId'] == 0) {
-    sendData['hyId'] = null
-  }
   const result = await request.get({ url: urlApi, params: sendData }, '/business')
   tableData.value = result['records']
   total.value = result['total']
@@ -249,20 +198,12 @@ queryProjectListAjax()
  */
 const queryProjectCalculate = async (): Promise<void> => {
   const urlApi = `/project/calculate`
-  if (lxsjObj.value && lxsjObj.value.length > 0) {
-    queryParams.lxsjOn = moment(lxsjObj.value[0]).format('YYYY-MM-DD')
-    queryParams.lxsjOff = moment(lxsjObj.value[1]).format('YYYY-MM-DD')
-  } else {
-    queryParams.lxsjOn = ''
-    queryParams.lxsjOff = ''
-  }
+  setSearchParams()
   const sendData = {
     ...queryParams,
+    userId,
     pageSize: 15
   }
-  if (sendData['hyId'] == 0) {
-    sendData['hyId'] = null
-  }
   const result = await request.get({ url: urlApi, params: sendData }, '/business')
   if (result) {
     infoList[0]['num'] = result.output ?? 0
@@ -295,18 +236,10 @@ const accepted = ref<number>(0)
 
 const queryXmztCount = async (): Promise<void> => {
   const urlApi = `/project/xmzt/count`
-  if (lxsjObj.value && lxsjObj.value.length > 0) {
-    queryParams.lxsjOn = moment(lxsjObj.value[0]).format('YYYY-MM-DD')
-    queryParams.lxsjOff = moment(lxsjObj.value[1]).format('YYYY-MM-DD')
-  } else {
-    queryParams.lxsjOn = ''
-    queryParams.lxsjOff = ''
-  }
+  setSearchParams()
   const sendData = {
-    ...queryParams
-  }
-  if (sendData['hyId'] == 0) {
-    sendData['hyId'] = null
+    ...deleteKey(queryParams, 'xmzt'),
+    userId
   }
   const result = await request.get({ url: urlApi, params: sendData }, '/business')
   if (result) {

+ 9 - 73
client/src/views/OaSystem/projectCenter/projectBook/projectBook.vue

@@ -19,7 +19,7 @@
       </div>
       <div class="form" style="width: unset">
         <span class="formSpan">合同状态:</span>
-        <el-radio-group v-model="queryParams.isSign">
+        <el-radio-group v-model="queryParams.isSign" @change="searchHandle">
           <el-radio>全部</el-radio>
           <el-radio label="1">已签订</el-radio>
           <el-radio label="0">未签订</el-radio>
@@ -27,11 +27,11 @@
       </div>
       <div class="form" style="width: unset">
         <span class="formSpan">项目状态:</span>
-        <el-radio-group v-model="queryParams.xmzt">
+        <el-radio-group v-model="queryParams.xmzt" @change="searchHandle">
           <el-radio :label="1">进行中({{ process }})</el-radio>
           <el-radio :label="4">已验收({{ accepted }})</el-radio>
           <el-radio :label="2">已结项({{ finished }})</el-radio>
-          <el-radio :label="9">已终止({{ terminated }})</el-radio>
+          <el-radio :label="3">已终止({{ terminated }})</el-radio>
           <el-radio>全部({{ totalNum }})</el-radio>
         </el-radio-group>
       </div>
@@ -110,61 +110,19 @@
   </div>
 </template>
 <script setup lang="ts">
-import moment from 'moment'
 import { useRouter } from 'vue-router'
+import { useMixins, infoList } from './common'
 import request from '@/config/axios'
+import { deleteKey } from '@/utils'
 import { getAssetURL } from '@/utils/auth'
 import UserOrgTree from '@/views/OaSystem/components/UserOrgTree/index.vue'
 import DeptTree from '@/views/OaSystem/components/DeptTree/index.vue'
 
 defineOptions({ name: 'ProjectBook' })
-const xmztMap: any = { 0: '立项申请中', 1: '进行中', 2: '已结项', 3: '中止' }
 const router = useRouter()
 const tableRef: any = ref(null)
 const tableHeight: any = ref(0)
-const queryParams = reactive<{
-  xmbh: string
-  xmmc: string
-  xmlbId: string
-  lxsjOn: string
-  lxsjOff: string
-  pageNo: number
-  xzqdm: number | string
-  pageSize: number
-  isSign: any
-  xmzt: any
-  hyId: any
-}>({
-  xmbh: '',
-  xmmc: '',
-  xmlbId: '15',
-  lxsjOn: '',
-  lxsjOff: '',
-  pageNo: 1,
-  xzqdm: '',
-  pageSize: 15,
-  isSign: '',
-  xmzt: '',
-  hyId: 0
-})
-const lxsjObj = ref()
-const infoList: any = reactive([
-  {
-    icon: 'xmzx/xmzcz',
-    name: '项目总产值(元)',
-    num: 0
-  },
-  {
-    icon: 'xmzx/xmzcb',
-    name: '项目总成本(元)',
-    num: 0
-  },
-  {
-    icon: 'xmzx/xmzlr',
-    name: '项目总利润(元)',
-    num: 0
-  }
-])
+const { xmztMap, queryParams, setSearchParams } = useMixins()
 
 const handleCurrentChange = (pageNo: number) => {
   queryParams.pageNo = pageNo
@@ -183,18 +141,6 @@ const searchHandle: () => void = () => {
   queryProjectCalculate()
   queryProjectListAjax()
 }
-const setSearchParams = (): void => {
-  if (lxsjObj.value && lxsjObj.value.length > 0) {
-    queryParams.lxsjOn = moment(lxsjObj.value[0]).format('YYYY-MM-DD')
-    queryParams.lxsjOff = moment(lxsjObj.value[1]).format('YYYY-MM-DD')
-  } else {
-    queryParams.lxsjOn = ''
-    queryParams.lxsjOff = ''
-  }
-  if (queryParams.hyId == 0) {
-    queryParams.hyId = null
-  }
-}
 const queryProjectListAjax = async (): Promise<void> => {
   const urlApi = `/project/page`
   setSearchParams()
@@ -236,19 +182,9 @@ const accepted = ref<number>(0)
 
 const queryXmztCount = async (): Promise<void> => {
   const urlApi = `/project/xmzt/count`
-  if (lxsjObj.value && lxsjObj.value.length > 0) {
-    queryParams.lxsjOn = moment(lxsjObj.value[0]).format('YYYY-MM-DD')
-    queryParams.lxsjOff = moment(lxsjObj.value[1]).format('YYYY-MM-DD')
-  } else {
-    queryParams.lxsjOn = ''
-    queryParams.lxsjOff = ''
-  }
-  const sendData = {
-    ...queryParams
-  }
-  if (sendData['hyId'] == 0) {
-    sendData['hyId'] = null
-  }
+  setSearchParams()
+
+  const sendData = deleteKey(queryParams, 'xmzt')
   const result = await request.get({ url: urlApi, params: sendData }, '/business')
   if (result) {
     totalNum.value = result['total']