299 lines
9.2 KiB
Vue
299 lines
9.2 KiB
Vue
<template>
|
|
<div class="app-container">
|
|
<basic-table
|
|
ref="tableRef"
|
|
:columns="columns"
|
|
:search-columns="searchColumns"
|
|
:query="queryList"
|
|
:default-params="defaultParams"
|
|
row-key="priceSetId"
|
|
>
|
|
<template #toolbar>
|
|
<el-col :span="1.5">
|
|
<el-button
|
|
type="primary"
|
|
plain
|
|
icon="Plus"
|
|
@click="handleCreate"
|
|
v-hasPermi="addPerm"
|
|
>{{ mod.labels.createButton }}</el-button>
|
|
</el-col>
|
|
</template>
|
|
|
|
<template #search-customerId="{ model }">
|
|
<customer-select
|
|
v-model="model.customerId"
|
|
option-select
|
|
remote-search
|
|
:page-size="20"
|
|
placeholder="客户名称 / 代码"
|
|
style="width: 240px"
|
|
/>
|
|
</template>
|
|
|
|
<template #col-setType="{ row }">
|
|
<el-tag :type="row.setType === 'FIXED' ? 'warning' : 'primary'" size="small" effect="plain">
|
|
{{ row.setType === 'FIXED' ? 'FIXED 固定价' : 'DISCOUNT 折扣' }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<template #col-status="{ row }">
|
|
<el-tag :type="statusTag(row)" size="small">{{ statusLabel(row) }}</el-tag>
|
|
</template>
|
|
|
|
<template #col-boundCustomers="{ row }">
|
|
<span v-if="row.boundCustomers">{{ row.boundCustomers }}</span>
|
|
<span v-else class="text-muted">-</span>
|
|
<el-tag v-if="row.customerCount > 0" size="small" type="info" effect="plain" class="cust-count">{{ row.customerCount }}</el-tag>
|
|
</template>
|
|
|
|
<template #col-activeDetail="{ row }">
|
|
<el-button
|
|
link
|
|
type="primary"
|
|
:loading="activeLoadingId === row.priceSetId"
|
|
@click="handleActiveDetail(row)"
|
|
v-hasPermi="queryPerm"
|
|
>查看明细</el-button>
|
|
</template>
|
|
|
|
<template #col-action="{ row }">
|
|
<el-button link type="primary" @click="handleDetail(row)" v-hasPermi="queryPerm">详情</el-button>
|
|
<el-button link type="primary" @click="openBasicEdit(row)" v-hasPermi="editPerm">修改</el-button>
|
|
<el-button
|
|
v-if="row.status === 'E'"
|
|
link
|
|
type="warning"
|
|
@click="handleDisable(row)"
|
|
v-hasPermi="auditPerm"
|
|
>停用</el-button>
|
|
<el-button
|
|
v-if="row.status === 'D' || row.status === 'S'"
|
|
link
|
|
type="success"
|
|
@click="handleEnable(row)"
|
|
v-hasPermi="auditPerm"
|
|
>启用</el-button>
|
|
</template>
|
|
</basic-table>
|
|
|
|
<el-dialog v-model="basicDialog.visible" :title="basicDialogTitle" width="520px" append-to-body destroy-on-close>
|
|
<el-form ref="basicFormRef" :model="basicForm" :rules="basicRules" label-width="96px">
|
|
<el-form-item :label="mod.labels.entityCode">
|
|
<el-input :model-value="basicForm.priceSetCode" disabled />
|
|
</el-form-item>
|
|
<el-form-item :label="mod.labels.entityName" prop="priceSetName">
|
|
<el-input v-model="basicForm.priceSetName" maxlength="50" show-word-limit :placeholder="'请输入' + mod.labels.entityName" />
|
|
</el-form-item>
|
|
<el-form-item label="说明备注" prop="priceSetNote">
|
|
<el-input v-model="basicForm.priceSetNote" type="textarea" :rows="3" maxlength="200" show-word-limit placeholder="可选" />
|
|
</el-form-item>
|
|
</el-form>
|
|
<template #footer>
|
|
<el-button @click="basicDialog.visible = false">取消</el-button>
|
|
<el-button type="primary" :loading="basicDialog.saving" @click="submitBasicEdit">确定</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
|
|
<set-version-detail-drawer
|
|
v-model="drawerVisible"
|
|
:version="activeVersion"
|
|
:set-type="drawerSetType"
|
|
/>
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script setup name="PriceSet">
|
|
import SetVersionDetailDrawer from './components/detail/SetVersionDetailDrawer.vue'
|
|
import CustomerSelect from '@/components/CustomerSelect/index.vue'
|
|
import { setStatusLabel, setStatusTagType } from './utils/priceSet'
|
|
import { usePriceSetModule, usePriceSetPerm } from './composables/usePriceSetModule'
|
|
|
|
const { proxy } = getCurrentInstance()
|
|
const mod = usePriceSetModule()
|
|
const addPerm = usePriceSetPerm('add')
|
|
const queryPerm = usePriceSetPerm('query')
|
|
const editPerm = usePriceSetPerm('edit')
|
|
const auditPerm = usePriceSetPerm('audit')
|
|
const tableRef = ref()
|
|
const isFirstActivate = ref(true)
|
|
/** 默认只看待启用、生效(排除已停用) */
|
|
const defaultParams = { statuses: ['D', 'E'] }
|
|
|
|
const searchColumns = computed(() => [
|
|
{
|
|
label: '状态',
|
|
prop: 'statuses',
|
|
component: 'select',
|
|
options: [
|
|
{ label: '待启用', value: 'D' },
|
|
{ label: '生效', value: 'E' },
|
|
{ label: '已停用', value: 'S' }
|
|
],
|
|
props: { multiple: true, collapseTags: true, clearable: true },
|
|
placeholder: '全部状态',
|
|
width: '200px'
|
|
},
|
|
{ label: '关键字', prop: 'keyword', component: 'input', placeholder: mod.labels.keywordPlaceholder, width: '200px' },
|
|
{ label: '客户', prop: 'customerId', placeholder: '客户名称 / 代码', width: '240px' }
|
|
])
|
|
|
|
const columns = computed(() => [
|
|
{ label: mod.labels.entityCode, prop: 'priceSetCode', width: 110 },
|
|
{ label: mod.labels.entityName, prop: 'priceSetName', minWidth: 160 },
|
|
{ label: '类型', prop: 'setType', width: 140 },
|
|
{ label: '绑定客户', prop: 'boundCustomers', minWidth: 220 },
|
|
{ label: '说明', prop: 'priceSetNote', minWidth: 140 },
|
|
{ label: '状态', prop: 'status', width: 90 },
|
|
{ label: '生效明细', prop: 'activeDetail', width: 100 },
|
|
{ label: '操作', prop: 'action', width: 200, showInToolbar: false }
|
|
])
|
|
|
|
function queryList(params) {
|
|
return mod.api.listPriceSet(params)
|
|
}
|
|
|
|
function statusLabel(row) {
|
|
return setStatusLabel(row)
|
|
}
|
|
|
|
function statusTag(row) {
|
|
return setStatusTagType(row)
|
|
}
|
|
|
|
function handleCreate() {
|
|
proxy.$router.push({ path: mod.routes.create })
|
|
}
|
|
|
|
function handleDetail(row) {
|
|
proxy.$router.push({ path: mod.routes.detail, query: { priceSetId: row.priceSetId } })
|
|
}
|
|
|
|
|
|
const basicDialog = reactive({ visible: false, saving: false })
|
|
const basicFormRef = ref()
|
|
const basicForm = reactive({
|
|
priceSetId: null,
|
|
priceSetCode: '',
|
|
priceSetName: '',
|
|
priceSetNote: ''
|
|
})
|
|
const basicRules = {
|
|
priceSetName: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
|
|
}
|
|
const basicDialogTitle = computed(() => mod.labels.basicEditTitle)
|
|
|
|
function openBasicEdit(row) {
|
|
if (!row || row.priceSetId == null) return
|
|
basicForm.priceSetId = row.priceSetId
|
|
basicForm.priceSetCode = row.priceSetCode || ''
|
|
basicForm.priceSetName = row.priceSetName || ''
|
|
basicForm.priceSetNote = row.priceSetNote || ''
|
|
basicDialog.visible = true
|
|
nextTick(() => basicFormRef.value && basicFormRef.value.clearValidate())
|
|
}
|
|
|
|
function submitBasicEdit() {
|
|
basicFormRef.value.validate(valid => {
|
|
if (!valid) return
|
|
basicDialog.saving = true
|
|
mod.api.updatePriceSetBasic({
|
|
priceSetId: basicForm.priceSetId,
|
|
priceSetName: basicForm.priceSetName,
|
|
priceSetNote: basicForm.priceSetNote
|
|
}).then(() => {
|
|
proxy.$modal.msgSuccess('保存成功')
|
|
basicDialog.visible = false
|
|
refresh()
|
|
}).finally(() => {
|
|
basicDialog.saving = false
|
|
})
|
|
})
|
|
}
|
|
|
|
|
|
/** 生效明细:拉详情找生效版本(status=1)弹抽屉 */
|
|
const drawerVisible = ref(false)
|
|
const activeVersion = ref(null)
|
|
const drawerSetType = ref('FIXED')
|
|
const activeLoadingId = ref(null)
|
|
|
|
function handleActiveDetail(row) {
|
|
activeLoadingId.value = row.priceSetId
|
|
mod.api.getPriceSet(row.priceSetId).then(res => {
|
|
const data = res.data || {}
|
|
const versions = data.versions || []
|
|
const active = versions.find(v => String(v.status) === '1')
|
|
if (!active || active.psvId == null) {
|
|
proxy.$modal.msgWarning(mod.labels.noActiveVersion)
|
|
return
|
|
}
|
|
drawerSetType.value = row.setType
|
|
activeVersion.value = { psvId: active.psvId, versionNo: active.versionNo }
|
|
drawerVisible.value = true
|
|
}).finally(() => {
|
|
activeLoadingId.value = null
|
|
})
|
|
}
|
|
|
|
|
|
function refresh() {
|
|
tableRef.value?.refresh()
|
|
}
|
|
|
|
onActivated(() => {
|
|
if (isFirstActivate.value) {
|
|
isFirstActivate.value = false
|
|
return
|
|
}
|
|
tableRef.value?.reload()
|
|
})
|
|
|
|
|
|
function handleDisable(row) {
|
|
proxy.$modal.confirm(mod.labels.disableConfirm.replace('{name}', row.priceSetName)).then(() => {
|
|
return mod.api.disablePriceSet(row.priceSetId)
|
|
}).then(() => {
|
|
proxy.$modal.msgSuccess('已停用')
|
|
refresh()
|
|
}).catch(() => {})
|
|
}
|
|
|
|
function handleEnable(row) {
|
|
proxy.$modal.confirm(mod.labels.enableConfirm.replace('{name}', row.priceSetName)).then(() => {
|
|
return mod.api.enablePriceSet(row.priceSetId)
|
|
}).then(() => {
|
|
proxy.$modal.msgSuccess('已启用')
|
|
tableRef.value.refresh()
|
|
}).catch(() => {})
|
|
}
|
|
|
|
function handleCopy(row) {
|
|
mod.api.copyPriceSet(row.priceSetId).then(res => {
|
|
proxy.$modal.msgSuccess('已复制为草稿')
|
|
proxy.$router.push({ path: mod.routes.create, query: { priceSetId: res.data } })
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.text-muted { color: #909399; }
|
|
.cust-count { margin-left: 6px; vertical-align: middle; }
|
|
.hint-card {
|
|
margin-top: 16px;
|
|
}
|
|
.hint-body {
|
|
font-size: 13px;
|
|
color: #595959;
|
|
line-height: 1.7;
|
|
padding: 8px 12px;
|
|
background: #f6ffed;
|
|
border: 1px solid #b7eb8f;
|
|
border-radius: 6px;
|
|
}
|
|
.hint-body b {
|
|
color: #ff4d4f;
|
|
}
|
|
</style>
|