195 lines
6.1 KiB
Vue
195 lines
6.1 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="['price:label:add']">新建打单套餐</el-button>
|
|
</el-col>
|
|
</template>
|
|
|
|
<template #col-setType>
|
|
<el-tag type="warning" size="small" effect="plain">打单 / LABEL</el-tag>
|
|
</template>
|
|
|
|
<template #col-status="{ row }">
|
|
<el-tag :type="statusTag(row)" size="small">{{ statusLabel(row) }}</el-tag>
|
|
</template>
|
|
|
|
<template #col-action="{ row }">
|
|
<el-button link type="primary" @click="handleDetail(row)" v-hasPermi="['price:label:query']">详情</el-button>
|
|
<el-button link type="primary" @click="openBasicEdit(row)" v-hasPermi="['price:label:edit']">修改</el-button>
|
|
<el-button
|
|
v-if="row.status === 'E'"
|
|
link
|
|
type="warning"
|
|
@click="handleDisable(row)"
|
|
v-hasPermi="['price:label:audit']"
|
|
>停用</el-button>
|
|
<el-button
|
|
v-if="row.status === 'D' || row.status === 'S'"
|
|
link
|
|
type="success"
|
|
@click="handleEnable(row)"
|
|
v-hasPermi="['price:label:audit']"
|
|
>启用</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="套餐编码">
|
|
<el-input :model-value="basicForm.priceSetCode" disabled />
|
|
</el-form-item>
|
|
<el-form-item label="套餐名称" prop="priceSetName">
|
|
<el-input v-model="basicForm.priceSetName" maxlength="50" show-word-limit placeholder="请输入套餐名称" />
|
|
</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>
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script setup name="LabelPackage">
|
|
import { setStatusLabel, setStatusTagType } from '@/views/price/set/utils/priceSet'
|
|
import {
|
|
listLabelPackage,
|
|
updateLabelBasic,
|
|
disableLabelPackage,
|
|
enableLabelPackage
|
|
} from '@/api/price/label'
|
|
|
|
const { proxy } = getCurrentInstance()
|
|
const tableRef = ref()
|
|
const isFirstActivate = ref(true)
|
|
|
|
/** 默认只看待启用、生效(排除已停用) */
|
|
const defaultParams = { statuses: ['D', 'E'] }
|
|
|
|
const searchColumns = [
|
|
{
|
|
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: '套餐编码 / 名称', width: '200px' }
|
|
]
|
|
|
|
const columns = [
|
|
{ label: '套餐编码', prop: 'priceSetCode', width: 110 },
|
|
{ label: '套餐名称', prop: 'priceSetName', minWidth: 160 },
|
|
{ label: '类型', prop: 'setType', width: 140 },
|
|
{ label: '说明', prop: 'priceSetNote', minWidth: 140 },
|
|
{ label: '状态', prop: 'status', width: 90 },
|
|
{ label: '操作', prop: 'action', width: 200, showInToolbar: false }
|
|
]
|
|
|
|
function queryList(params) {
|
|
return listLabelPackage(params)
|
|
}
|
|
|
|
function statusLabel(row) {
|
|
return setStatusLabel(row)
|
|
}
|
|
|
|
function statusTag(row) {
|
|
return setStatusTagType(row)
|
|
}
|
|
|
|
function handleCreate() {
|
|
proxy.$router.push({ path: '/customer/labelCreate' })
|
|
}
|
|
|
|
function handleDetail(row) {
|
|
proxy.$router.push({ path: '/customer/labelDetail', 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 = '修改打单套餐基本信息'
|
|
|
|
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
|
|
updateLabelBasic({
|
|
priceSetId: basicForm.priceSetId,
|
|
priceSetName: basicForm.priceSetName,
|
|
priceSetNote: basicForm.priceSetNote
|
|
}).then(() => {
|
|
proxy.$modal.msgSuccess('保存成功')
|
|
basicDialog.visible = false
|
|
tableRef.value?.refresh()
|
|
}).finally(() => {
|
|
basicDialog.saving = false
|
|
})
|
|
})
|
|
}
|
|
|
|
function handleDisable(row) {
|
|
proxy.$modal.confirm(`停用后该打单套餐不再参与计费命中,确认停用【${row.priceSetName}】?`).then(() => {
|
|
return disableLabelPackage(row.priceSetId)
|
|
}).then(() => {
|
|
proxy.$modal.msgSuccess('已停用')
|
|
tableRef.value?.refresh()
|
|
}).catch(() => {})
|
|
}
|
|
|
|
function handleEnable(row) {
|
|
proxy.$modal.confirm(`启用后该打单套餐将重新参与计费命中,确认启用【${row.priceSetName}】?`).then(() => {
|
|
return enableLabelPackage(row.priceSetId)
|
|
}).then(() => {
|
|
proxy.$modal.msgSuccess('已启用')
|
|
tableRef.value?.refresh()
|
|
}).catch(() => {})
|
|
}
|
|
|
|
onActivated(() => {
|
|
if (isFirstActivate.value) {
|
|
isFirstActivate.value = false
|
|
return
|
|
}
|
|
tableRef.value?.reload()
|
|
})
|
|
</script>
|