HTML
<div id="dipCheck">
<div class="layui-form">
<div class="layui-form-item" style="width: 100%">
<label class="layui-form-label">检测类型:</label>
<div class="layui-input-inline">
<select v-model="type" lay-filter="type">
<option v-for="(val, key) in checkType" :value="key">{{ val.name }}</option>
</select>
</div>
</div>
</div>
JS
var dipCheckType = {
1: {
name: 'AA',
checkType: 1,
},
2: {
name: 'BB',
checkType: 2,
},
3: {
name: 'CC',
checkType: 3,
},
}
> var pageData = new Vue({
> el: '#dipCheck',
> data: {
> form: {
> barCode: '',
> erpOrderNo: '',
> },
> checkType: dipCheckType,
> typeData: {},
> type: null,
> },
> watch: {
> type: function (value) {
> console.log("==========观察type的值" + value)
> }
> },
> methods: {
> dipCheck: function () {
> var $this = this;
>
> $.ajax({
> url: server + '/dip/addDipCheck',
> method: 'post',
> data: JSON.stringify({
> barCode: this.form.barCode,
> checkType: this.type,
> }),
> contentType: 'application/json',
> success: function (res) {
> if (res.type == 0) {
> $this.form.erpOrderNo = res.data.erpOrderNo
> }
> layer.msg(res.msg);
> }
> })
> }
> },
> mounted: function () {
>
> var $this = this;
> $(document).off('keyup').keyup(function (e) {
> if (e.keyCode == 13) {
> $this.dipCheck();
> }
> })
>
> var $this = this;
> $this.type = localStorage.getItem('dipCheckType') || 1;
> layui.use('form', function () {
> layui.form.render();
> layui.form.on('select(type)', function (e) {
> $this.type = parseInt(e.value);
> localStorage.setItem('dipCheckType', e.value)
> })
> })
>
> }, });