修改
This commit is contained in:
parent
995d06ea1d
commit
2ab964b734
|
|
@ -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'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,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>
|
||||
|
|
@ -43,6 +42,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>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,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>
|
||||
|
|
@ -60,6 +59,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">
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,189 +1,286 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'],
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'],
|
||||
function ($, undefined, Backend, Table, Form) {
|
||||
$.jstree.core.prototype.get_all_checked = function (full) {
|
||||
var obj = this.get_selected(), i, j;
|
||||
for (i = 0, j = obj.length; i < j; i++) {
|
||||
obj = obj.concat(this.get_node(obj[i]).parents);
|
||||
}
|
||||
obj = $.grep(obj, function (v, i, a) {
|
||||
return v != '#';
|
||||
});
|
||||
obj = obj.filter(function (itm, i, a) {
|
||||
return i == a.indexOf(itm);
|
||||
});
|
||||
return full ? $.map(obj, $.proxy(function (i) {
|
||||
return this.get_node(i);
|
||||
}, this)) : obj;
|
||||
};
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'workers/worker/index' + location.search,
|
||||
add_url: 'workers/worker/add',
|
||||
edit_url: 'workers/worker/edit',
|
||||
del_url: 'workers/worker/del',
|
||||
multi_url: 'workers/worker/multi',
|
||||
import_url: 'workers/worker/import',
|
||||
table: 'worker',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{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: 'tel', title: __('Tel'), operate: 'LIKE'},
|
||||
{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'),
|
||||
buttons:[
|
||||
{
|
||||
name: 'edit',
|
||||
text: "修改",
|
||||
icon: 'fa fa-pencil',
|
||||
title: __('Edit'),
|
||||
extend: 'data-toggle="tooltip" data-container="body"',
|
||||
classname: 'btn btn-xs btn-info btn-editone',
|
||||
},
|
||||
{
|
||||
name: 'del',
|
||||
text: "删除",
|
||||
icon: 'fa fa-trash',
|
||||
title: __('Delete'),
|
||||
extend: 'data-toggle="tooltip"',
|
||||
classname: 'btn btn-xs btn-danger btn-delone',
|
||||
},
|
||||
],
|
||||
table: table, events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
$("#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}});
|
||||
$('#area_id').val(code);
|
||||
});
|
||||
$("#search_btn").on("click", function() {
|
||||
table.bootstrapTable('refresh',{
|
||||
url:$.fn.bootstrapTable.defaults.extend.index_url +'&' + getQueryData(),
|
||||
});
|
||||
});
|
||||
function getQueryData(){
|
||||
return $('#select-form').serialize();
|
||||
$.jstree.core.prototype.get_all_checked = function (full) {
|
||||
var obj = this.get_selected(), i, j;
|
||||
for (i = 0, j = obj.length; i < j; i++) {
|
||||
obj = obj.concat(this.get_node(obj[i]).parents);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$("#reset_btn").on("click", function() {
|
||||
$("#c-city-search").citypicker('reset');
|
||||
$("#area_id").val('');
|
||||
$("#citem").val('').selectpicker('refresh');
|
||||
$("#keyword").val('');
|
||||
table.bootstrapTable('refresh',{
|
||||
url:$.fn.bootstrapTable.defaults.extend.index_url +'?' + getQueryData(),
|
||||
});
|
||||
obj = $.grep(obj, function (v, i, a) {
|
||||
return v != '#';
|
||||
});
|
||||
Form.events.citypicker($("#select-form"));
|
||||
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
Form.events.citypicker($("form"));
|
||||
},
|
||||
add: 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);
|
||||
obj = obj.filter(function (itm, i, a) {
|
||||
return i == a.indexOf(itm);
|
||||
});
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const type = urlParams.get('type');
|
||||
if (type) {
|
||||
const select = document.getElementById('worker_type');
|
||||
if (select) {
|
||||
select.value = type;
|
||||
}
|
||||
}
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"),null,null,function () {
|
||||
if ($("#treeview").length > 0) {
|
||||
var r = $("#treeview").jstree("get_all_checked");
|
||||
$("input[name='row[rules]']").val(r.join(','));
|
||||
return full ? $.map(obj, $.proxy(function (i) {
|
||||
return this.get_node(i);
|
||||
}, this)) : obj;
|
||||
};
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'workers/worker/index' + location.search,
|
||||
add_url: 'workers/worker/add',
|
||||
edit_url: 'workers/worker/edit',
|
||||
del_url: 'workers/worker/del',
|
||||
multi_url: 'workers/worker/multi',
|
||||
import_url: 'workers/worker/import',
|
||||
table: 'worker',
|
||||
}
|
||||
return true;
|
||||
});
|
||||
//渲染权限节点树
|
||||
//销毁已有的节点树
|
||||
$("#treeview").jstree("destroy");
|
||||
Controller.api.rendertree(nodeData);
|
||||
//全选和展开
|
||||
$(document).on("click", "#checkall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "check_all" : "uncheck_all");
|
||||
});
|
||||
$(document).on("click", "#expandall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "open_all" : "close_all");
|
||||
});
|
||||
$("select[name='row[pid]']").trigger("change");
|
||||
},
|
||||
rendertree: function (content) {
|
||||
$("#treeview")
|
||||
.on('redraw.jstree', function (e) {
|
||||
$(".layer-footer").attr("domrefresh", Math.random());
|
||||
})
|
||||
.jstree({
|
||||
"themes": {"stripes": true},
|
||||
"checkbox": {
|
||||
"keep_selected_style": false,
|
||||
},
|
||||
"types": {
|
||||
"root": {
|
||||
"icon": "fa fa-folder-open",
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{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,
|
||||
},
|
||||
"menu": {
|
||||
"icon": "fa fa-folder-open",
|
||||
{field: 'tel', title: __('Tel'), operate: 'LIKE'},
|
||||
{
|
||||
field: 'status',
|
||||
title: __('Status'),
|
||||
searchList: {"1": __('Status 1'), "0": __('Status 0')},
|
||||
formatter: Table.api.formatter.status
|
||||
},
|
||||
"file": {
|
||||
"icon": "fa fa-file-o",
|
||||
//{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'),
|
||||
buttons: [
|
||||
{
|
||||
name: 'edit',
|
||||
text: "修改",
|
||||
icon: 'fa fa-pencil',
|
||||
title: __('Edit'),
|
||||
extend: 'data-toggle="tooltip" data-container="body"',
|
||||
classname: 'btn btn-xs btn-info btn-editone',
|
||||
},
|
||||
{
|
||||
name: 'del',
|
||||
text: "删除",
|
||||
icon: 'fa fa-trash',
|
||||
title: __('Delete'),
|
||||
extend: 'data-toggle="tooltip"',
|
||||
classname: 'btn btn-xs btn-danger btn-delone',
|
||||
},
|
||||
],
|
||||
table: table, events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate
|
||||
}
|
||||
},
|
||||
"plugins": ["checkbox", "types"],
|
||||
"core": {
|
||||
'check_callback': true,
|
||||
"data": content
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
$("#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}});
|
||||
$('#area_id').val(code);
|
||||
});
|
||||
$("#search_btn").on("click", function () {
|
||||
table.bootstrapTable('refresh', {
|
||||
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('');
|
||||
$("#citem").val('').selectpicker('refresh');
|
||||
$("#keyword").val('');
|
||||
table.bootstrapTable('refresh', {
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData(),
|
||||
});
|
||||
});
|
||||
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);
|
||||
Form.events.citypicker($("form"));
|
||||
},
|
||||
add: 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);
|
||||
});
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const type = urlParams.get('type');
|
||||
if (type) {
|
||||
const select = document.getElementById('worker_type');
|
||||
if (select) {
|
||||
select.value = type;
|
||||
}
|
||||
}
|
||||
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: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"), null, null, function () {
|
||||
if ($("#treeview").length > 0) {
|
||||
var r = $("#treeview").jstree("get_all_checked");
|
||||
$("input[name='row[rules]']").val(r.join(','));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
//渲染权限节点树
|
||||
//销毁已有的节点树
|
||||
$("#treeview").jstree("destroy");
|
||||
Controller.api.rendertree(nodeData);
|
||||
//全选和展开
|
||||
$(document).on("click", "#checkall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "check_all" : "uncheck_all");
|
||||
});
|
||||
$(document).on("click", "#expandall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "open_all" : "close_all");
|
||||
});
|
||||
$("select[name='row[pid]']").trigger("change");
|
||||
},
|
||||
rendertree: function (content) {
|
||||
$("#treeview")
|
||||
.on('redraw.jstree', function (e) {
|
||||
$(".layer-footer").attr("domrefresh", Math.random());
|
||||
})
|
||||
.jstree({
|
||||
"themes": {"stripes": true},
|
||||
"checkbox": {
|
||||
"keep_selected_style": false,
|
||||
},
|
||||
"types": {
|
||||
"root": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"menu": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"file": {
|
||||
"icon": "fa fa-file-o",
|
||||
}
|
||||
},
|
||||
"plugins": ["checkbox", "types"],
|
||||
"core": {
|
||||
'check_callback': true,
|
||||
"data": content
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user