增加一个渠道绑定
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
<template>
|
||||
<set-section-card
|
||||
:title="title"
|
||||
tone="blue"
|
||||
:count="rows.length"
|
||||
:sub="sub"
|
||||
>
|
||||
<template #action>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="Plus"
|
||||
:disabled="!priceSetId"
|
||||
@click="openBind"
|
||||
v-hasPermi="['price:label:edit']"
|
||||
>添加渠道</el-button>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="rows" border empty-text="暂未绑定渠道">
|
||||
<el-table-column label="渠道编码" prop="channelCode" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="渠道名称" prop="channelName" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column label="应收产品" prop="productName" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="100" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="danger" @click="unbind(row)" v-hasPermi="['price:label:edit']">解绑</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-dialog v-model="bindOpen" title="绑定渠道" width="560px" append-to-body @closed="onClosed">
|
||||
<el-form label-width="110px">
|
||||
<el-form-item label="套餐产品" required>
|
||||
<el-select v-model="form.productId" filterable clearable placeholder="选择本套餐内应收产品" style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in productOptions"
|
||||
:key="item.productId"
|
||||
:label="item.productName"
|
||||
:value="item.productId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="渠道" required>
|
||||
<el-select
|
||||
v-model="form.channelIds"
|
||||
multiple
|
||||
filterable
|
||||
clearable
|
||||
collapse-tags
|
||||
collapse-tags-tooltip
|
||||
placeholder="可多选渠道"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in channelOptions"
|
||||
:key="item.id"
|
||||
:label="channelLabel(item)"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<div class="hint">绑定后会写入渠道应收产品,并关联本打单套餐。</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="bindOpen = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="submit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</set-section-card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import SetSectionCard from '../../set/components/detail/SetSectionCard.vue'
|
||||
import { listLabelChannels, bindLabelChannels, unbindLabelChannel, listLabelProducts } from '@/api/price/label'
|
||||
import { listChannelOptions } from '@/api/masterdata/serviceChannel'
|
||||
|
||||
const props = defineProps({
|
||||
priceSetId: { type: [Number, String], default: null }
|
||||
})
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const title = '绑定渠道'
|
||||
const sub = '渠道计费时按应收产品 + 本套餐取价'
|
||||
const loading = ref(false)
|
||||
const rows = ref([])
|
||||
const bindOpen = ref(false)
|
||||
const saving = ref(false)
|
||||
const productOptions = ref([])
|
||||
const channelOptions = ref([])
|
||||
const form = reactive({
|
||||
productId: undefined,
|
||||
channelIds: []
|
||||
})
|
||||
|
||||
function channelLabel(item) {
|
||||
const code = item.channelCode || item.id || ''
|
||||
const name = item.channelName || ''
|
||||
return name ? (code + ' / ' + name) : String(code)
|
||||
}
|
||||
|
||||
async function loadRows() {
|
||||
if (!props.priceSetId) {
|
||||
rows.value = []
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await listLabelChannels(props.priceSetId)
|
||||
rows.value = res.data || []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function openBind() {
|
||||
if (!props.priceSetId) return
|
||||
form.productId = undefined
|
||||
form.channelIds = []
|
||||
const [prodRes, chRes] = await Promise.all([
|
||||
listLabelProducts(props.priceSetId),
|
||||
listChannelOptions({ blOpen: '1' })
|
||||
])
|
||||
productOptions.value = prodRes.data || []
|
||||
channelOptions.value = chRes.data || []
|
||||
if (!productOptions.value.length) {
|
||||
proxy.$modal.msgWarning('请先导入套餐产品价卡')
|
||||
return
|
||||
}
|
||||
bindOpen.value = true
|
||||
}
|
||||
|
||||
function onClosed() {
|
||||
form.productId = undefined
|
||||
form.channelIds = []
|
||||
saving.value = false
|
||||
}
|
||||
|
||||
function submit() {
|
||||
if (!form.productId) {
|
||||
proxy.$modal.msgWarning('请选择套餐内应收产品')
|
||||
return
|
||||
}
|
||||
if (!form.channelIds.length) {
|
||||
proxy.$modal.msgWarning('请选择渠道')
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
bindLabelChannels(props.priceSetId, {
|
||||
productId: form.productId,
|
||||
channelIds: form.channelIds
|
||||
}).then(res => {
|
||||
proxy.$modal.msgSuccess(res.msg || res.data || '绑定成功')
|
||||
bindOpen.value = false
|
||||
loadRows()
|
||||
}).finally(() => {
|
||||
saving.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function unbind(row) {
|
||||
if (!row?.channelId) return
|
||||
const name = row.channelName || row.channelCode || row.channelId
|
||||
proxy.$modal.confirm('确认解绑渠道「' + name + '」?').then(() => {
|
||||
return unbindLabelChannel(props.priceSetId, row.channelId)
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已解绑')
|
||||
loadRows()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
watch(() => props.priceSetId, () => loadRows(), { immediate: true })
|
||||
|
||||
defineExpose({ reload: loadRows })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.hint {
|
||||
margin: -4px 0 0 110px;
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
@@ -95,11 +95,19 @@ const filteredRows = computed(() => {
|
||||
})
|
||||
})
|
||||
|
||||
function formatHour(val) {
|
||||
if (!val) return ''
|
||||
const text = String(val).replace('T', ' ')
|
||||
if (text.length >= 16) return text.slice(0, 13) + ':00'
|
||||
if (text.length >= 10) return text.slice(0, 10) + ' 00:00'
|
||||
return text
|
||||
}
|
||||
|
||||
function termText(row) {
|
||||
const start = row.termStart || row.effectiveDate || ''
|
||||
const end = row.termEnd || '不限'
|
||||
const start = formatHour(row.termStart || row.effectiveDate || '')
|
||||
const end = row.termEnd ? formatHour(row.termEnd) : '不限'
|
||||
if (!start) return '未设置'
|
||||
return `${String(start).slice(0, 10)} ~ ${String(end).slice(0, 10)}`
|
||||
return start + ' ~ ' + end
|
||||
}
|
||||
|
||||
function termStatusText(status) {
|
||||
|
||||
@@ -28,15 +28,15 @@
|
||||
<el-table-column label="版本号" width="100" align="center">
|
||||
<template #default="{ row }">{{ row.versionLabel || ('V' + (row.versionNo || 1)) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="生效时间" min-width="160" align="center">
|
||||
<el-table-column label="生效时间" min-width="170" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="$emit('open-details', row)">
|
||||
{{ formatDay(row.effectiveTime) || '未设置' }}
|
||||
{{ formatHour(row.effectiveTime) || '未设置' }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="失效时间" min-width="160" align="center">
|
||||
<template #default="{ row }">{{ formatDay(row.expireTime) || '-' }}</template>
|
||||
<el-table-column label="失效时间" min-width="170" align="center">
|
||||
<template #default="{ row }">{{ formatHour(row.expireTime) || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
@@ -49,7 +49,7 @@
|
||||
<el-table-column label="创建时间" min-width="170" align="center">
|
||||
<template #default="{ row }">{{ row.createTime || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="280" align="center" fixed="right">
|
||||
<el-table-column label="操作" width="340" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="$emit('open-details', row)">查看详情</el-button>
|
||||
<el-button
|
||||
@@ -66,6 +66,13 @@
|
||||
@click="$emit('reschedule', row)"
|
||||
v-hasPermi="['price:label:edit']"
|
||||
>修改生效时间</el-button>
|
||||
<el-button
|
||||
v-if="canDelete(row)"
|
||||
link
|
||||
type="danger"
|
||||
@click="$emit('remove', row)"
|
||||
v-hasPermi="['price:label:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -76,7 +83,7 @@
|
||||
const props = defineProps({
|
||||
versions: { type: Array, default: () => [] }
|
||||
})
|
||||
defineEmits(['edit', 'reschedule', 'open-details', 'create-version'])
|
||||
defineEmits(['edit', 'reschedule', 'remove', 'open-details', 'create-version'])
|
||||
|
||||
const statusTab = ref('all')
|
||||
|
||||
@@ -103,9 +110,12 @@ const filteredVersions = computed(() => {
|
||||
return list.filter(v => String(v.status) === statusTab.value)
|
||||
})
|
||||
|
||||
function formatDay(val) {
|
||||
function formatHour(val) {
|
||||
if (!val) return ''
|
||||
return String(val).slice(0, 10)
|
||||
const text = String(val).replace('T', ' ')
|
||||
if (text.length >= 16) return text.slice(0, 13) + ':00'
|
||||
if (text.length >= 10) return text.slice(0, 10) + ' 00:00'
|
||||
return text
|
||||
}
|
||||
|
||||
function statusText(status) {
|
||||
@@ -118,13 +128,19 @@ function statusTag(status) {
|
||||
return map[String(status)] || 'info'
|
||||
}
|
||||
|
||||
/** 待生效:可编辑价卡 */
|
||||
/** 待生效、已生效:可编辑价卡 */
|
||||
function canEdit(row) {
|
||||
const s = row ? String(row.status) : ''
|
||||
return s === '0' || s === '1'
|
||||
}
|
||||
|
||||
/** 仅待生效可改生效时间 */
|
||||
function canReschedule(row) {
|
||||
return row && String(row.status) === '0'
|
||||
}
|
||||
|
||||
/** 仅待生效可改生效时间;已生效不可改 */
|
||||
function canReschedule(row) {
|
||||
/** 仅待生效可删除整版 */
|
||||
function canDelete(row) {
|
||||
return row && String(row.status) === '0'
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user