123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <script>
- $(document).ready(function () {
- //初始化数据
- $('#outTimet').datetimepicker({
- format: "Y-m-d", //格式化日期
- timepicker: false //关闭时间选项
- });
- <?php if (isset($pmData) && $pmData):?>
- //编辑页面数据初始化
- var D = "<?php echo date('Y-m-d', strtotime($pmData['outDate']));?>";
- $("#outTimet").val(D);
- var itemId = "<?php echo $itemId;?>";
- $('#itemId').val(itemId);
- var pmObj = $('.diy_select_list li[val=' + itemId + ']');
- var txt = pmObj.html();
- $('.pm_name_txt').text(txt);
- $('.item-num').text(pmObj.attr('invNo'));
- <?php else:?>
- //新增页面数据初始化
- var date = new Date;
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var day = date.getDate(); //获取当前日(1-31)
- var maxD = year + '-' + month + '-' + day;
- $("#outTimet").attr("value", maxD);
- <?php endif;?>
- //显示库存
- $(".diy_select_list>li").click(function () {
- var invNo = $(this).attr('invNo');
- var unitName = $(this).attr('unitName');
- var typeId = $(this).attr('typeId');
- $(".item-num").text(invNo);
- $(".unit-name").text(unitName);
- $("#typeId").val(typeId);
- $('.selected_item').html('');
- });
- //加减库存
- $(".reduce-out").click(function () {
- if($("#itemId").val() > 0){
- var obj = $("input[name='out_stock_num']");
- var stock_nun = parseInt(obj.val());
- if(stock_nun > 1){
- obj.val(stock_nun - 1);
- }
- }else{
- showMsg('请选择品目名称!');
- return false;
- }
- });
- $(".add-out").click(function () {
- if($("#itemId").val() > 0){
- var obj = $("input[name='out_stock_num']");
- var stock_nun = parseInt(obj.val());
- if(stock_nun < $(".item-num").text()){
- obj.val(stock_nun + 1);
- }
- }else{
- showMsg('请选择品目名称!');
- return false;
- }
- });
- //提交数据
- $(".bth-s").click(function () {
- var flag = true;
- if (flag){
- flag = false;
- //验证数据
- var outTitle = $.trim($("input[name='outTitle']").val());
- if (outTitle.length == 0) {
- showMsg('标题名称不能为空!');
- return false;
- } else if (outTitle.length > 49) {
- showMsg('标题名称不能超过50个字符!');
- return false;
- }
- var relationPmId = $("#itemId").val();
- if (relationPmId <= 0 || !relationPmId) {
- showMsg('请选择出库品名!');
- return false;
- }
- var outDate = $.trim($("input[name='out_date']").val());
- if (!outDate) {
- showMsg('出库日期不正确!');
- return false;
- }
- if (!checkDate(outDate)) {
- showMsg('出库日期不正确!');
- return false;
- }
- //领用说明
- var useExplain = $(".use-explain").val();
- var itemId = $("#itemId").val();
- if (itemId <= 0) {
- showMsg('请选择品目名称!');
- return false;
- }
- //判断出库数量
- var itemNum = parseInt($(".item-num").text());
- var outStockNum = $("input[name='out_stock_num']").val();
- if(outStockNum > itemNum){
- showMsg('出库数量不能大于库存!');
- return false;
- }
- if(itemNum <= 0){
- showMsg('出库数量必须大于0!');
- return false;
- }
- var itemType = $("input[name='itemType']:checked").val();
- if (itemType <= 0 || !itemType) {
- showMsg('请选择品目类型!');
- return false;
- }
- var fcId=0;
- if(itemType==3){
- fcId=$.trim($("#fcId").val());
- }
- var orderId=$('.orderId').html();
- var outId = "<?php echo isset($_GET['outId'])?$_GET['outId']:0;?>";
- var data = {
- itemId: relationPmId,
- useExplain: useExplain,
- outTitle: outTitle,
- outDate: outDate,
- outStockNum: outStockNum,
- outId: outId,
- itemType:itemType,
- orderId:orderId,
- fcId:fcId
- }
- //提交数据
- $.ajax({
- type: 'POST',
- url: "<?php echo $this->createUrl('imsStore/ajaxUseAdd');?>",
- data: data,
- async: false,
- dataType: 'json',
- success: function (result) {
- console.log(result);
- if (result.status == 1) {
- layer.alert("提交成功", {icon: 1,closeBtn:0}, function () {
- window.location.href = "<?php echo $this->createUrl('imsStore/useOut');?>";
- })
- } else {
- flag = true;
- layer.msg(result.msg);
- }
- },
- error: function (jqXHR, textStatus, errorThrown) {
- /*错误信息处理*/
- flag = true;
- layer.msg('提交失败');
- }
- });
- }else{
- layer.msg("稍安勿躁,正在处理中...");
- }
- });
- //计算出库数目
- function outNum(has) {
- var getNum = $("input[name='stu_get_num']").val();
- var ever = parseInt(getNum);
- $('.rel-peapor-num').html(has);
- $('.out-num').html(ever * has);
- }
- function showMsg(msg) {
- layer.msg(msg);
- }
- function checkDate(date) {
- return (new Date(date).getDate() == date.substring(date.length - 2));
- }
- $(".label-primary-cancle").click(function () {
- history.go(-1);
- });
- //品目类型切花
- $("input[name='itemType']").click(function () {
- var itemType =$(this).val();
- if(itemType){
- var outId = "<?php echo isset($_GET['outId'])?$_GET['outId']:0;?>";
- window.location.href = "<?php echo $this->createUrl('imsStore/useAddEdit/outId');?>/"+outId+"/itemType/"+itemType;
- }
- })
- });
- </script>
|