号源合并调整

main
yanzai 8 months ago
parent 64a897e999
commit bf4f51a8aa

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

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