Accept Merge Request #90: (feature/hant -> develop)

Merge Request: 修改

Created By: @todayswind
Accepted By: @todayswind
URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/90?initial=true
This commit is contained in:
todayswind 2025-06-01 22:36:38 +08:00 committed by Coding
commit 03c72b86ad
5 changed files with 411 additions and 187 deletions

View File

@ -179,16 +179,16 @@ class Worker extends Backend
if ($items) {
$insert = [];
foreach ($items as $item) {
if ($item == '') continue;
$insert [] = [
'worker_id' => $result,
'worker_id' => $this->model->id,
'item_id' => $item,
'item_path_id' => $item_map[$item] ?? 0
];
}
model('WorkerItem')->saveAll($insert);
model('WorkerItem')->insertAll($insert);
}
}
Db::commit();
} catch (ValidateException | PDOException | Exception $e) {
Db::rollback();
@ -229,10 +229,12 @@ class Worker extends Backend
$item_map = model('item')->getAll();
$item_map = array_column($item_map, 'level', 'id');
if ($ids) {
$items = explode(',', $params['rules']);
$items = explode(',', $params['rules'] ?? '');
if ($items) {
$insert = [];
foreach ($items as $item) {
if ($item == '') continue;
$insert [] = [
'worker_id' => $ids,
'item_id' => $item,
@ -382,4 +384,50 @@ ORDER BY distance;",[$order->lng,$order->lat]);
}
public function status(){
$ids = input()['ids'] ?? [];
$status = input()['status'] ?? 1;
$res = Db::name('worker')->whereIn('id',$ids)->update([
'status' => $status
]);
return json([]);
}
public function del($ids = null)
{
if (false === $this->request->isPost()) {
$this->error(__("Invalid parameters"));
}
$ids = $ids ?: $this->request->post("ids");
if (empty($ids)) {
$this->error(__('Parameter %s can not be empty', 'ids'));
}
$pk = $this->model->getPk();
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
$this->model->where($this->dataLimitField, 'in', $adminIds);
}
$list = $this->model->where($pk, 'in', $ids)->select();
$count = 0;
Db::startTrans();
try {
foreach ($list as $item) {
$count += $item->delete();
}
Db::commit();
} catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($count) {
$this->success();
}
$this->error(__('No rows were deleted'));
}
}

View File

@ -40,7 +40,6 @@
<select data-live-search="true" id="worker_type" name="row[type]" class="form-control">
<option value="1">自营</option>
<option value="2">非自营</option>
<option value="3">新师傅</option>
</select>
</div>
</div>
@ -57,6 +56,44 @@
<input id="c-star" data-rule="required" class="form-control" max="5" min="1" step="0.1" name="row[star]" type="number" value="5.0">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">师傅分成:</label>
<div class="col-xs-12 col-sm-8">
<input data-rule="required" class="form-control" step="0.01" name="row[rate]" type="number" value="0.00">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">分成备注:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-detail" placeholder="待填" rows="8" style="width: 100%;resize: vertical" class="form-control" name="row[rate_remark]"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">备注:</label>
<div class="col-xs-12 col-sm-8">
<textarea placeholder="待填" rows="8" style="width: 100%;resize: vertical" class="form-control" name="row[remark]"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">师傅收款码:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-images" class="form-control" size="50" name="row[images]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-images"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-images"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">师傅技能:</label>

View File

@ -57,7 +57,6 @@
<select data-live-search="true" name="row[type]" class="form-control">
<option {if 1 == $row.type} selected {/if} value="1">自营</option>
<option {if 2 == $row.type} selected {/if} value="2">非自营</option>
<option {if 2 == $row.type} selected {/if} value="3">新师傅</option>
</select>
</div>
</div>
@ -74,6 +73,42 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">师傅分成:</label>
<div class="col-xs-12 col-sm-8">
<input data-rule="required" class="form-control" step="0.01" name="row[rate]" type="number" value="{$row.rate|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">分成备注:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-detail" placeholder="待填" rows="8" style="width: 100%;resize: vertical" class="form-control" name="row[rate_remark]">{$row.rate_remark|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">备注:</label>
<div class="col-xs-12 col-sm-8">
<textarea placeholder="待填" rows="8" style="width: 100%;resize: vertical" class="form-control" name="row[remark]">{$row.remark|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">师傅收款码:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-images" class="form-control" size="50" name="row[images]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-images"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-images"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">师傅技能:</label>
<div class="col-xs-12 col-sm-8">

View File

@ -21,12 +21,19 @@
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('workers/worker/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('workers/worker/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<button type="button" class="btn btn-danger btn-change-status-off" title="冻结">
<i class="fa fa-remove"></i> 冻结
</button>
<button type="button" class="btn btn-success btn-change-status-on" title="冻结">
<i class="fa fa-check-circle"></i> 激活
</button>
<div class="dropdown btn-group {:$auth->check('workers/worker/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
{foreach name="statusList" item="vo"}
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li>
{/foreach}
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="type=1">自营</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="type=2">非自营</a></li>
</ul>
</div>

View File

@ -45,19 +45,39 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'],
{field: 'id', title: __('Id')},
{field: 'admin.username', title: '创建人'},
{field: 'name', title: __('Name'), operate: 'LIKE'},
{field: 'type', title: '师傅归属', searchList: {"1":'自营',"2":'非自营','3':'新师傅'},
formatter: Table.api.formatter.status,},
{
field: 'type', title: '师傅归属', searchList: {"1": '自营', "2": '非自营', '3': '新师傅'},
formatter: Table.api.formatter.status,
},
{field: 'tel', title: __('Tel'), operate: 'LIKE'},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
{
field: 'status',
title: __('Status'),
searchList: {"1": __('Status 1'), "0": __('Status 0')},
formatter: Table.api.formatter.status
},
//{field: 'area_id', title: __('Area_id')},
//{field: 'lng', title: __('Lng'), operate:'BETWEEN'},
//{field: 'lat', title: __('Lat'), operate:'BETWEEN'},
{field: 'area.short_merge_name', title: __('Area.short_merge_name'), searchable: false},
{field: 'deposit_amount', title: __('Deposit_amount'), operate: 'BETWEEN'},
{field: 'star', title: __('Star'), operate: 'BETWEEN'},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'operate', title: __('Operate'),
{
field: 'create_time',
title: __('Create_time'),
operate: 'RANGE',
addclass: 'datetimerange',
autocomplete: false
},
{
field: 'update_time',
title: __('Update_time'),
operate: 'RANGE',
addclass: 'datetimerange',
autocomplete: false
},
{
field: 'operate', title: __('Operate'),
buttons: [
{
name: 'edit',
@ -77,7 +97,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'],
},
],
table: table, events: Table.api.events.operate,
formatter: Table.api.formatter.operate}
formatter: Table.api.formatter.operate
}
]
]
});
@ -92,12 +113,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'],
url: $.fn.bootstrapTable.defaults.extend.index_url + '&' + getQueryData(),
});
});
function getQueryData() {
return $('#select-form').serialize();
}
$("#reset_btn").on("click", function () {
$("#c-city-search").citypicker('reset');
$("#area_id").val('');
@ -109,6 +130,77 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'],
});
Form.events.citypicker($("#select-form"));
// 批量修改状态事件
$(document).on("click", ".btn-change-status-off", function () {
var ids = Table.api.selectedids(table);
if (ids.length === 0) {
Toastr.error("请选择至少一条记录");
return;
}
layer.confirm('是否全部冻结', function () {
Fast.api.ajax({
url: 'workers/worker/status',
type: "POST",
contentType: 'application/json',
data: JSON.stringify({
ids,
status: 0
}),
success:function (){
layer.closeAll();
Toastr.info('操作成功');
table.bootstrapTable("refresh");
}
});
});
}); // 批量修改状态事件
$(document).on("click", ".btn-change-status-on", function () {
var ids = Table.api.selectedids(table);
if (ids.length === 0) {
Toastr.error("请选择至少一条记录");
return;
}
layer.confirm('是否全部激活', function () {
$.ajax({
url: 'workers/worker/status',
type: "POST",
contentType: 'application/json',
data: JSON.stringify({
ids,
status: 1
}),
success:function (){
layer.closeAll();
Toastr.info('操作成功');
table.bootstrapTable("refresh");
}
});
});
});
$(document).on("click", ".btn-change-type", function () {
var ids = Table.api.selectedids(table);
if (ids.length === 0) {
Toastr.error("请选择至少一条记录");
return;
}
layer.confirm('批量修改类型', function () {
$.ajax({
url: 'workers/worker/status',
type: "POST",
contentType: 'application/json',
data: JSON.stringify({
ids,
status: 1
}),
success:function (){
layer.closeAll();
Toastr.info('操作成功');
table.bootstrapTable("refresh");
}
});
});
});
// 为表格绑定事件
Table.api.bindevent(table);
@ -131,6 +223,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'],
Controller.api.bindevent();
},
edit: function () {
$("#c-city").on("cp:updated", function () {
var citypicker = $(this).data("citypicker");
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
$("#area_id").val(code);
});
Controller.api.bindevent();
},
api: {