| | |
| | | </div> |
| | | </div> |
| | | <div class="table_list"> |
| | | <el-table :data="tableData" border :preserve-expanded-content="preserveExpanded" v-loading="tableLoading" |
| | | @selection-change="handleSelectionChange" @expand-change="expandChange" |
| | | <el-table :data="tableData" border v-loading="tableLoading" |
| | | @selection-change="handleSelectionChange" |
| | | :expand-row-keys="expandedRowKeys" |
| | | :row-key="row => row.id" |
| | | show-summary |
| | | :summary-method="summarizeMainTable" |
| | | @expand-change="expandChange" |
| | | height="calc(100vh - 18.5em)"> |
| | | <el-table-column align="center" type="selection" width="55" /> |
| | | <el-table-column type="expand"> |
| | | <template #default="props"> |
| | | <el-table :data="props.row.children" border> |
| | | <el-table :data="props.row.children" border |
| | | show-summary |
| | | :summary-method="summarizeChildrenTable"> |
| | | <el-table-column align="center" label="序号" type="index" width="60" /> |
| | | <el-table-column label="产品大类" prop="productCategory" /> |
| | | <el-table-column label="规格型号" prop="specificationModel" /> |
| | |
| | | <el-table-column label="客户名称" prop="customerName" show-overflow-tooltip/> |
| | | <el-table-column label="业务员" prop="salesman" show-overflow-tooltip/> |
| | | <el-table-column label="项目名称" prop="projectName" show-overflow-tooltip/> |
| | | <el-table-column label="合同金额(元)" prop="contractAmount" show-overflow-tooltip/> |
| | | <el-table-column label="录入人" prop="entryPerson" show-overflow-tooltip/> |
| | | <el-table-column label="录入日期" prop="entryDate" show-overflow-tooltip/> |
| | | <el-table-column fixed="right" label="操作" min-width="60" align="center"> |
| | |
| | | <pagination v-show="total > 0" :total="total" layout="total, sizes, prev, pager, next, jumper" :page="page.current" |
| | | :limit="page.size" @pagination="paginationChange" /> |
| | | </div> |
| | | <el-dialog v-model="dialogFormVisible" :title="operationType === 'add' ? '新增客户信息' : '编辑客户信息'" width="70%" @close="closeDia"> |
| | | <el-dialog v-model="dialogFormVisible" :title="operationType === 'add' ? '新增销售台账页面' : '编辑销售台账页面'" width="70%" @close="closeDia"> |
| | | <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="客户名称:" prop="customerName"> |
| | | <el-input v-model="form.customerName" placeholder="请输入" clearable/> |
| | | <el-form-item label="销售合同号:" prop="salesContractNo"> |
| | | <el-input v-model="form.salesContractNo" placeholder="自动生成" clearable disabled/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="纳税人识别号:" prop="taxpayerIdentificationNumber"> |
| | | <el-input v-model="form.taxpayerIdentificationNumber" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="公司地址:" prop="companyAddress"> |
| | | <el-input v-model="form.companyAddress" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="公司电话:" prop="companyPhone"> |
| | | <el-input v-model="form.companyPhone" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="联系人:" prop="contactPerson"> |
| | | <el-input v-model="form.contactPerson" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="联系电话:" prop="contactPhone"> |
| | | <el-input v-model="form.contactPhone" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="维护人:" prop="maintainer"> |
| | | <el-select v-model="form.maintainer" placeholder="请选择" clearable> |
| | | <el-form-item label="业务员:" prop="salesman"> |
| | | <el-select v-model="form.salesman" placeholder="请选择" clearable> |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="维护时间:" prop="maintenanceTime"> |
| | | <el-form-item label="客户合同号:" prop="customerContractNo"> |
| | | <el-input v-model="form.customerContractNo" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="客户名称:" prop="customerId"> |
| | | <el-select v-model="form.customerId" placeholder="请选择" clearable> |
| | | <el-option v-for="item in customerOption" :key="item.id" :label="item.customerName" :value="item.id"> |
| | | {{item.customerName + '——' + item.taxpayerIdentificationNumber}} |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="项目名称:" prop="projectName"> |
| | | <el-input v-model="form.projectName" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="录入人:" prop="entryPerson"> |
| | | <el-select v-model="form.entryPerson" placeholder="请选择" clearable> |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="录入日期:" prop="entryDate"> |
| | | <el-date-picker |
| | | style="width: 100%" |
| | | v-model="form.maintenanceTime" |
| | | v-model="form.entryDate" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | type="date" |
| | | placeholder="请选择" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-form-item label="产品信息:" prop="entryDate"> |
| | | <el-button type="primary" @click="openProductForm('add')">添加</el-button> |
| | | <el-button plain type="danger" @click="deleteProduct">删除</el-button> |
| | | </el-form-item> |
| | | </el-row> |
| | | <el-table :data="productData" border @selection-change="productSelected"> |
| | | <el-table-column align="center" type="selection" width="55" /> |
| | | <el-table-column align="center" label="序号" type="index" width="60" /> |
| | | <el-table-column label="产品大类" prop="productCategory" /> |
| | | <el-table-column label="规格型号" prop="specificationModel" /> |
| | | <el-table-column label="单位" prop="unit" /> |
| | | <el-table-column label="数量" prop="quantity" /> |
| | | <el-table-column label="税率" prop="taxRate" /> |
| | | <el-table-column label="含税单价(元)" prop="taxInclusiveUnitPrice" /> |
| | | <el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" /> |
| | | <el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" /> |
| | | <el-table-column fixed="right" label="操作" min-width="60" align="center"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" size="small" @click="openProductForm('edit', scope.row);">编辑</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="备注·:" prop="remark"> |
| | | <el-input v-model="form.remark" placeholder="请输入" clearable type="textarea" :rows="2"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="附件材料·:" prop="remark"> |
| | | <el-upload |
| | | :file-list="fileList" |
| | | action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15" |
| | | multiple |
| | | ref="fileUpload" |
| | | :headers="proxy.uploadHeader" |
| | | :before-upload="handleBeforeUpload" |
| | | :on-error="handleUploadError" |
| | | :on-success="handleUploadSuccess" |
| | | > |
| | | <el-button type="primary">上传</el-button> |
| | | <template #tip> |
| | | <div class="el-upload__tip"> |
| | | 文件格式支持 doc,docx,xls,xlsx,ppt,pptx,pdf,txt,xml,jpg,jpeg,png,gif,bmp,rar,zip,7z |
| | | </div> |
| | | </template> |
| | | </el-upload> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | <el-dialog v-model="productFormVisible" :title="productOperationType === 'add' ? '新增产品' : '编辑产品'" width="40%" @close="closeProductDia"> |
| | | <el-form :model="productForm" label-width="140px" label-position="top" :rules="productRules" ref="productFormRef"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="产品大类:" prop="productCategory"> |
| | | <el-select v-model="productForm.productCategory" placeholder="请选择" clearable> |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="规格型号:" prop="specificationModel"> |
| | | <el-select v-model="productForm.specificationModel" placeholder="请选择" clearable> |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="单位:" prop="unit"> |
| | | <el-input v-model="productForm.unit" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="数量:" prop="quantity"> |
| | | <el-input v-model="productForm.quantity" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="含税单价(元):" prop="taxInclusiveUnitPrice"> |
| | | <el-input v-model="productForm.taxInclusiveUnitPrice" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="税率:" prop="taxRate"> |
| | | <el-select v-model="productForm.taxRate" placeholder="请选择" clearable> |
| | | <el-option label="6%" value="6%"/> |
| | | <el-option label="13%" value="13%"/> |
| | | <el-option label="1%" value="1%"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="含税总价(元):" prop="taxInclusiveTotalPrice"> |
| | | <el-input v-model="productForm.taxInclusiveTotalPrice" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="不含税总价(元):" prop="taxExclusiveTotalPrice"> |
| | | <el-input v-model="productForm.taxExclusiveTotalPrice" placeholder="请输入" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="发票类型:" prop="invoiceType"> |
| | | <el-select v-model="productForm.invoiceType" placeholder="请选择" clearable> |
| | | <el-option label="增普票" value="增普票"/> |
| | | <el-option label="增专票" value="增专票"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitProduct">确认</el-button> |
| | | <el-button @click="closeProductDia">取消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | import pagination from '@/components/PIMTable/Pagination.vue' |
| | | import { ref } from 'vue' |
| | | import {Search} from "@element-plus/icons-vue"; |
| | | import {addCustomer, delCustomer, getCustomer, listCustomer, updateCustomer} from "@/api/basicData/customerFile.js"; |
| | | import {ElMessageBox } from "element-plus"; |
| | | import {userListNoPage} from "@/api/system/user.js"; |
| | | import {ledgerList} from "@/api/salesManagement/salesLedger.js"; |
| | | import { |
| | | ledgerList, |
| | | productList, |
| | | customerList, |
| | | addOrUpdateSalesLedger, |
| | | getSalesLedgerWithProducts, delLedger, addOrUpdateSalesLedgerProduct, delProduct |
| | | } from "@/api/salesManagement/salesLedger.js"; |
| | | const { proxy } = getCurrentInstance() |
| | | const preserveExpanded = ref(false) |
| | | const tableData = ref([]) |
| | | const productData = ref([]) |
| | | const selectedRows = ref([]) |
| | | const productSelectedRows = ref([]) |
| | | const userList = ref([]) |
| | | const customerOption = ref([]) |
| | | const tableLoading = ref(false) |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 10, |
| | | }) |
| | | const total = ref(0) |
| | | const fileList = ref([]) |
| | | const uploadList = ref([]) |
| | | |
| | | // 用户信息表单弹框数据 |
| | | const operationType = ref('') |
| | |
| | | customerName: '', |
| | | }, |
| | | form: { |
| | | customerName: '', |
| | | taxpayerIdentificationNumber: '', |
| | | companyAddress: '', |
| | | companyPhone: '', |
| | | contactPerson: '', |
| | | contactPhone: '', |
| | | maintainer: '', |
| | | salesContractNo: '', |
| | | salesman: '', |
| | | customerContractNo: '', |
| | | customerId: '', |
| | | projectName: '', |
| | | entryPerson: '', |
| | | entryDate: '', |
| | | maintenanceTime: '', |
| | | productData: [] |
| | | }, |
| | | rules: { |
| | | customerName: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | taxpayerIdentificationNumber: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | companyAddress: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | companyPhone: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | contactPerson: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | contactPhone: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | maintainer: [{ required: false, message: "请选择", trigger: "change" }], |
| | | maintenanceTime: [{ required: false, message: "请选择", trigger: "change" }], |
| | | salesman: [{ required: true, message: "请选择", trigger: "change" }], |
| | | customerContractNo: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | customerId: [{ required: true, message: "请选择", trigger: "change" }], |
| | | projectName: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | entryPerson: [{ required: true, message: "请选择", trigger: "change" }], |
| | | entryDate: [{ required: true, message: "请选择", trigger: "change" }], |
| | | } |
| | | }) |
| | | const { searchForm, form, rules } = toRefs(data) |
| | | // 产品表单弹框数据 |
| | | const productFormVisible = ref(false) |
| | | const productOperationType = ref('') |
| | | const currentId = ref('') |
| | | const productFormData = reactive({ |
| | | productForm: { |
| | | productCategory: '', |
| | | specificationModel: '', |
| | | unit: '', |
| | | quantity: '', |
| | | taxInclusiveUnitPrice: '', |
| | | taxRate: '', |
| | | taxInclusiveTotalPrice: '', |
| | | taxExclusiveTotalPrice: '', |
| | | invoiceType: '', |
| | | }, |
| | | productRules: { |
| | | productCategory: [{ required: true, message: "请选择", trigger: "change" }], |
| | | specificationModel: [{ required: true, message: "请选择", trigger: "change" }], |
| | | unit: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | quantity: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | taxInclusiveUnitPrice: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | taxRate: [{ required: true, message: "请选择", trigger: "change" }], |
| | | taxInclusiveTotalPrice: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | taxExclusiveTotalPrice: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | invoiceType: [{ required: true, message: "请选择", trigger: "change" }], |
| | | } |
| | | }) |
| | | const { productForm, productRules } = toRefs(productFormData) |
| | | |
| | | // 查询列表 |
| | | /** 搜索按钮操作 */ |
| | |
| | | ledgerList({...searchForm.value, ...page}).then(res => { |
| | | tableLoading.value = false |
| | | tableData.value = res.rows |
| | | tableData.value.map(item => { |
| | | item.children = [] |
| | | }) |
| | | total.value = res.total |
| | | }) |
| | | } |
| | |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection |
| | | } |
| | | const productSelected = (selectedRows) => { |
| | | productSelectedRows.value = selectedRows |
| | | } |
| | | const expandedRowKeys = ref([]) |
| | | // 展开行 |
| | | const expandChange = (row, expandedRows) => { |
| | | const isExpanded = expandedRows.includes(row.id); |
| | | if (isExpanded) { |
| | | console.log('该行已展开'); |
| | | // 可以在这里进行懒加载或其他操作 |
| | | if (expandedRows.length > 0) { |
| | | expandedRowKeys.value = [] |
| | | try { |
| | | productList({salesLedgerId: row.id}).then(res => { |
| | | const index = tableData.value.findIndex(item => item.id === row.id); |
| | | if (index > -1) { |
| | | tableData.value[index].children = res.rows; |
| | | } |
| | | expandedRowKeys.value.push(row.id) |
| | | }) |
| | | } catch (error) { |
| | | console.log(error) |
| | | } |
| | | } else { |
| | | console.log('该行已收起'); |
| | | expandedRowKeys.value = [] |
| | | } |
| | | } |
| | | // 主表合计方法 |
| | | const summarizeMainTable = (param) => { |
| | | const { columns, data } = param; |
| | | const sums = []; |
| | | columns.forEach((column, index) => { |
| | | if (index === 0) { |
| | | sums[index] = '合计'; |
| | | return; |
| | | } |
| | | const prop = column.property; |
| | | if (['contractAmount'].includes(prop)) { |
| | | const values = data.map(item => Number(item[prop])); |
| | | if (!values.every(value => isNaN(value))) { |
| | | sums[index] = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0); |
| | | } else { |
| | | sums[index] = ''; |
| | | } |
| | | } else { |
| | | sums[index] = ''; |
| | | } |
| | | }) |
| | | return sums; |
| | | }; |
| | | // 子表合计方法 |
| | | const summarizeChildrenTable = (param) => { |
| | | const { columns, data } = param; |
| | | const sums = []; |
| | | columns.forEach((column, index) => { |
| | | if (index === 0) { |
| | | sums[index] = '合计'; |
| | | return; |
| | | } |
| | | const prop = column.property; |
| | | if (['taxInclusiveUnitPrice', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice'].includes(prop)) { |
| | | const values = data.map(item => Number(item[prop])); |
| | | if (!values.every(value => isNaN(value))) { |
| | | sums[index] = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0); |
| | | } else { |
| | | sums[index] = ''; |
| | | } |
| | | } else { |
| | | sums[index] = ''; |
| | | } |
| | | }); |
| | | return sums; |
| | | } |
| | | // 打开弹框 |
| | | const openForm = (type, row) => { |
| | | operationType.value = type |
| | | form.value = {} |
| | | productData.value = [] |
| | | userListNoPage().then(res => { |
| | | userList.value = res.data |
| | | }) |
| | | customerList().then(res => { |
| | | customerOption.value = res |
| | | }) |
| | | if (type === 'edit') { |
| | | getCustomer(row.id).then(res => { |
| | | form.value = {...res.data} |
| | | currentId.value = row.id; |
| | | getSalesLedgerWithProducts({id: row.id}).then(res => { |
| | | form.value = {...res} |
| | | productData.value = form.value.productData |
| | | }) |
| | | } |
| | | dialogFormVisible.value = true |
| | | } |
| | | // 上传前校检 |
| | | function handleBeforeUpload(file) { |
| | | // 校检文件大小 |
| | | if (props.fileSize) { |
| | | if (file.size > 1024 * 1024) { |
| | | proxy.$modal.msgError('上传文件大小不能超过10MB!') |
| | | return false |
| | | } |
| | | } |
| | | proxy.$modal.loading("正在上传文件,请稍候...") |
| | | return true |
| | | } |
| | | // 上传失败 |
| | | function handleUploadError(err) { |
| | | proxy.$modal.msgError("上传文件失败") |
| | | proxy.$modal.closeLoading() |
| | | } |
| | | // 上传成功回调 |
| | | function handleUploadSuccess(res, file) { |
| | | if (res.code === 200) { |
| | | uploadList.value.push({ name: res.fileName, url: res.fileName }) |
| | | fileList.value = fileList.value.filter(f => f.url !== undefined).concat(uploadList.value) |
| | | uploadList.value = [] |
| | | } else { |
| | | proxy.$modal.closeLoading() |
| | | proxy.$modal.msgError(res.msg) |
| | | proxy.$refs.fileUpload.handleRemove(file) |
| | | } |
| | | } |
| | | // 提交表单 |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate(valid => { |
| | | if (valid) { |
| | | if (operationType.value === "edit") { |
| | | submitEdit() |
| | | if (productData.value.length > 0) { |
| | | form.value.productData = proxy.HaveJson(productData.value) |
| | | } else { |
| | | submitAdd() |
| | | proxy.$modal.msgWarning('请添加产品信息') |
| | | return |
| | | } |
| | | addOrUpdateSalesLedger(form.value).then(res => { |
| | | proxy.$modal.msgSuccess("提交成功") |
| | | closeDia() |
| | | getList() |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | // 提交新增 |
| | | const submitAdd = () => { |
| | | addCustomer(form.value).then(res => { |
| | | proxy.$modal.msgSuccess("提交成功") |
| | | closeDia() |
| | | getList() |
| | | }) |
| | | } |
| | | // 提交修改 |
| | | const submitEdit = () => { |
| | | updateCustomer(form.value).then(res => { |
| | | proxy.$modal.msgSuccess("提交成功") |
| | | closeDia() |
| | | getList() |
| | | }) |
| | | } |
| | | // 关闭弹框 |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef") |
| | | dialogFormVisible.value = false |
| | | } |
| | | // 打开产品弹框 |
| | | const openProductForm = (type, row) => { |
| | | productOperationType.value = type |
| | | productForm.value = {} |
| | | proxy.resetForm("productFormRef") |
| | | if (type === 'edit') { |
| | | productForm.value = {...row} |
| | | } |
| | | productFormVisible.value = true |
| | | } |
| | | // 提交产品表单 |
| | | const submitProduct = () => { |
| | | proxy.$refs["productFormRef"].validate(valid => { |
| | | if (valid) { |
| | | if (operationType.value === "edit") { |
| | | submitProductEdit() |
| | | } else { |
| | | productData.value.push({...productForm.value}) |
| | | closeProductDia() |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | const submitProductEdit = () => { |
| | | productForm.value.salesLedgerId = currentId.value |
| | | addOrUpdateSalesLedgerProduct(productForm.value).then(res => { |
| | | proxy.$modal.msgSuccess("提交成功") |
| | | closeProductDia() |
| | | getSalesLedgerWithProducts({id: currentId.value}).then(res => { |
| | | productData.value = res.productData |
| | | }) |
| | | }) |
| | | } |
| | | // 删除产品 |
| | | const deleteProduct = () => { |
| | | if (productSelectedRows.value.length === 0) { |
| | | proxy.$modal.msgWarning('请选择数据') |
| | | return |
| | | } |
| | | if (operationType.value === 'add') { |
| | | productSelectedRows.value.forEach(selectedRow => { |
| | | const index = productData.value.findIndex(product => product.id === selectedRow.id); |
| | | if (index !== -1) { |
| | | productData.value.splice(index, 1); |
| | | } |
| | | }); |
| | | } else { |
| | | let ids = [] |
| | | if (productSelectedRows.value.length > 0) { |
| | | ids = productSelectedRows.value.map(item => item.id); |
| | | } |
| | | ElMessageBox.confirm( |
| | | '选中的内容将被删除,是否确认删除?', |
| | | '导出', { |
| | | confirmButtonText: '确认', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | } |
| | | ).then(() => { |
| | | delProduct(ids).then(res => { |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | closeProductDia() |
| | | getSalesLedgerWithProducts({id: currentId.value}).then(res => { |
| | | productData.value = res.productData |
| | | }) |
| | | }) |
| | | }).catch(() => { |
| | | proxy.$modal.msg("已取消") |
| | | }) |
| | | |
| | | } |
| | | } |
| | | // 关闭产品弹框 |
| | | const closeProductDia = () => { |
| | | proxy.resetForm("productFormRef") |
| | | productFormVisible.value = false |
| | | } |
| | | // 导出 |
| | | const handleOut = () => { |
| | |
| | | type: 'warning', |
| | | } |
| | | ).then(() => { |
| | | proxy.download("/basic/customer/export", {}, '客户档案.xlsx') |
| | | proxy.download("/sales/ledger/export", {}, '销售台账.xlsx') |
| | | }).catch(() => { |
| | | proxy.$modal.msg("已取消") |
| | | }) |
| | |
| | | type: 'warning', |
| | | } |
| | | ).then(() => { |
| | | delCustomer(ids).then(res => { |
| | | delLedger(ids).then(res => { |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | getList() |