派单
This commit is contained in:
parent
b572345345
commit
bf4d2cf9ee
|
|
@ -100,19 +100,31 @@ class Dispatch extends Backend
|
|||
if (!$order) {
|
||||
$this->error(__('No results were found'));
|
||||
}
|
||||
$code = $this->getSelectAreaCode(substr_replace($order->area_id, '00', -2));
|
||||
$workers = model('worker')
|
||||
->where('area_id','like', $code.'%')
|
||||
->where('status',1)
|
||||
->field(['id','name','tel','area_id','lng','lat'])
|
||||
->select();
|
||||
|
||||
|
||||
$items = Db::name('item')
|
||||
->where('status',1)
|
||||
->field(['id','title','key_word','pid'])
|
||||
->order('pid','asc')
|
||||
->order('sort','desc')
|
||||
->select();
|
||||
$filtered = array_filter($items, function($item) {
|
||||
return $item['pid'] == 0;
|
||||
});
|
||||
|
||||
$pid_map = array_column($filtered,null,'id');
|
||||
$res_items = [];
|
||||
foreach ($items as $item){
|
||||
if ($item['pid'] != 0 && isset($pid_map[$item['pid']])){
|
||||
$res_items [] = [
|
||||
...$item,'ptitle' => $pid_map[$item['pid']]['title']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$area_name = model('area')->getNameByCode($order->area_id);
|
||||
$order->area_name = str_replace(',','/',$area_name);
|
||||
|
||||
$workers = $this->getWorkers($workers);
|
||||
$this->view->assign('workers', $workers);
|
||||
$this->view->assign('items', $res_items);
|
||||
$this->view->assign('row', $order);
|
||||
|
||||
return $this->view->fetch();
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ class Worker extends Backend
|
|||
];
|
||||
}
|
||||
model('WorkerItem')->where('worker_id',$ids)->delete();
|
||||
model('WorkerItem')->batchInsert($insert);
|
||||
model('WorkerItem')->insertAll($insert);
|
||||
}
|
||||
}
|
||||
unset($params['rules']);
|
||||
|
|
@ -220,4 +220,27 @@ class Worker extends Backend
|
|||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function dispatchList(){
|
||||
|
||||
$area_id = request()->get('area_id');
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
|
||||
$build = model('worker')
|
||||
->where('status',1)
|
||||
->with(['area'])
|
||||
->field(['id','name','tel','area_id','lng','lat']);
|
||||
|
||||
if ($area_id){
|
||||
$code = $this->getSelectAreaCode(substr_replace($area_id, '00', -2));
|
||||
$build->where('area_id','like', $code.'%');
|
||||
}
|
||||
$list = $build
|
||||
->paginate($limit);
|
||||
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
|
||||
return json($result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
|
||||
|
|
@ -50,6 +51,31 @@ class Item extends Model
|
|||
}
|
||||
|
||||
|
||||
public function getList(){
|
||||
$items = $this
|
||||
->where('status',1)
|
||||
->field(['id','title','key_word','pid'])
|
||||
->order('pid','asc')
|
||||
->order('sort','desc')
|
||||
->select();
|
||||
|
||||
|
||||
$this->items = $items;
|
||||
$filtered = array_filter($items, function($item) {
|
||||
return $item['pid'] == 0;
|
||||
});
|
||||
|
||||
$pid_map = array_column($filtered,null,'id');
|
||||
$res_items = [];
|
||||
foreach ($items as $item){
|
||||
if ($item['pid'] != 0 && isset($pid_map[$item['pid']])){
|
||||
$res_items [] = [
|
||||
...$item,'ptitle' => $pid_map[$item['pid']]['title']
|
||||
];
|
||||
}
|
||||
}
|
||||
return $res_items;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,15 @@
|
|||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Address')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-address" data-rule="required" disabled class="form-control" name="row[address]" type="text">
|
||||
<input id="c-address" data-rule="required" disabled value="{$row.address}" class="form-control" name="row[address]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">服务类型</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-item_title" data-rule="required" value="{$row.item_title}" disabled class="form-control" name="row[item_title]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Detail')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
|
@ -45,20 +50,14 @@
|
|||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Order_id')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-order_id" data-rule="required" data-field="order_no" disabled class="form-control" name="row[order_id]" type="text" value="{$row->order_no}">
|
||||
<input id="c-order_id" data-rule="required" data-field="order_no" disabled class="form-control" name="row[order_no]" type="text" value="{$row->order_no}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Worker_id')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-3">师傅名称:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-source" data-live-search="true" title="请选择" data-rule="required" name="row[worker_id]" class="form-control selectpicker">
|
||||
<!-- <option value="0">无可用工人</option>-->
|
||||
|
||||
{foreach $workers as $item}
|
||||
<option data-subtext="电话:{$item['tel'].'-'.$item['dist'] }" value="{$item['id']}">{$item['name']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<input id="c-worker_name" class="form-control" disabled name="row[worker_name]" type="text">
|
||||
<input id="c-worker_id" class="form-control" style="display: none" name="row[worker_id]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -84,18 +83,37 @@
|
|||
<div id="myTabContent" class="tab-content">
|
||||
<div class="tab-pane fade active in" id="one">
|
||||
<div class="widget-body no-padding">
|
||||
<div id="toolbar" class="toolbar">
|
||||
<h3>师傅选择</h3>
|
||||
<!-- <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>-->
|
||||
<form id="select-form" class="form-inline" role="form" style="margin-top: 5px">
|
||||
<div class='form-group'>
|
||||
<label style="padding-left: 0px;text-align: left">{:__('Area_id')}:</label>
|
||||
<div style="display: inline-block;width: 300px;margin-left: 5px">
|
||||
<input id="c-city-search" style="width: 100%;height: 32px" data-toggle="city-picker" name="row[address]" type="text" value="" />
|
||||
|
||||
<form id="select-form" role="form" class="form-horizontal" data-toggle="validator" method="POST" action="">
|
||||
<div class="form-group">
|
||||
<label class="col-xs-12 col-sm-2" style="padding-left: 0px;text-align: left">区域:</label>
|
||||
<div style="display: inline-block;width: 300px;position: absolute">
|
||||
<input id="c-city-search" data-rule="required" class="form-control" data-toggle="city-picker" value="{$row.area_name}" type="text" />
|
||||
<input id="area_id" style="display: none" class="form-control" name="area_id" hidden type="text" value="{$row.area_id}" />
|
||||
</div>
|
||||
<p id="reset" style="display: inline-block;margin-bottom: 2px;" class="btn btn-default">重置</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-12 col-sm-2" style="text-align: left;padding-left: 0px;">工种:</label>
|
||||
<div style="width: 300px;display: inline-block;">
|
||||
<select id="citem" data-live-search="true" title="请选择" value = "{$row.item_id}" name="item_id" class="form-control selectpicker show-tick">
|
||||
<option value="0">不过滤</option>
|
||||
{foreach $items as $item}
|
||||
<option {if $item['id'] == $row.item_id} selected {/if} data-subtext="{$item['key_word']}" value="{$item['id']}">{$item['title']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-12 col-sm-2" style="padding-left: 0px;text-align: left">关键字:</label>
|
||||
<div style="display: inline-block;width: 300px;position: absolute">
|
||||
<input id="keyword" class="form-control" style="width: 100%;height: 32px" placeholder="名称或电话号码搜索" name="keyword" type="text" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<p id="search_btn" class="btn btn-primary">搜索</p>
|
||||
<p id="reset_btn" class="btn btn-primary">清空</p>
|
||||
</form>
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
width="100%">
|
||||
</table>
|
||||
|
|
@ -106,4 +124,22 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.dropdown-menu {
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
width: 100%;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
|
||||
margin: 6px 12px;
|
||||
}
|
||||
#select-form .form-group{
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -168,7 +168,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
|
|||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'workers/worker/index' + location.search,
|
||||
index_url: 'workers/worker/dispatchList',
|
||||
table: 'worker',
|
||||
}
|
||||
});
|
||||
|
|
@ -177,7 +177,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
|
|||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url +'?' + getQueryData(),
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
fixedColumns: true,
|
||||
|
|
@ -185,7 +185,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
|
|||
columns: [
|
||||
[
|
||||
// {checkbox: true},
|
||||
// {field: 'id', title: __('Id')},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'name', title: __('Name'), operate: 'LIKE'},
|
||||
{field: 'tel', title: __('Tel'), operate: 'LIKE'},
|
||||
// {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
|
||||
|
|
@ -194,23 +194,49 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
|
|||
//{field: 'lat', title: __('Lat'), operate:'BETWEEN'},
|
||||
{field: 'area.short_merge_name', title: __('Area.short_merge_name'), operate: 'LIKE'},
|
||||
// {field: 'deposit_amount', title: __('Deposit_amount'), operate:'BETWEEN'},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
{field: 'id', title: '操作',formatter:function (id) {
|
||||
return `<p class="btn btn-primary tab_chose" data-id="${id}">选择</p>`;
|
||||
}},
|
||||
]
|
||||
]
|
||||
],
|
||||
search:false,
|
||||
commonSearch:false,
|
||||
});
|
||||
function getQueryData(){
|
||||
return $('#select-form').serialize();
|
||||
}
|
||||
$("#c-city-search").on("cp:updated", function() {
|
||||
var citypicker = $(this).data("citypicker");
|
||||
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
|
||||
table.bootstrapTable('refresh',{query: {area_code: code}});
|
||||
// table.bootstrapTable('refresh',{query: {area_code: code}});
|
||||
$('#area_id').val(code);
|
||||
});
|
||||
$("#reset").on("click", function() {
|
||||
$("#c-city").citypicker('reset');
|
||||
table.bootstrapTable('refresh');
|
||||
$("#search_btn").on("click", function() {
|
||||
table.bootstrapTable('refresh',{
|
||||
url:$.fn.bootstrapTable.defaults.extend.index_url +'?' + getQueryData(),
|
||||
});
|
||||
});
|
||||
$("#reset_btn").on("click", function() {
|
||||
$("#c-city-search").citypicker('reset');
|
||||
$("#area_id").val('');
|
||||
$("#citem").val('').selectpicker('refresh');
|
||||
$("#keyword").val('');
|
||||
console.log(1);
|
||||
table.bootstrapTable('refresh',{
|
||||
url:$.fn.bootstrapTable.defaults.extend.index_url +'?' + getQueryData(),
|
||||
});
|
||||
});
|
||||
Form.events.citypicker($("#select-form"));
|
||||
|
||||
$(document).on('click', '.tab_chose', function() {
|
||||
var dataId = $(this).data('id'); // 获取 data-id 的值
|
||||
const worker = Table.api.getrowbyid(table ,dataId);
|
||||
$('#c-worker_name').val(worker.name + '--' + worker.tel).trigger('input').trigger('change');
|
||||
$('#worker_id').val(worker.id).trigger('input').trigger('change');
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
Form.events.citypicker($("#select-form"));
|
||||
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
|
|
@ -219,7 +245,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
|
|||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
Form.api.bindevent($("#add-form"),null,null,function (data) {
|
||||
Form.api.submit($("#add-form"));
|
||||
return false;
|
||||
});
|
||||
Form.api.bindevent($("#select-form"));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1068,7 +1068,8 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
getrowbyid: function (table, id) {
|
||||
var row = {};
|
||||
var options = table.bootstrapTable("getOptions");
|
||||
$.each(Table.api.selecteddata(table), function (i, j) {
|
||||
var data = table.bootstrapTable('getData');
|
||||
$.each(data, function (i, j) {
|
||||
if (j[options.pk] == id) {
|
||||
row = j;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,16 @@
|
|||
background: url(../images/drop-arrow.png) -10px -25px no-repeat;
|
||||
}
|
||||
|
||||
.city-picker-span > .close {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 24px;
|
||||
width: 10px;
|
||||
margin-top: -12px;
|
||||
font-size: 20px;
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
.city-picker-span.focus,
|
||||
.city-picker-span.open {
|
||||
border-bottom-color: #46A4FF;
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
this.getWidthStyle(p.width) + 'height:' +
|
||||
p.height + 'px;line-height:' + (p.height - 1) + 'px;">' +
|
||||
(placeholder ? '<span class="placeholder">' + placeholder + '</span>' : '') +
|
||||
'<span class="title"></span><div class="arrow"></div>' + '</span>',
|
||||
'<span class="title"></span><div class="arrow"></div> <div class="close">X</div>' + '</span>',
|
||||
|
||||
dropdown = '<div class="city-picker-dropdown" style="left:0px;top:100%;' +
|
||||
this.getWidthStyle(p.width, true) + '">' +
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
this.getWidthStyle(p.width) + 'height:' +
|
||||
p.height + 'px;line-height:' + (p.height - 1) + 'px;">' +
|
||||
(placeholder ? '<span class="placeholder">' + placeholder + '</span>' : '') +
|
||||
'<span class="title"></span><div class="arrow"></div>' + '</span>',
|
||||
'<span class="title"></span><div class="arrow"></div><div class="close">X</div>' + '</span>',
|
||||
|
||||
dropdown = '<div class="city-picker-dropdown" style="left:0px;top:100%;' +
|
||||
this.getWidthStyle(p.width, true) + '">' +
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user