号源合并调整

main
yanzai 8 months ago
parent 64a897e999
commit bf4f51a8aa

@ -295,6 +295,7 @@ class PlanModelController extends Controller
foreach ($ratio as $k => $v) {
if ($value->id == $v->appointment_type_id) {
$appointment_type[$key]->ratio = $v->ratio;
$appointment_type[$key]->link = json_decode($v->link,true);
}
}
}
@ -318,6 +319,7 @@ class PlanModelController extends Controller
'department_id' => $department_id,
'appointment_type_id' => $value['id'],
'ratio' => $value['ratio'],
'link'=>isset($value['link'])?json_encode($value['link'],JSON_UNESCAPED_UNICODE):null,
]);
}
if ($u) {

@ -1,93 +1,141 @@
<template>
<div>
<div style="margin: 12px;color:#999">
设置说明此功能为各个预约渠道设置默认数量百分比用于为预约计划按比例自动分配数量此次设置各个渠道的数值总数应为100如果不想给某个渠道分配可设置为0
设置说明
<div>1预约渠道设置默认数量百分比用于为预约计划按比例自动分配数量此次设置各个渠道的数值总数应为100如果不想给某个渠道分配可设置为0 </div>
<div>
2渠道合并合并后的号源池可共用
</div>
</div>
<div style="display: flex" v-loading="loading">
<div style="width: 400px;margin-right: 40px">
<el-form :model="ratioInfo" label-width="auto" style="max-width: 600px">
<el-form-item v-for="(item,index) in ratioInfo" :key="index" :label="item.name">
<div style="width: 750px;margin-right: 40px">
<el-form :model="ratioInfo" label-width="auto" style="max-width: 600px">
<el-form-item v-for="(item,index) in ratioInfo" :key="index" :label="item.name">
<div style="display: flex;">
<el-input size="large" type="number" min="0" max="100" v-model="ratioInfo[index].ratio"
style="margin-left: 10px;width: 250px;" />
<div style="margin-left: 10px;">%</div>
<el-input size="large" type="number" min="0" max="100" v-model="ratioInfo[index].ratio"
style="margin-left: 10px;width: 250px;" />
<div style="margin-left: 10px; margin-right: 40px;">%</div>
<div style="width: 100px;color: #75b96c;">号源池合并</div>
<el-select size="large" v-model="ratioInfo[index].link" multiple placeholder="未合并"
style="width: 240px" @remove-tag="(value) => LinkRemove(index, value)"
@change="LinkChange(index,ratioInfo[index].link)">
<el-option v-for="(item2,index2) in filteredOptions(item)" :key="index2"
:label="item2.name" :value="item2.id" />
</el-select>
</div>
</el-form-item>
</el-form>
</div>
<div style="display: flex;justify-content: center; align-items: center;">
<el-button type="primary" @click="Save" style="height: 70px;width: 100px">
确定
</el-button>
</div>
</el-form-item>
</el-form>
</div>
<div style="display: flex;justify-content: center; align-items: center;">
<el-button type="primary" @click="Save" style="height: 70px;width: 100px">
确定
</el-button>
</div>
</div>
</div>
</template>
<script setup>
import {
ref,
onMounted
} from 'vue'
import {
GetAppointmentRatio,SaveAppointmentRatio
} from '@/api/api.js'
import { ElMessage } from 'element-plus'
let ratioInfo = ref([])
let loading = ref(false)
//
const GetRatio = () => {
loading.value = true
GetAppointmentRatio({}).then(res => {
loading.value = false
if (res.status) {
ratioInfo.value=res.data
} else {
ElMessage.error(res.msg)
}
import {
ref,
onMounted
} from 'vue'
import {
GetAppointmentRatio,
SaveAppointmentRatio
} from '@/api/api.js'
import {
ElMessage
} from 'element-plus'
let ratioInfo = ref([])
let loading = ref(false)
//
const GetRatio = () => {
loading.value = true
GetAppointmentRatio({}).then(res => {
loading.value = false
if (res.status) {
ratioInfo.value = res.data
} else {
ElMessage.error(res.msg)
}
})
}
//
const Save=()=>{
let status=false
let zong=0
ratioInfo.value.forEach((v,i)=>{
if(v.ratio>=0 && v.ratio<=100){
zong=zong+Number(v.ratio)
}else{
ElMessage.error("第"+(i+1)+"个渠道数据不正确")
}
})
if( zong ==100){
status=true
}else{
status=false
ElMessage.error("各渠道总和应为100当前为"+zong)
}
if(!status) return false
loading.value = true
SaveAppointmentRatio({ratioInfo:ratioInfo.value}).then(res => {
loading.value = false
if (res.status) {
ElMessage({
message: '保存成功',
type: 'success',
})
GetRatio()
} else {
ElMessage.error(res.msg)
}
})
}
onMounted(() => {
GetRatio()
})
})
}
//
const Save = () => {
let status = false
let zong = 0
ratioInfo.value.forEach((v, i) => {
if (v.ratio >= 0 && v.ratio <= 100) {
zong = zong + Number(v.ratio)
} else {
ElMessage.error("第" + (i + 1) + "个渠道数据不正确")
}
})
if (zong == 100) {
status = true
} else {
status = false
ElMessage.error("各渠道总和应为100当前为" + zong)
}
if (!status) return false
loading.value = true
SaveAppointmentRatio({
ratioInfo: ratioInfo.value
}).then(res => {
loading.value = false
if (res.status) {
ElMessage({
message: '保存成功',
type: 'success',
})
GetRatio()
} else {
ElMessage.error(res.msg)
}
})
}
//
const filteredOptions = (item) => {
return ratioInfo.value.filter(option => option.id !== item.id);
};
const LinkChange = (index, newLinks) => {
const currentId = ratioInfo.value[index].id;
ratioInfo.value.forEach((item) => {
if (item.id === currentId) return; //
const shouldInclude = newLinks.includes(item.id);
const hasCurrentId = item.link.includes(currentId);
if (shouldInclude && !hasCurrentId) {
item.link.push(currentId);
} else if (!shouldInclude && hasCurrentId) {
item.link = item.link.filter(id => id !== currentId);
}
});
};
const LinkRemove = (currentIndex, removedValue) => {
const currentId = ratioInfo.value[currentIndex].id;
const removedItem = ratioInfo.value.find(item => item.id === removedValue);
if (removedItem) {
removedItem.link = removedItem.link.filter(id => id !== currentId);
}
};
onMounted(() => {
GetRatio()
})
</script>
<style scoped>
<style >
.el-select__tags .el-tag--info{
background-color: #b3e19d;
color:#68825b;
}
</style>
Loading…
Cancel
Save