//controllers(控制器)
public function getPickerForUpAction() {
//职位
$cond = array();
$obj = new User_Model_Position();
$pos = $obj->getByCondition($cond);
if ( !empty( $pos ) ) {
foreach ( $pos as $val ) {
$cond = array( 'up_id' => $val['up_id'], 'status' => 1);
$temp = User_Service_User::getList( $cond );
//无职员的职位不显示
if ( empty( $temp ) ) {
continue;
}
$position[] = $val;
}
}
//获取页面职位ID
$job = $this->_request->getParam( 'job', '' );
$up_id = 103;
if ( !empty( $job ) ) {
$up_id = $job;
}
//人员
if ( $position != $job ) {
$cond = array( 'up_id' => $up_id ? $up_id : '', 'status' => 1);
$member = User_Service_User::getList( $cond );
}
//字母排序
if ( $member ) {
$name = array();
foreach ( $member as $key => $value ) {
//按首字母存进$name数组
$userName = $value["name"];
$firstCharacter = Common_Service_Common::getFirstCharacter( mb_substr( trim( $userName ), 0, 1, 'utf-8' ) );
$firstCharacter = $firstCharacter ? $firstCharacter : 1;
$temp = array( 'name' => $userName, 'id' => $value['user_id'] );
$name[$firstCharacter][$userName] = $temp;
}
//对数组按照键名排序
ksort( $name );
foreach ( $name as $k => $v ) {
ksort($v);
$name[$k] = array_values( $v );
}
if ( !empty( $member ) ) {
$result = array( 'position' => $position, "name" => $name, "job" => $up_id );
}
die( json_encode( $result ) );
}
}
//js
$(function () {
$("#pickupuserDialog").dialog({
autoOpen: false,
modal: true,
width: 700,
show: "slide",
buttons: {
"确定": function () {
$(this).dialog("close");
initData(0);
},
"关闭": function () {
$(this).dialog("close");
}
}
});
}
function pickupuser() {
var job = $('#upId').val();
loading();
$.ajax({
url: '/product/off-shelf/get-picker-for-up/',
data: { 'job': job},
type: 'post',
dataType: 'json',
async: false,
success: function (json) {
var Html = "职位 <select id='upId' name='upId' width='120px;' onchange=pickupuser()>";
Html += '<option value="">请选择</option>';
$.each(json.position, function (k, v) {
if (v.up_id == job) {
Html += '<option selected="selected" value=\"' + v.up_id + '\" >' + v.up_name + '</option>';
} else {
if(json.job == v.up_id){
Html += '<option selected="selected" value=\"' + v.up_id + '\" >' + v.up_name + '</option>';
}else{
Html += '<option value=\"' + v.up_id + '\" >' + v.up_name + '</option>';
}
}
});
Html += "</select>";
Html += '<div style="float: left;width: 100%;"><hr></div>';
Html += '<table>';
$.each(json.name, function (key, val) {
//配货员
Html += '<tr><td valign="top" align="center" style="margin-right: 10px;">' + key + ':</td><td>';
$.each(val, function (k, v) {
Html += '<label style="float:left;width:100px;height: 30px;white-space:nowrap;">\n\
<span style="display:inline-block;width:100px;overflow:hidden;" title="' + v.name + '">\n\
<input style="float:left;padding-left: 5px;" type="radio" name="pickerUserId" value="' + v.id + '" pickerName="' + v.name + '"/>' + v.name + '</span></label>';
});
Html += '</td></tr>';
});
Html += '</table><div style="float: left;width: 100%;"><hr></div>';
$('#pickupuserDialog').html(Html);
$("#pickupuserDialog").dialog("open");
closeLoading();
}
});
}
根据配货员筛选订单
最新推荐文章于 2024-03-15 18:04:17 发布