向input中输入数据报错

zhc945189
  • 1
新手上路,请多包涵

TypeError: Cannot create property 'productionNo' on string ''

at Object.eval [as setter] (eval at CSPcompile (avalon.js:78), <anonymous>:3:81)
at HTMLInputElement.updateVModel [as avalonSetter] (avalon.js:3993)

报错信息如上

以下为js代码




 /** 下达订单*/
             $(".grid-wrap").on("click", ".detail", function (e) {
                 
                 var t = $(this).parent().data("id");
                 var rowData = $("#grid").jqGrid('getRowData',t);
                 var orderNo = rowData.orderNo;
                 console.log('this is [orderNo]::::',orderNo);
                 $.ajax({
                     type:"POST",
                     url:"/api/produce/list",
                     data:{
                         "orderNo":orderNo,
                     },
                     success: function (data) {
                         console.log('this is data::::',data);
                         model.productionInfo=data;
                         console.log('this is [model.productionInfo22222222222]',model.productionInfo);
                         
                     },
                     beforeSend: function (xhr) {
                         xhr.setRequestHeader("X-AuthToken", token);
                     },
                     error: function (responseData, textStatus, errorThrown) {
                         alert("Failed: " + responseData);
                     }
                 });
                     model.edit($("#grid").getRowData(orderNo),orderNo);
                
             });
             
             
             
             
       //添加或更新
         edit: function (productionInfo,orderNo) {
             dialog({
                 title: '下达生产指令',
                 content: $('#editUser'),
                 okValue: "确定",
                 ok: function () {
             // 提交修改
                     console.log(model.productionInfo.productionNo);
                 $.ajax({    
                     type: "POST",
                     url: "/api/produce/save" ,
                     contentType: "application/json;charset=utf-8",
                     data:JSON.stringify(model.productionInfo.$model),
                     beforeSend: function (xhr) {
                         xhr.setRequestHeader("X-AuthToken", token);
                     },
                     success: function () {
                         
                         $.ajax({
                             type: "POST",
                             url: "/api/order/changeStatus" ,
//                                     contentType: "application/json;charset=utf-8",
                             data:{"orderNo":orderNo},
                             beforeSend: function (xhr) {
                                 xhr.setRequestHeader("X-AuthToken", token);
                             },
                             success: function () {
                                 window.history.go(0); 
                             },
                             error: function (responseData, textStatus, errorThrown) {
                                 alert("系统异常");
                             }
                         });
                     },
                         error: function (responseData, textStatus, errorThrown) {
                         alert("系统异常");
                     }
                 });
                //     }
                 },
                 cancelValue: "取消",
                 cancel: function () {}
             }).showModal();
         },
     

以下为html代码:

<div id="editUser" style="display: none; ">
        <form id="userForm" class="form-dl" style="height: 180px;">
            <table style="float: left; width: 50px">
                <tr>
                    <td class="left"><label>生产指令号:</label></td>
                    <td class="short applay_td"><input type="text"
                        id="productionNo" name="productionNo" class="text required"
                        ms-duplex="productionInfo.productionNo" /></td>
                </tr>
                <tr>
                    <td class="left"><label>目的港:</label></td>
                    <td class="short applay_td"><input type="text"
                        id="destination" name="destination" class="text required"
                        ms-duplex="productionInfo.destination" /></td>
                </tr>
                <tr>
                    <td class="left"><label>ceva:</label></td>
                    <td class="short applay_td"><input type="text" id="ceva"
                        name="ceva" class="text required" ms-duplex="productionInfo.ceva" /></td>
                </tr>

                <tr>
                    <td class="left"><label>质检部:</label></td>
                    <td class="short applay_td"><input type="text"
                        id="qcDepartment" name="qcDepartment" class="text"
                        ms-duplex="productionInfo.qcDepartment" /></td>
                </tr>
            </table>

            <table style="float: left ;">
                <tr>
                    <td class="left"><label>投产时间:</label></td>
                    <td class="short applay_td"><input type="text"
                        id="startingDate" name="startingDate" class="text required"
                        ms-duplex="productionInfo.startingDate" style="width: 95%;float: right;"/></td>
                </tr>
                <tr>
                    <td class="left"><label>货代:</label></td>
                    <td class="short applay_td"><input type="text"
                        id="freightForwarding" name="freightForwarding"
                        class="text required" ms-duplex="productionInfo.freightForwarding" style="width: 95%;float: right;"/></td>
                </tr>
                <tr>
                    <td class="left"><label>编制/供销部:</label></td>
                    <td class="short applay_td"><input type="text"
                        id="samDepartment" name="samDepartment" class="text required"
                        ms-duplex="productionInfo.samDepartment" style="width: 95%;float: right;"/></td>
                </tr>
                <tr>
                    <td class="left"><label>生产部:</label></td>
                    <td class="short applay_td"><input type="text"
                        id="productDepartment" name="productDepartment"
                        class="text required" ms-duplex="productionInfo.productDepartment" style="width: 95%;float: right;" /></td>
                </tr>
            </table>
            <table style="float: left ;">
                <tr>
                    <td class="left"><label>备注:</label></td>
                    </br>
                    <td class="short applay_td"><textarea type="text"
                        id="deliveriesStatus" name="deliveries_Status"
                        class="text required" ms-duplex="productionInfo.comment" style="width: 385px"></textarea></td>
                </tr>
            </table>
        </form>
    </div>
回复
阅读 1.7k
1 个回答

错误是 console.log(model.productionInfo.productionNo);
这一行报的吧?

从错误信息上看,原因是你以为它是Object对象,但是实际上model.productionInfo是string

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏