addDevice.vue
3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<template>
<div class="addorder_page">
<glsx-dialog :show="show" width="30%">
<el-form ref="addForm" :model="form" :rules="formRules" label-width="110px">
<el-form-item label="设备名称" prop="deviceName">
<el-input v-model="form.deviceName" maxlength="10" show-word-limit />
</el-form-item>
<el-form-item label="设备类型" prop="typeId">
<el-select v-model="form.typeId" placeholder="请选择" class="el_select">
<el-option v-for="item in deviceType" :key="item.id" :value="item.id" :label="item.name">{{ item.name }}</el-option>
</el-select>
</el-form-item>
<el-form-item label="品牌定制商" prop="merchantId">
<el-select v-model="form.merchantId" placeholder="请选择" class="el_select">
<el-option v-for="item in merchantList" :key="item.merchantId" :value="item.merchantId" :label="item.merchantId + '/' + item.merchantName">{{ item.merchantId }}/{{ item.merchantName }}</el-option>
</el-select>
</el-form-item>
<el-form-item label="设备介绍">
<el-input v-model="form.remark" type="textarea" rows="5" maxlength="200" show-word-limit />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveInfo">提交</el-button>
<el-button @click="cancel">取消</el-button>
</el-form-item>
</el-form>
</glsx-dialog>
</div>
</template>
<script>
import {
FINDSENDMERCHANTNO,
INSERTANDUPDATEDEVICE
} from '@/http/interface'
import {
Validator
} from '@/common/validator'
import GlsxDialog from '@/components/dialog/index'
export default {
name: 'AddDevice',
components: {
'glsx-dialog': GlsxDialog
},
props: {
deviceType: {
type: Array,
default: function() {
return []
}
},
id: {
type: [String, Number],
default: ''
},
show: {
type: Boolean,
default: false
}
},
data() {
return {
form: {
typeId: ''
},
deviceList: [],
radio: '',
loading: false,
merchantList: [],
tableLoading: false,
formRules: {
deviceName: [{
required: true,
message: '请输入设备名称',
trigger: 'blur'
}],
typeId: [{
required: true,
message: '请选择设备类型',
trigger: 'blur'
}],
merchantId: [{
required: true,
message: '请输入品牌定制商',
trigger: 'blur'
}]
}
}
},
created() {
},
mounted: function() {
this.init()
},
methods: {
/**
* 初始化函数
*/
init: function() {
const o = this.$props || {}
this.getMerchant()
},
/**
* 保存数据
*/
saveInfo: function() {
const _this = this
const m = _this.form
const oParams = JSON.parse(JSON.stringify(m))
console.log(oParams)
_this.$refs.addForm.validate((valid) => {
if (!valid) {
return false
}
INSERTANDUPDATEDEVICE(oParams).then(res => {
if (res.returnCode == 0) {
_this.$emit('closed', true)
}
})
})
},
/**
* 关闭弹框
*/
cancel: function() {
this.$emit('closed')
},
/**
* 获取品牌定制商
*/
getMerchant: function() {
const _this = this
FINDSENDMERCHANTNO().then(res => {
console.log(res)
const { data } = res
_this.merchantList = data || []
})
}
}
}
</script>
<style lang="scss" scoped>
.addorder_page {
padding: 20px;
position: relative;
}
.el_select {
width: 100%;
}
</style>