Files
ss-crm-manage-web/src/views/Clue/Order/Comp/MallOrderList.vue

422 lines
12 KiB
Vue
Raw Normal View History

2024-06-20 19:43:07 +08:00
<template>
<div>
<!-- 搜索工作栏 -->
<div>
<Search
v-if="!loading"
ref="searchRef"
:schema="allSchemas.searchSchema"
inlineBlock
labelWidth="0"
>
<template #actionMore>
<el-button @click="getTableList" v-hasPermi="['clue:order:search']"> 搜索 </el-button>
<el-button @click="resetQuery" v-hasPermi="['clue:order:reset']"> 重置 </el-button>
2024-08-12 17:54:34 +08:00
<el-button
type="primary"
@click="handleBatchUpdateInstall"
2024-08-12 18:06:10 +08:00
v-hasPermi="['clue:order:batch-update-install']"
2024-08-12 17:54:34 +08:00
>
批量修改安装状态
</el-button>
2024-06-20 19:43:07 +08:00
</template>
</Search>
</div>
<!-- 列表 -->
<SSTable
v-if="!loading"
class="mt-10px"
v-model:tableObject="tableObject"
2025-08-28 16:43:03 +08:00
:tableColumns="allSchemas.tableColumns.filter((it) => it.paramLevel == 1)"
rowkey="signOrderId"
2024-08-12 17:54:34 +08:00
:expandRowKeys="expendRows"
2025-09-02 18:18:15 +08:00
:showSummary="true"
:summaryMethod="summaryMethod"
2024-06-20 19:43:07 +08:00
@get-list="getTableList"
2024-06-24 23:28:56 +08:00
@get-checked-columns="getCheckedColumns"
2024-08-12 17:54:34 +08:00
@selection-change="handleSelectionChange"
2024-06-20 19:43:07 +08:00
>
2024-10-22 17:07:48 +08:00
<el-table-column type="selection" width="60" fixed="left" />
<el-table-column type="expand" fixed="left">
2024-06-20 19:43:07 +08:00
<template #default="{ row }">
<div class="p-10px flex justify-center">
2025-08-28 18:06:55 +08:00
<el-table :data="row.childrenOrder" row-key="signId" stripe>
<el-table-column
:prop="item.field"
:label="item.label"
v-for="item in allSchemas.tableColumns.filter((it) => it.paramLevel == 2)"
:key="item.id"
width="100px"
>
2025-08-28 16:43:03 +08:00
<template #default="scope">
2025-08-28 18:06:55 +08:00
<el-popover
v-if="item.field == 'remark' || item.form?.component == 'Editor'"
trigger="hover"
placement="top"
>
2025-08-28 16:43:03 +08:00
<div v-dompurify-html="scope.row.remark"></div>
<template #reference>
<el-button type="primary" link>查看</el-button>
</template>
</el-popover>
2025-08-28 18:06:55 +08:00
<div v-else>
<span v-if="item.isCustom">{{ scope.row.diyParams[item.field] }}</span>
<span v-else>{{ scope.row[item.field] }}</span>
</div>
2025-08-28 16:43:03 +08:00
</template>
</el-table-column>
<el-table-column label="操作" width="260px" fixed="right">
2025-08-21 11:04:43 +08:00
<template #default="scope">
2025-08-28 16:43:03 +08:00
<el-button
type="primary"
class="mr-10px"
link
style="padding: 0; margin-left: 0"
@click="openProduct(scope.row)"
>
成交商品
</el-button>
2025-08-21 11:04:43 +08:00
<el-button
type="primary"
class="mr-10px"
link
style="padding: 0; margin-left: 0"
v-hasPermi="['clue:order:after-sale']"
@click="sellAfter(scope.row)"
>
售后
</el-button>
<el-button
type="primary"
class="mr-10px"
link
style="padding: 0; margin-left: 0"
v-hasPermi="['clue:order:return']"
@click="feeBack(scope.row)"
>
回款
</el-button>
<el-button
type="primary"
class="mr-10px"
link
style="padding: 0; margin-left: 0"
v-hasPermi="['clue:pool:enroll']"
@click="cancelDeal(scope.row)"
>
取消登记
</el-button>
2025-09-03 17:35:32 +08:00
<el-button
type="primary"
class="mr-10px"
link
style="padding: 0; margin-left: 0"
v-hasPermi="['clue:order:add-product']"
@click="handleAddProduct(scope.row)"
>
添加产品
</el-button>
2025-08-21 11:04:43 +08:00
</template>
</el-table-column>
</el-table>
2024-06-20 19:43:07 +08:00
</div>
</template>
</el-table-column>
<el-table-column
2024-06-24 23:28:56 +08:00
v-for="item in showColumns"
2024-06-20 19:43:07 +08:00
:key="item.field"
:prop="item.field"
:label="item.label"
min-width="120px"
2024-06-21 16:09:34 +08:00
>
<template #default="{ row }">
2024-08-09 11:47:56 +08:00
<div v-if="item.field == 'remark' || item.form?.component == 'Editor'">
<el-popover placement="top" width="500px" trigger="click" v-if="row[item.field]">
<template #reference>
2025-08-28 18:06:55 +08:00
<el-button type="primary" style="padding: 0" link>点击查看</el-button>
2024-08-09 11:47:56 +08:00
</template>
<div v-dompurify-html="row[item.field]"></div>
</el-popover>
</div>
2024-07-11 15:25:00 +08:00
<span v-else-if="item.form?.component == 'DatePicker'">
{{ formatDate(row[item.field]) }}
</span>
2024-06-21 16:09:34 +08:00
</template>
</el-table-column>
2025-08-21 11:04:43 +08:00
<el-table-column label="操作" width="120px" fixed="right">
2024-06-20 19:43:07 +08:00
<template #default="scope">
<el-button
type="primary"
class="mr-10px"
link
style="padding: 0; margin-left: 0"
v-hasPermi="['clue:order:add-fee']"
@click="handleAddFee(scope.row)"
>
添加支出
</el-button>
</template>
</el-table-column>
</SSTable>
<!-- 详情 -->
<DialogFeeback ref="feedbackDialog" />
<DialogAfterSale ref="afterSaleDialog" />
<DialogExtraFee ref="extraFeeDialog" />
2024-11-01 18:13:44 +08:00
<DialogAddProduct ref="addProductDialog" @success="getTableList" />
2025-08-28 16:43:03 +08:00
<DialogOrderProduct ref="orderProductDialog" />
2024-06-20 19:43:07 +08:00
</div>
</template>
<script setup name="ClueOrderList">
import { getSimpleFieldList } from '@/api/clue/orderField'
import * as SignApi from '@/api/clue/sign'
2025-09-03 17:35:32 +08:00
import { getSimpleProductList } from '@/api/mall/product'
2025-09-17 11:56:09 +08:00
import { getSimpleUserList as getUserOption, getAllUserListWithHire } from '@/api/system/user'
2024-06-20 19:43:07 +08:00
import DialogFeeback from './DialogFeeback.vue'
import DialogAfterSale from './DialogAfterSale.vue'
import DialogExtraFee from './DialogExtraPay.vue'
2024-11-01 18:13:44 +08:00
import DialogAddProduct from './DialogAddProduct.vue'
2025-08-28 16:43:03 +08:00
import DialogOrderProduct from './DialogOrderProduct.vue'
2024-06-20 19:43:07 +08:00
import { removeNullField } from '@/utils'
2024-07-11 15:25:00 +08:00
import { formatDate } from '@/utils/formatTime'
2024-08-12 17:54:34 +08:00
import { ElMessageBox, ElOption, ElSelect } from 'element-plus'
2024-06-20 19:43:07 +08:00
2024-07-05 15:29:18 +08:00
const userOptions = ref([])
2024-07-30 18:55:30 +08:00
const allUserOptions = ref([])
2024-07-05 15:29:18 +08:00
onMounted(() => {
getOptions()
})
2024-06-20 19:43:07 +08:00
const message = useMessage() // 消息弹窗
const allSchemas = ref({})
const searchRef = ref()
const searchForm = ref({
signProduct: undefined
})
const tableObject = ref({
tableList: [],
loading: false,
total: 1,
pageSize: 20,
2025-09-02 18:18:15 +08:00
pageNo: 1,
totalData: {
totalReceivedMoney: 0,
totalSignPrice: 0,
totalPayAmount: 0
}
2024-06-20 19:43:07 +08:00
})
function resetQuery() {
searchForm.value = {
signProduct: undefined
}
searchRef.value.reset()
2024-06-29 20:26:05 +08:00
tableObject.value.pageNo = 1
2024-06-20 19:43:07 +08:00
getTableList()
}
// 查询
async function getTableList() {
// 查询
tableObject.value.loading = true
try {
const queryParams = await searchRef.value.getFormModel()
const params = {
...queryParams,
...searchForm.value,
2024-06-29 20:26:05 +08:00
pageNo: tableObject.value.pageNo,
2025-08-30 17:05:48 +08:00
pageSize: tableObject.value.pageSize,
diyParams: {}
2024-06-20 19:43:07 +08:00
}
2025-08-30 17:05:48 +08:00
searchFieldList.value.map((it) => {
if (params[it.field]) {
params.diyParams[it.field] = params[it.field]
}
})
2024-06-20 19:43:07 +08:00
const data = await SignApi.getSignPage(removeNullField(params))
2025-08-28 18:06:55 +08:00
tableObject.value.tableList = data.list.map((it) => ({ ...it, ...it.orderDiyParams }))
2024-06-20 19:43:07 +08:00
tableObject.value.total = data.total
2025-09-02 18:18:15 +08:00
tableObject.value.totalData = data.totalData
2024-06-20 19:43:07 +08:00
} finally {
tableObject.value.loading = false
}
}
const loading = ref(true)
2025-08-30 17:05:48 +08:00
const searchFieldList = ref([])
2024-06-20 19:43:07 +08:00
async function getCurdSchemas() {
loading.value = true
try {
const data = await getSimpleFieldList()
2025-08-30 17:05:48 +08:00
searchFieldList.value = data.filter((it) => it.isCustom && it.isSearch)
2025-08-28 16:43:03 +08:00
// const mainOrderFields = data.filter((it) => it.paramLevel == 1)
2024-06-20 19:43:07 +08:00
data.forEach((elem) => {
2025-08-29 17:03:58 +08:00
if (elem.isSearch) {
2025-09-17 11:56:09 +08:00
// if (['createUser'].includes(elem.field)) {
// elem.search.options = userOptions.value
// } else
if (['convertPeople', 'receiver', 'createUser'].includes(elem.field)) {
2025-08-29 17:03:58 +08:00
elem.search.options = allUserOptions.value
}
2024-06-20 19:43:07 +08:00
}
})
allSchemas.value = useCrudSchemas(data).allSchemas
2025-08-29 17:03:58 +08:00
} catch (err) {
console.log(err)
2024-06-20 19:43:07 +08:00
} finally {
loading.value = false
nextTick(() => {
getTableList()
})
}
}
2024-06-24 23:28:56 +08:00
const showColumns = ref([])
// 初始化表格
function getCheckedColumns(list) {
2025-08-28 16:43:03 +08:00
showColumns.value =
list && list.length ? list : allSchemas.value.tableColumns.filter((it) => it.paramLevel == 1)
2024-06-24 23:28:56 +08:00
}
2024-06-20 19:43:07 +08:00
const feedbackDialog = ref()
const afterSaleDialog = ref()
// 售后
function sellAfter(row) {
afterSaleDialog.value.open(row.signId)
}
// 回款
function feeBack(row) {
feedbackDialog.value.open(row.signId)
}
// 取消登记
async function cancelDeal(row) {
try {
// 二次确认
await message.confirm('是否确认取消登记该线索?')
// 发起删除
await SignApi.cancelDeal(row.signId)
message.success('取消登记成功!')
// 刷新列表
await getTableList()
} catch (err) {
console.log(err)
}
}
const extraFeeDialog = ref()
function handleAddFee(row) {
2025-08-29 11:14:59 +08:00
extraFeeDialog.value.open(row.signOrderId)
2024-06-20 19:43:07 +08:00
}
2024-07-30 18:55:30 +08:00
async function getOptions() {
userOptions.value = await getUserOption()
2025-09-17 11:56:09 +08:00
allUserOptions.value = await getAllUserListWithHire()
2024-07-30 18:55:30 +08:00
getCurdSchemas()
2025-09-03 17:35:32 +08:00
// 产品
getSimpleProductList().then((data) => {
prodOptions.value = data
})
2024-06-20 19:43:07 +08:00
}
2024-08-12 17:54:34 +08:00
const batchIds = ref([])
function handleSelectionChange(val) {
2025-08-30 17:05:48 +08:00
batchIds.value = val.map((it) => it.signOrderId)
2024-08-12 17:54:34 +08:00
}
const selectedValue = ref(undefined)
const installOptions = [
{ label: '待安装', value: 1 },
{ label: '已安装', value: 2 },
{ label: '无需安装', value: 3 }
]
const select = () =>
h(
ElSelect,
{
modelValue: selectedValue.value,
placeholder: '新状态',
'onUpdate:modelValue': (val) => {
selectedValue.value = val
}
},
() =>
installOptions.map((item) => {
return h(ElOption, { label: item.label, value: item.value })
})
)
function handleBatchUpdateInstall() {
if (batchIds.value.length) {
ElMessageBox({
title: '是否确认修改安装状态?',
message: select,
showCancelButton: true,
confirmButtonText: '确定',
cancelButtonText: '取消'
}).then(async (action) => {
// 处理用户点击确定或取消按钮后的逻辑
if (action == 'confirm') {
try {
// 发起修改状态
await SignApi.updateInstallStatus(batchIds.value, selectedValue.value)
message.success('修改成功')
// 刷新列表
await getTableList()
} catch (err) {
// 取消后,进行恢复按钮
console.log(err)
}
}
})
} else {
message.info('请选择表格行')
}
}
2025-08-28 16:43:03 +08:00
const orderProductDialog = ref()
function openProduct(row) {
2025-08-29 10:55:50 +08:00
orderProductDialog.value.open(row.signId)
2025-08-28 16:43:03 +08:00
}
2025-09-02 18:18:15 +08:00
function summaryMethod({ columns }) {
const sums = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计'
return
}
if (column.property == 'payTotalAmount') {
sums[index] = tableObject.value.totalData?.totalPayAmount || 0
} else if (column.property == 'signTotalPrice') {
sums[index] = tableObject.value.totalData?.totalSignPrice || 0
} else if (column.property == 'receivedMoney') {
sums[index] = tableObject.value.totalData?.totalReceivedMoney || 0
} else {
sums[index] = ''
}
})
return sums
}
2024-08-12 17:54:34 +08:00
2025-08-28 16:43:03 +08:00
const expendRows = ref([])
2025-09-03 17:35:32 +08:00
const addProductDialog = ref()
const prodOptions = ref([])
function handleAddProduct(row) {
addProductDialog.value.open(row.signId, prodOptions.value)
}
2024-06-20 19:43:07 +08:00
</script>
<style lang="scss" scoped></style>