Browse Source

收入分析

2545307760@qq.com 2 months ago
parent
commit
4f27d36c4e

+ 2 - 3
web/src/api/progress.js

@@ -27,10 +27,9 @@ export const putUserProgress = (data) => {
 }
 
 // 删除进度
-export const delUserProgress = (data) => {
+export const delUserProgress = (id) => {
   return service({
-    url: '/progress/deleteProgress',
+    url: '/progress/deleteProgress?id=' + id,
     method: 'delete',
-    data
   })
 }

+ 23 - 0
web/src/pinia/customer/customer.js

@@ -0,0 +1,23 @@
+import { defineStore } from 'pinia'
+import { reactive, ref } from 'vue'
+import { getUserProgress } from '@/api/progress'
+
+export const useCustomer = defineStore('customer', () => {
+  const progressList = reactive([])
+  const customerId = ref(0)
+  const getProgressList = (id) => {
+    customerId.value = id
+    getUserProgress(id).then(res => {
+      if (res.code === 0) {
+        progressList.length = 0
+        progressList.push(...res.data)
+      }
+    })
+  }
+  return {
+    progressList,
+    getProgressList,
+    customerId
+  }
+})
+

+ 203 - 13
web/src/view/customer/component/progress.vue

@@ -3,51 +3,241 @@
     <div>
       <el-button
         icon="plus"
-        @click="addProgress"
+        @click="openAddProgress"
       >
         新增进度信息
       </el-button>
     </div>
     <div style="margin-top: 20px">
-      <el-table :data="progressInfo">
+      <el-table
+        :data="customerData.progressList"
+        height="750px"
+        stripe
+      >
         <el-table-column
           label="填写用户"
           align="center"
           width="180px"
-          prop="progressInfo.userId"
+          prop="userId"
         />
         <el-table-column
           label="所属客户"
           align="center"
           width="180px"
-          prop="progressInfo.customerId"
+          prop="customerId"
         />
         <el-table-column
           label="跟进时间"
           align="center"
           width="180px"
-          prop="progressInfo.followUpTime"
+          prop="followUpTime"
         />
         <el-table-column
           label="内容"
           align="center"
-          prop="progressInfo.content"
+          width="300px"
         >
           <template #default="scope">
-            <el-input v-model="scope.row.content" />
+            <el-input
+              v-model="scope.row.content"
+              type="textarea"
+              :rows="3"
+            />
+          </template>
+        </el-table-column>
+        <el-table-column
+          label="操作"
+          align="center"
+        >
+          <template #default="scope">
+            <el-button
+              type="primary"
+              text
+              icon="Edit"
+              @click="progressEdit(scope.row)"
+            >
+              编辑
+            </el-button>
+            <el-button
+              type="primary"
+              text
+              icon="delete"
+              @click="deleteProgress(scope.row)"
+            >
+              删除
+            </el-button>
           </template>
         </el-table-column>
       </el-table>
     </div>
+    <el-dialog
+      v-model="addProgressShow"
+      width="35%"
+      title="新增客户进度"
+    >
+      <el-form label-width="100px">
+        <el-form-item label="跟进时间:">
+          <el-date-picker
+            v-model="addProgressData.followUpTime"
+            type="date"
+            placeholder="请选择跟进时间"
+            size="large"
+            format="YYYY-MM-DD"
+            value-format="YYYY-MM-DD"
+            clearable
+            @clear="addProgressData.followUpTime = ''"
+          />
+        </el-form-item>
+        <el-form-item label="进度内容:">
+          <el-input
+            v-model="addProgressData.content"
+            type="textarea"
+            :rows="3"
+            placeholder="请输入进度内容"
+          />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button
+          type="primary"
+          size="large"
+          @click="addProgress"
+        >确定</el-button>
+      </template>
+    </el-dialog>
+    <el-dialog
+      v-model="editProgressShow"
+      width="35%"
+      title="新增客户进度"
+    >
+      <el-form label-width="100px">
+        <el-form-item label="跟进时间:">
+          <el-date-picker
+            v-model="editProgressData.followUpTime"
+            type="date"
+            placeholder="请选择跟进时间"
+            size="large"
+            format="YYYY-MM-DD"
+            value-format="YYYY-MM-DD"
+            clearable
+            @clear="editProgressData.followUpTime = ''"
+          />
+        </el-form-item>
+        <el-form-item label="进度内容:">
+          <el-input
+            v-model="editProgressData.content"
+            type="textarea"
+            :rows="3"
+            placeholder="请输入进度内容"
+          />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button
+          type="primary"
+          size="large"
+          @click="editProgress"
+        >确定</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
-
 <script setup>
-import { reactive } from 'vue'
-const progressInfo = reactive([
-  { userId: '管理员', customerId: '客户', followUpTime: '2025-04-25', content: '数据' }
-])
-const addProgress = () => {}
+import { reactive, ref } from 'vue'
+import { postUserProgress, delUserProgress, putUserProgress } from '@/api/progress'
+import { ElMessage, ElMessageBox } from 'element-plus'
+import { useCustomer } from '@/pinia/customer/customer'
+import { useUserStore } from '@/pinia/modules/user'
+defineOptions({
+  name: 'ProgressUnit'
+})
+const customerData = useCustomer()
+const userData = useUserStore()
+
+// 新增客户进度
+const addProgressShow = ref(false)
+
+const addProgressData = reactive({
+  content: '',
+  userId: userData.userInfo.ID,
+  customerId: customerData.customerId,
+  followUpTime: '',
+})
+
+const openAddProgress = () => {
+  addProgressShow.value = true
+}
+
+const addProgress = () => {
+  for (const key in addProgressData) {
+    if (key === 'content') {
+      continue
+    }
+    if (addProgressData[key] === '' || addProgressData[key] === 0) {
+      ElMessage.error('请选择跟进时间')
+      return
+    }
+  }
+  postUserProgress(addProgressData).then(res => {
+    if (res.code === 0) {
+      ElMessage.success(res.msg)
+      addProgressShow.value = false
+      customerData.getProgressList(customerData.customerId)
+    }
+  })
+}
+
+const progressEdit = (row) => {
+  editProgressShow.value = true
+  editProgressData.content = row.content
+  editProgressData.followUpTime = row.followUpTime
+}
+
+const deleteProgress = (row) => {
+  ElMessageBox.confirm(
+    '确定删除此客户进度吗?',
+    '删除',
+    {
+      confirmButtonText: '确定',
+      cancelButtonText: '取消',
+      type: 'warning',
+    }
+  )
+    .then(() => {
+      delUserProgress(row.ID).then(res => {
+        if (res.code === 0) {
+          ElMessage.success(res.msg)
+          customerData.getProgressList(row.ID)
+        }
+      })
+    })
+    .catch(() => {
+      ElMessage({
+        type: 'info',
+        message: '取消删除',
+      })
+    })
+}
+
+// 编辑进度
+const editProgressShow = ref(false)
+
+const editProgressData = reactive({
+  content: '',
+  userId: userData.userInfo.ID,
+  customerId: customerData.customerId,
+  followUpTime: '',
+})
+
+const editProgress = () => {
+  putUserProgress(editProgressData).then(res => {
+    if (res.code === 0) {
+      editProgressShow.value = false
+      customerData.getProgressList(userData.userInfo.ID)
+      console.log(res.data)
+    }
+  })
+}
 </script>
 
 <style scoped lang="scss">

+ 7 - 47
web/src/view/customer/customer.vue

@@ -342,43 +342,9 @@
     <el-drawer
       v-model="progressShow"
       title="客户进度信息"
-      size="50%"
+      size="60%"
     >
-      <div>
-        <el-button
-          icon="plus"
-          @click="addProgress"
-        >
-          新增进度信息
-        </el-button>
-      </div>
-      <div style="margin-top: 20px">
-        <el-table :data="progressInfo">
-          <el-table-column
-            label="填写用户"
-            align="center"
-            width="180px"
-          />
-          <el-table-column
-            label="所属客户"
-            align="center"
-            width="180px"
-          />
-          <el-table-column
-            label="跟进时间"
-            align="center"
-            width="180px"
-          />
-          <el-table-column
-            label="内容"
-            align="center"
-          >
-            <template #default="scope">
-              <el-input v-model="scope.row.content" />
-            </template>
-          </el-table-column>
-        </el-table>
-      </div>
+      <progress-unit />
     </el-drawer>
   </div>
 </template>
@@ -395,12 +361,13 @@ import {
   delCustomerType,
   putCustomer
 } from '@/api/customer'
-import { getUserProgress } from '@/api/progress'
 import { ElMessage, ElMessageBox } from 'element-plus'
+import progressUnit from './component/progress.vue'
+import { useCustomer } from '@/pinia/customer/customer'
 defineOptions({
   name: 'Customer'
 })
-
+const customerData = useCustomer()
 const searchData = reactive({
   contacts: '',
   customerType: ''
@@ -598,17 +565,10 @@ const editUserInfo = () => {
 
 // 客户进度信息
 const progressShow = ref(false)
-const progressInfo = reactive([])
 const openProgressEdit = (row) => {
-  getUserProgress(row.ID).then(res => {
-    if (res.code === 0) {
-      console.log(res.data)
-      progressShow.value = true
-    }
-  })
+  progressShow.value = true
+  customerData.getProgressList(row.ID)
 }
-// 添加客户进度信息
-const addProgress = () => {}
 
 onMounted(() => {
   queryUserTypeList()