|
|
|
<template>
|
|
|
|
<basic-container v-loading="pageLoading">
|
|
|
|
<!-- 模板内容 -->
|
|
|
|
<div class="content">
|
|
|
|
<el-tabs type="border-card" v-model="Tabmenu">
|
|
|
|
<template v-for="item in ServiceList" :key="item.label">
|
|
|
|
<el-tab-pane :name="item.label" v-if="item.state" :label="item.label">
|
|
|
|
<span v-if="item.label == '提货'"><FinancialBill /></span>
|
|
|
|
<span v-if="item.label == '干线'"
|
|
|
|
><FinancialTrunkLine @request-data="provideData" :templateData="templateInfo"
|
|
|
|
/></span>
|
|
|
|
<span v-if="item.label == '仓储'"
|
|
|
|
><FinancialWarehousing @request-data="provideData" :templateData="templateInfo"
|
|
|
|
/></span>
|
|
|
|
<span v-if="item.label == '配送'"
|
|
|
|
><FinancialDelivery @request-data="provideData" :templateData="templateInfo"
|
|
|
|
/></span>
|
|
|
|
<span v-if="item.label == '安装'">安装</span>
|
|
|
|
</el-tab-pane>
|
|
|
|
</template>
|
|
|
|
</el-tabs>
|
|
|
|
</div>
|
|
|
|
</basic-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref, defineAsyncComponent } from 'vue';
|
|
|
|
import { getDictionaryBiz } from '@/api/system/dict'; //字典
|
|
|
|
import { $_basicdataBrande } from '@/api/financialsector/index'; //价格模板
|
|
|
|
import { $_InfopriceTemplate as getInfo } from '@/api/Pricesystem/index.js';
|
|
|
|
import { $_InfopriceTemplate } from '@/api/financialsector/index.js';
|
|
|
|
import { useRoute } from 'vue-router';
|
|
|
|
|
|
|
|
const $route = useRoute();
|
|
|
|
|
|
|
|
//仓储模板
|
|
|
|
const FinancialWarehousing = defineAsyncComponent(() =>
|
|
|
|
import('@/views/Pricesystem/Price/PriceWarehousing.vue')
|
|
|
|
);
|
|
|
|
/** 提货模板 */
|
|
|
|
const FinancialBill = defineAsyncComponent(() => import('@/views/Pricesystem/Price/PriceBill.vue'));
|
|
|
|
/** 干线模板 */
|
|
|
|
const FinancialTrunkLine = defineAsyncComponent(() =>
|
|
|
|
import('@/views/Pricesystem/Price/PriceTrunkLine.vue')
|
|
|
|
);
|
|
|
|
// 配送模板
|
|
|
|
const FinancialDelivery = defineAsyncComponent(() =>
|
|
|
|
import('@/views/Pricesystem/Price/PriceDelivery.vue')
|
|
|
|
);
|
|
|
|
/** 页面loading */
|
|
|
|
const pageLoading = ref(true); //菜单加载
|
|
|
|
const form = ref({});
|
|
|
|
const Tabmenu = ref('仓储');
|
|
|
|
const templateInfo = ref({});
|
|
|
|
// 菜单列表
|
|
|
|
const ServiceList = ref([]);
|
|
|
|
/** 车辆类型 */
|
|
|
|
const VehicleTypeList = ref([]);
|
|
|
|
|
|
|
|
const request = ref({}); //用于保存会显的值
|
|
|
|
|
|
|
|
// 字典公共函数
|
|
|
|
function updateDictionary(targetArray, dictionaryType) {
|
|
|
|
getDictionaryBiz(dictionaryType)
|
|
|
|
.then(res => {
|
|
|
|
console.log(res, '字典');
|
|
|
|
if (res.data.code == 200) {
|
|
|
|
if (res.data.data.length) {
|
|
|
|
res.data.data.forEach(item => {
|
|
|
|
targetArray.push({
|
|
|
|
value: item.dictKey,
|
|
|
|
label: item.dictValue,
|
|
|
|
id: item.id,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(() => {});
|
|
|
|
}
|
|
|
|
|
|
|
|
// 循环渲染菜单
|
|
|
|
async function executeCheckedResults(results) {
|
|
|
|
await nextTick();
|
|
|
|
for (const res of results) {
|
|
|
|
await isChecked(res, false, false);
|
|
|
|
await provideData();
|
|
|
|
}
|
|
|
|
pageLoading.value = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 获取回显数据 */
|
|
|
|
const initData = async () => {
|
|
|
|
try {
|
|
|
|
const res = await getInfo({ id: $route.query.id });
|
|
|
|
|
|
|
|
const { code, data } = res.data;
|
|
|
|
|
|
|
|
if (code !== 200) return;
|
|
|
|
|
|
|
|
// form.value = data;
|
|
|
|
} catch (error) {
|
|
|
|
console.log('error :>> ', error);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// 页面初始化必要请求
|
|
|
|
const onLoad = async () => {
|
|
|
|
try {
|
|
|
|
pageLoading.value = true;
|
|
|
|
|
|
|
|
const PromiseAll = [
|
|
|
|
/** 服务类型 */
|
|
|
|
updateDictionary(ServiceList.value, 'service_type'),
|
|
|
|
/** 车辆类型 */
|
|
|
|
updateDictionary(VehicleTypeList.value, 'price_vehicle_type'),
|
|
|
|
];
|
|
|
|
|
|
|
|
await Promise.all(PromiseAll);
|
|
|
|
|
|
|
|
initData();
|
|
|
|
|
|
|
|
console.log('VehicleTypeList :>> ', VehicleTypeList);
|
|
|
|
let data = {
|
|
|
|
id: $route.query.templateId,
|
|
|
|
};
|
|
|
|
$_InfopriceTemplate(data).then(res => {
|
|
|
|
console.log(res, '获取详情');
|
|
|
|
if (res.data.code == 200) {
|
|
|
|
request.value = res.data.data; //发送回显数据
|
|
|
|
form.value.TemplateName = res.data.data.name || ''; //模板名称
|
|
|
|
form.value.ServiceType = res.data.data.serviceType.split(',') || []; //服务类型
|
|
|
|
|
|
|
|
console.log('form.value.ServiceType :>> ', form.value.ServiceType);
|
|
|
|
const result = ServiceList.value.filter(item =>
|
|
|
|
form.value.ServiceType.includes(item.value)
|
|
|
|
);
|
|
|
|
// 激活菜单设置为已经存在的
|
|
|
|
executeCheckedResults(result);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
console.log('error :>> ', error);
|
|
|
|
} finally {
|
|
|
|
pageLoading.value = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
onLoad();
|
|
|
|
|
|
|
|
// 点击菜单
|
|
|
|
const isChecked = (val, isCheck = false) => {
|
|
|
|
//菜单隐藏/显示
|
|
|
|
val.state = !val.state;
|
|
|
|
//设置激活菜单
|
|
|
|
if (!isCheck) Tabmenu.value = val.label;
|
|
|
|
// 如果当前菜单被关闭则显示最新菜单
|
|
|
|
if (!val.state && form.value.ServiceType.length) {
|
|
|
|
Tabmenu.value = ServiceList.value.find(res => res.state).label;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// 点击移除
|
|
|
|
const removeTag = value => {
|
|
|
|
ServiceList.value.find(res => res.value == value).check = false;
|
|
|
|
ServiceList.value.find(res => res.value == value).state = false;
|
|
|
|
// 激活菜单设置为已经存在的
|
|
|
|
if (form.value.ServiceType.length) {
|
|
|
|
Tabmenu.value = ServiceList.value.find(res => res.state).label;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// 给子页面传递数据
|
|
|
|
const provideData = data => {
|
|
|
|
console.log(data, '来自子页面的数据');
|
|
|
|
console.log(form.value, 'form.value');
|
|
|
|
|
|
|
|
templateInfo.value = form.value;
|
|
|
|
if (data) {
|
|
|
|
templateInfo.value.code = data; //接收来自子页面第一次保存的返回值
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.content_box {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
.header {
|
|
|
|
border-bottom: 1px solid #ccc;
|
|
|
|
padding: 10px;
|
|
|
|
box-shadow: -1px -1px 3px;
|
|
|
|
.el_Template {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
.name {
|
|
|
|
font-size: 16px;
|
|
|
|
margin-right: 10px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
display: flex;
|
|
|
|
.el_Service {
|
|
|
|
margin-left: 30px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
.name {
|
|
|
|
margin-right: 10px;
|
|
|
|
}
|
|
|
|
.el-checkbox {
|
|
|
|
width: 100% !important;
|
|
|
|
padding: 0 30px;
|
|
|
|
.el-checkbox__label {
|
|
|
|
width: 100%;
|
|
|
|
margin-left: 20px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.name {
|
|
|
|
font-size: 16px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.el-checkbox {
|
|
|
|
width: 100% !important;
|
|
|
|
padding-left: 10px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
.el-checkbox__label {
|
|
|
|
margin-left: 20px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.el-select-dropdown__item {
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
.el-select-dropdown__item::after {
|
|
|
|
content: '';
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
.content {
|
|
|
|
margin-top: 6px;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
</style>
|