threeMobile.vue
5.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
158
159
<template>
<el-dialog :title="title" :visible.sync="open" v-if="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="130px">
<el-form-item label="三级分类代码" prop="threeClass">
<el-input v-model="form.threeClass" placeholder="请输入三级分类代码" :disabled='disabled' />
</el-form-item>
<el-form-item label="三级分类名称" prop="name">
<el-input v-model="form.name" placeholder="请输入三级分类名称" :disabled='disabled' />
</el-form-item>
<el-form-item label="所属一级分类名称" prop="targetOneId">
<el-select v-model="form.targetOneId" placeholder="所属一级分类名称" clearable size="small" @change="yiji">
<el-option v-for="(item,index) in targetOneList" :key="index" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="所属二级分类名称" prop="targetTwoId">
<el-select v-model="form.targetTwoId" placeholder="所属二级分类名称" clearable size="small">
<el-option v-for="(item,index) in erji" :key="index" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="备注" prop="note">
<el-input v-model="form.note" type="textarea" placeholder="请输入备注" :disabled='disabled' />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</template>
<script>
import { targetThreeSave, targetThreeEdit, targetOneList,targetTwoList } from "@/api/postList/list";
export default {
name: 'indexMobile',
dicts: ['index_mobile_type', 'index_type_list'],
data() {
return {
imageUrl: '',
disabled: true,
open: false,
// 弹出层标题
title: "",
// 表单参数
form: {
},
checkList: [],
targetOneList:[],
erji:[],
// 表单校验
rules: {
threeClass: [
{ required: true, message: "三级分类代码不能为空", trigger: "blur" }
],
name: [
{ required: true, message: "三级分类名称不能为空", trigger: "blur" }
],
targetOneId:[
{ required: true, message: "一级分类名称不能为空", trigger: "blur" }
],
targetTwoId:[
{ required: true, message: "二级分类名称不能为空", trigger: "blur" }
]
},
id: ''
}
},
methods: {
// 取消按钮
cancel() {
this.open = false;
this.form = {}
},
add() {
this.open = true;
this.form = {}
this.id = ''
this.getTargetOneList()
},
edit(res) {
this.open = true;
this.form = res
this.id = res.id
this.getTargetOneList()
var p = {
id:res.targetOneId
}
targetTwoList(p).then(response => {
if (response.code == 200) {
this.erji = response.data
console.log("111111111",response.data)
} else {
}
});
},
getTargetOneList() {
targetOneList().then(response => {
if (response.code == 200) {
this.targetOneList = response.data
} else {
}
});
},
yiji(val){
console.log(val)
var p = {
id:val
}
targetTwoList(p).then(response => {
if (response.code == 200) {
this.erji = response.data
} else {
}
});
},
/** 提交按钮 */
submitForm: function () {
this.$refs["form"].validate(valid => {
this.form.id = this.id
if (valid) {
if (this.id) {
targetThreeEdit(this.form).then(response => {
if (response.code == 200) {
this.$modal.msgSuccess(response.msg);
this.open = false;
this.$emit("getList")
} else {
this.$modal.msgSuccess(response.msg);
this.open = false;
}
});
} else {
targetThreeSave(this.form).then(response => {
if (response.code == 200) {
this.$modal.msgSuccess(response.msg);
this.open = false;
this.$emit("getList")
} else {
this.$modal.msgSuccess(response.msg);
this.open = false;
}
});
}
}
});
},
}
}
</script>
<style>
.new_dialog {
height: 80%;
overflow: hidden;
overflow-y: scroll;
}
</style>