莳松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/MallOrderList.vue

499 lines
14 KiB

10 months ago
<template>
<div>
<!-- 搜索工作栏 -->
<div>
<el-form
:model="searchForm"
ref="moreSearchRef"
inline
label-width="0"
style="display: inline"
>
<el-form-item style="margin-bottom: 10px">
<el-select
v-model="searchForm.signProduct"
placeholder="选择成交产品"
filterable
10 months ago
clearable
10 months ago
@change="searchForm.specsId = undefined"
>
<el-option
v-for="item in prodOptions"
:key="item.productId"
:label="item.productName"
:value="item.productId"
/>
</el-select>
</el-form-item>
<el-form-item style="margin-bottom: 10px">
<el-select
v-model="searchForm.specsId"
placeholder="选择规格"
filterable
10 months ago
clearable
10 months ago
:disabled="!searchForm.signProduct"
>
<el-option
v-for="item in specsOptions(searchForm.signProduct)"
:key="item.specsId"
:label="item.specsName"
:value="item.specsId"
/>
</el-select>
</el-form-item>
</el-form>
<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>
8 months ago
<el-button
type="primary"
@click="handleBatchUpdateInstall"
8 months ago
v-hasPermi="['clue:order:batch-update-install']"
8 months ago
>
批量修改安装状态
</el-button>
10 months ago
</template>
</Search>
</div>
<!-- 列表 -->
<SSTable
v-if="!loading"
class="mt-10px"
v-model:tableObject="tableObject"
:tableColumns="allSchemas.tableColumns"
8 months ago
rowkey="signId"
:expandRowKeys="expendRows"
10 months ago
@get-list="getTableList"
10 months ago
@get-checked-columns="getCheckedColumns"
8 months ago
@selection-change="handleSelectionChange"
10 months ago
>
6 months ago
<el-table-column type="selection" width="60" fixed="left" />
<el-table-column type="expand" fixed="left">
10 months ago
<template #default="{ row }">
<div class="p-10px flex justify-center">
8 months ago
<VueDraggable
target="tbody"
v-model="row.signProducts"
:animation="150"
@end="onDragEnd"
style="width: 100%"
>
<el-table
:data="row.signProducts"
row-key="id"
stripe
style="width: 80%; margin: 0 auto"
>
6 months ago
<el-table-column prop="productName" label="成交产品" width="120px" />
<el-table-column prop="specsName" label="产品规格" width="120px" />
8 months ago
<el-table-column prop="signNum" label="成交数量" width="90px" />
<el-table-column prop="remark" label="成交备注" width="100px" />
<el-table-column label="生产状态" width="160px">
<template #default="scope">
<el-switch
v-model="scope.row.isProduced"
:active-value="true"
:inactive-value="false"
active-text="已生产"
inactive-text="待生产"
8 months ago
:disabled="!checkPermi(['clue:order:update-produce'])"
8 months ago
size="small"
@change="handleChangeProdoce(scope.row)"
/>
</template>
</el-table-column>
<el-table-column label="发货状态" prop="sendState" width="90px">
<template #default="scope">
<el-tag
:type="scope.row.sendState == '待发货' ? 'danger' : 'success'"
size="small"
>
{{ scope.row.sendState }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="发货备注" width="100px">
<template #default="scope">
<el-popover
placement="top"
width="500px"
trigger="click"
v-if="scope.row.warehouseName && scope.row.sendRemark"
>
<template #reference>
<el-button type="primary" style="padding: 0" text>点击查看</el-button>
</template>
<div v-dompurify-html="scope.row.sendRemark"></div>
</el-popover>
</template>
</el-table-column>
<el-table-column label="操作" width="100px">
<template #default="scope">
<el-button
type="primary"
class="mr-10px"
link
:disabled="scope.row.sendState == '已发货'"
style="padding: 0; margin-left: 0"
v-hasPermi="['clue:order:send']"
@click="handleDelivery(scope.row)"
>
发货
</el-button>
</template>
</el-table-column>
</el-table>
</VueDraggable>
10 months ago
</div>
</template>
</el-table-column>
<el-table-column
10 months ago
v-for="item in showColumns"
10 months ago
:key="item.field"
:prop="item.field"
:label="item.label"
min-width="120px"
10 months ago
>
<template #default="{ row }">
9 months ago
<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>
<el-button type="primary" style="padding: 0" text>点击查看</el-button>
</template>
<div v-dompurify-html="row[item.field]"></div>
</el-popover>
</div>
10 months ago
<span v-else-if="item.form?.component == 'DatePicker'">
{{ formatDate(row[item.field]) }}
</span>
10 months ago
</template>
</el-table-column>
10 months ago
<el-table-column label="操作" width="240px" fixed="right">
<template #default="scope">
<el-button
type="primary"
class="mr-10px"
link
style="padding: 0; margin-left: 0"
v-hasPermi="['clue:order:detail']"
@click="handleDetail(scope.row)"
>
详情
</el-button>
<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"
10 months ago
v-if="scope.row.isPayoff == '未结清'"
10 months ago
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:order:add-fee']"
@click="handleAddFee(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>
</template>
</el-table-column>
</SSTable>
<!-- 详情 -->
<DialogOrder ref="orderDetailDialog" />
<DialogFeeback ref="feedbackDialog" />
<DialogAfterSale ref="afterSaleDialog" />
<DialogExtraFee ref="extraFeeDialog" />
<DialogDelivery ref="deliveryDialog" @success="getTableList" />
</div>
</template>
<script setup name="ClueOrderList">
import { getSimpleFieldList } from '@/api/clue/orderField'
import * as SignApi from '@/api/clue/sign'
9 months ago
import { getSimpleUserList as getUserOption, getAllUserList } from '@/api/system/user'
10 months ago
import { getSimpleProductList } from '@/api/mall/product'
import DialogOrder from './DialogOrder.vue'
import DialogFeeback from './DialogFeeback.vue'
import DialogAfterSale from './DialogAfterSale.vue'
import DialogExtraFee from './DialogExtraPay.vue'
import DialogDelivery from './DialogDelivery.vue'
import { removeNullField } from '@/utils'
10 months ago
import { formatDate } from '@/utils/formatTime'
8 months ago
import { ElMessageBox, ElOption, ElSelect } from 'element-plus'
import { VueDraggable } from 'vue-draggable-plus'
8 months ago
import { checkPermi } from '@/utils/permission'
10 months ago
10 months ago
const userOptions = ref([])
9 months ago
const allUserOptions = ref([])
10 months ago
onMounted(() => {
getOptions()
})
10 months ago
const message = useMessage() // 消息弹窗
const allSchemas = ref({})
const orderDetailDialog = ref()
const searchRef = ref()
const prodOptions = ref([])
const specsOptions = computed({
get() {
return (prodId) => {
if (prodId) {
return prodOptions.value.find((it) => it.productId == prodId).productSpecList
}
return []
}
}
})
const searchForm = ref({
signProduct: undefined
})
const tableObject = ref({
tableList: [],
loading: false,
total: 1,
pageSize: 20,
10 months ago
pageNo: 1
10 months ago
})
function resetQuery() {
searchForm.value = {
signProduct: undefined
}
searchRef.value.reset()
10 months ago
tableObject.value.pageNo = 1
10 months ago
getTableList()
}
// 查询
async function getTableList() {
// 查询
tableObject.value.loading = true
try {
const queryParams = await searchRef.value.getFormModel()
const params = {
...queryParams,
...searchForm.value,
10 months ago
pageNo: tableObject.value.pageNo,
10 months ago
pageSize: tableObject.value.pageSize
}
const data = await SignApi.getSignPage(removeNullField(params))
tableObject.value.tableList = data.list.map((it) => ({ ...it, ...it.diyParams }))
tableObject.value.total = data.total
} finally {
tableObject.value.loading = false
}
}
const loading = ref(true)
async function getCurdSchemas() {
loading.value = true
try {
const data = await getSimpleFieldList()
data.forEach((elem) => {
9 months ago
if (['createUser'].includes(elem.field)) {
10 months ago
elem.search.options = userOptions.value
9 months ago
} else if (['convertPeople', 'receiver'].includes(elem.field)) {
elem.search.options = allUserOptions.value
10 months ago
}
})
allSchemas.value = useCrudSchemas(data).allSchemas
} finally {
loading.value = false
nextTick(() => {
getTableList()
})
}
}
10 months ago
const showColumns = ref([])
// 初始化表格
function getCheckedColumns(list) {
showColumns.value = list && list.length ? list : allSchemas.value.tableColumns
}
10 months ago
// 详情
function handleDetail(row) {
orderDetailDialog.value.open(row.clueId, row.signId)
}
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) {
extraFeeDialog.value.open(row.signId)
}
9 months ago
async function getOptions() {
10 months ago
// 产品
getSimpleProductList().then((data) => {
prodOptions.value = data
})
9 months ago
userOptions.value = await getUserOption()
allUserOptions.value = await getAllUserList()
getCurdSchemas()
10 months ago
}
const deliveryDialog = ref()
function handleDelivery(row) {
10 months ago
deliveryDialog.value.open(row)
10 months ago
}
8 months ago
const batchIds = ref([])
function handleSelectionChange(val) {
batchIds.value = val.map((it) => it.signId)
}
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('请选择表格行')
}
}
async function handleChangeProdoce(row) {
try {
// 修改状态的二次确认
await message.confirm('确认要修改生产状态吗?')
// 发起修改状态
await SignApi.updateProduceStatus({
signId: row.signId,
id: row.id,
isProduced: row.isProduced
})
message.success('修改成功')
// 刷新列表
getTableList()
} catch {
// 取消后,进行恢复按钮
row.isProduced = !row.isProduced
}
}
const expendRows = ref([])
async function onDragEnd(ev) {
try {
expendRows.value = [ev.data.signId]
const list = tableObject.value.tableList.find((it) => it.signId == ev.data.signId).signProducts
await SignApi.updateProduceSort(list.map((it) => it.id))
message.success('修改成功')
// 刷新列表
getTableList()
} catch (error) {
console.log(error)
getTableList()
}
}
10 months ago
</script>
<style lang="scss" scoped></style>