号源模板创建

wenjuan
yanzai 1 year ago
parent cf1eb92d8d
commit 8c63097f2a

@ -0,0 +1,109 @@
<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class PlanModelController extends Controller
{
public function timeList()
{
$TimeRange = request('TimeRange');
if(count($TimeRange)<>2){
return \Yz::echoError1('起止时间格式错误');
}
$start_time=$TimeRange[0];
$end_time=$TimeRange[1];
if (count(explode(':', $start_time)) == 1) $start_time = date('H:i:s', $start_time / 1000);
if (count(explode(':', $end_time)) == 1) $end_time = date('H:i:s', $end_time / 1000);
$interval_time = request('interval_time');
$list=$this->timeArr($start_time, $end_time, $interval_time);
return \Yz::Return(true,"查询完成",['list' =>$list]);
}
public function GetList()
{
$page =request('page');
$pageSize =request('pageSize');
$searchInfo=request('searchInfo');
$list=DB::table('plan_model as a')
->leftJoin('plan_type as b','a.plan_type','=','b.id')
->select('a.*','b.name as plan_type_name')
->where(['a.is_del'=>0]);
if(isset($searchInfo['name'])){
$list = $list->where('a.name', 'like','%'.$searchInfo['name'].'%');
}
if(isset($searchInfo['status'])){
$list = $list->where('a.status',$searchInfo['status']);
}
$count=$list->count();
if(isset($page) and isset($pageSize)){
$list=$list->orderBy('a.id', 'desc')->limit($pageSize)->skip(($page - 1) * $pageSize)->take($pageSize);
}
$list=$list ->get();
foreach ($list as $l){
$l->y_number=json_decode($l->y_number,true);
}
return \Yz::Return(true,'查询完成',['list'=>$list,'count'=>$count]);
}
public function Save()
{
$Info =request('Info');
$params = [
'name' => isset($Info['name']) ? $Info['name'] : null,
'interval_time' => isset($Info['interval_time']) ? $Info['interval_time'] : null,
'plan_type' => isset($Info['plan_type']) ? $Info['plan_type'] : null,
'y_number' => isset($Info['y_number']) ? json_encode($Info['y_number']) : [],
'count' => isset($Info['count']) ? $Info['count'] : 0,
'status'=>isset($Info['status']) ? $Info['status'] : 0,
];
$requiredFields = ['name'=>'名称','interval_time'=>'时间间隔','plan_type'=>'号源类型'];
// 判断是否为空
foreach ($requiredFields as $key=> $field) {
if (!isset($params[$key]) || $params[$key] === null) {
return \Yz::echoError1('参数 ' . $field . ' 不能为空');
}
}
if(!isset($Info['TimeRange']) or count($Info['TimeRange'])<>2){
return \Yz::echoError1('起止时间格式错误');
}
$params['start_time']=$Info['TimeRange'][0];
$params['end_time']=$Info['TimeRange'][1];
$do=false;
$table=DB::table('plan_model');
if($Info['id']==0){
$do=$table->insert($params);
}
if($Info['id']>0){
$do=$table->where(['id'=>$Info['id']])->update($params);
}
if($do){
return \Yz::Return(true,'操作成功',[]);
}else{
return \Yz::echoError1('操作失败');
}
}
public function GetDetail()
{
$id =request('id');
$info=DB::table('plan_model')->where(['id'=>$id,'is_del'=>0])->first();
if(!!$info){
$info->TimeRange=[$info->start_time,$info->end_time];
$info->y_number=json_decode($info->y_number,true);
return \Yz::Return(true,'查询完成',$info);
}else{
return \Yz::echoError1('查询失败');
}
}
function timeArr($start_time, $end_time, $interval_time, $arr = [])
{
if (strtotime($start_time) > strtotime($end_time)) return $arr;
$arr[] = date('H:i', strtotime($start_time));
return $this->timeArr(date('Y-m-d H:i:s', strtotime($start_time) + ($interval_time * 60)), $end_time, $interval_time, $arr);
}
}

@ -21,7 +21,7 @@ class PlanTypeController extends Controller
'amount_limit2' => isset($Info['amount_limit2']) ? $Info['amount_limit2'] : 0,
'status'=>isset($Info['status']) ? $Info['status'] : 0,
];
$requiredFields = ['name'=>'名','is_vip'=>'vip类型','use_type'=>'个检/团检类型','checkup_type_id'=>'体检类型','status'=>'状态'];
$requiredFields = ['name'=>'名','is_vip'=>'vip类型','use_type'=>'个检/团检类型','checkup_type_id'=>'体检类型','status'=>'状态'];
// 判断是否为空
foreach ($requiredFields as $key=> $field) {
if (!isset($params[$key]) || $params[$key] === null) {

@ -55,7 +55,10 @@ Route::group(['middleware'=>['checktoken','log'],'prefix'=>'v1'],function () {
Route::post('admin/PlanTypeGetDetail','App\Http\Controllers\API\Admin\YeWu\PlanTypeController@GetDetail');//号源类型详情
Route::post('admin/PlanTypeDel','App\Http\Controllers\API\Admin\YeWu\PlanTypeController@Del');//号源类型详情
Route::post('admin/CheckUpTypeGetEnableList','App\Http\Controllers\API\Admin\YeWu\CheckUpTypeController@GetEnableList');//可用体检类型列表
Route::post('admin/PlanModelTimeList','App\Http\Controllers\API\Admin\YeWu\PlanModelController@timeList');//可用体检类型列表
Route::post('admin/PlanModelTimeList','App\Http\Controllers\API\Admin\YeWu\PlanModelController@timeList');//获取时间点列表
Route::post('admin/PlanModelSave','App\Http\Controllers\API\Admin\YeWu\PlanModelController@Save');//保存号源模板
Route::post('admin/PlanModelGetList','App\Http\Controllers\API\Admin\YeWu\PlanModelController@GetList');//号源模板列表
Route::post('admin/PlanModelGetDetail','App\Http\Controllers\API\Admin\YeWu\PlanModelController@GetDetail');//号源模板详情
});

@ -135,4 +135,16 @@ export const PlanTypeDel = (data={}) => {
//号源模板获取时间段列表
export const PlanModelTimeList = (data={}) => {
return axios({url:import.meta.env.VITE_APP_API+'v1/admin/PlanModelTimeList',data:data})
}
//保存号源模板
export const PlanModelSave = (data={}) => {
return axios({url:import.meta.env.VITE_APP_API+'v1/admin/PlanModelSave',data:data})
}
//号源模板列表
export const PlanModelGetList = (data={}) => {
return axios({url:import.meta.env.VITE_APP_API+'v1/admin/PlanModelGetList',data:data})
}
//号源模板详情
export const PlanModelGetDetail = (data={}) => {
return axios({url:import.meta.env.VITE_APP_API+'v1/admin/PlanModelGetDetail',data:data})
}

@ -0,0 +1,279 @@
<template>
<div>
<div class="head">
<div class="head">
<el-row>
<el-form-item>
<el-input v-model="searchInfo.name" placeholder="请输入模板名称" style="margin-left: 10px;" />
</el-form-item>
<el-button type="primary" @click="GetList()" style="margin-left: 10px;">查询</el-button>
<el-button type="success" @click="Add()" style="margin-left: 10px;">添加</el-button>
</el-row>
</div>
</div>
<el-table :data="tableData" style="width: 100%;" row-key="id" v-loading="loading">
<el-table-column prop="id" label="Id" width="100" v-if="false" />
<el-table-column prop="name" label="名称" />
<el-table-column prop="plan_type_name" label="号源类型" />
<el-table-column prop="" label="起止时间">
<template #default="scope">
{{scope.row.start_time}} - {{scope.row.end_time}}
</template>
</el-table-column>
<el-table-column prop="interval_time" label="时间间隔">
<template #default="scope">
{{scope.row.interval_time}}分钟
</template>
</el-table-column>
<el-table-column prop="count" label="号源总数" />
<el-table-column prop="count" label="预留号源数">
<template #default="scope">
{{scope.row.y_number.length}}
</template>
</el-table-column>
<el-table-column prop="" label="操作" width="150">
<template #default="scope">
<el-button type="primary" @click="Edit(scope.row)" size="small">修改</el-button>
<el-button type="danger" @click="Del(scope.row.id)" size="small">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="page">
<el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize"
:page-sizes="[15, 50, 100, 200]" layout="total,sizes, prev, pager, next" :total="total"
@size-change="PageSizeChange" @current-change="PageCurrentChange" />
</div>
<el-dialog v-model="dialogVisible" title="号源模板设置">
<div class="chuansuokuang" v-loading="loading">
<el-form :model="Info" label-width="150" style="max-width: 600px">
<el-form-item label="名称">
<el-input v-model="Info.name" />
</el-form-item>
<el-form-item label="起止时间">
<div style="display: flex;">
<el-time-picker v-model="Info.TimeRange" value-format='HH:mm:00' is-range
range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" />
</div>
</el-form-item>
<el-form-item label="时间间隔">
<el-input-number v-model="Info.interval_time" :min="1" :max="10000"
@input.native="handle($event)" />
</el-form-item>
<el-form-item label="号源类型">
<el-select :filterable="true" clearable v-model="Info.plan_type" placeholder="选择号源类型">
<el-option v-for="(item,index) in PlabTypeList" :key="index" :label="item.name"
:value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-switch v-model="Info.status" size="large" active-text="" inactive-text=""
:active-value="1" :inactive-value="0" />
</el-form-item>
</el-form>
<div class="timelist_k">
<div v-for="(item,index) in timeList" :key="index" :class="['timelist_button', item.class]"
@click="TimeClick(index)">{{item.time}}</div>
</div>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="Save()">
确定
</el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script setup>
import {
ref,
onMounted
} from 'vue';
import {
ElMessage,
ElMessageBox
} from 'element-plus'
import {
PlanTypeGetList,
PlanModelTimeList,
PlanModelSave,
PlanModelGetList,
PlanModelGetDetail
} from '@/api/api.js'
let loading = ref(false)
let searchInfo = ref({})
let tableData = ref([])
let currentPage = ref(1) //
let pageSize = ref(15) //
let total = 0 //
const PageSizeChange = (e) => { //
pageSize.value = e
GetList()
}
const PageCurrentChange = (e) => { //
currentPage.value = e
GetList()
}
const GetList = () => {
loading.value = true
PlanModelGetList({
searchInfo: searchInfo.value,
page: currentPage.value,
pageSize: pageSize.value
}).then(res => {
loading.value = false
if (res.status) {
tableData.value = res.data.list
total = res.data.count
} else {
ElMessage.error(res.msg)
}
})
}
let Info = ref({});
let dialogVisible = ref(false);
const Add = () => {
Info.value = {}
Info.value.id = 0
Info.value.status = 1
Info.value.TimeRange = ['08:00:00', '12:00:00']
Info.value.interval_time = 5 //
dialogVisible.value = true
GetPlanTypeList()
GetTimeList()
}
let PlabTypeList = ref([]); //
const GetPlanTypeList = () => {
loading.value = true
PlanTypeGetList({
searchInfo: {
status: 1
},
}).then(res => {
loading.value = false
if (res.status) {
PlabTypeList.value = res.data.list
} else {
ElMessage.error(res.msg)
}
})
}
const handle = (e) => {
Info.value.interval_time = e
setTimeout(() => {
GetTimeList()
}, 500)
}
//
let timeList = ref([])
const GetTimeList = () => {
timeList.value = []
loading.value = true
PlanModelTimeList({
TimeRange: Info.value.TimeRange,
interval_time: Info.value.interval_time
}).then(res => {
loading.value = false
if (res.status) {
res.data.list.forEach((v, i) => {
timeList.value.push({
time: v
})
});
} else {
ElMessage.error(res.msg)
}
})
}
//
const TimeClick = (index) => {
if (timeList.value[index].class == "timelist_button_selected") {
timeList.value[index].class = ""
} else {
timeList.value[index].class = "timelist_button_selected"
}
}
//
const Save = () => {
Info.value.y_number = [] //
timeList.value.forEach((v, i) => {
if (v.class != 'timelist_button_selected') {
Info.value.y_number.push(i)
}
})
Info.value.count = timeList.value.length
loading.value = true
PlanModelSave({
Info: Info.value
}).then(res => {
loading.value = false
if (res.status) {
dialogVisible.value = false
GetList()
} else {
ElMessage.error(res.msg)
}
})
}
const Edit=(row)=>{
dialogVisible.value = true
GetPlanTypeList()
GetDetail(row.id)
}
const GetDetail=(id)=>{
loading.value = true
PlanModelGetDetail({
id: id
}).then(res => {
loading.value = false
if (res.status) {
Info.value=res.data
GetTimeList()
} else {
ElMessage.error(res.msg)
}
})
}
onMounted(() => {
GetList()
})
</script>
<style scoped>
.timelist_k {
display: flex;
flex-wrap: wrap;
}
.timelist_button {
width: 150px;
border: 1px solid #e2e2e2;
margin-top: 8px;
margin-left: 8px;
text-align: center;
height: 28px;
line-height: 28px;
cursor: pointer;
background-color: #f4f4f4;
font-weight: 700;
border-radius: 4px;
}
.timelist_button:hover {
border: 2px solid #8fc2ff;
line-height: 26px;
color: #2b5885;
}
.timelist_button_selected {
background-color: #8fc2ff;
color: #405772
}
</style>

@ -106,7 +106,7 @@
<el-input v-model="Info.amount_limit2" placeholder="0" />
</el-form-item>
</el-form-item>
<el-form-item label="状态">
<el-form-item label="状态">
<el-switch v-model="Info.status" size="large" active-text="" inactive-text=""
:active-value="1" :inactive-value="0" />
</el-form-item>

Loading…
Cancel
Save