123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- @using MES.Production.Service;
- @using Central.Control.Domain;
- @using Ant.Service.Common;
- @using CommonToolHelper;
- @{
- ViewBag.Title = "添加/修改商品";
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
- @model MES.Production.Entity.Entity.YW_Product
- <style>
- body {
- background-color: white;
- }
- .changeicon {
- float: right;
- margin-right: 22px;
- position: absolute;
- right: -7px;
- top: 0px;
- border: none;
- background-color: #18a689;
- color: #FFFFFF;
- line-height: 33px;
- height: 33px;
- }
- </style>
- <link href="~/Content/uploadone/CSS/webuploader.css" rel="stylesheet" />
- <link href="~/Content/uploadone/CSS/bootstrap.min.css" rel="stylesheet" />
- <link href="~/Content/uploadone/CSS/uploadstyle.css" rel="stylesheet" />
- <link href="~/Content/uploadone/CSS/font-awesome.css" rel="stylesheet" />
- <script src="~/Content/uploadone/Script/webuploader.js"></script>
- @using (Ajax.BeginForm("Save", null, new AjaxOptions()
- {
- HttpMethod = "Post",
- OnBegin = "SubAjax.Loading",
- OnComplete = "SubAjax.Complate",
- OnFailure = "SubAjax.Failure",
- OnSuccess = "SubAjax.Success"
- },
- new { @class = "form-horizontal dig-from", @role = "form" }))
- {
- <div class="wrapper-content">
- <div class="panel-body">
- <div class="tab-content">
- <div id="tab-1" class="tab-pane active">
- @Html.HiddenFor(p => p.Id)
- <div class="form-group">
- <label class="col-lg-3 control-label">商品名称:</label>
- <div class="col-lg-8">
- @Html.TextBoxFor(p => p.Name, new { @class = "form-control", @id = "Name", @placeholder = "请输入商品名称", @datatype = "*", @nullmsg = "请输入商品名称!", @errormsg = "请输入商品名称!" })
- </div>
- </div>
- <div class="form-group">
- <label class="col-lg-3 control-label">商品编号:</label>
- <div class="col-lg-8">
- @Html.TextBoxFor(p => p.Code, new { @class = "form-control", @id = "Code", @placeholder = "请输入商品编号", @datatype = "*", @nullmsg = "请输入商品编号!", @errormsg = "请输入商品编号!" })
- </div>
- </div>
- <div class="form-group fileUpload">
- @Html.Hidden("hidfilename", Model.Img, new { @class = "hidfilename" })
- @Html.Hidden("hidfileid", Model.Img, new { @class = "hidfileid" })
- <label class="col-lg-3 control-label">图片:</label>
- <div class="col-lg-8">
- <div class="fileNameList">
- </div>
- <div class="cp_img_jia fileNamePicker"></div>
- </div>
- </div>
- <div class="form-group">
- <label class="col-lg-3 control-label">进货价:</label>
- <div class="col-lg-8">
- @Html.TextBoxFor(p => p.BuyingPrice, new { @class = "form-control", @id = "BuyingPrice", @placeholder = "请输入进货价", @type = "number", @nullmsg = "请输入进货价!", @errormsg = "请输入进货价!" })
- </div>
- </div>
- <div class="form-group">
- <label class="col-lg-3 control-label">售卖价:</label>
- <div class="col-lg-8">
- @Html.TextBoxFor(p => p.Price, new { @class = "form-control", @id = "Price", @placeholder = "请输入售卖价", @type = "number", @nullmsg = "请输入售卖价!", @errormsg = "请输入售卖价!" })
- </div>
- </div>
- <div class="form-group">
- <label class="col-lg-3 control-label">库存:</label>
- <div class="col-lg-8">
- @Html.TextBoxFor(p => p.Stock, new { @class = "form-control", @id = "Stock", @placeholder = "请输入库存", @type = "number", @nullmsg = "请输入库存!", @errormsg = "请输入库存!" })
- </div>
- </div>
- <div class="form-group hidden-1024">
- <label class="col-lg-3 control-label">商品简介:</label>
- <div class="col-lg-8">
- @Html.TextAreaFor(p => p.Info, new { @class = "form-control", @id = "Info" })
- </div>
- </div>
- <div class="hr-line-dashed">
- <div class="form-group m20" style="text-align:center">
- <div class="col-sm-2 col-sm-offset-2">
- <button class="btn btn-primary btn-save" onclick="return verificationForm()" type="submit"><i class="fa fa-check"></i> <span>确定保存</span></button>
- <button class="btn btn-warning" id="btn-dig-close" type="button"><i class="im-undo2"></i> 取消返回</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- }
- @section scripts{
- <script type="text/javascript">
- $.fn.extend(
- {
- FileUpload: function (options) {
- $(this).each(function () {
- var filename = $(this).find(".hidfilename").val();
- if (filename != null && filename != "") {
- var headstr = "<div id=\"WU_FILE_0\" class=\"cpup_img upload-state-done\"><img src=\"";
- var footstr = "\"><div class=\"upcp_img_jian\"></div><p class=\"progress hide\"><span style=\"width: 100%;\"></span></p></div>";
- $(this).find(".fileNameList").html(headstr + filename + footstr);
- }
- options = options || {};
- var applicationPath = "http://" + window.location.host;
- var fileId;
- var $list = $(this).find('.fileNameList');
- var _this = this;
- var ratio = window.devicePixelRatio || 1;
- var defaultOptions = {
- thumbnailWidth: 90 * ratio,
- thumbnailHeight: 90 * ratio,
- auto: true,
- disableGlobalDnd: true,
- swf: applicationPath + '/Script/Uploader.swf',
- server: applicationPath + '/Sys/Home/UpLoadProcess',
- pick: $(_this).find(".fileNamePicker"),
- accept: {
- title: 'Images',
- extensions: 'gif,jpg,jpeg,bmp,png',
- mimeTypes: 'image/*'
- },
- fileNumLimit: 1
- };
- options = $.extend(options, defaultOptions);
- var uploader = WebUploader.create(options);
- // 当有文件添加进来的时候
- uploader.on('fileQueued', function (file) {
- debugger;
- var $li = $(
- '<div id="' + file.id + '" class="cpup_img">' +
- '<img class="jjgimg">' +
- '<div class="upcp_img_jian"></div></div>'
- );
- var $img = $li.find('img');
- $list.children().remove();//先清空元素内容
- if (fileId != file.id && fileId != null) {
- uploader.removeFile(uploader.getFile(fileId, true));
- }
- fileId = file.id;
- $list.append($li);
- // 创建缩略图
- // 如果为非图片文件,可以不用调用此方法。
- // thumbnailWidth x thumbnailHeight 为 100 x 100
- uploader.makeThumb(file, function (error, src) {
- if (error) {
- $img.replaceWith('<span>不能预览</span>');
- return;
- }
- $img.attr('src', src);
- }, options.thumbnailWidth, options.thumbnailHeight);
- });
- //上传压缩宽度
- uploader.option('compress', {
- width: 700
- });
- // 文件上传过程中创建进度条实时显示。
- uploader.on('uploadProgress', function (file, percentage) {
- var $li = $(_this).find('#' + file.id),
- $percent = $li.find('.progress span');
- // 避免重复创建
- if (!$percent.length) {
- $percent = $('<p class="progress"><span></span></p>')
- .appendTo($li)
- .find('span');
- }
- $percent.css('width', percentage * 100 + '%');
- });
- // 文件上传成功,给item添加成功class, 用样式标记上传成功。
- uploader.on('uploadSuccess', function (file, response) {
- debugger;
- var imgurl = response.filePath; //上传图片的路径
- var fileid = response.fileid; //上传图片的路径
- $(_this).find('#' + file.id).addClass('upload-state-done');
- $(_this).find(".hidfilename").val(imgurl);
- $(_this).find(".jjgimg").attr('src', imgurl);//季健国加为了解决保存一串字符串
- $(_this).find(".hidfileid").val(fileid);
- });
- // 文件上传失败,显示上传出错。
- uploader.on('uploadError', function (file) {
- var $li = $(_this).find('#' + file.id),
- $error = $li.find('div.error');
- // 避免重复创建
- if (!$error.length) {
- $error = $('<div class="error"></div>').appendTo($li);
- }
- $error.text('上传失败');
- });
- // 完成上传完了,成功或者失败,先删除进度条。
- uploader.on('uploadComplete', function (file) {
- $(_this).find('#' + file.id).find('.progress').remove();
- });
- //所有文件上传完毕
- uploader.on("uploadFinished", function () {
- //提交表单
- });
- //开始上传
- $(this).find("#ctlUpBtn").click(function () {
- uploader.upload();
- });
- //显示删除按钮
- $(this).find(".cpup_img").on("mouseover", function () {
- $(this).children(".upcp_img_jian").css('display', 'block');
- });
- //隐藏删除按钮
- $(this).find(".cpup_img").on("mouseout", function () {
- $(this).children(".upcp_img_jian").css('display', 'none');
- });
- //执行删除方法
- $list.on("click", ".upcp_img_jian", function () {
- debugger;
- var Id = $(this).parent().attr("id");
- try {
- $(_this).find(".hidfilename").val("");
- $(_this).find(".hidfileid").val("");
- uploader.removeFile(uploader.getFile(Id, true));
- }
- catch (ex) { }
- $(this).parent().remove();
- });
- });
- }
- }
- );
- $(function () {
- $(".fileUpload").FileUpload();
- $('.form-horizontal').initValidform();
- $('.select2').select2();
- });
- function verificationForm() {
- var buyingPrice = parseInt($("#BuyingPrice").val());
- var price = parseInt($("#Price").val());
- var stock = parseInt($("#Stock").val());
- if (buyingPrice <= 0 || price <= 0) {
- dig.alertError("提示", "进货价或售卖价不能小于0");
- return false;
- }
- if (stock < 0) {
- dig.alertError("提示", "库存不能小于0");
- return false;
- }
- if (price < buyingPrice) {
- dig.alertError("提示", "当前售卖价小于进货价,即将亏本!");
- return false;
- }
- return true;
- }
- function isCardNo() {
- // 身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X
- //\d 匹配数字
- // |将两个匹配条件进行逻辑“或”(or)运算。
- //^匹配输入字符串的开始位置。
- //$匹配输入字符串的结束位置
- //()是为了提取匹配字符串的,表达式中有几个()就有几个相应的匹配字符串
- //{}一般是用来匹配的长度。比如\s{3}表示匹配三个空格,\s[1,3]表示匹配1到3个空格
- var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
- var card = document.getElementById("IDCard").value;
- //console.log(card);
- if (reg.test(card) === false) {
- dig.alertError("提示", "对不起,身份证号输入不合法!");
- return false;
- } else {
- //alert("输入正确");
- return true;
- }
- }
- </script>
- }
|