|
|
@@ -2,7 +2,7 @@
|
|
|
import {
|
|
|
apisystemdzbcMultiSitePathlist, apisystemdzbcMultiSitePathexport, apisystemdzbcMultiSitePathDel, apisystemdzbcMultiSitePathAdd, apisystemdzbcMultiSitePathUpdate,
|
|
|
apisystemdzbcPathSiteByPathId, apisystemdzbcPathSiteAdd, apisystemdzbcPathSiteDel,
|
|
|
- apisystemdzbcSitePriceByPathId, apisystemdzbcSitePriceAdd, apisystemdzbcSitePriceDel,
|
|
|
+ apisystemdzbcSitePriceByPathId, apisystemdzbcSitePriceAdd, apisystemdzbcSitePriceDel, apisystemdzbcSitePriceUpdate,
|
|
|
apisystemdzbcSitelist, // Import site list API
|
|
|
apisystemdzbcArealist // Import area list API
|
|
|
} from '../../request/api.js'
|
|
|
@@ -84,6 +84,8 @@ const siteForm = reactive({
|
|
|
const priceDialogVisible = ref(false)
|
|
|
const priceList = ref([])
|
|
|
const pathSites = ref([]) // Store sites for current path
|
|
|
+const isEditPrice = ref(false)
|
|
|
+const currentPriceId = ref('')
|
|
|
const priceForm = reactive({
|
|
|
pathId: '',
|
|
|
fromSiteId: '', // Changed from 'startSiteId'
|
|
|
@@ -357,6 +359,32 @@ const addPrice = () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+const updatePrice = () => {
|
|
|
+ if (!currentPriceId.value) {
|
|
|
+ ElMessage.warning('缺少要修改的价格ID')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!priceForm.fromSiteId || !priceForm.toSiteId) {
|
|
|
+ ElMessage.warning('请输入起始和结束站点ID')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let ext2 = {}
|
|
|
+ if(priceForm.cargoPrice){
|
|
|
+ ext2['cargoPrice'] = priceForm.cargoPrice * 100
|
|
|
+ }
|
|
|
+ apisystemdzbcSitePriceUpdate({
|
|
|
+ id: currentPriceId.value,
|
|
|
+ pathId: priceForm.pathId,
|
|
|
+ fromSiteId: priceForm.fromSiteId,
|
|
|
+ toSiteId: priceForm.toSiteId,
|
|
|
+ price: priceForm.price * 100,
|
|
|
+ ext2: JSON.stringify(ext2)
|
|
|
+ }).then(() => {
|
|
|
+ ElMessage.success('修改成功')
|
|
|
+ loadPrices()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
const deletePrice = (id) => {
|
|
|
apisystemdzbcSitePriceDel({ id }).then(() => {
|
|
|
ElMessage.success('删除成功')
|
|
|
@@ -390,6 +418,7 @@ const openMatrixDialog = async (row) => {
|
|
|
// 2. Fetch prices
|
|
|
const priceRes = await apisystemdzbcSitePriceByPathId({ pathId: row.id })
|
|
|
if (priceRes.code === 200) {
|
|
|
+ priceList.value = priceRes.data
|
|
|
priceRes.data.forEach(p => {
|
|
|
const key = `${p.fromSiteId}-${p.toSiteId}`;
|
|
|
matrixPrices.value[key] = p.price;
|
|
|
@@ -408,6 +437,7 @@ const openMatrixDialog = async (row) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ currentPathId.value = row.id
|
|
|
matrixDialogVisible.value = true
|
|
|
} catch (e) {
|
|
|
console.error(e)
|
|
|
@@ -415,6 +445,32 @@ const openMatrixDialog = async (row) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+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 }))
|
|
|
+ const existing = priceList.value.find(p => p.fromSiteId === fromId && p.toSiteId === toId)
|
|
|
+ if (existing) {
|
|
|
+ isEditPrice.value = true
|
|
|
+ currentPriceId.value = existing.id
|
|
|
+ priceForm.price = (existing.price || 0) / 100
|
|
|
+ try {
|
|
|
+ const ext2 = existing.ext2 ? JSON.parse(existing.ext2) : {}
|
|
|
+ priceForm.cargoPrice = ext2.cargoPrice ? ext2.cargoPrice / 100 : 0
|
|
|
+ } catch {
|
|
|
+ priceForm.cargoPrice = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ isEditPrice.value = false
|
|
|
+ currentPriceId.value = ''
|
|
|
+ priceForm.price = 0
|
|
|
+ priceForm.cargoPrice = 0
|
|
|
+ }
|
|
|
+ matrixDialogVisible.value = false
|
|
|
+ priceDialogVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
const getMatrixPrice = (fromId, toId) => {
|
|
|
const price = matrixPrices.value[`${fromId}-${toId}`]
|
|
|
const cargoPrice = matrixCargoPrices.value[`${fromId}-${toId}`]
|
|
|
@@ -594,7 +650,8 @@ onMounted(() => {
|
|
|
</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" />
|
|
|
- <el-button type="primary" @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>
|
|
|
</div>
|
|
|
<el-table :data="priceList" border style="width: 100%">
|
|
|
<el-table-column label="起始站点">
|
|
|
@@ -644,7 +701,9 @@ onMounted(() => {
|
|
|
{{ rowSite.name }}
|
|
|
</template>
|
|
|
<template v-else-if="rowIndex < colIndex">
|
|
|
- {{ getMatrixPrice(rowSite.id, colSite.id) }}
|
|
|
+ <span style="cursor: pointer;" @click="openEditFromMatrix(rowSite.id, colSite.id)">
|
|
|
+ {{ getMatrixPrice(rowSite.id, colSite.id) || '点击新增' }}
|
|
|
+ </span>
|
|
|
</template>
|
|
|
</td>
|
|
|
</tr>
|
|
|
@@ -735,4 +794,4 @@ onMounted(() => {
|
|
|
align-items: center;
|
|
|
}
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|