Browse Source

收入分析

2545307760@qq.com 2 months ago
parent
commit
dd51fb61ed

+ 2 - 0
server/api/v1/crm/demand.go

@@ -1,6 +1,7 @@
 package crm
 
 import (
+	"fmt"
 	"github.com/gin-gonic/gin"
 	"server/dao/crm"
 	"server/global"
@@ -13,6 +14,7 @@ type DemandApi struct{}
 func (da *DemandApi) QueryDemandsByCustomerId(c *gin.Context) {
 	id := c.Query("id")
 	customerId, err := strconv.Atoi(id)
+	fmt.Print("customerId:", customerId)
 	demands, err := demandService.QueryDemandsByCustomerId(customerId)
 	if err != nil {
 		response.FailWithMessage("查询失败", c)

+ 8 - 2
web/src/pinia/customer/customer.js

@@ -11,7 +11,6 @@ export const useCustomer = defineStore('customer', () => {
     getUserProgress(id).then(res => {
       if (res.code === 0) {
         progressList.length = 0
-        console.log('数据', res.data)
         progressList.push(...res.data)
       }
     })
@@ -20,7 +19,14 @@ export const useCustomer = defineStore('customer', () => {
     customerId.value = id
   }
   // 需求
-  const demandList = reactive([])
+  const demandList = reactive([
+    {
+      content: '',
+      customerId: 0,
+      proposeTime: '2024-01-10',
+      isFinish: false
+    }
+  ])
   const demandId = ref(0)
   const getDemandList = (id) => {
     getUserDemand(id).then(res => {

+ 176 - 4
web/src/view/customer/component/demand.vue

@@ -18,13 +18,13 @@
           label="提出时间"
           align="center"
           width="150px"
-          prop="customerId"
+          prop="proposeTime"
         />
         <el-table-column
           label="是否完成"
           align="center"
           width="150px"
-          prop="followUpTime"
+          prop="isFinish"
         />
         <el-table-column
           label="需求内容"
@@ -48,7 +48,7 @@
               type="primary"
               text
               icon="Edit"
-              @click="progressEdit(scope.row)"
+              @click="demandEdit(scope.row)"
             >
               编辑
             </el-button>
@@ -56,7 +56,7 @@
               type="primary"
               text
               icon="delete"
-              @click="deleteProgress(scope.row)"
+              @click="deleteDemand(scope.row)"
             >
               删除
             </el-button>
@@ -64,16 +64,188 @@
         </el-table-column>
       </el-table>
     </div>
+    <el-dialog
+      v-model="addDemandShow"
+      width="35%"
+      title="新增客户进度"
+    >
+      <el-form label-width="100px">
+        <el-form-item label="提出时间:">
+          <el-date-picker
+            v-model="addDemandData.proposeTime"
+            type="date"
+            placeholder="请选择提出时间"
+            size="large"
+            format="YYYY-MM-DD"
+            value-format="YYYY-MM-DD"
+            clearable
+            @clear="addDemandData.proposeTime = ''"
+          />
+        </el-form-item>
+        <el-form-item label="需求内容:">
+          <el-input
+            v-model="addDemandData.content"
+            type="textarea"
+            :rows="3"
+            placeholder="请输入需求内容"
+          />
+        </el-form-item>
+        <el-form-item label="是否完成:">
+          <el-select
+            v-model="addDemandData.isFinish"
+            size="large"
+            placeholder="是否完成"
+          >
+            <el-option
+              label="已完成"
+              :value="true"
+            />
+            <el-option
+              label="未完成"
+              :value="false"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button
+          type="primary"
+          size="large"
+          @click="addDemand"
+        >确定</el-button>
+      </template>
+    </el-dialog>
+    <el-dialog
+      v-model="editDemandShow"
+      width="35%"
+      title="新增客户进度"
+    >
+      <el-form label-width="100px">
+        <el-form-item label="提出时间:">
+          <el-date-picker
+            v-model="editDemandData.proposeTime"
+            type="date"
+            placeholder="请选择提出时间"
+            size="large"
+            format="YYYY-MM-DD"
+            value-format="YYYY-MM-DD"
+            clearable
+            @clear="editDemandData.proposeTime = ''"
+          />
+        </el-form-item>
+        <el-form-item label="需求内容:">
+          <el-input
+            v-model="editDemandData.content"
+            type="textarea"
+            :rows="3"
+            placeholder="请输入需求内容"
+          />
+        </el-form-item>
+        <el-form-item label="是否完成:">
+          <el-select
+            v-model="editDemandData.isFinish"
+            size="large"
+            placeholder="是否完成"
+          >
+            <el-option
+              label="已完成"
+              :value="true"
+            />
+            <el-option
+              label="未完成"
+              :value="false"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button
+          type="primary"
+          size="large"
+          @click="addDemand"
+        >确定</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
 <script setup>
+import { ref, reactive } from 'vue'
 import { useCustomer } from '@/pinia/customer/customer'
+import { ElMessage, ElMessageBox } from 'element-plus'
+import { postUserDemand, delUserDemand } from '@/api/demand'
 defineOptions({
   name: 'DemandUnit'
 })
 const customerData = useCustomer()
 const openAddDemand = () => {
+  addDemandShow.value = true
+}
+
+// 新增需求
+const addDemandShow = ref(false)
+
+const addDemandData = reactive({
+  content: '',
+  customerId: customerData.customerId,
+  proposeTime: '',
+  isFinish: false
+})
+
+const addDemand = () => {
+  for (const key in addDemandData) {
+    if (addDemandData[key] === '' || addDemandData[key] === 0) {
+      ElMessage.error('请将信息填写完整')
+      return
+    }
+  }
+  postUserDemand(addDemandData).then(res => {
+    console.log(res)
+    if (res.code === 0) {
+      ElMessage.success(res.msg)
+      customerData.getDemandList(customerData.demandId)
+    }
+  })
+}
+
+// 编辑需求
+const editDemandShow = ref(false)
+const editDemandData = reactive({
+  proposeTime: '',
+  content: '',
+  isFinish: false,
+  customerId: customerData.customerId
+})
+const demandEdit = (row) => {
+  console.log(row)
+}
+
+// 删除需求
+const deleteDemand = (row) => {
+  console.log(row)
+  ElMessageBox.confirm(
+    '确定删除此客户进度吗?',
+    '删除',
+    {
+      confirmButtonText: '确定',
+      cancelButtonText: '取消',
+      type: 'warning',
+    }
+  )
+    .then(() => {
+      delUserDemand(row.ID).then(res => {
+        if (res.code === 0) {
+          ElMessage.success(res.msg)
+          customerData.getProgressList(customerData.customerId)
+        }
+      })
+    })
+    .catch(() => {
+      ElMessage({
+        type: 'info',
+        message: '取消删除',
+      })
+    })
 }
 </script>
 

+ 39 - 22
web/src/view/customer/customer.vue

@@ -6,10 +6,11 @@
           <div class="customerSearch">
             <div>
               <el-select
-                v-model="searchData.customerType"
+                v-model="customerType"
                 placeholder="类型"
                 style="width: 120px"
                 clearable
+                @change="changeCustomerType"
               >
                 <el-option
                   v-for="item in userTypeList"
@@ -23,11 +24,16 @@
               <el-input
                 v-model="userJson.name"
                 style="max-width: 600px"
-                placeholder="联系人"
+                placeholder="请输入客户名称"
                 class="input-with-select"
+                clearable
+                @clear="clearCustomerName"
               >
                 <template #append>
-                  <el-button icon="Search" />
+                  <el-button
+                    icon="Search"
+                    @click="queryCustomerList"
+                  />
                 </template>
               </el-input>
             </div>
@@ -141,13 +147,13 @@
             </el-table-column>
           </el-table>
           <el-pagination
-            :current-page="pageSet.page"
-            :page-size="pageSet.pageSize"
+            :current-page="userJson.pageInfo.page"
+            :page-size="userJson.pageInfo.pageSize"
             :page-sizes="[10, 30, 50, 100]"
-            :total="pageSet.total"
+            :total="customerTotal"
             layout="total, sizes, prev, pager, next, jumper"
-            @current-change="handleCurrentChange"
-            @size-change="handleSizeChange"
+            @current-change="changeCurrentPage"
+            @size-change="changeCurrentPageSize"
           />
         </el-card>
       </el-col>
@@ -377,21 +383,12 @@ defineOptions({
   name: 'Customer'
 })
 const customerData = useCustomer()
-const searchData = reactive({
-  contacts: '',
-  customerType: ''
-})
-
-const pageSet = reactive({
-  page: 1,
-  pageSize: 10,
-  total: 100
-})
-
-const handleCurrentChange = () => {}
 
-const handleSizeChange = () => {}
+const customerType = ref('')
 
+const changeCustomerType = (val) => {
+  console.log(val)
+}
 // 客户类型
 const userTypeList = reactive([])
 
@@ -466,10 +463,19 @@ const userJson = reactive({
   },
   name: ''
 })
+
+const customerTotal = ref(0)
+
 const customerList = reactive([])
+
+const clearCustomerName = () => {
+  userJson.name = ''
+  queryCustomerList()
+}
 const queryCustomerList = () => {
   getCustomerList(userJson).then(res => {
     if (res.code === 0) {
+      customerTotal.value = res.data.total
       const list = res.data.list
       customerList.length = 0
       customerList.push(...list)
@@ -477,6 +483,15 @@ const queryCustomerList = () => {
   })
 }
 
+const changeCurrentPage = (val) => {
+  userJson.pageInfo.page = val
+  queryCustomerList()
+}
+
+const changeCurrentPageSize = (val) => {
+  userJson.pageInfo.pageSize = val
+  queryCustomerList()
+}
 // 新增客户
 const addCustomerShow = ref(false)
 const addCustomerJson = reactive({
@@ -590,7 +605,9 @@ const demandShow = ref(false)
 const demandTitle = ref('')
 
 const openDemandEdit = (row) => {
-  console.log(row)
+  demandTitle.value = '客户需求信息:' + row.name
+  customerData.getDemandList(row.ID)
+  customerData.changeCustomerId(row.ID)
   demandShow.value = true
 }