马远东 12 months ago
parent
commit
eab388ed29
  1. 10
      src/api/Pricesystem/index.js
  2. 300
      src/views/Pricesystem/Price/PriceBill.vue

10
src/api/Pricesystem/index.js

@ -91,11 +91,11 @@ export const putBasicdataPrice = data => {
* 获取价格路径列表 * 获取价格路径列表
* @returns * @returns
*/ */
export const getPage = data => { export const getPage = params => {
return request({ return request({
url: '/api/logpm-basicdata/priceRoute/page', url: '/api/logpm-basicdata/priceRoute/page',
method: 'get', method: 'get',
data, params,
}); });
}; };
@ -104,8 +104,9 @@ export const getPage = data => {
* @returns * @returns
*/ */
export const getDetails = data => { export const getDetails = data => {
console.log('data :>> ', data);
return request({ return request({
url: `/api/logpm-basicdata/priceRoute/${data.id}`, url: `/api/logpm-basicdata/priceRoute/${data}`,
method: 'get', method: 'get',
}); });
}; };
@ -126,9 +127,10 @@ export const postSubmit = data => {
* 删除 * 删除
* @returns * @returns
*/ */
export const postRemove = data => { export const postRemove = params => {
return request({ return request({
url: `/api/logpm-basicdata/priceRoute/remove`, url: `/api/logpm-basicdata/priceRoute/remove`,
method: 'post', method: 'post',
params,
}); });
}; };

300
src/views/Pricesystem/Price/PriceBill.vue

@ -221,19 +221,20 @@
<tablecmt <tablecmt
class="tableNode" class="tableNode"
ref="tableNode"
:columnList="details.columnList" :columnList="details.columnList"
:tableData="details.data" :tableData="details.data"
:loading="details.loadingObj.list" :loading="details.loadingObj.list"
> >
<template #default="slotProps"> <template #default="slotProps">
<template v-if="slotProps.scope.column.label === '操作'"> <template v-if="slotProps.scope.column.label === '操作'">
<el-text @click="() => handlePlusVehicle(slotProps.scope)" <el-text class="button" @click="() => handleEdit(slotProps.scope)"
><el-icon> ><el-icon>
<CirclePlus /> <CirclePlus />
</el-icon> </el-icon>
</el-text> </el-text>
<el-text class="remove" @click="() => handlePlusVehicle(slotProps.scope)"> <el-text class="button remove" @click="() => handleRemoveLine(slotProps.scope)">
<el-icon> <el-icon>
<Delete /> <Delete />
</el-icon> </el-icon>
@ -262,7 +263,7 @@
</div> </div>
<el-dialog <el-dialog
title="新增提货路径" :title="details.lineType === 'add' ? '新增提货路径' : '编辑提货路径'"
:visible.sync="details.popUpShow.addVsitied" :visible.sync="details.popUpShow.addVsitied"
width="70%" width="70%"
v-model="details.popUpShow.addVsitied" v-model="details.popUpShow.addVsitied"
@ -305,12 +306,17 @@
<el-form-item label="发货单位"> <el-form-item label="发货单位">
<el-select <el-select
class="w100" class="w100"
v-model="details.form.sendOrgId" v-model="details.form.sendOrg"
filterable filterable
clearable clearable
placeholder="请选择发货单位" placeholder="请选择发货单位"
style="width: 240px" style="width: 240px"
:loading="details.loadingObj.loading" :loading="details.loadingObj.loading"
@change="
() => {
details.form.sendOrgId = details.form.sendOrg;
}
"
remote remote
reserve-keyword reserve-keyword
default-first-option default-first-option
@ -510,10 +516,16 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, getCurrentInstance, nextTick } from 'vue'; import { ref, reactive, getCurrentInstance, nextTick } from 'vue';
import { getLazyTreeAll } from '@/api/base/region'; import { getLazyTreeAll } from '@/api/base/region';
import { debounce, deepClone } from '@/utils/util'; import { debounce, deepClone, setNodeHeight } from '@/utils/util';
import { ElMessage, ElMessageBox } from 'element-plus'; import { ElMessage, ElMessageBox } from 'element-plus';
import { getDictionaryBiz } from '@/api/system/dict'; import { getDictionaryBiz } from '@/api/system/dict';
import { putBasicdataPrice, getPage, postSubmit } from '@/api/Pricesystem/index'; import {
putBasicdataPrice,
getPage,
postSubmit,
postRemove,
getDetails,
} from '@/api/Pricesystem/index';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { getList } from '@/api/basicdata/basicClient'; import { getList } from '@/api/basicdata/basicClient';
const $route = useRoute(); // const $route = useRoute(); //
@ -619,36 +631,36 @@ const details = reactive({
// fixed: true, // fixed: true,
// }, // },
{ {
prop: 'name', prop: 'startCountyName',
label: '始发地', label: '始发地',
type: 1, type: 1,
values: '', values: '',
width: '150', width: '150',
checkarr: [], checkarr: [],
fixed: false, fixed: false,
sortable: true, // sortable: true,
head: false, head: false,
}, },
{ {
prop: 'name', prop: 'endCountyName',
label: '目的地', label: '目的地',
type: 1, type: 1,
values: '', values: '',
width: '150', width: '150',
checkarr: [], checkarr: [],
fixed: false, fixed: false,
sortable: true, // sortable: true,
head: false, head: false,
}, },
{ {
prop: 'name', prop: 'sendOrgName',
label: '发货单位', label: '发货单位',
type: 1, type: 1,
values: '', values: '',
width: '150', width: '150',
checkarr: [], checkarr: [],
fixed: false, fixed: false,
sortable: true, // sortable: true,
head: false, head: false,
}, },
{ {
@ -659,7 +671,6 @@ const details = reactive({
width: '150', width: '150',
checkarr: [], checkarr: [],
fixed: false, fixed: false,
sortable: false,
head: false, head: false,
}, },
], ],
@ -676,8 +687,14 @@ const details = reactive({
}, },
/** 发货单位数组 */ /** 发货单位数组 */
sendOrgArr: [], sendOrgArr: [],
/** 省市区 */
regionOptione: [],
/** 提货路线type */
lineType: 'add' as 'add' | 'edit',
}); });
const tableNode = ref();
const validatePrice = (rule: any, value: any, callback: any) => { const validatePrice = (rule: any, value: any, callback: any) => {
const message = '请输入大于0的费用'; const message = '请输入大于0的费用';
@ -692,13 +709,6 @@ const validatePrice = (rule: any, value: any, callback: any) => {
} }
}; };
//
getLazyTreeAll().then(res => {
if (res.data.success) {
details.regionOptione = res.data.data;
}
});
/** 处理干线计费模式 */ /** 处理干线计费模式 */
const handleTrunkLinePricingType = response => { const handleTrunkLinePricingType = response => {
const { code, data } = response.data; const { code, data } = response.data;
@ -842,7 +852,15 @@ const initDictionaryBiz = async () => {
details.form.additionalCost = 0; details.form.additionalCost = 0;
// , // ,
if (details.form.pickupIsUnifyAreaBill === '0') initLineData(); if (details.form.pickupIsUnifyAreaBill === '0') {
//
const res = await getLazyTreeAll();
if (res.data.success) {
details.regionOptione = res.data.data || [];
}
initLineData();
}
} }
// 线 // 线
@ -904,12 +922,81 @@ const handleCheckVehicleType = () => {
} }
}; };
/**
* @param {Array} 循环数组
* @param {String} province
* @param {String} city
* @param {String} region
*/
const handleTranslation = (province, city, region) => {
console.log('province, city, region :>> ', province, city, region);
let name = '';
for (let i = 0; i < details.regionOptione.length; i++) {
const value = details.regionOptione[i];
if (value.value !== province + '') continue;
name += value.label;
if (!value.children || value.children.length === 0) return name;
for (let index = 0; index < value.children.length; index++) {
const element = value.children[index];
if (element.value !== city + '') continue;
name += '/' + element.label;
if (!element.children || element.children.length === 0) return name;
for (let j = 0; j < element.children.length; j++) {
const item = element.children[j];
if (item.value === region + '') {
name += '/' + item.label;
break;
}
}
break;
}
break;
}
return name;
};
/** 获取提货路径数据 */ /** 获取提货路径数据 */
const initLineData = async () => { const initLineData = async () => {
setNodeHeight(tableNode.value.$el, '70vh');
try { try {
details.loadingObj.list = true; details.loadingObj.list = true;
const res = await getPage({ ...details.page }); const res = await getPage({ ...details.page, priceId: $route.query.id });
const { code, data } = res.data;
if (code !== 200) return;
details.data = data.records;
for (let i = 0; i < details.data.length; i++) {
const value = details.data[i];
value.startCountyName = handleTranslation(
value.startProvinceId,
value.startCityId,
value.startCountyId
);
value.endCountyName = handleTranslation(
value.endProvinceId,
value.endCityId,
value.endCountyId
);
}
console.log('details.data :>> ', details.data);
details.page.total = data.total;
} catch (error) { } catch (error) {
console.log('error :>> ', error); console.log('error :>> ', error);
} finally { } finally {
@ -931,12 +1018,12 @@ const currentChange = current => {
}; };
/** 城市改变 */ /** 城市改变 */
const handleChangeCity = (CascaderValue: any[] | null, type: 'strat' | 'end') => { const handleChangeCity = (CascaderValue: any[] | null, type: 'start' | 'end') => {
console.log('CascaderValue :>> ', CascaderValue); console.log('CascaderValue :>> ', CascaderValue);
// //
switch (type) { switch (type) {
case 'strat': case 'start':
if (!CascaderValue) { if (!CascaderValue) {
details.form.startProvinceId = ''; // details.form.startProvinceId = ''; //
details.form.startCityId = ''; // details.form.startCityId = ''; //
@ -987,6 +1074,10 @@ const handleChangeCity = (CascaderValue: any[] | null, type: 'strat' | 'end') =>
/** 新增提货路径 */ /** 新增提货路径 */
const handleAdd = () => { const handleAdd = () => {
handleVehicleTypeStatus();
details.lineType = 'add';
details.VehicleBillingDetal = [ details.VehicleBillingDetal = [
{ {
/** 车型 */ /** 车型 */
@ -999,6 +1090,109 @@ const handleAdd = () => {
details.popUpShow.addVsitied = true; details.popUpShow.addVsitied = true;
}; };
/** 给form赋值 */
const initAssignmentForm = data => {
details.form.startCity = [
...new Set([data.startProvinceId + '', data.startCityId + '', data.startCountyId + '']),
];
details.form.endCity = [
...new Set([data.endProvinceId + '', data.endCityId + '', data.endCountyId + '']),
];
details.form.sendOrgId = data.sendOrgId;
details.form.sendOrg = data.sendOrgName;
details.form.priceId = data.priceId;
details.form.minCost = data.minCost || 0;
details.form.additionalCost = data.additionalCost || 0;
//
details.VehicleBillingDetal = data.fullVehicle || [];
for (let i = 0; i < details.VehicleBillingDetal.length; i++) {
const value = details.VehicleBillingDetal[i];
value.vehicleType += '';
}
const _billTemplateDetailArr = [];
//
for (let i = 0; i < details.form.billTemplateDetail.length; i++) {
const value = details.form.billTemplateDetail[i];
const _itemObj = {
title: value.dictValue + '计费品类',
code: value.dictKey,
categories: [
{
title: '',
categoryId: '',
goods: '',
price: 0,
},
],
};
const _arr = [];
for (let i = 0; i < value.categories.length; i++) {
const item = value.categories[i];
const Arr =
value.code === '1'
? //
data.pieceCategory
: value.code === '3'
? //
data.cubeCategory
: //
data.weightCategory;
if (!Arr || Arr.length === 0) break;
for (let index = 0; index < Arr.length; index++) {
const val = Arr[index];
if (val.categoryId !== item.categoryId) continue;
item.price = val.price;
}
}
}
};
/** 编辑提货路径 */
const handleEdit = async ({ row }) => {
try {
details.loadingObj.pageLoading = true;
details.form = deepClone(details.initForm);
handleVehicleTypeStatus();
details.lineType = 'edit';
details.VehicleBillingDetal = [
{
/** 车型 */
pickupPricingType: '',
/** 车型计费(元/车) */
price: 0,
},
];
const res = await getDetails(row.id);
const { code, data } = res.data;
if (code !== 200) return;
initAssignmentForm(data);
details.form.id = row.id;
console.log('details.form :>> ', details.form);
details.popUpShow.addVsitied = true;
} catch (error) {
console.log('error :>> ', error);
} finally {
details.loadingObj.pageLoading = false;
}
};
/** 查询收货单位 */ /** 查询收货单位 */
const remoteMethod = async value => { const remoteMethod = async value => {
try { try {
@ -1019,6 +1213,14 @@ const remoteMethod = async value => {
} }
}; };
/** 恢复车辆选择状态 */
const handleVehicleTypeStatus = () => {
for (let i = 0; i < details.vehicleTypeArr.length; i++) {
const value = details.vehicleTypeArr[i];
value.isCheck = false;
}
};
/** 重置数据 */ /** 重置数据 */
const resetFormData = () => { const resetFormData = () => {
ElMessageBox.confirm('是否重置数据?', '提示', { ElMessageBox.confirm('是否重置数据?', '提示', {
@ -1109,21 +1311,27 @@ const handleSubmitLine = () => {
type: 'success', type: 'success',
}).then(async () => { }).then(async () => {
try { try {
details.loadingObj.pageLoading = true; details.popUpShow.addVsitied = false; //
details.loadingObj.pageLoading = true; // loading
console.log('details.form :>> ', details.form);
const submitData: any = { const submitData: any = {
startProvinceId: details.form.startProvinceId, // startProvinceId: details.form.startProvinceId, //
startCityId: details.form.startCityId, // startCityId: details.form.startCityId, //
startCountyId: details.form.startCountyId, // , startCountyId: details.form.startCountyId, // ,
endProvinceId: details.form.endProvinceId, // endProvinceId: details.form.endProvinceId, //
endCityId: details.form.startCityId, // endCityId: details.form.endCityId, //
endCountyId: details.form.endCountyId, // , endCountyId: details.form.endCountyId, // ,
/** 提货 */ /** 提货 */
serviceType: '1', serviceType: '1',
id: $route.query.id, priceId: $route.query.id,
sendOrgId: details.form.sendOrgId, sendOrgId: details.form.sendOrgId,
}; };
//
if (details.lineType === 'edit') submitData.id = details.form.id;
// //
if (details.form.pickupIsMinCost === '1') { if (details.form.pickupIsMinCost === '1') {
submitData.minCost = details.form.minCost; submitData.minCost = details.form.minCost;
@ -1153,6 +1361,10 @@ const handleSubmitLine = () => {
if (code !== 200) return; if (code !== 200) return;
ElMessage.success(msg); ElMessage.success(msg);
handleVehicleTypeStatus();
initLineData();
console.log('submitData :>> ', submitData); console.log('submitData :>> ', submitData);
} catch (error) { } catch (error) {
console.log('error :>> ', error); console.log('error :>> ', error);
@ -1162,6 +1374,30 @@ const handleSubmitLine = () => {
}); });
}; };
/** 删除路径 */
const handleRemoveLine = ({ row }) => {
ElMessageBox.confirm(`确认删除 【${row.startCountyName}】-【${row.endCountyName}】 数据`, '', {
confirmButtonText: '删除',
cancelButtonText: '取消',
type: 'warning',
}).then(async () => {
try {
details.loadingObj.pageLoading = true;
const res = await postRemove({ ids: row.id });
const { code, msg } = res.data;
if (code !== 200) return;
ElMessage.success(msg);
initLineData();
} catch (error) {
console.log('error :>> ', error);
} finally {
details.loadingObj.pageLoading = false;
}
});
};
defineExpose({ initDictionaryBiz }); defineExpose({ initDictionaryBiz });
</script> </script>
@ -1280,6 +1516,7 @@ defineExpose({ initDictionaryBiz });
background: #0086f1; background: #0086f1;
border-color: #0086f1; border-color: #0086f1;
color: #fff !important; color: #fff !important;
cursor: pointer;
&:hover { &:hover {
background: #79bbff; background: #79bbff;
@ -1292,6 +1529,7 @@ defineExpose({ initDictionaryBiz });
background: #f85b52; background: #f85b52;
border-color: #f85b52; border-color: #f85b52;
color: #fff !important; color: #fff !important;
cursor: pointer;
&:hover { &:hover {
background: #f89898; background: #f89898;
@ -1303,7 +1541,7 @@ defineExpose({ initDictionaryBiz });
width: 100% !important; width: 100% !important;
} }
:deep(.el-text) { :deep(.button.el-text) {
color: #d3832a !important; color: #d3832a !important;
font-weight: normal; font-weight: normal;
cursor: pointer; cursor: pointer;
@ -1323,12 +1561,6 @@ defineExpose({ initDictionaryBiz });
} }
} }
:deep(.tableNode thead .el-text) {
color: var(--el-text-color-primary) !important;
font-weight: bold;
cursor: pointer;
}
.dialog-footer { .dialog-footer {
text-align: end; text-align: end;
} }

Loading…
Cancel
Save