소스 검색

收入分析

curry 1 년 전
부모
커밋
9ec34a0a8c

+ 8 - 0
web/src/api/finance.js

@@ -165,3 +165,11 @@ export const deleteWorkingHours = (data) => {
     data
   })
 }
+
+export const createWorkingHours = (data) => {
+  return service({
+    url: '/project/createWorkingHours',
+    method: 'post',
+    data
+  })
+}

+ 0 - 6
web/src/pinia/collection/Collection.js

@@ -6,7 +6,6 @@ import { formatDate } from '@/utils/formatDate'
 export const collectionOperate = defineStore('payment', () => {
   // 定义数据
   const paymentList = reactive([])
-  const paymentCode = ref('')
   const paymentTotal = ref(0)
   // 定义修改数据的方法
   const getPaymentList = (data) => {
@@ -50,23 +49,18 @@ export const collectionOperate = defineStore('payment', () => {
     paymentList.length = 0
     paymentList.push(...list)
   }
-  const changePaymentCode = (code) => {
-    paymentCode.value = code
-  }
   const changePaymentTotal = (total) => {
     paymentTotal.value = total
   }
 
   return {
     paymentList,
-    paymentCode,
     paymentTotal,
     getPaymentList,
     postCollection,
     putCollection,
     delCollection,
     changePaymentList,
-    changePaymentCode,
     changePaymentTotal
   }
 })

+ 3 - 1
web/src/pinia/hour/Hour.js

@@ -11,7 +11,9 @@ export const hourOperate = defineStore('time', () => {
     queryHour(data).then(res => {
       if (res.code === 0) {
         timeList.length = 0
-        timeList.push(...res.data.list)
+        const list = res.data.list === null ? [] : res.data.list
+        timeTotal.value = res.data.total
+        timeList.push(...list)
       }
     })
   }

+ 59 - 9
web/src/view/finance/components/hour.vue

@@ -86,6 +86,21 @@
         </el-table>
       </el-col>
     </el-row>
+    <el-row>
+      <el-col
+        :span="23"
+        style="display: flex;justify-content: end"
+      >
+        <el-pagination
+          v-model:current-page="condition.pageInfo.page"
+          background
+          layout="prev, pager, next"
+          :page-size="8"
+          :total="hour.timeTotal"
+          @change="changeHourPage"
+        />
+      </el-col>
+    </el-row>
     <el-dialog
       v-model="addTimeShow"
       title="新增工时"
@@ -93,12 +108,19 @@
     >
       <el-form label-width="100px">
         <el-form-item label="工人名称:">
-          <el-input
+          <el-select
             v-model="addCondition.people"
+            placeholder="请选择工作人员"
             clearable
-            placeholder="请输入工人名称"
             @clear="addCondition.people = ''"
-          />
+          >
+            <el-option
+              v-for="item in peopleList"
+              :key="item.ID"
+              :label="item.name"
+              :value="item.ID"
+            />
+          </el-select>
         </el-form-item>
         <el-form-item label="工作天数:">
           <el-input-number v-model="addCondition.days" />
@@ -123,14 +145,15 @@
 <script setup>
 import { reactive, onMounted, ref } from 'vue'
 import { hourOperate } from '@/pinia/hour/Hour'
-// import { codeOperate } from '@/pinia/code/code'
-import { queryConstructor } from '@/api/finance'
+import { codeOperate } from '@/pinia/code/code'
+import { queryConstructor, createWorkingHours } from '@/api/finance'
 import { Search, Plus } from '@element-plus/icons-vue'
+import { ElMessage } from 'element-plus'
 defineOptions({
   name: 'Hour'
 })
 const hour = hourOperate()
-// const serial = codeOperate()
+const serial = codeOperate()
 const condition = reactive({
   pageInfo: {
     page: 1,
@@ -156,18 +179,45 @@ onMounted(() => {
       peopleList.length = 0
       peopleList.push(...res.data)
     }
-    console.log(res)
   })
 })
 
 const retrievalTime = () => {
   peopleId.value === '' ? condition.people = 0 : condition.people = parseFloat(peopleId.value)
-  console.log(condition)
+  condition.code = serial.currentCode
   hour.getTimeList(condition)
 }
 
 const addTime = () => {
-  console.log()
+  addCondition.projectCode = serial.currentCode
+  for (const i in addCondition) {
+    if (addCondition[i] === '' || addCondition[i] === null || addCondition[i] === 0) {
+      ElMessage({
+        message: '请将信息填写完整',
+        type: 'error',
+        showClose: true,
+        duration: 2000
+      })
+      return
+    }
+  }
+  console.log(addCondition)
+  createWorkingHours(addCondition).then(res => {
+    console.log(res)
+    if (res.code === 0) {
+      ElMessage.success('添加成功')
+      addTimeShow.value = false
+      retrievalTime()
+      addCondition.days = 0
+      addCondition.people = ''
+      addCondition.price = 0
+    }
+  })
+}
+
+const changeHourPage = (page) => {
+  condition.pageInfo.page = page
+  retrievalTime()
 }
 </script>
 

+ 18 - 8
web/src/view/finance/components/payment.vue

@@ -28,7 +28,7 @@
         <el-button
           type="primary"
           :icon="Plus"
-          @click="paymentAddShow.value = true"
+          @click="paymentAddShow = true"
         >
           新增
         </el-button>
@@ -97,6 +97,7 @@
         </el-row>
         <el-row justify="end">
           <el-pagination
+            v-model:current-page="condition.pageInfo.page"
             background
             layout="prev, pager, next"
             :page-size="8"
@@ -175,7 +176,7 @@
             placeholder="请输入收款金额"
             clearable
             type="number"
-            @clear="addAmount.value = ''"
+            @clear="addAmount = ''"
           />
         </el-form-item>
         <el-form-item
@@ -226,10 +227,12 @@ import { Search, Delete, Edit, Notebook, Plus } from '@element-plus/icons-vue'
 import { retrievalCollection, updateCollection, deleteCollection, createCollection } from '@/api/collection'
 import { collectionOperate } from '@/pinia/collection/Collection'
 import { ElMessage, ElMessageBox } from 'element-plus'
+import { codeOperate } from '@/pinia/code/code'
 defineOptions({
   name: 'Payment'
 })
 const pay = collectionOperate()
+const serial = codeOperate()
 // 数据
 const condition = reactive({
   pageInfo: {
@@ -291,7 +294,7 @@ const paymentEdit = () => {
 }
 const paymentDelete = (row) => {
   const delCondition = condition
-  delCondition.code = pay.paymentCode
+  delCondition.code = serial.currentCode
   delCondition.pageInfo.page = 1
   delCondition.time = ''
   ElMessageBox.confirm(
@@ -319,9 +322,9 @@ const paymentDelete = (row) => {
     }).catch(() => {})
 }
 const searchCollection = () => {
-  condition.code = pay.paymentCode
+  condition.code = serial.currentCode
+  condition.pageInfo.page = 1
   retrievalCollection(condition).then(res => {
-    console.log(res.data)
     if (res.code === 0) {
       pay.changePaymentList(res.data.list)
     }
@@ -330,7 +333,7 @@ const searchCollection = () => {
 const paymentAdd = () => {
   const addData = paymentAddData
   addData.collectionPrice = addAmount.value.length === 0 ? 0 : parseFloat(addAmount.value)
-  addData.projectCode = pay.paymentCode
+  addData.projectCode = serial.currentCode
   console.log(addData)
   for (const item in addData) {
     if (addData[item] === '' || addData[item] === 0) {
@@ -347,7 +350,7 @@ const paymentAdd = () => {
     console.log(res)
     const reset = condition
     reset.pageInfo.page = 1
-    reset.code = pay.paymentCode
+    reset.code = serial.currentCode
     reset.time = ''
     if (res.code === 0) {
       ElMessage({
@@ -365,11 +368,18 @@ const paymentAdd = () => {
 }
 const changePaymentPage = (page) => {
   const pageCondition = condition
-  pageCondition.code = pay.paymentCode
+  pageCondition.code = serial.currentCode
   pageCondition.pageInfo.page = page
   pay.getPaymentList(pageCondition)
 }
+const outsideChangePage = () => {
+  console.log('父组件调用')
+  condition.pageInfo.page = 1
+}
 
+defineExpose({
+  outsideChangePage
+})
 </script>
 
 <style scoped>

+ 1 - 0
web/src/view/finance/components/reimburse.vue

@@ -459,6 +459,7 @@ onMounted(() => {
 })
 const searchReimburse = () => {
   condition.code = serial.currentCode
+  condition.pageInfo.page = 1
   submit.getReimburseList(condition)
 }
 const openReimburseEdit = (row) => {

+ 53 - 29
web/src/view/finance/financeAnalysis/financeAnalysis.vue

@@ -65,7 +65,7 @@
                 tag="b"
                 :line-clamp="1"
               >
-                {{ projectMessage.name }}
+                {{ collectionAmount }}
               </el-text>
             </el-row>
             <el-row
@@ -124,7 +124,7 @@
             label="项目收款"
             :name="3"
           >
-            <payment />
+            <payment ref="paymentRef" />
           </el-tab-pane>
         </el-tabs>
       </el-col>
@@ -280,6 +280,7 @@ const listData = reactive([])
 const projectTotal = ref(0)
 const projectMessage = reactive({})
 const listSort = ref(1)
+const projectSum = ref(0)
 
 // 计算属性
 const buttonType = computed(() => (state) => {
@@ -303,6 +304,16 @@ const projectAmount = computed(() => {
     return parseFloat(tenThousand) + '万元'
   }
 })
+const collectionAmount = computed(() => {
+  const price = ref(projectSum.value)
+  // const price = ref(4892703)
+  if (price.value < 10000) {
+    return price.value + '元'
+  } else {
+    const tenThousand = (price.value / 10000).toFixed(4)
+    return parseFloat(tenThousand) + '万元'
+  }
+})
 // 方法
 onMounted(() => {
   projectList(condition)
@@ -314,33 +325,8 @@ const projectList = (condition) => {
       const list = res.data.list
       projectTotal.value = res.data.total
       listData.push(...list)
-      payment.changePaymentCode(list[0].code)
       symbol.changeCode(list[0].code)
-      queryProjectExpense(list[0].code).then(res => {
-        if (res.code === 0) {
-          const summaryData = res.data
-          console.log(summaryData)
-          payment.changePaymentList(summaryData.collection)
-          payment.changePaymentTotal(summaryData.collectionTotal)
-          submit.changeReimburseList(summaryData.reimbursement)
-          submit.changeReimburseTotal(summaryData.reimbursementTotal)
-          hour.getTimeList({
-            pageInfo: {
-              page: 1,
-              pageSize: 8
-            },
-            code: symbol.currentCode,
-            time: '',
-            yearTime: '',
-            people: 0
-          })
-        }
-      })
-      getProjectMessage(list[0].code).then(res => {
-        if (res.code === 0) {
-          Object.assign(projectMessage, res.data)
-        }
-      })
+      getMainMessage(list[0].code)
     }
   })
 }
@@ -358,7 +344,45 @@ const changePage = (page) => {
 
 const changeSort = () => {}
 
-const incomeExpenses = (code) => {}
+const incomeExpenses = (code) => {
+  symbol.changeCode(code)
+  getMainMessage(code)
+  listShow.value = false
+}
+
+const getMainMessage = (code) => {
+  queryProjectExpense(code).then(res => {
+    if (res.code === 0) {
+      const summaryData = res.data
+      const sumList = summaryData.collection
+      let sum = 0
+      sumList.forEach(item => {
+        sum += parseFloat(item.collectionPrice)
+      })
+      projectSum.value = sum
+      console.log(projectSum.value)
+      payment.changePaymentList(summaryData.collection)
+      payment.changePaymentTotal(summaryData.collectionTotal)
+      submit.changeReimburseList(summaryData.reimbursement)
+      submit.changeReimburseTotal(summaryData.reimbursementTotal)
+      hour.getTimeList({
+        pageInfo: {
+          page: 1,
+          pageSize: 8
+        },
+        code: code,
+        time: '',
+        yearTime: '',
+        people: 0
+      })
+    }
+  })
+  getProjectMessage(code).then(res => {
+    if (res.code === 0) {
+      Object.assign(projectMessage, res.data)
+    }
+  })
+}
 
 </script>