angularjs 下拉框

@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>货位档案</title>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/angularJs")
</head>
<body>
<div class="container-fluid" ng-app="myApp" ng-controller="LocationController">
<div class="row">
<div class="col-xs-11 table-responsive">
<table class="table table-bordered table-condensed" style="table-layout:unset;">
<tr>
<td colspan="17" style="text-align:center;border:none"><h2>货位档案</h2></td>
</tr>
<tr>
<td style="border:none" colspan="2"><input type="text" class="form-control" placeholder="请输入查询条件" value="" ng-model="searchstr" /></td>
<td style="border:none"></td>
<td colspan="14" style="border:none;text-align:right"><button type="button" class="btn btn-success btn-md" ng-click="btnAdd()">&nbsp;&nbsp;&nbsp;添&nbsp;&nbsp;&nbsp;加&nbsp;&nbsp;&nbsp;</button></td>
</tr>
<tr>
<th style="width:90px;">货位编码</th>
<th>货位名称</th>
<th style="width:120px;">所属仓库</th>
<th>备注</th>
<th>部门</th>
<th>部门ID</th>
<th>公司</th>
<th>公司ID</th>
<th>建档人</th>
<th>建档日期</th>
<th>编辑</th>
<th>删除</th>
</tr>
<tr ng-repeat="record in info | filter:searchstr">
<td>{{record.Id}}</td>
<td>{{record.Name}}</td>
<td>{{record.warehouseName}}</td>
<td>{{record.Remark}}</td>
<td>{{record.Department}}</td>
<td>{{record.DepartmentId}}</td>
<td>{{record.Company}}</td>
<td>{{record.CompanyId}}</td>
<td>{{record.CreateBy}}</td>
<td>{{record.CreateDate}}</td>
<td style="width:70px"><button type="button" class="btn btn-info btn-xs" ng-click="btnEdit(record)">&nbsp;&nbsp;&nbsp;编&nbsp;&nbsp;&nbsp;辑&nbsp;&nbsp;&nbsp;</button></td>
<td style="width:70px"><button type="button" class="btn btn-danger btn-xs" ng-click="btnDelete(record)">&nbsp;&nbsp;&nbsp;删&nbsp;&nbsp;&nbsp;除&nbsp;&nbsp;&nbsp;</button></td>
</tr>
</table>
@*-------------------------------------货位案模态框-----------------------------------------*@
<div class="modal fade" id="personchoose">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">请填写货位档案信息</h4>
</div>
<div class="modal-body">
<table class="table table-bordered">
<tr>
<td style="width:90px">货位名称</td>
<td><input class="form-control" type="text" name="name" ng-model="source.Name" /></td>
<td style="width:80px">所属仓库</td>
<td>
<select class="form-control" ng-options="y.Id as y.Name for (x, y) in companyDepts" ng-model="warehouse"></select>
</td>
</tr>
<tr>
<td>备注</td>
<td colspan="3">
<input class="form-control" type="text" name="name" ng-model="source.Remark" />
</td>
</tr>
<tr>
<td>建档人</td>
<td><input class="form-control" type="text" name="name" ng-model="source.CreateBy" /></td>
<td style="width:80px">建档日期</td>
<td><input class="form-control" type="date" name="name" ng-model="source.CreateDate" /></td>
</tr>
</table>
<table class="table" style="border:none">
<tr>
<td style="text-align:right"><button type="button" class="btn btn-primary btn-md" ng-click="btnSave()">&nbsp;&nbsp;&nbsp;保&nbsp;&nbsp;&nbsp;存&nbsp;&nbsp;&nbsp;</button></td>
<td style="width:60px;"><button type="button" class="btn btn-default btn-md" ng-click="btnCancel()">&nbsp;&nbsp;&nbsp;取&nbsp;&nbsp;&nbsp;消&nbsp;&nbsp;&nbsp;</button></td>
</tr>
</table>
<div class="alert alert-success" role="alert" style="text-align:center" ng-show="!showmsg == ‘‘">{{showmsg}}</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
@*-------------------------------------货位模态框end-----------------------------------------*@
@*-------------------------------------编辑模态框-----------------------------------------*@
<div class="modal fade" id="deletecom">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">确定要删除吗?</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary" ng-click="delcom()">确认</button>
<div class="alert alert-success" role="alert" style="text-align:center" ng-show="!delmsg == ‘‘">{{delmsg}}</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
@*-------------------------------------编辑模态框end-----------------------------------------*@
</div>
</div>
</div>
<script>
//日期格式
//json日期格式转换为正常格式
function jsonDateFormat(jsonDate) {
try {
var date = new Date(parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var milliseconds = date.getMilliseconds();
return date.getFullYear() + "-" + month + "-" + day;
// return date.getFullYear() + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds + "." + milliseconds;
} catch (ex) {
return "";
}
}
//主程序
var myApp = angular.module(‘myApp‘, []);
//数据控制器
myApp.controller(‘LocationController‘, function ($scope, $http, $timeout) {
//初始化提示消息
$scope.showmsg = ‘‘;
$scope.delmsg = ‘‘;
/*
$http.post("/GoodItem/GetData", {}, {}).success(function (response) {
response.CreateDate = jsonDateFormat(response.CreateDate);
response.IsBatch = response.IsBatch == "1" ? "是" : "否";
//绑定数据源
$scope.info = response;
});*/
//---------------------------------------------------------------------------
//刷新数据
$scope.GetData = function () {
$http.post("/Location/GetData", {}, {}).success(function (response) {
//绑定数据源
for (var i = 0; i < response.length; i++) {
response[i].CreateDate = jsonDateFormat(response[i].CreateDate);
}
$scope.info = response;
});
}
//点击添加按钮事件
$scope.btnAdd = function () {
$scope.state = ‘add‘;
$(‘#personchoose‘).modal(‘show‘);
}
//保存数据
$scope.btnSave = function () {
$scope.source.WarehouseId = $scope.warehouse;
$http.post("/Location/SaveData", {}, { params: { "Location": $scope.source, "savetype": $scope.state } }).success(function (response) {
if (response) {
$scope.showmsg = ‘保存成功!‘;
$timeout(function () {
$scope.showmsg = ‘‘;
$scope.source = null;//清空数据
$(‘#personchoose‘).modal(‘hide‘);
}, 800); //该函数延迟1.5秒执行
}
else {
$scope.showmsg = ‘保存失败!‘;
$timeout(function () {
$scope.showmsg = ‘‘;
$(‘#personchoose‘).modal(‘hide‘);
}, 800); //该函数延迟1.5秒执行
}
$scope.GetData();
});
}
//编辑事件
$scope.btnEdit = function (item) {
item.CreateDate = new Date(item.CreateDate);
$scope.source = item;
$scope.warehouse = item.WarehouseId;
$scope.state = ‘edit‘;
$(‘#personchoose‘).modal(‘show‘);
}
//取消按钮
$scope.btnCancel = function () {
$scope.source = null;
$(‘#personchoose‘).modal(‘hide‘);
$scope.GetData();
}
//删除按钮
$scope.btnDelete = function (item) {
$scope.delitem = item; //存值
$(‘#deletecom‘).modal(‘show‘);
}
//确认删除
$scope.delcom = function () {
$http.post("/Location/DeleteData", {}, { params: { "DeleteItem": $scope.delitem } }).success(function (response) {
$scope.delmsg = response;
$timeout(function () {
$scope.delmsg = ‘‘;
$(‘#deletecom‘).modal(‘hide‘);
}, 800); //该函数延迟1.5秒执行
$scope.GetData();//导入数据
});
};
$scope.GetData();//导入数据
//获取所属仓库
$http.post("/Location/GetWareHouse").success(function (response) {
$scope.companyDepts = response;
});
})
</script>
</body>
</html>

时间: 2024-11-08 18:58:27

angularjs 下拉框的相关文章

angularjs下拉框空白

搜索angularjs下拉框空白,可以出现很多解决方案,但是对于静态字段来说,网上目前还没有找到解决方案,如下: 1 <select class="form-control" ng-model="UserState" 2 ng-init="UserState=0"> 3 <option value="-1">选择状态</option> 4 <option value="0&q

angularjs下拉框实现渲染html

angualrjs处于安全的考虑,插值 指令会对相应字符串进行过滤,避免出现html攻击.但是在一些时候,我们需要渲染html,比如实现一个分级的下拉框,代码如下: 1 <body ng-app="app" ng-controller="controller"> 2 <select ng-model="value" ng-options="t.text for t in testList"></s

angularJs下拉框

1 只是一个下拉框 <!-- <select ng-model="areaType" ng-disabled="isDisable" class="form-control" ng-options="c.code as c.code for c in codes"> --><!-- <option value="">---请选择---</option>

【经验】angularjs 实现带查找筛选功能的select下拉框

一.背景 对于select的下拉列表,像国家选择这样的功能,全世界那么多国家,一直拉滚动条多辛苦,眼睛也要盯着找,累!so,为优化用户体验,带查找功能的下拉框是非常非常有必要的.都知道jquery里有这样的插件,但我们用的是Angularjs,更希望用双向绑定,指令的方式优雅地解决这个问题. 分析:    目标 在原来的<select ng-options="">标签上新加一个属性 select-search 就能支持查找的功能.如果这个属性没起作用,也不影响原来的sele

AngularJS: 使用ng-option生成下拉框,添加全部选择项

效果图如下: HTML代码: <div class="controls pull-left"> 消费类型: <select id="selectType" ng-model="currentType" ng-options="optiontype.id as optiontype.typeName for optiontype in typemodel"> </select> </di

angularJs实现下拉框多选

话不多说,直接上干货. 肯定需要下拉选插件.必须引入的是   注意 先后顺序 select2.css select2-bootstrap.css select2.min.js angular.min.js angular-select2.js ok,然后只需要写上一段代码就ok,如下 <input select2 select2-model="entity.brandIds" config="brandList" multiple placeholder=&q

在angular中实现下拉框的两种方式 ng-repeat和 ng-option

1. ng-repeat实现下拉框: select下拉框里option组装成下拉框,这里利用ng-repeat指令来创建 实现源码   <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>AngularJS之下拉框(方式二)</title> <script type="text/javascript" src="

Bootstrap:解决Bootstrap下拉框需要双击才能打开的问题

当使用AngularJS和Bootstrap时,会发生菜单栏navbar控件 需要点击两下才能打开的问题.解决的方法就是在页面加载后,执行如下语句: // 防止下拉菜单需要双击的bug $('.dropdown-toggle').click(function(e) { e.preventDefault(); e.stopPropagation(); return false; }); Bootstrap:解决Bootstrap下拉框需要双击才能打开的问题

读取mysql中的特定列值放入页面的下拉框中

1.使用的技术:JSP,Spring JDBC(Mapper) 2.代码 2.1 接口 public interface IMeetingRoomDao { public List<Mrcap> selectCap(); public List<Mrfloor> selectFloor(); } 2.2 实现类 @Override public List<Mrcap> selectCap() { List<Mrcap> caplist = new Array