|
|
|
@ -73,7 +73,7 @@
|
|
|
|
|
|
|
|
|
|
<!-- 表格循环 --> |
|
|
|
|
<div class="el_table_td" v-for="(item, index) in value.categories"> |
|
|
|
|
<div class="el_table_idNumber">{{ index+1 }}</div> |
|
|
|
|
<div class="el_table_idNumber">{{ index + 1 }}</div> |
|
|
|
|
<el-select |
|
|
|
|
:ref="value.title + index" |
|
|
|
|
class="el_Cselect" |
|
|
|
@ -171,11 +171,11 @@
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
|
import { ref, reactive, getCurrentInstance, nextTick,defineEmits, defineComponent } from 'vue'; |
|
|
|
|
import { ref, reactive, getCurrentInstance, nextTick, defineEmits, defineComponent } from 'vue'; |
|
|
|
|
import { debounce, deepClone } from '@/utils/util'; |
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'; |
|
|
|
|
import { getDictionaryBiz } from '@/api/system/dict'; |
|
|
|
|
import { $_priceTemplate ,$_putpriceTemplate} from '@/api/financialsector/index'; //价格模板 |
|
|
|
|
import { $_priceTemplate, $_putpriceTemplate } from '@/api/financialsector/index'; //价格模板 |
|
|
|
|
import { postFindCategoryInfo } from '@/api/distribution/CreateOrder.js'; |
|
|
|
|
const emit = defineEmits(['request-data']); |
|
|
|
|
defineComponent({ |
|
|
|
@ -332,29 +332,105 @@ const handleTrunkLinePricingType = response => {
|
|
|
|
|
const _billTemplateDetailArr = []; |
|
|
|
|
for (let i = 0; i < details.priceMethodType.length; i++) { |
|
|
|
|
const value = details.priceMethodType[i]; |
|
|
|
|
console.log(value,'value'); |
|
|
|
|
|
|
|
|
|
if(value.dictKey !='2'){ |
|
|
|
|
console.log(value,'value===='); |
|
|
|
|
_billTemplateDetailArr.push({ |
|
|
|
|
title: value.dictValue + '计费品类', |
|
|
|
|
code: value.dictKey, |
|
|
|
|
categories: [ |
|
|
|
|
{ |
|
|
|
|
reduce: false, |
|
|
|
|
plus: true, |
|
|
|
|
goodsName: '', |
|
|
|
|
goodsId: '', |
|
|
|
|
goods: '', |
|
|
|
|
goodsArr: [], |
|
|
|
|
loading: false, |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (value.dictKey != '2') { |
|
|
|
|
const _itemObj = { |
|
|
|
|
title: value.dictValue + '计费品类', |
|
|
|
|
code: value.dictKey, |
|
|
|
|
categories: [ |
|
|
|
|
{ |
|
|
|
|
reduce: false, |
|
|
|
|
plus: true, |
|
|
|
|
goodsName: '', |
|
|
|
|
goodsId: '', |
|
|
|
|
goods: '', |
|
|
|
|
goodsArr: [], |
|
|
|
|
loading: false, |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (!props.templateData.request) { |
|
|
|
|
console.log('123123 :>> ', 123123); |
|
|
|
|
_billTemplateDetailArr.push(_itemObj); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log('222 :>> ', 222); |
|
|
|
|
const _arr = []; |
|
|
|
|
|
|
|
|
|
// 按件 |
|
|
|
|
if (value.dictKey === '1') { |
|
|
|
|
const { trunklinePieceCategorys } = props.templateData.request; |
|
|
|
|
|
|
|
|
|
if (trunklinePieceCategorys && trunklinePieceCategorys.length !== 0) { |
|
|
|
|
for (let i = 0; i < trunklinePieceCategorys.length; i++) { |
|
|
|
|
const item = trunklinePieceCategorys[i]; |
|
|
|
|
|
|
|
|
|
_arr.push({ |
|
|
|
|
reduce: i === 0 ? false : true, |
|
|
|
|
plus: true, |
|
|
|
|
goodsName: item.name, |
|
|
|
|
goodsId: item.id, |
|
|
|
|
goods: item.name, |
|
|
|
|
goodsArr: [], |
|
|
|
|
loading: false, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_itemObj.categories = _arr; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 按重量 |
|
|
|
|
if (value.dictKey === '4') { |
|
|
|
|
const { trunklineWeightCategorys } = props.templateData.request; |
|
|
|
|
|
|
|
|
|
if (trunklineWeightCategorys && trunklineWeightCategorys.length !== 0) { |
|
|
|
|
for (let i = 0; i < trunklineWeightCategorys.length; i++) { |
|
|
|
|
const item = trunklineWeightCategorys[i]; |
|
|
|
|
|
|
|
|
|
_arr.push({ |
|
|
|
|
reduce: i === 0 ? false : true, |
|
|
|
|
plus: true, |
|
|
|
|
goodsName: item.name, |
|
|
|
|
goodsId: item.id, |
|
|
|
|
goods: item.name, |
|
|
|
|
goodsArr: [], |
|
|
|
|
loading: false, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_itemObj.categories = _arr; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 按方 |
|
|
|
|
if (value.dictKey === '3') { |
|
|
|
|
const { trunklineCubeCategorys } = props.templateData.request; |
|
|
|
|
|
|
|
|
|
if (trunklineCubeCategorys && trunklineCubeCategorys.length !== 0) { |
|
|
|
|
for (let i = 0; i < trunklineCubeCategorys.length; i++) { |
|
|
|
|
const item = trunklineCubeCategorys[i]; |
|
|
|
|
|
|
|
|
|
_arr.push({ |
|
|
|
|
reduce: i === 0 ? false : true, |
|
|
|
|
plus: true, |
|
|
|
|
goodsName: item.name, |
|
|
|
|
goodsId: item.id, |
|
|
|
|
goods: item.name, |
|
|
|
|
goodsArr: [], |
|
|
|
|
loading: false, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_itemObj.categories = _arr; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_billTemplateDetailArr.push(_itemObj); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log('_billTemplateDetailArr :>> ', _billTemplateDetailArr); |
|
|
|
|
details.form.billTemplateDetail = _billTemplateDetailArr; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -388,11 +464,28 @@ const initDictionaryBiz = async () => {
|
|
|
|
|
|
|
|
|
|
const [trunkLineResult, minCostResult] = await Promise.all([trunkLinePromise, minCostPromise]); |
|
|
|
|
|
|
|
|
|
await nextTick(); |
|
|
|
|
console.log('props.templateData.request :>> ', props.templateData.request); |
|
|
|
|
|
|
|
|
|
if (Object.keys(props.templateData).length !== 0) { |
|
|
|
|
details.form = deepClone(props.templateData.request); |
|
|
|
|
|
|
|
|
|
details.form.trunklinePricingType = details.form.trunklinePricingType |
|
|
|
|
? details.form.trunklinePricingType.split(',') |
|
|
|
|
: []; |
|
|
|
|
details.form.trunklineIsUnifyAreaBill += ''; |
|
|
|
|
details.form.trunklineIsByCategory += ''; |
|
|
|
|
details.form.trunklineIsPeculiarSetup += ''; |
|
|
|
|
details.form.trunklineIsMinCost += ''; |
|
|
|
|
details.form.trunklineMinCostType += ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log('details.form :>> ', details.form); |
|
|
|
|
|
|
|
|
|
// 处理干线 |
|
|
|
|
handleTrunkLinePricingType(trunkLineResult); |
|
|
|
|
handleLowestPrice(minCostResult); |
|
|
|
|
|
|
|
|
|
// 初始化复制form数据 |
|
|
|
|
initFormData(); |
|
|
|
|
} catch (error) { |
|
|
|
|
console.log('error :>> ', error); |
|
|
|
@ -402,7 +495,6 @@ const initDictionaryBiz = async () => {
|
|
|
|
|
|
|
|
|
|
initDictionaryBiz(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 新增品类 */ |
|
|
|
|
const handlePlus = async (value: any, index: number) => { |
|
|
|
|
value.categories.splice(index + 1, 0, { |
|
|
|
@ -483,91 +575,100 @@ const resetFormData = () => {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/** 提交 */ |
|
|
|
|
const handleSubmit = async() => { |
|
|
|
|
const handleSubmit = async () => { |
|
|
|
|
if (details.form.trunklinePricingType.length === 0) ElMessage.error('请选择计价方式'); |
|
|
|
|
|
|
|
|
|
formRef.value.validate(async valid => { |
|
|
|
|
await emit('request-data'); //通知父页面传递数据 |
|
|
|
|
if (!valid) return; |
|
|
|
|
console.log(props, 'props'); |
|
|
|
|
if (!props.templateData.TemplateName) { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: '请输入模板名称', |
|
|
|
|
type: 'warning', |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
details.form.name = props.templateData.TemplateName; //模板名称 |
|
|
|
|
} |
|
|
|
|
console.log(props, 'props'); |
|
|
|
|
if (!props.templateData.TemplateName) { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: '请输入模板名称', |
|
|
|
|
type: 'warning', |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
details.form.name = props.templateData.TemplateName; //模板名称 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!props.templateData.brand) { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: '请选择品牌', |
|
|
|
|
type: 'warning', |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
details.form.brandId = props.templateData.brand; //品牌ID |
|
|
|
|
} |
|
|
|
|
if (!props.templateData.brand) { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: '请选择品牌', |
|
|
|
|
type: 'warning', |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
details.form.brandId = props.templateData.brand; //品牌ID |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
details.form.serviceType=props.templateData.ServiceType.join(',');//顶部选择的服务类型 |
|
|
|
|
console.log(details.form,'初始表单'); |
|
|
|
|
const submitData = deepClone(details.form);//深拷贝 |
|
|
|
|
details.form.serviceType = props.templateData.ServiceType.join(','); //顶部选择的服务类型 |
|
|
|
|
console.log(details.form, '初始表单'); |
|
|
|
|
const submitData = deepClone(details.form); //深拷贝 |
|
|
|
|
// 计价方式 |
|
|
|
|
submitData.trunklinePricingType= submitData.trunklinePricingType.join(',') |
|
|
|
|
submitData.trunklinePricingType = submitData.trunklinePricingType.join(','); |
|
|
|
|
//品类管理 |
|
|
|
|
// 是否区分品类,选择是才进行处理 |
|
|
|
|
if(details.form.trunklineIsByCategory === '1'){ |
|
|
|
|
submitData.billTemplateDetail.forEach(item=>{ |
|
|
|
|
switch (item.code) { |
|
|
|
|
case '1': |
|
|
|
|
submitData.trunklinePieceCategory = item.categories.filter(res => res.goodsId).map(res => res.goodsId).join(','); |
|
|
|
|
break; |
|
|
|
|
case '3': |
|
|
|
|
submitData.trunklineCubeCategory = item.categories.filter(res => res.goodsId).map(res => res.goodsId).join(','); |
|
|
|
|
break; |
|
|
|
|
case '4': |
|
|
|
|
submitData.trunklineWeightCategory = item.categories.filter(res => res.goodsId).map(res => res.goodsId).join(','); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
if (details.form.trunklineIsByCategory === '1') { |
|
|
|
|
submitData.billTemplateDetail.forEach(item => { |
|
|
|
|
switch (item.code) { |
|
|
|
|
case '1': |
|
|
|
|
submitData.trunklinePieceCategory = item.categories |
|
|
|
|
.filter(res => res.goodsId) |
|
|
|
|
.map(res => res.goodsId) |
|
|
|
|
.join(','); |
|
|
|
|
break; |
|
|
|
|
case '3': |
|
|
|
|
submitData.trunklineCubeCategory = item.categories |
|
|
|
|
.filter(res => res.goodsId) |
|
|
|
|
.map(res => res.goodsId) |
|
|
|
|
.join(','); |
|
|
|
|
break; |
|
|
|
|
case '4': |
|
|
|
|
submitData.trunklineWeightCategory = item.categories |
|
|
|
|
.filter(res => res.goodsId) |
|
|
|
|
.map(res => res.goodsId) |
|
|
|
|
.join(','); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
delete submitData.billTemplateDetail;//删除是否区分品类多余参数 |
|
|
|
|
console.log(submitData,'处理好的参数'); |
|
|
|
|
|
|
|
|
|
if(props.templateData.code){ |
|
|
|
|
let data={ |
|
|
|
|
checkType:'2', |
|
|
|
|
...submitData,//提交的参数 |
|
|
|
|
id:props.templateData.code,//编辑参数 |
|
|
|
|
} |
|
|
|
|
delete submitData.billTemplateDetail; //删除是否区分品类多余参数 |
|
|
|
|
console.log(submitData, '处理好的参数'); |
|
|
|
|
|
|
|
|
|
if (props.templateData.code) { |
|
|
|
|
let data = { |
|
|
|
|
checkType: '2', |
|
|
|
|
...submitData, //提交的参数 |
|
|
|
|
id: props.templateData.code, //编辑参数 |
|
|
|
|
}; |
|
|
|
|
// 走编辑 |
|
|
|
|
$_putpriceTemplate(data).then(res=>{ |
|
|
|
|
console.log(res,'编辑成功之后返回值'); |
|
|
|
|
if (res.data.code == 200) { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: res.data.msg, |
|
|
|
|
type: 'success', |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
$_putpriceTemplate(data).then(res => { |
|
|
|
|
console.log(res, '编辑成功之后返回值'); |
|
|
|
|
if (res.data.code == 200) { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: res.data.msg, |
|
|
|
|
type: 'success', |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
// 走新增 |
|
|
|
|
let data={ |
|
|
|
|
...submitData,//提交的参数 |
|
|
|
|
} |
|
|
|
|
$_priceTemplate(data).then(res=>{ |
|
|
|
|
console.log(res,'提交成功返回值'); |
|
|
|
|
if (res.data.code == 200) { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: res.data.msg, |
|
|
|
|
type: 'success', |
|
|
|
|
let data = { |
|
|
|
|
...submitData, //提交的参数 |
|
|
|
|
}; |
|
|
|
|
$_priceTemplate(data).then(res => { |
|
|
|
|
console.log(res, '提交成功返回值'); |
|
|
|
|
if (res.data.code == 200) { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: res.data.msg, |
|
|
|
|
type: 'success', |
|
|
|
|
}); |
|
|
|
|
emit('request-data', res.data.data); //把获取到的数据传递给父页面 |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
emit('request-data',res.data.data);//把获取到的数据传递给父页面 |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|