Prechádzať zdrojové kódy

提交销售订单相关代码

Lijy 11 mesiacov pred
rodič
commit
b797687c6d

+ 6 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/order/api.ts

@@ -1,5 +1,5 @@
 export const MOD = '/order'
-export const IMPOERMOD = 'Order'
+export const IMPORTMOD = 'Order'
 
 export const GETSYSFILED = "/sys-dict/getListByCode";
 export const GETPERSONNEL = "/user/getSimpleActiveUserList";
@@ -9,6 +9,11 @@ export const GETTABLELISTPRODUCT = `/product/list`
 export const GETTABLELIST = `${MOD}/list`
 export const URL_OEDERUPDATE = `${MOD}/addOrUpdate`
 export const URL_PRODUTWITHORDER = `${MOD}/productWithOrder`
+export const URL_DETELEITEM = `${MOD}/delete`
+export const EXPORTTIME = `${MOD}/exportData`
+export const IMPORITEM = `${MOD}/importData`
+export const URL_BATCHDELETE = `${MOD}/batchDeleteOrder`
+export const URL_RECOVER = `${MOD}/recover`
 
 export const tableColumns: TableColumn[] = [
     { prop: 'orderCode', label: '订单编号', event: 'toDetali', width: '150' },

+ 156 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/order/component/deteleTables.vue

@@ -0,0 +1,156 @@
+<template>
+    <el-dialog v-model="deteleBusinessDialogVisible" width="1000" :before-close="beForeCancel" :show-close="false"
+        top="10vh">
+        <template #header="{ close, titleId, titleClass }">
+            <div class="flex justify-between items-center border-b pb-3 dialog-header">
+                <h4 :id="titleId">销售订单回收站</h4>
+                <div>
+                    <el-button type="primary" v-loading="allLoading.batchRecoveryLoading" :disabled="batchTableData.length == 0"
+                        @click="batchOperation('恢复')">批量恢复</el-button>
+                    <el-button type="primary" v-loading="allLoading.batchDeteleLoading" :disabled="batchTableData.length == 0"
+                        @click="batchOperation('删除')">批量删除</el-button>
+                    <el-button @click="cancel()">取消</el-button>
+                </div>
+            </div>
+        </template>
+        <div class="h-[60vh] flex flex-col">
+            <div class="flex-1 w-full overflow-hidden">
+                <el-table ref="busiessTableRef" :data="deteleBusinessTable" border v-loading="allLoading.tableLoading"
+                    @selection-change="changeBatch" style="width: 100%;height: 100%;">
+                    <el-table-column type="selection" width="55" />
+                    <el-table-column v-for="(item, index) in tableColumns" :prop="item.prop" :label="item.label" :key="index"
+                        :width="item.width">
+                        <template #default="scope">
+                            <span>{{ scope.row[item.prop] }}</span>
+                        </template>
+                    </el-table-column>
+                    <el-table-column label="操作" fixed="right" width="120">
+                        <template #default="scope">
+                            <el-button link type="primary" size="large"
+                                @click="businessOperationItem(scope.row.id, scope.row.name, '恢复')">恢复</el-button>
+                            <el-button link type="danger" size="large"
+                                @click="businessOperationItem(scope.row.id, scope.row.name, '删除')">删除</el-button>
+                        </template>
+                    </el-table-column>
+                </el-table>
+            </div>
+            <div class="flex justify-end pt-3">
+                <el-pagination layout="total, prev, pager, next, sizes" :page-size="tableForm.pageSize"
+                    @size-change="handleSizeChange" @current-change="handleCurrentChange" :total="businessTotalTable"
+                    :hide-on-single-page="true" />
+            </div>
+        </div>
+    </el-dialog>
+</template>
+<script lang="ts" setup>
+import { post } from '@/utils/request';
+import { ref, reactive, onMounted, watchEffect, watch, inject } from 'vue'
+import { GETTABLELIST, tableColumns, URL_BATCHDELETE, URL_RECOVER } from '../api';
+import { ElTable } from 'element-plus';
+import { confirmAction } from '@/utils/tools';
+import { formatDate } from '@/utils/times';
+
+type operationType = '恢复' | '删除'
+
+const emits = defineEmits(['closeVisible']);
+const globalPopup = inject<GlobalPopup>('globalPopup')
+const deteleBusinessTable = ref([])
+const deteleBusinessDialogVisible = ref(false)
+const businessTotalTable = ref(0)
+const batchTableData = ref([])
+const allLoading = reactive({
+    batchRecoveryLoading: false,
+    batchDeteleLoading: false,
+    tableLoading: false
+})
+
+const tableForm = reactive({
+    pageIndex: 1,
+    pageSize: 10
+})
+
+const busiessTableRef = ref<InstanceType<typeof ElTable>>() // 线索table dom
+
+const props = defineProps<{
+    visibles: boolean
+}>()
+
+watch(() => props.visibles, (newVal) => {
+    deteleBusinessDialogVisible.value = newVal
+    if (newVal) {
+        getTableList()
+    }
+})
+
+function batchOperation(type: operationType) {
+    const value = batchTableData.value.map((item: any) => item.id).join(',')
+    const label = batchTableData.value.map((item: any) => item.name).join(',')
+    businessOperationItem(value, label, type, true)
+}
+
+function businessOperationItem(value: string | number, label: string, type: operationType, batch: boolean = false) {
+    confirmAction(`确定${batch ? '批量' : ''}${type}【${label}】销售订单吗?`).then(() => {
+        let url = type == '恢复' ? URL_RECOVER : URL_BATCHDELETE
+        // let url = ''
+        post(url, { ids: value }).then(res => {
+            if (res.code != 'ok') {
+                globalPopup?.showError(res.msg)
+                return
+            }
+            globalPopup?.showSuccess(`${type}成功`)
+            getTableList()
+            changeBatch(false)
+        }).catch((err) => {
+            globalPopup?.showError(err.message)
+        })
+    })
+}
+
+function changeBatch(flag: boolean = true) {
+    if (flag) {
+        batchTableData.value = busiessTableRef.value && busiessTableRef.value.getSelectionRows()
+    } else {
+        batchTableData.value = []
+        busiessTableRef.value && busiessTableRef.value.clearSelection()
+    }
+}
+
+function getTableList() {
+    allLoading.tableLoading = true
+    post(GETTABLELIST, { ...tableForm, isDelete: 1 }).then((res) => {
+        if (res.code == 'ok') {
+            const { record, total } = res.data
+            deteleBusinessTable.value = record
+            businessTotalTable.value = total
+        }
+    }).finally(() => {
+        allLoading.tableLoading = false
+    })
+}
+
+function handleSizeChange(val: number) {
+    tableForm.pageIndex = 1
+    tableForm.pageSize = val
+    getTableList()
+}
+
+function handleCurrentChange(val: number) {
+    tableForm.pageIndex = val
+    getTableList()
+}
+
+function cancel() {
+    emits('closeVisible', 'deteleOrderVisible')
+}
+
+function beForeCancel(done: () => void) {
+    emits('closeVisible', 'deteleOrderVisible')
+    done()
+}
+
+onMounted(() => {
+
+})
+
+</script>
+<style lang="scss" scoped></style>

+ 173 - 26
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/order/index.vue

@@ -37,16 +37,17 @@
         <div class="flex justify-end pb-3">
           <!-- 操作按钮 -->
           <el-button type="primary" @click="editOrder(false)">新建订单</el-button>
-          <el-button type="primary">批量转移</el-button>
-          <el-button type="primary">批量删除</el-button>
-          <el-button type="primary">回收站</el-button>
-          <el-button type="primary">导入</el-button>
-          <el-button type="primary">导出</el-button>
+          <el-button type="primary" :disabled="batchTableData.length <= 0">批量转移</el-button>
+          <el-button type="primary" @click="batchDeteleItem()" :disabled="batchTableData.length <= 0">批量删除</el-button>
+          <el-button type="primary" @click="showVisible('deteleOrderVisible')">回收站</el-button>
+          <el-button type="primary" @click="showVisible('importVisible')">导入</el-button>
+          <el-button type="primary" @click="exportOrderTableList()" :loading="allLoading.exoprtLoading">导出</el-button>
         </div>
         <div class="flex-1 w-full overflow-hidden">
           <!-- 表格 -->
           <el-table ref="otherTableRef" :data="formTable" border v-loading="allLoading.formTableLading"
-            style="width: 100%;height: 100%;">
+            style="width: 100%;height: 100%;" @selection-change="changeBatch">
+            <el-table-column type="selection" width="55" />
             <el-table-column v-for="(column, index) in tableColumns" :key="index" :prop="column.prop"
               :label="column.label" :width="column.width">
               <template #default="scope">
@@ -59,8 +60,9 @@
             <el-table-column :label="'操作'" :width="'200px'" fixed="right">
               <template #default="scope">
                 <el-button link type="primary" size="large" @click="editOrder(scope.row)">编辑</el-button>
-                <el-button link type="primary" size="large">新建任务</el-button>
-                <el-button link type="danger" size="large">删除</el-button>
+                <el-button link type="primary" size="large" @click="newTask(scope.row)">新建任务</el-button>
+                <el-button link type="danger" size="large"
+                  @click="orderDeteleItem(scope.row.id, scope.row.orderName)">删除</el-button>
               </template>
             </el-table-column>
           </el-table>
@@ -68,7 +70,7 @@
         <div class="flex justify-end pt-3">
           <!-- 分页 -->
           <el-pagination layout="total, prev, pager, next, sizes" :total="formTablePaging.total"
-            :hide-on-single-page="true" />
+            :hide-on-single-page="true" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
         </div>
       </div>
     </div>
@@ -88,7 +90,39 @@
       <div class="h-[60vh] overflow-y-auto scroll-bar pt-3" v-loading="allLoading.orderTemplateLoadinng">
         <GenerateForm ref="orderTemplateRef" :data="orderTemplate" :value="orderTemplateValue" />
         <div>相关产品</div>
-        <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList" :productTableListValue="productTableListValue" />
+        <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList"
+          :productTableListValue="productTableListValue" />
+      </div>
+    </el-dialog>
+
+    <!-- 新建任务 -->
+    <TaskModal :visible="allVisible.taskModalVisible" :edit-form="taskModalForm" :save-loading="taskLoading"
+      @close="allVisible.taskModalVisible = false" @submit="submitForm" :title="'新建任务'"
+      :disabled-list="['taskType', 'orderId']" />
+
+    <!-- 回收站 -->
+    <DeteleTables :visibles="allVisible.deteleOrderVisible" @closeVisible="closeVisible" />
+
+    <!-- 导入 -->
+    <el-dialog v-model="allVisible.importVisible" width="680" :show-close="false" top="10vh">
+      <template #header="{ close, titleId, titleClass }">
+        <div class="flex justify-between items-center border-b pb-3 dialog-header">
+          <h4 :id="titleId">导入联系人</h4>
+          <div class="flex">
+            <el-upload class="upload-demo mr-3" :limit="1" :show-file-list="false" accept=".xlsx"
+              :http-request="importBusiness">
+              <el-button type="primary" :loading="allLoading.importLoading">导入</el-button>
+            </el-upload>
+            <el-button @click="allVisible.importVisible = false">取消</el-button>
+          </div>
+        </div>
+      </template>
+      <div class="p-8">
+        <div class="ml-4 mr-4">
+          <div class="flex items-center">1、点击下载 <el-link type="primary"
+              @click="downloadTemplate(IMPORTMOD, allText.importText)">{{ allText.importText }}</el-link></div>
+          <div class="mt-4">2、填写excel文件、订单名称、客户名称、订单金额、负责人必填</div>
+        </div>
       </div>
     </el-dialog>
   </div>
@@ -96,16 +130,20 @@
 
 <script lang="ts" setup>
 import { ref, reactive, onMounted, inject, defineExpose } from "vue";
-import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate, getTemplateKey } from '@/utils/tools'
-import { post, get } from "@/utils/request";
-import { tableColumns, GETSYSFILED, GETPERSONNEL, GETGENERATEFOEM, MOD, GETTABLELIST, GETALLPRODUCT, GETTABLELISTPRODUCT, URL_OEDERUPDATE, URL_PRODUTWITHORDER } from "./api";
+import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate, getTemplateKey, createTaskFromType, confirmAction, downloadFile, downloadTemplate } from '@/utils/tools'
+import { post, get, uploadFile } from "@/utils/request";
+import { tableColumns, GETSYSFILED, GETPERSONNEL, GETGENERATEFOEM, MOD, GETTABLELIST, GETALLPRODUCT, GETTABLELISTPRODUCT, URL_OEDERUPDATE, URL_PRODUTWITHORDER, URL_DETELEITEM, EXPORTTIME, IMPORTMOD, IMPORITEM } from "./api";
 import { useRouter, useRoute } from "vue-router";
 import { GenerateForm } from '@zmjs/form-design';
+import { formatDateTime } from "@/utils/times";
+import { ElTable, UploadRequestOptions } from "element-plus";
+import { createTask } from "@/components/TaskModal/taskFunction";
 import { URL_FETALL } from "../customer/api";
 
 import RelatedProducts from '@/components/relatedProducts/relatedProducts.vue'
+import DeteleTables from './component/deteleTables.vue'
 import TaskModal from '@/components/TaskModal/index.vue'
-import { formatDateTime } from "@/utils/times";
+
 
 const router = useRouter()
 const globalPopup = inject<GlobalPopup>('globalPopup')
@@ -127,41 +165,129 @@ const selectData = reactive({ // 下拉数据
   AllProduct: [] as any[] // 所有产品
 })
 const formTablePaging = reactive({ // 分页条件
-  currentPage: 1,
+  pageIndex: 1,
   pageSize: 10,
   total: 0,
 })
 const allLoading = reactive({ // 按钮加载 Loading
   formTableLading: false,
   editSaveLading: false,
-  orderTemplateLoadinng: false
+  orderTemplateLoadinng: false,
+  exoprtLoading: false,
+  importLoading: false
 })
 const allVisible = reactive({
-  editOrderVisible: false
+  editOrderVisible: false,
+  taskModalVisible: false,
+  deteleOrderVisible: false,
+  importVisible: false
 })
 const allText = reactive({
-  orderEditText: '新建订单'
+  orderEditText: '新建订单',
+  importText: '销售订单表导出.xlsx'
 })
 const orderTemplate = ref({
   list: [],
   config: {}
 })
+const filterItems = ref<FilterItem[]>([
+  { label: '订单编号', key: 'orderCode', type: 'input' },
+  { label: '订单名称', key: 'orderName', type: 'input' },
+  { label: '客户名称', key: 'customId', type: 'select', options: selectData.Customer },
+  { label: '商机名称', key: 'businessOpportunityId', type: 'input' },
+  { label: '订单类型', key: 'ordertype', type: 'select', options: selectData.OrderType },
+  { label: '回款状态', key: 'receivedStatus', type: 'select', options: selectData.RemittanceStatus },
+  { label: '负责人', key: 'inchargerId', type: 'select', options: selectData.Personnel },
+  { label: '下单时间', key: '', type: 'date' },
+]) // 渲染筛选条件
 const orderTemplateValue = ref({})
 const orderTemplateKey = ref(1)
 const orderTemplateRef = ref<typeof GenerateForm>()
 const relatedProductsRef = ref<typeof RelatedProducts>()
-const filterItems = ref<FilterItem[]>([]) // 渲染筛选条件
+const otherTableRef = ref<InstanceType<typeof ElTable>>()
+const taskLoading = ref<saveLoadingType>('1')
+const batchTableData = ref([])
 const formTable = ref([]) // 表格数据
 const productTableList = ref([])
 const productTableListValue = ref([])
+const taskModalForm = ref({})
+
+async function importBusiness(param: UploadRequestOptions) {
+  allLoading.importLoading = true
+  const formData = new FormData();
+  formData.append('multipartFile', param.file)
+  const res = await uploadFile(IMPORITEM, formData).finally(() => {
+    allLoading.importLoading = false
+  })
+  if (res.code == 'ok') {
+    globalPopup?.showSuccess('导入成功' || '')
+    getTableList()
+    return
+  }
+  globalPopup?.showError(res.msg || '')
+}
+
+function exportOrderTableList() {
+  allLoading.exoprtLoading = true
+  let valueForm = getFromValue(filterForm)
+  post(EXPORTTIME, {...valueForm}).then((res) => {
+    downloadFile(res.data, allText.importText)
+  }).finally(() => {
+    allLoading.exoprtLoading = false
+  })
+}
+
+function batchDeteleItem() {
+  const value = batchTableData.value.map((item: any) => item.id).join(',')
+  const label = batchTableData.value.map((item: any) => item.orderName).join(',')
+  orderDeteleItem(value, label, true)
+}
+
+function orderDeteleItem(value: string | number, label: string, batch: boolean = false) {
+  confirmAction(`确定${batch ? '批量' : ''}删除【${label}】客户吗?`).then(() => {
+    post(URL_DETELEITEM, { ids: value }).then(res => {
+      if (res.code != 'ok') {
+        globalPopup?.showError(res.msg)
+        return
+      }
+      globalPopup?.showSuccess('删除成功')
+      changeBatch(false)
+      getTableList()
+    }).catch((err) => {
+      globalPopup?.showError(err.message)
+    })
+  })
+}
+
+function submitForm(submitData: any, isClose: boolean) {
+  taskLoading.value = '2'
+  createTask(submitData, isClose).then((res) => {
+    const { saveLoading, isClose } = res
+    taskLoading.value = saveLoading
+    allVisible.taskModalVisible = isClose
+    globalPopup?.showSuccess('新增成功')
+  }).catch((err) => {
+    const { saveLoading, isClose, message } = err
+    taskLoading.value = saveLoading
+    allVisible.taskModalVisible = isClose
+    globalPopup?.showError(message)
+  })
+}
+
+function newTask(item: any) {
+  const { id } = item
+  taskModalForm.value = { ...createTaskFromType(2), orderId: id, }
+  console.log(taskModalForm.value)
+  allVisible.taskModalVisible = true
+}
 
 function saveOrder(flag: boolean) {
   orderTemplateRef.value?.getData().then((res: any) => {
     let productTableListData = relatedProductsRef?.value?.returnData()
-    for(var i in productTableListData) {
+    for (var i in productTableListData) {
       productTableListData[i].sealPrice = productTableListData[i].sellingPrice,
-      productTableListData[i].discount = productTableListData[i].discount,
-      productTableListData[i].num = productTableListData[i].quantity
+        productTableListData[i].discount = productTableListData[i].discount,
+        productTableListData[i].num = productTableListData[i].quantity
     }
     const produt = productTableListData ? JSON.stringify(productTableListData) : []
     allLoading.editSaveLading = true
@@ -221,7 +347,7 @@ function toDetali(row: any) {
 
 function getTableList() {
   const formValue = getFromValue(filterForm)
-  const formPaging = { pageIndex: formTablePaging.currentPage, pageSize: formTablePaging.pageSize }
+  const formPaging = { pageIndex: formTablePaging.pageIndex, pageSize: formTablePaging.pageSize }
   allLoading.formTableLading = true
   post(GETTABLELIST, { ...formValue, ...formPaging }).then(res => {
     const { total, record } = res.data
@@ -273,6 +399,15 @@ async function getSystemField() {
   setFilterItems()
 }
 
+function changeBatch(flag: boolean = true) {
+  if (flag) {
+    batchTableData.value = otherTableRef.value && otherTableRef.value.getSelectionRows()
+  } else {
+    batchTableData.value = []
+    otherTableRef.value && otherTableRef.value.clearSelection()
+  }
+}
+
 function showVisible(type: keyof typeof allVisible) { // 显示弹窗
   allVisible[type] = true
 }
@@ -298,9 +433,10 @@ function editProduct(row: any) {
   post(URL_PRODUTWITHORDER, { id: row.id }).then(({ data }) => {
     const list = data.map((item: any) => {
       const { id, productName, productCode, unit, unitName, typeName, type, price, inventory, orderProductDetail } = item
-      return { id, productId: id, productName, productCode, unit, unitName, typeName, type, price, inventory, 
-        quantity: +orderProductDetail?.num, 
-        discount: +orderProductDetail?.discount, 
+      return {
+        id, productId: id, productName, productCode, unit, unitName, typeName, type, price, inventory,
+        quantity: +orderProductDetail?.num,
+        discount: +orderProductDetail?.discount,
         sellingPrice: +orderProductDetail?.sealPrice,
         totalPrice: +orderProductDetail?.totalPrice
       }
@@ -336,6 +472,17 @@ function getProductTableList() {
   })
 }
 
+function handleSizeChange(val: number) {
+  formTablePaging.pageIndex = 1
+  formTablePaging.pageSize = val
+  getTableList()
+}
+
+function handleCurrentChange(val: number) {
+  formTablePaging.pageIndex = val
+  getTableList()
+}
+
 onMounted(() => {
   getSystemField()
   getAllProduct()