钟表维修管理系统技术解析 维修记录(五)

维修记录模块


维修记录就是记录钟表的维修内容和所使用的配件,使用配件时会生成出库记录,记录库存的数量变化。如果单据维修完成,也可以执行完成维修的操作。


实现思路:

      当点击维修记录时跳转到维修记录的界面并且将当前行的工单录入ID设置为全局变量,当我录入记录单的时候工单录入ID作为外键插入到表中。


界面效果图:


2.2.7 (图1)


2.2.7(图2)

从界面上看这里用到的特殊控件:

表格中嵌入数字文本框(easyui-numberbox)和下拉框(easyui-combobox)

第一步:数据库

表与关系:


2.2.7(图3)

表1:维修记录(pw_GongDanWeiXiu)

用于记录钟表维修内容

列名

类型

主外键

说明

GongDanWeiXiuID

int

主键

工单维修ID

GongDanLuRuID

int

外键

工单录入ID

LuRuYuanID

int

外键

录入员ID

BiaoKe

nchar(10)

 

表壳

BiaoDai

nchar(10)

 

表带

BaTou

nchar(10)

 

表头

BoLi

nchar(10)

 

玻璃

JiXin

nchar(10)

 

机芯

ZouShi

nchar(10)

 

走时

WaiGuan

nchar(10)

 

外观

FangShui

nchar(10)

 

防水

FuWuNeiRong

nchar(400)

 

服务内容

GenXinShiJian

datetime

 

更新时间

YouXiaoFou

Bit

 

有效否

表2:维修记录明细(pw_GongDanChanPinMingXi)

用于存放维修记录时所用到的配件信息和保修内容

列名

类型

主外键

说明

GongDanChanPinMingXiID

int

主键

配件记录明细ID

GongDanWeiXiuID

int

外键

工单维修ID

ChanPinID

int

外键

产品ID

ShuLiang

decimal(18, 0)

 

数量

DanJia

decimal(18, 3)

 

单价

ChanPinCangWeiID

int

外键

产品仓位

BaoXiuQiID

int

外键

保修期ID

BaoXiuBeiZhu

nchar(400)

 

保修备注

GenXinShiJian

datetime

 

更新时间

YouXiaoFou

bit

 

有效否

表3:工单录入表(pw_GongDianLuRu)

用于存放钟表录入的信息

列名

数据类型

主键/外键

说明

GongDanLuRuID

int

主键

工单录入ID

YuanShiDanHaoID

int

外键

原始单号ID

GongDanZhuanTaiID

int

外键

工单状态ID

JinEZhuangTaiID

int

外键

金额状态ID

GongDanLeiXingID

int

外键

工单类型ID

KeHuID

int

外键

客户ID

JianXiuLeiXingID

int

外键

检修类型ID

PinPaiID

int

外键

品牌ID

GongDanRiQi

date

 

工单日期

GongDanBianHao

nchar(50)

 

工单编号

SongXiuRiQi

data

 

送修日期

YuFanRiQi

data

 

预返日期

FenYongJinE

decimal(18, 4)

 

费用金额

ZhongBiaoLeiXing

nchar(10)

 

钟表类型

BiaoKuan

nchar(10)

 

表款

GuiGe

text

 

规格/名称

XiuPeiJiLu

text

 

修配记录

JiXinXingHao

nchar(50)

 

机芯号

BiaoXingHao

nchar(50)

 

表型号

BiaoShenHao

nchar(50)

 

表身号

BiaoDaiJieShu

nchar(50)

 

表带节数

ZhongBiaoQiTaoMiaoShu

varchar(400)

 

钟表其他描述

WaiGuan

text

 

外观

KeHuZhiShu

varchar(400)

 

客户自述

YouXiaoFou

Bit

 

有效否

表4:员工表(sys_YuanGong)

列名

数据类型

主外键

说明

YuanGongID

int

主键

员工ID

LuRuYuanID

int

外键

录入员ID

JueSeID

int

外键

角色ID

YuanGongZhuangTaiID

int

外键

员工状态ID

MenDianID

int

外键

门店ID

YuanGongBianHao

nchar(50)

 

员工编号

YuanGongXingMing

nchar(50)

 

员工姓名

XingBie

nchar(50)

 

性别

JiGuan

nchar(50)

 

籍贯

XueLi

nchar(50)

 

学历

ChuShengRiQi

date

 

出生日期

ShenFenZhengHao

nchar(50)

 

身份证号

RuZhiRiQi

date

 

入职日期

RuZhiDiDian

nchar(50)

 

入职地址

YiDongShouJi

nchar(50)

 

移动手机

JiaTingDianHua

nchar(50)

 

家庭电话

DiXin

nchar(50)

 

底薪

DianZiYouXiang

nchar(50)

 

电子邮箱

TongXunDiZhi

nchar(100)

 

通讯地址

BeiZhu

nchar(100)

 

备注

GengXinShiJian

datetime

 

更新时间

YouXiaoFou

bit

 

有效否

MiMa

 

 

密码

表5:保修期表(sys_BaoXiuQi)

列名

数据类型

主键/外键

说明

BaoXiuQiID

int

主键

保修期ID

LuRuYuanID

int

外键

录入员ID

BaoXiuQiMingCheng

nchar(100)

 

保修期名称

BaoXiuTianShu

nchar(10)

 

保修天数

GengXinShiJian

datetime

 

更新时间

YouXiaoFou

bit

 

有效否

表6:仓位表 (sys_CangWei)

列名

数据类型

主/外键

说明

CangWeiID

int

主键

仓位ID

MenDianID

int

外键

门店ID

CangWeiLeiXingID

int

外键

仓位类型ID

CangWeiMingCheng

nchar(50)

 

仓位名称

PaiXuHao

nchar(50)

 

排序号

GengXinShiJian

datetime

 

更新时间

YouXiaoFou

bit

 

有效否

BeiZhu

nchar(50)

 

备注

表7:库存表 (sys_KuCun)

列名

数据类型

主键/外键

说明

CangKuID

int

主键

 库存ID

LuRuYuanID

int

外键

录入员ID

CangWeiID

int

外键

仓位ID

ChanPinID

int

外键

产品ID

KuCunShuLiang

int

 

库存数量

GengXinShiJian

datetime

 

更新时间

表8:产品资料表(sys_ChanPinZiLiao)

列名

数据类型

主键/外键

说明

ChanPinID

int

主键

产品ID

LuRuYuanID

int

外键

录入员ID

CangWeiID

int

外键

仓位ID

ChanPinLeiXingID

int

外键

产品类型ID

ChanPinZhongLeiID

int

外键

产品种类ID

ChanPinPinPaiID

int

外键

产品品牌ID

DanWeiID

int

外键

单位ID

ChanPinBianHao

nchar(50)

 

产品编号

ChanPinMingCheng

nchar(50)

 

产品名称

CaiGouDanJia

decimal(10, 4)

 

采购单价

YiJiXiaoShouJia

decimal(10, 4)

 

销售单价

ZuiShaoKuCun

int

 

最小库存数

ZuiDaKuCun

int

 

最大库存数

JianJie

varchar(500)

 

简介

GengXinShiJian

datetime

 

更新时间

YouXiaoFou

bit

 

有效否

第二步:控件使用

如后在表格里面嵌入其他控件

效果图:

2.2.7 (图4)

表格嵌入控件html代码:

               <table id="dgvWeiXiuJiLuMingXi" class="easyui-datagrid" style="width: 900px; height: 250px" 
                    data-options="singleSelect:true,onClickCell:YiChuChanPin,toolbar:'#TB'">
                    <thead>
                        <tr>
                            <th data-options="field:'ChanPinID',width:90,align:'center',hidden:true">
                                产品ID
                            </th>
                            <th data-options="field:'ChanPinCangWeiID',width:90,align:'center',hidden:true">
                                仓位ID
                            </th>
                            <th data-options="field:'ChanPinBianHao',width:120,align:'center'">
                                产品编号
                            </th>
                            <th data-options="field:'ChanPinMingCheng',width:120,align:'center'">
                                产品名称
                            </th>
                            <th data-options="field:'KuCunShuLiang',width:'100',align:'center'">
                                 库存数量
                            </th>
                            <th data-options="field:'ShuLiang',width:60,align:'center',editor:{ type: 'numberbox' , options:{ onChange : SearchInventory } }">
                                数量
                            </th>                             
                            <th data-options="field:'DanJia',width:80,align:'center',editor:'numberbox'">
                                单价
                            </th>
                            <th data-options="field:'BaoXiuQiID',width:180,align:'center',formatter:function(value,row){
                            return row.BaoXiuQiMingCheng;
                            },editor:{
                                type:'combobox',
                            options:{
                                        url:'/WeiXiuGuanLi/SelectBaoXiuQi',
                                        valueField:'BaoXiuQiID',
                                        textField:'BaoXiuQiMingCheng',                                        
                                        editable:false,
                                        onSelect:onselect
                                    }                                        
                                }">
                                保修期
                            </th>
                            <th data-options="field:'BaoXiuBeiZhu',width:200,align:'center',editor:'textbox'">
                                保修备注
                            </th>
                            <th data-options="field:'YiChu',width:60,align:'center',formatter:myformatter">
                                操作
                            </th>
                        </tr>
                    </thead>
                </table><strong>
</strong>


表格里面的下拉框绑定数据代码:

<th data-options="field:'BaoXiuQiID',width:180,align:'center',formatter:function(value,row){
                            return row.BaoXiuQiMingCheng;
                            },editor:{
                                type:'combobox',
                            options:{
                                        url:'/WeiXiuGuanLi/SelectBaoXiuQi',
                                        valueField:'BaoXiuQiID',
                                        textField:'BaoXiuQiMingCheng',                                        
                                        editable:false,
                                        onSelect:onselect
                                    }                                        
                                }">
                                保修期
                            </th><strong>
</strong>



解释:

在例里面定义一个editor,类型为combobox,然后在options里面绑定下拉框的数据也可以设置其他的属性,onSelect是下拉框选择时触发的事件。

onSelect事件触发的方法代码是:

function onselect(data, index,sd) {
        $("#dgvWeiXiuJiLuMingXi").datagrid("getSelected").BaoXiuQiMingCheng = data.BaoXiuQiMingCheng;
    }

方法里面有三个参数:第一个参数是当前行的数据,第二个参数是索引,第三个参数我也忘了,不过可以用alert()弹出来看看。

这个方法的作用是把选择的值赋值给表格。

第三步:控制器

提交维修记录要执行4个步奏(提交维修记录——>提交使用配件——>出库——>出库明细)

控制器代码:

#region 提交维修记录
        int intGongDanWeiXiuID = 0;
        public int TiJiaoWeiXiuJiLu(Models.pw_GongDanWeiXiu dtWeiXiuJiLu, int intGongDanID)
        {
            #region 报废前一条
            var varGongDanWeiXiuJiLu = (from dtGongDanWeiXiuJiLu in myMdl.pw_GongDanWeiXiu
                                        where dtGongDanWeiXiuJiLu.GongDanLuRuID == intGongDanID && dtGongDanWeiXiuJiLu.YouXiaoFou == true
                                        select dtGongDanWeiXiuJiLu);
            int intCount = varGongDanWeiXiuJiLu.Count();//获取总数
            if (intCount > 0)
            {
                var varWeiXiuJiLu = varGongDanWeiXiuJiLu.Single<Models.pw_GongDanWeiXiu>();
                #region ----回滚库存数量----
                var varPeiJian = (from dtPeiJian in myMdl.pw_GongDanChanPinMingXi
                                  where dtPeiJian.GongDanWeiXiuID == varWeiXiuJiLu.GongDanWeiXiuID
                                  select dtPeiJian).ToArray();//转数组类型
                for (var i = 0; i < varPeiJian.Count(); i++)
                {
                    int intCangWeiID = Convert.ToInt32(varPeiJian[i].ChanPinCangWeiID);
                    int intChanPinID = Convert.ToInt32(varPeiJian[i].ChanPinID);
                    int intShuLiang = Convert.ToInt32(varPeiJian[i].ShuLiang);
                    var varXiuGaiKuCun = (from dtCunKu in myMdl.sys_KuCun
                                          where dtCunKu.CangWeiID == intCangWeiID && dtCunKu.ChanPinID == intChanPinID
                                          select dtCunKu).Single<Models.sys_KuCun>();
                    varXiuGaiKuCun.KuCunShuLiang = varXiuGaiKuCun.KuCunShuLiang + intShuLiang;//改变库存数
                    varXiuGaiKuCun.GengXinShiJian = DateTime.Now;//更新时间
                    myMdl.SaveChanges();
                }
                #endregion
                varWeiXiuJiLu.YouXiaoFou = false;//修改有效否
                myMdl.SaveChanges();
            }
            #endregion
            dtWeiXiuJiLu.YouXiaoFou = true;
            dtWeiXiuJiLu.GenXinShiJian = DateTime.Now;
            dtWeiXiuJiLu.GongDanLuRuID = intGongDanID;
            myMdl.pw_GongDanWeiXiu.AddObject(dtWeiXiuJiLu);//新增
            int intCG = myMdl.SaveChanges();
            if (intCG > 0)
            {
                #region 获取当前插入单据的ID
                var varGongDanWeiXiu = (from dtGongDanWeiXiu in myMdl.pw_GongDanWeiXiu
                                        orderby dtGongDanWeiXiu.GongDanWeiXiuID descending//倒叙
                                        select dtGongDanWeiXiu).ToList();
                intGongDanWeiXiuID = varGongDanWeiXiu.First().GongDanWeiXiuID;//获取第一行的ID
                #endregion
            }
            return intGongDanWeiXiuID;
        }
        #endregion
        #region 提交使用配件
        public ActionResult PeiJianOnChuKu(Models.pw_GongDanChanPinMingXi dtPeiJian, int intChuKuID, int intWeiXiuID)
        {
            #region 提交使用配件
            dtPeiJian.GongDanWeiXiuID = intWeiXiuID;
            dtPeiJian.YouXiaoFou = true;
            dtPeiJian.GenXinShiJian = DateTime.Now;
            myMdl.pw_GongDanChanPinMingXi.AddObject(dtPeiJian);
            int i = myMdl.SaveChanges();
            int intChanPinID = Convert.ToInt32(dtPeiJian.ChanPinID);
            int intCagWeiID = Convert.ToInt32(dtPeiJian.ChanPinCangWeiID);
            int intShuLiang = Convert.ToInt32(dtPeiJian.ShuLiang);
            decimal decJinE = Convert.ToDecimal(dtPeiJian.DanJia);
            ChuKuMingXi(intChanPinID, intCagWeiID, intShuLiang, decJinE, intChuKuID);
            #endregion
            if (i > 0)
            {
                return Json(true, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(false, JsonRequestBehavior.AllowGet);
            }
        }
        public string ShengChengChuKuDanJu()//生成单据
        {
            string strNian = DateTime.Now.Year.ToString();
            string strYe = DateTime.Now.Month.ToString();
            string strTian = DateTime.Now.Day.ToString();
            var varZuiDaDanHaoShu = (from dtDanHao in myMdl.DangRiZuiDaDanShu
                                     select dtDanHao).Single<Models.DangRiZuiDaDanShu>();
            int intDanHaoShu = Convert.ToInt32(varZuiDaDanHaoShu.ChuKuDanHao) + 1;//修改最大单号数
            varZuiDaDanHaoShu.ChuKuDanHao = intDanHaoShu;
            myMdl.SaveChanges();
            string strDanHaoShu = intDanHaoShu.ToString();
            if (strDanHaoShu.Length == 1)
            {
                strDanHaoShu = "000" + strDanHaoShu;
            }
            else if (strDanHaoShu.Length == 2)
            {
                strDanHaoShu = "00" + strDanHaoShu;
            }
            else if (strDanHaoShu.Length == 3)
            {
                strDanHaoShu = "0" + strDanHaoShu;
            }
            return "CK" + strNian + (strYe.Length > 2 ? strYe : "0" + strYe) + (strTian.Length > 2 ? strTian : "0" + strTian) + strDanHaoShu;
        }
        #endregion
        #region 出库
        int intChuKuID = 0;
        public int ChuKu(string strDanJuBianHao, int intLuRuYuanID)
        {
            #region 报废出库记录
            int intMenDianID = Convert.ToInt32(Session["ShopID"]);
            var varChuKuDan = from dtChuKuDan in myMdl.pw_ChuRuKuDanJu
                              join dtLuRuYuan in myMdl.sys_YuanGong on dtChuKuDan.LuRuYuanID equals dtLuRuYuan.YuanGongID
                              where dtChuKuDan.BeiZhu.Contains(strDanJuBianHao) && dtChuKuDan.YouXiaoFou == true && dtLuRuYuan.MenDianID == intMenDianID
                              select dtChuKuDan;
            if (varChuKuDan.Count() == 1)
            {
                varChuKuDan.Single<Models.pw_ChuRuKuDanJu>().YouXiaoFou = false;
                myMdl.SaveChanges();
            }
            #endregion
            #region  出库记录
            Models.pw_ChuRuKuDanJu dtChuKu = new Models.pw_ChuRuKuDanJu();
            dtChuKu.BeiZhu = "维修使用【" + strDanJuBianHao + "】";
            dtChuKu.DanJuRiQi = DateTime.Now;
            dtChuKu.YouXiaoFou = true;
            dtChuKu.ShenHeFou = true;
            dtChuKu.GongZuoZhanID = 4;
            dtChuKu.LuRuYuanID = intLuRuYuanID;
            dtChuKu.DanJuBianHao = ShengChengChuKuDanJu();
            dtChuKu.RuKuFou = false;
            myMdl.pw_ChuRuKuDanJu.AddObject(dtChuKu);
            int i = myMdl.SaveChanges();
            #endregion
            if (i > 0)
            {
                var varChuKu = (from DtChuKu in myMdl.pw_ChuRuKuDanJu
                                orderby DtChuKu.ChuRuKuDanID descending
                                select DtChuKu).ToList();
                intChuKuID = varChuKu.First().ChuRuKuDanID;
                return intChuKuID;
            }
            else
            {
                return intChuKuID;
            }
        }
        #endregion
        #region 出库明细
        public ActionResult ChuKuMingXi(int intChanPinID, int intCangWeiID, int intShuLiang, decimal decJinE, int intChuKuID)
        {
            Models.pw_ChuRuKuDanJuMingXi myChuKuMingXi = new Models.pw_ChuRuKuDanJuMingXi();
            myChuKuMingXi.CangWeiID = intCangWeiID;
            myChuKuMingXi.ChanPinID = intChanPinID;
            myChuKuMingXi.ChuRuKuDanJuID = intChuKuID;
            myChuKuMingXi.JinE = decJinE;
            myChuKuMingXi.ShuLiang = intShuLiang;
            myChuKuMingXi.YouXiaoFou = true;
            myMdl.pw_ChuRuKuDanJuMingXi.AddObject(myChuKuMingXi);
            int i = myMdl.SaveChanges();
            if (i > 0)
            {
                #region 修改库存数
                var varXiuGaiKuCun = (from dtCunKu in myMdl.sys_KuCun
                                      where dtCunKu.CangWeiID == intCangWeiID && dtCunKu.ChanPinID == intChanPinID
                                      select dtCunKu).Single<Models.sys_KuCun>();
                varXiuGaiKuCun.KuCunShuLiang = varXiuGaiKuCun.KuCunShuLiang - intShuLiang;
                varXiuGaiKuCun.GengXinShiJian = DateTime.Now;
                myMdl.SaveChanges();
                #endregion
                return Json(true, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(false, JsonRequestBehavior.AllowGet);
            }
        }
        #endregion


第四步:视图层

视图层html代码:

<body>    
    <center>
    <table>
        <tr>
            <td style="width:5px;"></td>          
            <td style="width:250px;">工单:<label id="lblGongDanBianHao" style="color: #FF0000; border-bottom:1px solid #FF0000;"></label></td>
            <td style="width:255px;">客户:<label id="lblKeHuXingMing" style="color: #FF0000;border-bottom:1px solid #FF0000;"></label></td>
            <td style="width:255px;">电话:<label id="lblLianXiDianHua" style="color: #FF0000;border-bottom:1px solid #FF0000;"></label></td>
        </tr>
    </table>   
    <form id="formTiJiaoWeiXiuJiLu">
          <center>
            <br />
            <div class="imgl">
            钟表检测
            </div>
                    <table>
                        <tr>
                            <td style="width:250px;">
                                表壳:
                                <select id="cboBiaoKe" name="BiaoKe" class="easyui-combobox" style="width: 150px"
                                data-options="editable: false, panelHeight:'auto'">
                                <option value="无">无</option>
                                <option value="正常">正常</option>
                                <option value="变形">变形</option>
                                <option value="缺损">缺损</option>
                                </select>
                            </td>
                            <td style="width:250px;">
                                表带:
                                <select id="cboBiaoDai" name="BiaoDai" class="easyui-combobox" style="width: 150px"
                                data-options="editable: false, panelHeight:'auto'">
                                <option value="无">无</option>
                                <option value="正常">正常</option>
                                <option value="变形">变形</option>
                                <option value="缺损">缺损</option>
                                <option value="松动">松动</option>
                                </select>
                            </td>
                            <td style="width:250px;">
                                把头:
                                <select id="cboBiaoTou" name="BaTou" class="easyui-combobox" style="width: 150px"
                                data-options="editable: false, panelHeight:'auto'">
                                <option value="无">无</option>
                                <option value="正常">正常</option>
                                <option value="变形">变形</option>
                                <option value="缺损">缺损</option>
                                <option value="松动">松动</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td style="width:250px;">
                                玻璃:
                                <select id="cboBoLi" name="BoLi" class="easyui-combobox" style="width: 150px"
                                data-options="editable: false, panelHeight:'auto'">
                                <option value="无">无</option>
                                <option value="正常">正常</option>
                                <option value="变形">变形</option>
                                <option value="缺损">缺损</option>
                                <option value="松动">松动</option>
                                </select>
                            </td>
                            <td style="width:250px;">
                                机芯:
                                <select id="cboJiXin" name="JiXin" class="easyui-combobox" style="width: 150px"
                                data-options="editable: false, panelHeight:'auto'">
                                <option value="无">无</option>
                                <option value="正常">正常</option>
                                <option value="缺油">缺油</option>
                                <option value="零部件变形">零部件变形</option>
                                <option value="零部件缺损">零部件缺损</option>
                                <option value="零部件生锈">零部件生锈</option>
                                </select>
                            </td>
                        </tr>
                    </table>
            </center>
            <center>
            <br />
                <div class="imgl">钟表建议</div>
                    <table>
                        <tr>
                            <td style="width:250px">
                                走时:
                                <select id="cboZouShu" name="ZouShi" class="easyui-combobox" style="width: 150px"
                                data-options="editable: false, panelHeight:'auto'">
                                <option value="无">无</option>
                                <option value="走时正常">走时正常</option>
                                <option value="建议抹油保养">建议抹油保养</option>
                                <option value="建议更换零部件">建议更换零部件</option>
                                </select>
                            </td>
                            <td style="width:250px">
                                外观:
                                <select id="cboWeiGuan" name="WaiGuan" class="easyui-combobox" style="width: 150px"
                                data-options="editable: false, panelHeight:'auto'">
                                <option value="无">无</option>
                                <option value="正常漂亮">正常漂亮</option>
                                <option value="建议表壳翻新">建议表壳翻新</option>
                                <option value="建议表带翻新">建议表带翻新</option>
                                <option value="建议全面翻新">建议全面翻新</option>
                                <option value="建议更换表带">建议更换表带</option>
                                <option value="建议更换表带">建议更换表带</option>
                                </select>
                            </td>
                            <td style="width:250px">
                                防水:
                                <select id="cboFanShui" name="FangShui" class="easyui-combobox" style="width: 150px"
                                data-options="editable: false, panelHeight:'auto'">
                                <option value="无">无</option>
                                <option value="防水正常">防水正常</option>
                                <option value="建议检查防水">建议检查防水</option>
                                <option value="建议修复防水">建议修复防水</option>
                                </select>
                            </td>
                        </tr>
                    </table>
            </center>                            
                    <input id="txtFuWuNeiRong" name="FuWuNeiRong" class="easyui-textbox" style="width:900px;height:49px" data-options="multiline:true" />                            
                    <input id="LuRuYuan" name="LuRuYuanID" type="hidden" />
                <table id="dgvWeiXiuJiLuMingXi" class="easyui-datagrid" style="width: 900px; height: 250px" 
                    data-options="singleSelect:true,onClickCell:YiChuChanPin,toolbar:'#TB'">
                    <thead>
                        <tr>
                            <th data-options="field:'ChanPinID',width:90,align:'center',hidden:true">
                                产品ID
                            </th>
                            <th data-options="field:'ChanPinCangWeiID',width:90,align:'center',hidden:true">
                                仓位ID
                            </th>
                            <th data-options="field:'ChanPinBianHao',width:120,align:'center'">
                                产品编号
                            </th>
                            <th data-options="field:'ChanPinMingCheng',width:120,align:'center'">
                                产品名称
                            </th>
                            <th data-options="field:'KuCunShuLiang',width:'100',align:'center'">
                                 库存数量
                            </th>
                            <th data-options="field:'ShuLiang',width:60,align:'center',editor:{ type: 'numberbox' , options:{ onChange : SearchInventory } }">
                                数量
                            </th>                             
                            <th data-options="field:'DanJia',width:80,align:'center',editor:'numberbox'">
                                单价
                            </th>
                            <th data-options="field:'BaoXiuQiID',width:180,align:'center',formatter:function(value,row){
                            return row.BaoXiuQiMingCheng;
                            },editor:{
                                type:'combobox',
                            options:{
                                        url:'/WeiXiuGuanLi/SelectBaoXiuQi',
                                        valueField:'BaoXiuQiID',
                                        textField:'BaoXiuQiMingCheng',                                        
                                        editable:false,
                                        onSelect:onselect
                                    }                                        
                                }">
                                保修期
                            </th>
                            <th data-options="field:'BaoXiuBeiZhu',width:200,align:'center',editor:'textbox'">
                                保修备注
                            </th>
                            <th data-options="field:'YiChu',width:60,align:'center',formatter:myformatter">
                                操作
                            </th>
                        </tr>
                    </thead>
                </table>
            </form>
        <br />
        <table>
            <tr>
                <td><a οnclick="BaoCunWeiXiuJiLu()" class="goodButton1" style="width: 90px;height: 28px" plain="true">保存</a></td>
                <td><a οnclick="ZhongBiaoWeiXiu()" class="goodButton1_c1" style="width: 90px; height: 28px;">返回</a></td>
            </tr>
        </table>
    </center>  
    <div id="TB">
        <a οnclick="XuanZuoChangPin()" class="easyui-linkbutton" style="width: auto;height: auto;" iconcls="icon-add"  plain="true" ">选择配件</a>
        <a οnclick="butononclick()" class="easyui-linkbutton" style="width: auto;height: auto;" iconcls="icon-add"  plain="true" ">选择服务内容</a>
    </div>
    @*选择服务内容*@
    <div class="reveal-modal" id="frmXuanZheNeiRong" style="width: 330px; height: 150px; background:White;">
    <form name="formXuanZheNeiRong">
        <input name="chk" type="checkbox" value="此表()磨损严重,配换()" />此表()磨损严重,配换()<br />
        <input name="chk" type="checkbox" value="此表需要(简单/全面)翻新" />此表需要(简单/全面)翻新<br />
        <input name="chk" type="checkbox" value="此表()生锈磨损,需查修,抹油保养,微调校对" />此表()生锈磨损,需查修,抹油保养,微调校对<br />
        <input name="chk" type="checkbox" value="此表因()导致进水,需烘干更换" />此表因()导致进水,需烘干更换<br /><br />
        <center>
            <a οnclick="XuanZheNeiRong()" class="goodButton" style="width:80px;height:28px">选择</a>
        </center>
    </form>
        <a class="close-reveal-modal">×</a><!--关闭按钮-->
    </div>
    @*选择配件*@
    <div id="frmXuanZheChanPin" class="reveal-modal" style="width: 820px; height: 360px;padding: 10px; background:White; top:100px; left:400px;">
        <center>
            <table>
            <tr style="height:8px"></tr>
                <tr>
                    <td>
                        所在仓位:
                        <input id="cboCangWei" class="easyui-combobox" style="width: 150px;"
                            data-options="onLoadSuccess:LoadSuccess,editable:true" />
                        关键字:
                        <input id="txtMoHu" class="easyui-textbox" style="width: 200px;" />
                    </td>
                    <td>
                        <a οnclick="ChaXunChanPinZiLiao()" class="goodButton" style="width: 80px;height:20px">查询</a> 
                    </td>
                    <td>
                        <a οnclick="QueDingXuanZheChanPin()" class="goodButton" style="width: 80px;height:20px">确定</a> 
                    </td>
                </tr>
            </table>
                        <table id="dgvChanPinZiLiao" class="easyui-datagrid" style="width: 820px; height: 308px"
                            data-options="singleSelect:true,collapsible:true,onLoadSuccess:BangDingXuanShe,onClickCell:TiGou,onClickRow:PanDuan,footer:'#_Paging'">
                            <thead>
                                <tr>
                                    <th data-options="field:'XuanZe',width:25,align:'center',formatter: function (value, rec, rowIndex) {
                        return '<input type=\'checkbox\'  name=\'PD\' id=\'' + 'ChanPinZiLiao' + rowIndex + '\' >' ;}"></th>
                                    <th data-options="field:'ChanPinID',width:90,align:'center',hidden:true">
                                        产品ID
                                    </th>
                                    <th data-options="field:'ChanPinPinPaiID',width:90,align:'center',hidden:true">
                                        品牌ID
                                    </th>
                                    <th data-options="field:'DanWeiID',width:90,align:'center',hidden:true">
                                        单位ID
                                    </th>
                                    <th data-options="field:'CangWeiID',width:90,align:'center',hidden:true">
                                        仓位ID
                                    </th>
                                    <th data-options="field:'ChanPinLeiXingID',width:90,align:'center',hidden:true">
                                        产品类型ID
                                    </th>
                                    <th data-options="field:'ChanPinZhongLeiID',width:90,align:'center',hidden:true">
                                        产品种类ID
                                    </th>
                                    <th data-options="field:'ChanPinMingCheng',width:120,align:'center'">
                                        名称
                                    </th>
                                    <th data-options="field:'PinPaiMingCheng',width:70,align:'center'">
                                        品牌
                                    </th>
                                    <th data-options="field:'ChanPinBianHao',width:70,align:'center'">
                                        编号
                                    </th>
                                    <th data-options="field:'ChanPinLeiXing',width:70,align:'center'">
                                        类型
                                    </th>
                                    <th data-options="field:'PinZhongMingCheng',width:60,align:'center'">
                                        品种
                                    </th>
                                    <th data-options="field:'CaiGouDanJia',width:70,align:'center'">
                                        采购单价
                                    </th>
                                    <th data-options="field:'YiJiXiaoShouJia',width:70,align:'center'">
                                        销售价格
                                    </th>
                                    <th data-options="field:'BaoXiuQiXian',width:100,align:'center',hidden:true">
                                        保修期限
                                    </th>
                                    <th data-options="field:'KuCunShuLiang',width:70,align:'center'">
                                        库存
                                    </th>
                                    <th data-options="field:'CangWeiMingCheng',width:70,align:'center'">
                                        仓位
                                    </th>
                                    <th data-options="field:'ZuiShaoKuCun',width:90,align:'center',hidden:true">
                                        最少库存
                                    </th>
                                    <th data-options="field:'ZuiDaKuCun',width:90,align:'center',hidden:true">
                                        最大库存
                                    </th>
                                    <th data-options="field:'JianJie',width:100,align:'center'">
                                        简介
                                    </th>
                                    <th data-options="field:'GengXinShiJian',width:155,align:'center',hidden:true">
                                        更新时间
                                    </th>
                                </tr>
                            </thead>
                        </table>
<div class="_Paging" id="_Paging">
    <center>
    	<table class="_Layout">
        	<tr>
            <td id="_Shop"></td>
            	<td><a href="javascript:;" class="_HomePage" title="首页" οnclick="ShouYe()"></a></td>
                <td><a href="javascript:;" class="_PreviousPage" title="上一页" οnclick="ShangYiYe()"></a></td>
                 <td><input class="_Skip" id="txtTiaoZhuan" title="回车跳转" οnkeypress="TiaoZhuan(event)" οnkeyup="value=value.replace(/[^\d]/g,'') 

"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" /></td>
                <td>/<label id="lblZongYeShu"></label></td>
                <td><a href="javascript:;" class="_NextPage" title="下一页" οnclick="XiaYiYe()"></a></td>
                <td><a href="javascript:;" class="_TrailerPage" title="尾页" οnclick="WeiYe()"></a></td>
                 <td>|</td>
                <td>
                	总记录数:<label class = "_Totals" id="lblZongJiLuShu"></label>条
                </td>
            </tr>
        </table>
</center>
</div>
        </center>
        <a class="close-reveal-modal">×</a><!--关闭按钮-->
    </div>
</body>


当我们点击选择产品会弹出产品的弹窗:

2.2.7(图5)

点击确定按钮jQuery代码:
//确定选择产品
    function QueDingXuanZheChanPin(){
      var varPeiJianShu = $("#dgvWeiXiuJiLuMingXi").datagrid("getData").rows.length;
      var varChanPinZiLiao=$("#dgvChanPinZiLiao").datagrid("getData");
      for(var varRows = 0 ; varRows < varChanPinZiLiao.rows.length ; varRows++){
           var Bol = true;
           if ($('#ChanPinZiLiao' + varRows + "").prop("checked")){
                if(varPeiJianShu==0){
                    $('#dgvWeiXiuJiLuMingXi').datagrid('appendRow',{ status: 'P' });//新增一行
                    var ChanPinZiLiaoRow1 = varChanPinZiLiao.rows[varRows];
                    var PeiJian=$("#dgvWeiXiuJiLuMingXi").datagrid("getData").rows[$("#dgvWeiXiuJiLuMingXi").datagrid("getData").rows.length - 1];
                    PeiJian.ChanPinID = ChanPinZiLiaoRow1.ChanPinID;
                    PeiJian.ChanPinCangWeiID=ChanPinZiLiaoRow1.CangWeiID;
                    PeiJian.ChanPinBianHao=ChanPinZiLiaoRow1.ChanPinBianHao;
                    PeiJian.ChanPinMingCheng=ChanPinZiLiaoRow1.ChanPinMingCheng;       
                    PeiJian.ShuLiang=1;
                    PeiJian.KuCunShuLiang = ChanPinZiLiaoRow1.KuCunShuLiang;
                    PeiJian.DanJia=ChanPinZiLiaoRow1.YiJiXiaoShouJia;
                    $('#dgvWeiXiuJiLuMingXi').datagrid('refreshRow', $("#dgvWeiXiuJiLuMingXi").datagrid("getData").rows.length - 1);//刷新行
                }
                else{
                  for(var varR=0;varR<varPeiJianShu;varR++){
                     if (varChanPinZiLiao.rows[varRows].ChanPinID==$("#dgvWeiXiuJiLuMingXi").datagrid("getData").rows[varR].ChanPinID && varChanPinZiLiao.rows[varRows].CangWeiID==$("#dgvWeiXiuJiLuMingXi").datagrid("getData").rows[varR].ChanPinCangWeiID){
                        Bol=false;//判断是否存在
                     }
                     else{
                     }
                  }//for结尾
                  if(Bol==true){
                  $('#dgvWeiXiuJiLuMingXi').datagrid('appendRow',{ status: 'P' });
                  var ChanPinZiLiaoRow = varChanPinZiLiao.rows[varRows];
                  var PeiJian1=$("#dgvWeiXiuJiLuMingXi").datagrid("getData").rows[$("#dgvWeiXiuJiLuMingXi").datagrid("getData").rows.length - 1];
                  PeiJian1.ChanPinID = ChanPinZiLiaoRow.ChanPinID;
                  PeiJian1.ChanPinCangWeiID=ChanPinZiLiaoRow.CangWeiID;
                  PeiJian1.ChanPinBianHao=ChanPinZiLiaoRow.ChanPinBianHao;
                  PeiJian1.ChanPinMingCheng=ChanPinZiLiaoRow.ChanPinMingCheng;       
                  PeiJian1.ShuLiang=1;
                  PeiJian1.KuCunShuLiang = ChanPinZiLiaoRow.KuCunShuLiang;
                  PeiJian1.DanJia=ChanPinZiLiaoRow.YiJiXiaoShouJia;
                  $('#dgvWeiXiuJiLuMingXi').datagrid('refreshRow', $("#dgvWeiXiuJiLuMingXi").datagrid("getData").rows.length - 1);//刷新行
                }
              }
           }
           else{
              for(var varRS=0;varRS<varPeiJianShu;varRS++){
              if (varChanPinZiLiao.rows[varRows].ChanPinID==$("#dgvWeiXiuJiLuMingXi").datagrid("getData").rows[varRS].ChanPinID && varChanPinZiLiao.rows[varRows].CangWeiID==$("#dgvWeiXiuJiLuMingXi").datagrid("getData").rows[varRS].ChanPinCangWeiID){
                 $("#dgvWeiXiuJiLuMingXi").datagrid("deleteRow",varRS);
                 varPeiJianShu--;
              }
             }
           }
      }
      $('#frmXuanZheChanPin').css('visibility','hidden');  
      $('.reveal-modal-bg').css('display','none');       
    }

接下来我们可以按保存按钮提交我们所要保存的维修记录

JQuery代码:

//保存
    function BaoCunWeiXiuJiLu(){
        var bol=false;
         $('#dgvWeiXiuJiLuMingXi').datagrid('endEdit', endInsex); //停止编辑状态
         endInsex=undefined;
          for(var varRow=0;varRow<$('#dgvWeiXiuJiLuMingXi').datagrid("getData").rows.length;varRow++){       
            if($('#dgvWeiXiuJiLuMingXi').datagrid("getData").rows[varRow].ShuLiang=="" || $('#dgvWeiXiuJiLuMingXi').datagrid("getData").rows[varRow].ShuLiang <= 0 || $('#dgvWeiXiuJiLuMingXi').datagrid("getData").rows[varRow].DanJia==null || $('#dgvWeiXiuJiLuMingXi').datagrid("getData").rows[varRow].DanJia <0 || $('#dgvWeiXiuJiLuMingXi').datagrid("getData").rows[varRow].BaoXiuQiID==null || $('#dgvWeiXiuJiLuMingXi').datagrid("getData").rows[varRow].BaoXiuQiID==""){
                bol=true;
            }
            else{}
        }
        if(bol){
          alert("配件列表里面填写有错误或填写不完整");return;
        }
        else{
        $.ajax({
          type:'post',
          url:'../WeiXiuGuanLi/TiJiaoWeiXiuJiLu?intGongDanID='+@Session["GongDanID"],
          data: $('#formTiJiaoWeiXiuJiLu').serialize(),
          success:function(intGongDanWeiXiuID){
            if(intGongDanWeiXiuID>0){              
              if($('#dgvWeiXiuJiLuMingXi').datagrid("getData").rows.length > 0){
                $.getJSON("/WeiXiuGuanLi/ChuKu?strDanJuBianHao="+$.trim($('#lblGongDanBianHao').text())
                           +"&"+"intLuRuYuanID="+$('#LuRuYuan').val()+"&",
                           function(intChuKuID){
                             if(intChuKuID>0){
                               var PeiJian=$('#dgvWeiXiuJiLuMingXi').datagrid("getData");
                               var _ChengGongShu=0;
                               for(var varR=0;varR<=PeiJian.rows.length;varR++){//循环表格里面的数据
                                  var strPeiJian="";
                                  strPeiJian = "GongDanWeiXiuID="+intGongDanWeiXiuID+"&"+"ChanPinID="+PeiJian.rows[varR].ChanPinID+"&"+"ShuLiang="+PeiJian.rows[varR].ShuLiang
                                        +"&"+"DanJia="+PeiJian.rows[varR].DanJia+"&"+"ChanPinCangWeiID="+PeiJian.rows[varR].ChanPinCangWeiID+"&"+"BaoXiuQiID="+PeiJian.rows[varR].BaoXiuQiID
                                        +"&"+"BaoXiuBeiZhu="+PeiJian.rows[varR].BaoXiuBeiZhu + "&";//拼接表单
                                  $.ajax({
                                     type:'post',
                                     url:'../WeiXiuGuanLi/PeiJianOnChuKu?intChuKuID='+intChuKuID +"&"+"intWeiXiuID=" + intGongDanWeiXiuID,
                                     data:strPeiJian,
                                     success:function(_true){
                                        if(_true){
                                          _ChengGongShu++;
                                          if(_ChengGongShu==PeiJian.rows.length){
                                             alert("保存成功");
                                             ZhongBiaoWeiXiu();
                                          }else{}
                                        }
                                        else{}
                                     }
                                  });
                               }
                             }
                             else{
                              alert("新增出库记录单失败");
                             }
                           });
              }
              else{
                alert("保存成功");
                ZhongBiaoWeiXiu();
              }
            }
            else{
              alert("提交维修工单失败");
            }
          }
        });        
       }
    }






以上内容仅供学习,禁止用于商业用途










评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值