vue添加

<script src="~/Vue/vue.js"></script>
<script src="~/Vue/vue-resource.min.js"></script>
<script src="~/Vue/axios.min.js"></script>
<link href="~/layui-v2.5.6/layui/css/layui.css" rel="stylesheet" />
<script src="~/layui-v2.5.6/layui/layui.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/layer-v3.1.1/layer-v3.1.1/layer/layer.js"></script>
<script src="~/layer-v3.1.1/layer-v3.1.1/layer/mobile/layer.js"></script>
<a href="~/Vue/element/fonts/element-icons.ttf"></a>
<a href="~/Vue/element/fonts/element-icons.woff"></a>
<script src="~/element/index.js"></script>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<link href="~/element/index.css" rel="stylesheet" />
<h1>添加物料</h1>
<div id="sed">
<table class=" table table-bordered">

<tr>
<td class="layui-bg-gray">物料分类</td>
<td>
<select v-model="materialType" lay-verify="required">
<option value="0">DA</option>
<option value="1"> 礼品</option>
</select>
</td>
</tr>
<tr>
<td class="layui-bg-gray">物料用途</td>
<td>
<select v-model="materialUses" lay-verify="required" >
<option >科会室</option>
<option>圆桌会</option>
<option>城市会</option>
<option>拜访</option>
</select>
</td>
</tr>
<tr>
<td class="layui-bg-gray">物料编号</td>
<td><input type="text" v-model="list.matnrBian" required lay-verify="required" autocomplete="off" class="layui-input" pattern="/^s*$/" title="不能为空"></td>
</tr>
<tr>
<td class="layui-bg-gray">物料名称</td>
@*<td><input type="date" v-model="list.nameMaterial" required lay-verify="required" autocomplete="off" class="layui-input"></td>*@
<td><input type="text" v-model="list.nameMaterial" required lay-verify="required" autocomplete="off" class="layui-input" pattern="/^s*$/" title="不能为空"></td>
</tr>
<tr>
<td class="layui-bg-gray">单价</td>
<td><input type="text" v-model="list.pricee" required lay-verify="required" autocomplete="off" class="layui-input" pattern="/^s*$/" title="不能为空"></td>
@*<td><input type="date" v-model="list.pricee" required lay-verify="required" autocomplete="off" placeholder="0.0" class="layui-input" ></td>*@
</tr>
<tr>
<td class="layui-bg-gray">数量</td>
<td><input type="text" v-model="list.stockQty" required lay-verify="required" autocomplete="off" class="layui-input" pattern="/^s*$/" title="不能为空"></td>
</tr>
@*<tr>
<td class="layui-bg-gray">物料状态</td>
<td>
<input v-model="added" type="radio" name="1"/>&nbsp; 下架
<input type="radio" name="1" value="1"/>&nbsp; 上架
</td>
</tr>*@
</table>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
<el-button class="btn-info" v-on:click="Add()">提交</el-button>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<el-button class="btn-info" href="Index()">返回</el-button>
</div>

<script>
new Vue({
el: '#sed',
data() {
return {
list: {}, materialType: '0', materialUses:'0',added:'0',
};
},
methods:{

Add:function(){

var parmeter = new URLSearchParams();
console.log(this.list.materialType);
this.materialType ? this.materialType : 0;
this.added ? this.added : 0;


parmeter.append('MaterialType', this.materialType);
parmeter.append('MATNRBian', this.list.matnrBian);
parmeter.append('NameMaterial', this.list.nameMaterial);
parmeter.append('Pricee', this.list.pricee);
parmeter.append('StockQty', this.list.stockQty);
//parmeter.append('Added', this.added);
axios.post('http://localhost:53466/api/Meeting/Add', parmeter).then(response => {
console.log(response.data);
alert('添加成功');
location.href = "/Home/Index";
}).catch(error => (console.log(error)))
},


}
})
</script>

原文地址:https://www.cnblogs.com/zhang2000/p/13402716.html