wansfa 2 лет назад
Родитель
Сommit
2cc6ec588b

+ 53 - 0
src/api/crm/customerHisOrder.js

@@ -0,0 +1,53 @@
+import request from '@/utils/request'
+
+// 查询客户历史订单列表
+export function listCustomerHisOrder(query) {
+  return request({
+    url: '/crm/customerHisOrder/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询客户历史订单详细
+export function getCustomerHisOrder(orderId) {
+  return request({
+    url: '/crm/customerHisOrder/' + orderId,
+    method: 'get'
+  })
+}
+
+// 新增客户历史订单
+export function addCustomerHisOrder(data) {
+  return request({
+    url: '/crm/customerHisOrder',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改客户历史订单
+export function updateCustomerHisOrder(data) {
+  return request({
+    url: '/crm/customerHisOrder',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除客户历史订单
+export function delCustomerHisOrder(orderId) {
+  return request({
+    url: '/crm/customerHisOrder/' + orderId,
+    method: 'delete'
+  })
+}
+
+// 导出客户历史订单
+export function exportCustomerHisOrder(query) {
+  return request({
+    url: '/crm/customerHisOrder/export',
+    method: 'get',
+    params: query
+  })
+}

+ 8 - 1
src/views/crm/components/customerDetails.vue

@@ -172,6 +172,9 @@
             <el-tab-pane label="客户日志" name="logs">
                 <customer-logs-list ref="logs"></customer-logs-list>
             </el-tab-pane>
+            <el-tab-pane label="历史订单" name="hisOrder">
+                <customer-his-order-list ref="hisOrder"></customer-his-order-list>
+            </el-tab-pane>
         </el-tabs>
        
         <el-dialog :title="addTag.title" :visible.sync="addTag.open" width="600px" append-to-body>
@@ -208,6 +211,7 @@
     import customerStoreOrderList from '../components/customerStoreOrderList.vue';
     import duplicateCustomer from '../components/duplicateCustomer.vue';
     import customerContacts from './customerContacts.vue';
+    import customerHisOrderList from '../components/customerHisOrderList.vue';
     import { getCustomerDetails,updateCustomer  } from "@/api/crm/customer";
     import addTag from './addTag.vue';
     import addRemark from './addRemark.vue';
@@ -215,7 +219,7 @@
     import addOrEditCustomer from '../components/addOrEditCustomer.vue';
     export default {
         name: "customer",
-        components: {addOrEditCustomer,addSms,addTag,addRemark, customerContacts,customerVisitList,customerLogsList,customerVoiceLogsList,customerStoreOrderList,customerSmsLogsList,duplicateCustomer },
+        components: {customerHisOrderList,addOrEditCustomer,addSms,addTag,addRemark, customerContacts,customerVisitList,customerLogsList,customerVoiceLogsList,customerStoreOrderList,customerSmsLogsList,duplicateCustomer },
         data() {
             return {
                 customer:{
@@ -359,6 +363,9 @@
                 }
                 if(tab.name=="smsLogs"){
                     this.$refs.smsLogs.getData(this.item.customerId);
+                }  
+                if(tab.name=="hisOrder"){
+                    this.$refs.hisOrder.getData(this.item.customerId);
                 }
             },
             getDetails(customerId) {

+ 235 - 0
src/views/crm/components/customerHisOrderList.vue

@@ -0,0 +1,235 @@
+<template>
+  <div >
+    <el-table border v-loading="loading" :data="customerHisOrderList" >
+      <el-table-column   type="expand"   >
+        <template slot-scope="props">
+          <el-table
+          border
+          :data="props.row.items"
+          >
+          <el-table-column
+            prop="productName"
+            label="名称"
+             >
+          </el-table-column>
+          <el-table-column
+            prop="count"
+            label="数量"
+            >
+          </el-table-column>
+        </el-table>
+        </template>
+      </el-table-column>
+      <el-table-column  label="订单号"  width="120px"  align="center"   >
+        <template slot-scope="scope">
+          {{scope.row.order.orderCode}}
+        </template>
+      </el-table-column>
+      <el-table-column  label="商品数量" width="120px"  align="center"   >
+        <template slot-scope="scope">
+          {{scope.row.order.count}}
+        </template>
+      </el-table-column>
+      <el-table-column  label="订单金额" width="120px"  align="center"   >
+        <template slot-scope="scope">
+          {{scope.row.order.orderPrice}}元
+        </template>
+      </el-table-column>
+      <el-table-column  label="订金" width="120px"  align="center"   >
+        <template slot-scope="scope">
+          {{scope.row.order.djPrice}}元
+        </template>
+      </el-table-column>
+      <el-table-column  label="代收" width="120px"  align="center"   >
+        <template slot-scope="scope">
+          {{scope.row.order.shippingPrice}}元
+        </template>
+      </el-table-column>
+      <el-table-column  label="支付金额" width="120px"  align="center"   >
+        <template slot-scope="scope">
+          {{scope.row.order.payPrice}}元
+        </template>
+      </el-table-column>
+      <el-table-column label="创建时间" align="center" prop="createTime" />
+    </el-table>
+    
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+     
+  </div>
+</template>
+
+<script>
+import { listCustomerHisOrder, getCustomerHisOrder, delCustomerHisOrder, addCustomerHisOrder, updateCustomerHisOrder, exportCustomerHisOrder } from "@/api/crm/customerHisOrder";
+
+export default {
+  name: "CustomerHisOrder",
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 客户历史订单表格数据
+      customerHisOrderList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        customerId: null,
+        customerCode: null,
+        orderJson: null,
+        itemJson: null,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+      }
+    };
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    getData(customerId){
+        this.queryParams.customerId=customerId;
+        this.queryParams.pageNum=1;
+        this.getList();
+    },
+    /** 查询客户历史订单列表 */
+    getList() {
+      this.loading = true;
+      listCustomerHisOrder(this.queryParams).then(response => {
+        this.customerHisOrderList = response.rows;
+        this.customerHisOrderList.forEach(function(value,index,array){
+          var order=JSON.parse(value.orderJson);
+          value.order=order;
+          var items=JSON.parse(value.itemJson);
+          value.items=items;
+        });
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        orderId: null,
+        customerId: null,
+        customerCode: null,
+        orderJson: null,
+        itemJson: null,
+        createTime: null
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.orderId)
+      this.single = selection.length!==1
+      this.multiple = !selection.length
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.title = "添加客户历史订单";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      const orderId = row.orderId || this.ids
+      getCustomerHisOrder(orderId).then(response => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "修改客户历史订单";
+      });
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          if (this.form.orderId != null) {
+            updateCustomerHisOrder(this.form).then(response => {
+              if (response.code === 200) {
+                this.msgSuccess("修改成功");
+                this.open = false;
+                this.getList();
+              }
+            });
+          } else {
+            addCustomerHisOrder(this.form).then(response => {
+              if (response.code === 200) {
+                this.msgSuccess("新增成功");
+                this.open = false;
+                this.getList();
+              }
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const orderIds = row.orderId || this.ids;
+      this.$confirm('是否确认删除客户历史订单编号为"' + orderIds + '"的数据项?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(function() {
+          return delCustomerHisOrder(orderIds);
+        }).then(() => {
+          this.getList();
+          this.msgSuccess("删除成功");
+        }).catch(function() {});
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      const queryParams = this.queryParams;
+      this.$confirm('是否确认导出所有客户历史订单数据项?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(function() {
+          return exportCustomerHisOrder(queryParams);
+        }).then(response => {
+          this.download(response.msg);
+        }).catch(function() {});
+    }
+  }
+};
+</script>

+ 6 - 0
src/views/crm/customer/index.vue

@@ -123,6 +123,12 @@
               <el-option key="0"  label="否" value="0" />
             </el-select>
           </el-form-item>
+          <el-form-item label="历史订单" prop="isHisOrder">
+            <el-select style="width:220px" filterable v-model="queryParams.isHisOrder" placeholder="请选择历史订单" clearable size="small">
+              <el-option key="1"  label="是" value="1" />
+              <el-option key="0"  label="否" value="0" />
+            </el-select>
+          </el-form-item>
           <el-form-item>
             <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>

+ 6 - 0
src/views/crm/customer/my.vue

@@ -91,6 +91,12 @@
               end-placeholder="结束日期">
             </el-date-picker>
       </el-form-item>
+      <el-form-item label="历史订单" prop="isHisOrder">
+          <el-select style="width:220px" filterable v-model="queryParams.isHisOrder" placeholder="请选择历史订单" clearable size="small">
+            <el-option key="1"  label="是" value="1" />
+            <el-option key="0"  label="否" value="0" />
+          </el-select>
+      </el-form-item>
       <el-form-item>
         <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>

+ 2 - 1
src/views/login.vue

@@ -136,7 +136,8 @@ export default {
           this.$store
             .dispatch("Login", this.loginForm)
             .then(() => {
-              this.$router.push({ path: this.redirect || "/" });
+              //this.$router.push({ path: this.redirect || "/" });
+              this.$router.push({ path:  "/" });
             })
             .catch(() => {
               this.loading = false;