莳松crm管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ss-crm-manage-web/src/views/Clue/Order/Comp/MallSettle.vue

446 lines
13 KiB

8 months ago
<template>
<div>
<el-form :model="searchForm" label-width="0" inline>
<el-form-item>
7 months ago
<el-input
v-model="searchForm.signId"
placeholder="成交单号"
clearable
style="width: 120px"
/>
8 months ago
</el-form-item>
<el-form-item>
7 months ago
<el-input v-model="searchForm.name" placeholder="线索名称" clearable style="width: 120px" />
8 months ago
</el-form-item>
<el-form-item>
7 months ago
<el-input
v-model="searchForm.phone"
placeholder="联系方式"
clearable
style="width: 120px"
/>
8 months ago
</el-form-item>
<el-form-item>
7 months ago
<el-select
v-model="searchForm.settlementType"
placeholder="结算类型"
clearable
filterable
style="width: 120px"
>
8 months ago
<el-option label="货款" value="货款" />
<el-option label="其他支出" value="其他支出" />
8 months ago
</el-select>
</el-form-item>
<el-form-item>
7 months ago
<el-select
v-model="searchForm.signUser"
placeholder="登记人"
clearable
filterable
style="width: 120px"
>
8 months ago
<el-option
v-for="item in userOptions"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-date-picker
v-model="searchForm.dealDate"
type="daterange"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
range-separator="-"
8 months ago
start-placeholder="成交日期"
end-placeholder="成交日期"
7 months ago
style="width: 240px"
/>
</el-form-item>
<el-form-item>
<el-date-picker
v-model="searchForm.createDate"
type="daterange"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
range-separator="-"
start-placeholder="支出日期"
end-placeholder="支出日期"
style="width: 240px"
8 months ago
/>
</el-form-item>
<el-form-item>
<el-select
8 months ago
v-model="searchForm.signProduct"
8 months ago
placeholder="选择成交产品"
filterable
clearable
8 months ago
@change="searchForm.signSpecs = undefined"
7 months ago
style="width: 150px"
8 months ago
>
<el-option
v-for="item in prodOptions"
:key="item.productId"
:label="item.productName"
:value="item.productId"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-select
8 months ago
v-model="searchForm.signSpecs"
8 months ago
placeholder="选择规格"
filterable
clearable
8 months ago
:disabled="!searchForm.signProduct"
7 months ago
style="width: 120px"
8 months ago
>
<el-option
8 months ago
v-for="item in specsOptions(searchForm.signProduct)"
8 months ago
:key="item.specsId"
:label="item.specsName"
:value="item.specsId"
/>
</el-select>
</el-form-item>
<el-form-item>
7 months ago
<el-select
v-model="searchForm.supplier"
placeholder="选择供应商"
filterable
clearable
style="width: 120px"
>
8 months ago
<el-option
v-for="item in supplierOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
8 months ago
<el-radio-group v-model="searchForm.settlementState">
8 months ago
<el-radio :label="1"> 已结算 </el-radio>
8 months ago
<el-radio :label="0"> 待结算 </el-radio>
8 months ago
</el-radio-group>
</el-form-item>
<el-form-item>
7 months ago
<el-button @click="handleSearch" v-hasPermi="['clue:order:settle-search']">查询</el-button>
<el-button @click="handleReset" v-hasPermi="['clue:order:settle-reset']">重置</el-button>
<el-button @click="batchSettle" v-hasPermi="['clue:order:settle-batch-audit']">
批量结算
</el-button>
8 months ago
</el-form-item>
</el-form>
<el-table
v-loading="loading"
:data="tableList"
border
show-summary
:summary-method="getSummaries"
@selection-change="handleSelectionChange"
>
8 months ago
<el-table-column
type="selection"
width="60"
fixed="left"
:selectable="(row) => row.settlementState == '待结算'"
/>
8 months ago
<el-table-column prop="signId" label="成交单号" min-width="120px" />
<el-table-column prop="name" label="线索名称" min-width="120px" />
<el-table-column prop="phone" label="联系方式" width="120px" />
<el-table-column prop="signUserName" label="登记人" min-width="90" />
8 months ago
<el-table-column prop="dealDate" label="成交日期" width="120px" :formatter="dateFormatter" />
6 months ago
<el-table-column prop="createTime" label="支出日期" width="140px">
<template #default="{ row, col }">
<el-date-picker
v-if="row.edit"
v-model="row.createTime"
type="date"
size="small"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
style="width: 110px"
:clearable="false"
placeholder="选择日期"
/>
<div v-else>{{ dateFormatter(row, col, row.createTime) }}</div>
</template>
</el-table-column>
8 months ago
<el-table-column prop="signProduct" label="成交产品" min-width="150px" />
<el-table-column prop="signSpecs" label="成交规格" min-width="150px" />
<el-table-column prop="supplier" label="供应商" min-width="150px" />
6 months ago
<el-table-column prop="settlementPrice" label="结算单价" min-width="150px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
v-model="row.settlementPrice"
size="small"
:min="0"
:controls="false"
style="width: 100%"
/>
<div v-else>{{ row.settlementPrice }}</div>
</template>
</el-table-column>
8 months ago
<el-table-column prop="settlementNum" label="结算数量" min-width="150px" />
<el-table-column prop="settlementMoney" label="结算金额" min-width="150px" />
8 months ago
<el-table-column label="费用备注" width="90px">
<template #default="scope">
8 months ago
<el-popover placement="top" width="500px" trigger="click" v-if="scope.row.extraRemark">
8 months ago
<template #reference>
<el-button type="primary" style="padding: 0" text>点击查看</el-button>
</template>
8 months ago
<div v-dompurify-html="scope.row.extraRemark"></div>
8 months ago
</el-popover>
</template>
</el-table-column>
<el-table-column
8 months ago
prop="settlementDate"
8 months ago
label="结算时间"
width="120px"
:formatter="dateFormatter"
/>
8 months ago
<el-table-column prop="settlementUserName" label="结算人" min-width="90px" />
<el-table-column prop="settlementType" label="结算类型" width="90px" fixed="right" />
7 months ago
<el-table-column prop="isCommissioned" label="提成状态" width="90px" fixed="right" />
8 months ago
<el-table-column prop="settlementState" label="结算状态" width="90px" fixed="right" />
8 months ago
<el-table-column label="结算备注" width="90px">
<template #default="scope">
<el-popover placement="top" width="500px" trigger="click" v-if="scope.row.remark">
<template #reference>
<el-button type="primary" style="padding: 0" text>点击查看</el-button>
</template>
<div v-dompurify-html="scope.row.remark"></div>
</el-popover>
</template>
</el-table-column>
6 months ago
<el-table-column label="操作" width="100px" fixed="right">
<template #default="{ row }">
<el-button
v-if="row.settlementState == '待结算'"
type="primary"
text
@click="handleUpdate(row)"
>
{{ row.edit ? '保存' : '修改' }}
</el-button>
</template>
</el-table-column>
8 months ago
</el-table>
<Pagination
v-model:limit="searchForm.pageSize"
v-model:page="searchForm.pageNo"
:total="total"
@pagination="getList"
/>
<el-dialog title="批量结算" v-model="showDailog" width="600px">
<el-form :model="form" ref="formRef" :rules="rules" label-width="80px">
8 months ago
<el-form-item label="结算金额">
{{ settleAmount }}
</el-form-item>
8 months ago
<el-form-item label="结算备注" prop="remark">
<Editor v-model:modelValue="form.remark" />
</el-form-item>
</el-form>
<template #footer>
<span>
<el-button @click="showDailog = false"> </el-button>
<el-button :disabled="formLoading" type="primary" @click="handleSaveSettle">
</el-button>
</span>
</template>
</el-dialog>
</div>
</template>
8 months ago
<script setup name="MallSettle">
8 months ago
import { getSimpleUserList as getUserOption } from '@/api/system/user'
import { getSimpleProductList } from '@/api/mall/product'
import * as SettleApi from '@/api/clue/settle'
import { getDictOptions } from '@/utils/dict'
8 months ago
import { removeNullField } from '@/utils/index'
8 months ago
import { dateFormatter } from '@/utils/formatTime'
const message = useMessage() // 消息弹窗
onMounted(() => {
getOptions()
handleSearch()
})
const searchForm = ref({
name: undefined,
phone: undefined,
signUser: undefined,
dealDate: [],
7 months ago
createDate: [],
8 months ago
signProduct: undefined,
signSpecs: undefined,
8 months ago
signId: undefined,
8 months ago
settlementState: 0,
settlementType: undefined,
8 months ago
supplier: undefined,
pageSize: 20,
pageNo: 1
})
function handleReset() {
searchForm.value = {
name: undefined,
phone: undefined,
signUser: undefined,
dealDate: [],
7 months ago
createDate: [],
8 months ago
signProduct: undefined,
signSpecs: undefined,
8 months ago
signId: undefined,
8 months ago
settlementState: 0,
settlementType: undefined,
8 months ago
supplier: undefined,
pageSize: 20,
pageNo: 1
}
}
function handleSearch() {
searchForm.value.pageNo = 1
getList()
}
const loading = ref(false)
const tableList = ref([])
const total = ref(0)
8 months ago
const totalNum = ref(0)
const totalAmount = ref(0)
8 months ago
async function getList() {
loading.value = true
try {
8 months ago
const data = await SettleApi.getMallSettlePage(removeNullField(searchForm.value))
8 months ago
tableList.value = data.list
total.value = data.total
8 months ago
totalNum.value = data.totalNum
totalAmount.value = data.totalAmount
8 months ago
} finally {
loading.value = false
}
}
function getSummaries(param) {
const { columns } = param
const sums = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计'
8 months ago
} else if (column.property == 'settlementNum') {
8 months ago
sums[index] = totalNum.value
8 months ago
} else if (column.property == 'settlementMoney') {
8 months ago
sums[index] = totalAmount.value
8 months ago
} else {
sums[index] = ''
}
})
return sums
}
6 months ago
async function handleUpdate(row) {
if (row.edit) {
// 删除的二次确认
await message.confirm('是否确认修改结算数据?')
// 保存
SettleApi.updateSettle({
settlementId: row.settlementId,
settlementPrice: row.settlementPrice,
createTime: row.createTime
})
.then(() => {
message.success('修改成功')
getList()
})
.finally(() => {
row.edit = false
})
} else {
row.edit = true
}
}
8 months ago
const selectList = ref([])
8 months ago
function handleSelectionChange(val) {
8 months ago
selectList.value = [...val]
8 months ago
}
const showDailog = ref(false)
const form = ref({})
const formRef = ref()
const formLoading = ref(false)
const rules = {
remark: { required: true, message: '结算备注不可为空', trigger: 'change,blur' }
}
8 months ago
const settleAmount = ref(0)
8 months ago
function batchSettle() {
8 months ago
if (selectList.value.length) {
8 months ago
showDailog.value = true
form.value = {
8 months ago
settlementIds: selectList.value.map((it) => it.settlementId),
8 months ago
reamrk: undefined
}
8 months ago
settleAmount.value = selectList.value.reduce((pre, cur) => pre + cur.settlementMoney, 0)
8 months ago
} else {
message.info('请选择表格数据!')
}
}
async function handleSaveSettle() {
if (!formRef.value) return
8 months ago
const valid = await formRef.value.validate()
8 months ago
if (!valid) return
try {
formLoading.value = true
await SettleApi.batchSaveSettle(form.value)
8 months ago
message.success('结算成功')
8 months ago
showDailog.value = false
getList()
} finally {
formLoading.value = false
}
}
const userOptions = ref([])
const prodOptions = ref([])
const supplierOptions = getDictOptions('erp_supplier')
function getOptions() {
// 产品
getSimpleProductList().then((data) => {
prodOptions.value = data
})
getUserOption().then((data) => {
userOptions.value = data
})
}
const specsOptions = computed({
get() {
return (prodId) => {
if (prodId) {
return prodOptions.value.find((it) => it.productId == prodId).productSpecList
}
return []
}
}
})
</script>
<style lang="scss" scoped></style>