|
@@ -86,6 +86,7 @@ const priceList = ref([])
|
|
|
const pathSites = ref([]) // Store sites for current path
|
|
const pathSites = ref([]) // Store sites for current path
|
|
|
const isEditPrice = ref(false)
|
|
const isEditPrice = ref(false)
|
|
|
const currentPriceId = ref('')
|
|
const currentPriceId = ref('')
|
|
|
|
|
+const isMatrixEdit = ref(false)
|
|
|
const priceForm = reactive({
|
|
const priceForm = reactive({
|
|
|
pathId: '',
|
|
pathId: '',
|
|
|
fromSiteId: '', // Changed from 'startSiteId'
|
|
fromSiteId: '', // Changed from 'startSiteId'
|
|
@@ -98,7 +99,13 @@ const priceForm = reactive({
|
|
|
const matrixDialogVisible = ref(false)
|
|
const matrixDialogVisible = ref(false)
|
|
|
const matrixSites = ref([])
|
|
const matrixSites = ref([])
|
|
|
const matrixPrices = ref({})
|
|
const matrixPrices = ref({})
|
|
|
-const matrixCargoPrices = ref({}) // 带货价格矩阵
|
|
|
|
|
|
|
+const matrixCargoPrices = ref({})
|
|
|
|
|
+const editingPanelVisible = ref(false)
|
|
|
|
|
+const editingFromId = ref('')
|
|
|
|
|
+const editingToId = ref('')
|
|
|
|
|
+const editingPrice = ref(0)
|
|
|
|
|
+const editingCargoPrice = ref(0)
|
|
|
|
|
+const editingPriceId = ref('')
|
|
|
|
|
|
|
|
const downExcell = () => {
|
|
const downExcell = () => {
|
|
|
excellloading.value = true
|
|
excellloading.value = true
|
|
@@ -305,6 +312,11 @@ const openPriceDialog = (row) => {
|
|
|
currentPathId.value = row.id
|
|
currentPathId.value = row.id
|
|
|
priceForm.pathId = row.id
|
|
priceForm.pathId = row.id
|
|
|
loadPrices()
|
|
loadPrices()
|
|
|
|
|
+ isMatrixEdit.value = false
|
|
|
|
|
+ isEditPrice.value = false
|
|
|
|
|
+ currentPriceId.value = ''
|
|
|
|
|
+ priceForm.price = 0
|
|
|
|
|
+ priceForm.cargoPrice = 0
|
|
|
|
|
|
|
|
// Fetch sites for this path
|
|
// Fetch sites for this path
|
|
|
apisystemdzbcPathSiteByPathId({ pathId: row.id }).then(res => {
|
|
apisystemdzbcPathSiteByPathId({ pathId: row.id }).then(res => {
|
|
@@ -397,6 +409,7 @@ const openMatrixDialog = async (row) => {
|
|
|
matrixSites.value = []
|
|
matrixSites.value = []
|
|
|
matrixPrices.value = {}
|
|
matrixPrices.value = {}
|
|
|
matrixCargoPrices.value = {}
|
|
matrixCargoPrices.value = {}
|
|
|
|
|
+ editingPanelVisible.value = false
|
|
|
|
|
|
|
|
// 1. Fetch sites
|
|
// 1. Fetch sites
|
|
|
const siteRes = await apisystemdzbcPathSiteByPathId({ pathId: row.id })
|
|
const siteRes = await apisystemdzbcPathSiteByPathId({ pathId: row.id })
|
|
@@ -423,7 +436,6 @@ const openMatrixDialog = async (row) => {
|
|
|
const key = `${p.fromSiteId}-${p.toSiteId}`;
|
|
const key = `${p.fromSiteId}-${p.toSiteId}`;
|
|
|
matrixPrices.value[key] = p.price;
|
|
matrixPrices.value[key] = p.price;
|
|
|
|
|
|
|
|
- // 解析带货价格
|
|
|
|
|
if(p.ext2){
|
|
if(p.ext2){
|
|
|
try {
|
|
try {
|
|
|
const ext2 = JSON.parse(p.ext2);
|
|
const ext2 = JSON.parse(p.ext2);
|
|
@@ -446,29 +458,75 @@ const openMatrixDialog = async (row) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const openEditFromMatrix = (fromId, toId) => {
|
|
const openEditFromMatrix = (fromId, toId) => {
|
|
|
- priceForm.pathId = currentPathId.value
|
|
|
|
|
- priceForm.fromSiteId = fromId
|
|
|
|
|
- priceForm.toSiteId = toId
|
|
|
|
|
- pathSites.value = matrixSites.value.map(s => ({ id: s.id, name: s.name }))
|
|
|
|
|
|
|
+ editingPanelVisible.value = true
|
|
|
|
|
+ editingFromId.value = fromId
|
|
|
|
|
+ editingToId.value = toId
|
|
|
const existing = priceList.value.find(p => p.fromSiteId === fromId && p.toSiteId === toId)
|
|
const existing = priceList.value.find(p => p.fromSiteId === fromId && p.toSiteId === toId)
|
|
|
if (existing) {
|
|
if (existing) {
|
|
|
- isEditPrice.value = true
|
|
|
|
|
- currentPriceId.value = existing.id
|
|
|
|
|
- priceForm.price = (existing.price || 0) / 100
|
|
|
|
|
|
|
+ editingPriceId.value = existing.id
|
|
|
|
|
+ editingPrice.value = (existing.price || 0) / 100
|
|
|
try {
|
|
try {
|
|
|
const ext2 = existing.ext2 ? JSON.parse(existing.ext2) : {}
|
|
const ext2 = existing.ext2 ? JSON.parse(existing.ext2) : {}
|
|
|
- priceForm.cargoPrice = ext2.cargoPrice ? ext2.cargoPrice / 100 : 0
|
|
|
|
|
|
|
+ editingCargoPrice.value = ext2.cargoPrice ? ext2.cargoPrice / 100 : 0
|
|
|
} catch {
|
|
} catch {
|
|
|
- priceForm.cargoPrice = 0
|
|
|
|
|
|
|
+ editingCargoPrice.value = 0
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- isEditPrice.value = false
|
|
|
|
|
- currentPriceId.value = ''
|
|
|
|
|
- priceForm.price = 0
|
|
|
|
|
- priceForm.cargoPrice = 0
|
|
|
|
|
|
|
+ editingPriceId.value = ''
|
|
|
|
|
+ editingPrice.value = 0
|
|
|
|
|
+ editingCargoPrice.value = 0
|
|
|
}
|
|
}
|
|
|
- matrixDialogVisible.value = false
|
|
|
|
|
- priceDialogVisible.value = true
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const saveMatrixEdit = async () => {
|
|
|
|
|
+ const ext2 = {}
|
|
|
|
|
+ if (editingCargoPrice.value && editingCargoPrice.value > 0) {
|
|
|
|
|
+ // @ts-ignore
|
|
|
|
|
+ ext2['cargoPrice'] = editingCargoPrice.value * 100
|
|
|
|
|
+ }
|
|
|
|
|
+ if (editingPriceId.value) {
|
|
|
|
|
+ await apisystemdzbcSitePriceUpdate({
|
|
|
|
|
+ id: editingPriceId.value,
|
|
|
|
|
+ pathId: currentPathId.value,
|
|
|
|
|
+ fromSiteId: editingFromId.value,
|
|
|
|
|
+ toSiteId: editingToId.value,
|
|
|
|
|
+ price: editingPrice.value * 100,
|
|
|
|
|
+ ext2: JSON.stringify(ext2)
|
|
|
|
|
+ })
|
|
|
|
|
+ ElMessage.success('修改成功')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ await apisystemdzbcSitePriceAdd({
|
|
|
|
|
+ pathId: currentPathId.value,
|
|
|
|
|
+ fromSiteId: editingFromId.value,
|
|
|
|
|
+ toSiteId: editingToId.value,
|
|
|
|
|
+ price: editingPrice.value * 100,
|
|
|
|
|
+ ext2: JSON.stringify(ext2)
|
|
|
|
|
+ })
|
|
|
|
|
+ ElMessage.success('添加成功')
|
|
|
|
|
+ }
|
|
|
|
|
+ const priceRes = await apisystemdzbcSitePriceByPathId({ pathId: currentPathId.value })
|
|
|
|
|
+ if (priceRes.code === 200) {
|
|
|
|
|
+ priceList.value = priceRes.data
|
|
|
|
|
+ matrixPrices.value = {}
|
|
|
|
|
+ matrixCargoPrices.value = {}
|
|
|
|
|
+ priceRes.data.forEach(p => {
|
|
|
|
|
+ const key = `${p.fromSiteId}-${p.toSiteId}`
|
|
|
|
|
+ matrixPrices.value[key] = p.price
|
|
|
|
|
+ if (p.ext2) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const ext2p = JSON.parse(p.ext2)
|
|
|
|
|
+ if (ext2p.cargoPrice) {
|
|
|
|
|
+ matrixCargoPrices.value[key] = ext2p.cargoPrice
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) { void 0 }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ editingPanelVisible.value = false
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const cancelMatrixEdit = () => {
|
|
|
|
|
+ editingPanelVisible.value = false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const getMatrixPrice = (fromId, toId) => {
|
|
const getMatrixPrice = (fromId, toId) => {
|
|
@@ -620,40 +678,55 @@ onMounted(() => {
|
|
|
|
|
|
|
|
<!-- Price Management Dialog -->
|
|
<!-- Price Management Dialog -->
|
|
|
<el-dialog v-model="priceDialogVisible" title="价格管理" width="800px">
|
|
<el-dialog v-model="priceDialogVisible" title="价格管理" width="800px">
|
|
|
- <div class="add-section" style="margin-bottom: 20px; display: flex; gap: 10px; align-items: center;">
|
|
|
|
|
- <el-select
|
|
|
|
|
- v-model="priceForm.fromSiteId"
|
|
|
|
|
- filterable
|
|
|
|
|
- placeholder="起始站点"
|
|
|
|
|
- style="width: 200px"
|
|
|
|
|
- >
|
|
|
|
|
- <el-option
|
|
|
|
|
- v-for="item in pathSites"
|
|
|
|
|
- :key="item.id"
|
|
|
|
|
- :label="item.name"
|
|
|
|
|
- :value="item.id"
|
|
|
|
|
- />
|
|
|
|
|
- </el-select>
|
|
|
|
|
- <span>至</span>
|
|
|
|
|
- <el-select
|
|
|
|
|
- v-model="priceForm.toSiteId"
|
|
|
|
|
- filterable
|
|
|
|
|
- placeholder="结束站点"
|
|
|
|
|
- style="width: 200px"
|
|
|
|
|
- >
|
|
|
|
|
- <el-option
|
|
|
|
|
- v-for="item in pathSites"
|
|
|
|
|
- :key="item.id"
|
|
|
|
|
- :label="item.name"
|
|
|
|
|
- :value="item.id"
|
|
|
|
|
- />
|
|
|
|
|
- </el-select>
|
|
|
|
|
- <el-input v-model="priceForm.price" placeholder="客运价格(元)" type="number" style="width: 120px" />
|
|
|
|
|
- <el-input v-model="priceForm.cargoPrice" placeholder="带货价格(元)" type="number" style="width: 120px" />
|
|
|
|
|
|
|
+ <div class="add-section" style="margin-bottom: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;">
|
|
|
|
|
+ <template v-if="isMatrixEdit">
|
|
|
|
|
+ <div style="display:flex; align-items:center; gap:6px;">
|
|
|
|
|
+ <span style="color:#6B7280;">起点</span>
|
|
|
|
|
+ <div style="background:#eef2ff;color:#4f46e5;padding:4px 8px;border-radius:6px;">
|
|
|
|
|
+ {{ getSiteName(priceForm.fromSiteId) }}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <span style="margin:0 6px;color:#6B7280;">至</span>
|
|
|
|
|
+ <span style="color:#6B7280;">终点</span>
|
|
|
|
|
+ <div style="background:#eef2ff;color:#4f46e5;padding:4px 8px;border-radius:6px;">
|
|
|
|
|
+ {{ getSiteName(priceForm.toSiteId) }}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template v-else>
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="priceForm.fromSiteId"
|
|
|
|
|
+ filterable
|
|
|
|
|
+ placeholder="起始站点"
|
|
|
|
|
+ style="width: 220px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="item in pathSites"
|
|
|
|
|
+ :key="item.id"
|
|
|
|
|
+ :label="item.name"
|
|
|
|
|
+ :value="item.id"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ <span>至</span>
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="priceForm.toSiteId"
|
|
|
|
|
+ filterable
|
|
|
|
|
+ placeholder="结束站点"
|
|
|
|
|
+ style="width: 220px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="item in pathSites"
|
|
|
|
|
+ :key="item.id"
|
|
|
|
|
+ :label="item.name"
|
|
|
|
|
+ :value="item.id"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <el-input v-model="priceForm.price" placeholder="客运价格(元)" type="number" style="width: 160px" />
|
|
|
|
|
+ <el-input v-model="priceForm.cargoPrice" placeholder="带货价格(元)" type="number" style="width: 160px" />
|
|
|
<el-button type="primary" v-if="!isEditPrice" @click="addPrice">添加价格</el-button>
|
|
<el-button type="primary" v-if="!isEditPrice" @click="addPrice">添加价格</el-button>
|
|
|
<el-button type="warning" v-else @click="updatePrice">保存修改</el-button>
|
|
<el-button type="warning" v-else @click="updatePrice">保存修改</el-button>
|
|
|
</div>
|
|
</div>
|
|
|
- <el-table :data="priceList" border style="width: 100%">
|
|
|
|
|
|
|
+ <el-table v-if="!isMatrixEdit" :data="priceList" border style="width: 100%">
|
|
|
<el-table-column label="起始站点">
|
|
<el-table-column label="起始站点">
|
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
|
{{ getSiteName(scope.row.fromSiteId) }}
|
|
{{ getSiteName(scope.row.fromSiteId) }}
|
|
@@ -701,14 +774,29 @@ onMounted(() => {
|
|
|
{{ rowSite.name }}
|
|
{{ rowSite.name }}
|
|
|
</template>
|
|
</template>
|
|
|
<template v-else-if="rowIndex < colIndex">
|
|
<template v-else-if="rowIndex < colIndex">
|
|
|
- <span style="cursor: pointer;" @click="openEditFromMatrix(rowSite.id, colSite.id)">
|
|
|
|
|
- {{ getMatrixPrice(rowSite.id, colSite.id) || '点击新增' }}
|
|
|
|
|
- </span>
|
|
|
|
|
|
|
+ <span style="cursor: pointer;" @click="openEditFromMatrix(rowSite.id, colSite.id)">{{ getMatrixPrice(rowSite.id, colSite.id) || '点击新增' }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</td>
|
|
</td>
|
|
|
</tr>
|
|
</tr>
|
|
|
</tbody>
|
|
</tbody>
|
|
|
</table>
|
|
</table>
|
|
|
|
|
+ <div v-if="editingPanelVisible" style="margin-top:12px; padding-top:12px; border-top:1px solid #e5e7eb; display:flex; align-items:center; flex-wrap: wrap; gap: 10px;">
|
|
|
|
|
+ <div style="display:flex; align-items:center; gap:6px;">
|
|
|
|
|
+ <span style="color:#6B7280;">起点</span>
|
|
|
|
|
+ <div style="background:#eef2ff;color:#4f46e5;padding:4px 8px;border-radius:6px;">
|
|
|
|
|
+ {{ getSiteName(editingFromId) }}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <span style="margin:0 6px;color:#6B7280;">至</span>
|
|
|
|
|
+ <span style="color:#6B7280;">终点</span>
|
|
|
|
|
+ <div style="background:#eef2ff;color:#4f46e5;padding:4px 8px;border-radius:6px;">
|
|
|
|
|
+ {{ getSiteName(editingToId) }}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <el-input v-model="editingPrice" placeholder="客运价格(元)" type="number" style="width: 160px" />
|
|
|
|
|
+ <el-input v-model="editingCargoPrice" placeholder="带货价格(元)" type="number" style="width: 160px" />
|
|
|
|
|
+ <el-button type="primary" @click="saveMatrixEdit">{{ editingPriceId ? '保存修改' : '添加价格' }}</el-button>
|
|
|
|
|
+ <el-button @click="cancelMatrixEdit">取消</el-button>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
</div>
|
|
</div>
|