<template>
|
<div class="setting-container">
|
<el-card class="box-card">
|
<div slot="header" class="clearfix">
|
<span>货主收费模板设置</span>
|
</div>
|
<el-form :inline="true" :model="formData" class="demo-form-inline">
|
<el-form-item label="口岸">
|
<el-select v-model="formData.port_Id" placeholder="请选择口岸" @change="changePort">
|
<el-option v-for="(item, index) in portList" :key="index" :label="item.portName" :value="item.port_Id"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-form>
|
<el-table :data="tableData" style="width: 100%">
|
<el-table-column prop="expressCorpName" label="快递公司" width="180">
|
</el-table-column>
|
<el-table-column prop="feeRate" label="费率" width="180">
|
<template slot-scope="{row}">
|
<el-input-number v-model="row.feeRate" size="mini" controls-position="right" class="w-120"></el-input-number>
|
</template>
|
</el-table-column>
|
<el-table-column prop="unit" label="单位" width="180">
|
<template slot-scope="{row}">
|
<el-select v-model="row.unit_Id">
|
<el-option v-for="(item, index) in unitList" :key="index" :label="item.unit" :value="item.unit_Id"></el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<el-table-column prop="enable" label="是否可用">
|
<template slot-scope="{row}">
|
<el-switch v-model="row.enable" :active-value="1" :inactive-value="0"></el-switch>
|
</template>
|
</el-table-column>
|
</el-table>
|
<div class="padding-20">
|
<el-button type="primary" icon="el-icon-yrt-baocun" @click="btnSave">保存</el-button>
|
</div>
|
</el-card>
|
</div>
|
</template>
|
<script>
|
export default {
|
name: "tms-basic-freight-price-setting",
|
components: {},
|
data() {
|
return {
|
// 表单数据
|
formData: {},
|
// 快递公司下拉框值
|
portList: [],
|
// 表格数据
|
tableData: [],
|
// 单位数据
|
unitList: []
|
};
|
},
|
created() {
|
this.getPortList();
|
this.getUnitList();
|
},
|
activated() {
|
this.init();
|
},
|
methods: {
|
changePort() {
|
this.getTemplateSettingList();
|
},
|
// 获得口岸列表
|
getPortList() {
|
var url = "/api/basicInfo/base/port/getList";
|
var params = {};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.portList = res.data;
|
}
|
},
|
true
|
);
|
},
|
// 初始化数据
|
init() {
|
var params = localStorage.getItem("freight-price");
|
if (params) {
|
params = JSON.parse(params);
|
this.$set(this.formData, "port_Id", params.port_Id);
|
this.$set(this.formData, "portName", params.portName);
|
}
|
this.tableData = [];
|
this.getexpressCorpNameList();
|
},
|
// 获取单位列表
|
getUnitList() {
|
var url = "/api/tms/feeTemplate/getUnitList";
|
var params = {};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.unitList = res.data;
|
}
|
},
|
true
|
);
|
}, // 获取快递公司信息
|
getexpressCorpNameList() {
|
var url = "/api/basicInfo/base/expressCorp/getList";
|
var params = {};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
if (res.data.length) {
|
res.data.forEach(item => {
|
var obj = {
|
expressCorp_Id: item.expressCorp_Id,
|
expressCorpName: item.expressCorpName,
|
feeRate: 0,
|
unit: null,
|
enable: 0
|
};
|
this.$set(this.tableData, this.tableData.length, obj);
|
});
|
var parms = JSON.parse(localStorage.getItem("freight-price"));
|
if (parms) {
|
this.getTemplateSettingList();
|
}
|
}
|
localStorage.removeItem("freight-price");
|
}
|
},
|
true
|
);
|
},
|
// 获取运费模板中的数据
|
getTemplateSettingList() {
|
var userInfo = this.common.getUserInfo();
|
var url = "/api/tms/freightPrice/getFreightPriceList";
|
var params = {
|
userProduct_Id: userInfo.userProduct_Id,
|
port_Id: this.formData.port_Id
|
};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
if (res.data.length) {
|
res.data.forEach(item => {
|
this.tableData.forEach(temp => {
|
if (item.expressCorpName === temp.expressCorpName) {
|
// 如果有给其重新赋值
|
this.$set(temp, "expressCorpName", item.expressCorpName);
|
this.$set(temp, "expressCorp_Id", item.expressCorp_Id);
|
this.$set(temp, "feeRate", item.feeRate);
|
this.$set(temp, "enable", item.enable);
|
this.$set(temp, "FreightPrice_Id", item.FreightPrice_Id);
|
this.unitList.forEach(index => {
|
// 单位赋值
|
if (item.unit === index.unit) {
|
this.$set(temp, "unit", index.unit);
|
this.$set(temp, "unit_Id", index.unit_Id);
|
}
|
});
|
}
|
this.$set(temp, "port_Id", item.port_Id);
|
this.$set(temp, "portName", item.portName);
|
this.$set(temp, "orderNo", item.orderNo);
|
this.$set(temp, "remark", item.remark);
|
this.$set(temp, "createID", item.createID);
|
this.$set(temp, "creator", item.creator);
|
this.$set(temp, "platUser_Id", item.platUser_Id);
|
this.$set(temp, "userProduct_Id", item.userProduct_Id);
|
this.$set(temp, "userProductCode", item.userProductCode);
|
this.$set(temp, "userProductAlias", item.userProductAlias);
|
});
|
});
|
} else {
|
this.tableData = [];
|
this.getexpressCorpNameList();
|
}
|
}
|
},
|
true
|
);
|
},
|
// 保存
|
btnSave() {
|
var url = "/api/tms/freightPrice/saveTemplateSettingList";
|
if (this.tableData.length) {
|
this.tableData.forEach(item => {
|
this.$set(item, "port_Id", this.formData.port_Id);
|
this.portList.forEach(port => {
|
if (item.port_Id === port.port_Id) {
|
item.portName = port.portName;
|
}
|
});
|
this.$set(item, "consignor_Id", this.formData.consignor_Id);
|
this.unitList.forEach(temp => {
|
if (item.unit_Id === temp.unit_Id) {
|
item.unit = temp.unit;
|
}
|
});
|
});
|
}
|
var params = {
|
dataList: this.tableData,
|
port_Id: this.formData.port_Id
|
};
|
this.common.ajax(url, params, res => {
|
this.common.showMsg(res);
|
});
|
}
|
}
|
};
|
</script>
|