|
@@ -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()
|