3-1

本文介绍了一个使用AngularJS开发的药品库存管理系统。该系统包括药品信息的增删查改、排序及搜索功能。通过选择不同的排序方式可以对药品按库存数量或入库时间进行排序。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <!--<link rel="stylesheet" type="text/css" href="lib/css/ionic.css"/>-->
        <script src="lib/js/ionic.bundle.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
            angular.module("jun",[])
            .controller("dd",function($scope){
                $scope.order=["-------请选择排序方式","按照库存数量正序","按照库存数量倒序","按照入库时间正序","按照入库时间倒序"];
                $scope.goods=[{                    
                    "name":"云南白药",
                    "num":100,
                    "produce":"云南",
                    "price":19.9,
                    "date1":"20171120093221"
                },{
                    "name":"999感冒灵",
                    "num":30,
                    "produce":"北京",
                    "price":12.5,
                    "date1":"20171120103221"
                },{
                    "name":"感康",
                    "num":20,
                    "produce":"河北",
                    "price":16.6,
                    "date1":"20171120111111"
                }]
                $scope.isshow=false;
                $scope.change=function(){
                    var name=$scope.SelectedName;
                    if(name=="按照库存数量正序"){
                        $scope.goods.stort(function(a,b){
                            return a.num-b.num;
                        });
                    }else if(name=="按照库存数量倒序"){
                        $scope.goods.stort(function(a,b){
                            return b.num-a.num;
                        });
                    }else if(name=="按照入库时间正序"){
                        $scope.goods.stort(function(a,b){
                            return a.date1-b.date1;
                        });
                    }else if(name=="按照入库时间倒序"){
                        $scope.goods.stort(function(a,b){
                            return b.date1-a.date1;
                        });
                    }
                }
                $scope.dele=function($index){
                    var a=confirm("是否删除");
                    if (a) {
                        $scope.goods.splice($index,1);alert("删除成功");
                    }
                }
                $scope.add=function(){
                    $scope.isshow=true;
                }
                $scope.sub=function(){
                    var name=$(".name").val();
                    var num=$(".num").val();
                    var price=$(".price").val();
                    var produce=$(".produce").val();
                    var date=new Date();
                    var y=date.getFullYear();
                    var m = date.getMonth() + 1;
                    var d = date.getDate();
                    var h = date.getHours();
                    var mm = date.getMinutes();
                    var s = date.getSeconds();
                    var time = y + "年" + m + "月" + d + "日" + h + "时" + mm + "分" + s+"秒";
                    if (name=="") {
                        alert("货品为空");
                        return;
                    }
                    $scope.goods.push({
                        "name":name,
                        "num":num,
                        "produce":produce,
                        "price":price,
                        "date1":time
                    })
                    $(".name").val("");
                    $(".num").val("");
                    $(".price").val("");
                    $(".produce").val("");
                    $scope.isshow=false;
                }
            })
        </script>
    </head>
    <body ng-app="jun" ng-controller="dd">
        <div class="tab">
            <input type="text" placeholder="输入关键字搜索" class="select" ng-model="select"/>
            <div class="right">
                <select ng-model="SlectedName" ng-init="SelectedName=order[0]" ng-options="x for x in order" ng-change="change()">
                    {{x}}
                </select>
                <input type="button" value="入库" class="add" ng-click="add()"/>
            </div>
            <table border="1px" cellspacing="1px" cellpadding="1px" class="table table-striped">
                <tr style="background: #999999;">
                    <th>
                        货物名称
                    </th>
                    <th>
                        货物数量
                    </th>
                    <th>
                        货物产地
                    </th>
                    <th>
                        货物单价
                    </th>
                    <th>
                        货物入库日期
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                <tr ng-repeat="x in goods|filter:select">
                    <td>
                        {{x.name}}
                    </td>
                    <td>
                        {{x.num}}
                    </td>
                    <td>
                        {{x.produce}}
                    </td>
                    <td>
                        {{x.price|currency:"¥:"}}
                    </td>
                    <td>
                        {{x.date1|date:"yyyy年MM月dd日 hh时mm分ss秒"}}
                    </td>
                    <td>
                        <a href="javasript:void(0)" ng-click="dele($index)">删除</a>
                    </td>
                </tr>
            </table>
        </div>
        <div class="goods" ng-show="isshow">
            货物名称:
            <input type="text" class="name"/>
            货物数量:
            <input type="text" class="num"/>
            货物产地
            <input type="text" class="produce"/>
            货物单价:
            <input type="text" class="price"/>
            货物入库日期
            <input type="text" class="date1"/>
            <button ng-click="sub()" class="sub">提交</button>
        </div>
    </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值