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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
| <script setup>
| import request from "@/utils/request"
| import {onMounted, ref, watch} from "vue";
| import {useI18n} from "vue-i18n"
| import {ElMessage} from "element-plus"
| import {useRouter,useRoute} from "vue-router"
| const { t } = useI18n()
| const router = useRouter()
| const route = useRoute()
|
|
| let basic = ref({
| basicType : ['',''],
| input:''
| })
| let options=ref([
| { "label": "订单",
| "value": "order",
| "children": [
| {
| "label": "订单类型",
| "value": "orderType"
| },
| {
| "label": "订单分类",
| "value": "orderClassify"
| },
| {
| "label": "商标选项",
| "value": "icon"
| },
| {
| "label": "包装方式",
| "value": "packType"
| },
| {
| "label": "铝条方式",
| "value": "alType"
| },
| {
| "label": "业务员",
| "value": "saleMan"
| }
| ]
| },
| {
| "label": "产品",
| "value": "product",
| "children": [
| {
| "label": "材料厚度",
| "value": "stuffThickness"
| },
| {
| "label": "材料颜色",
| "value": "stuffColor"
| },
| {
| "label": "工艺属性",
| "value": "stuffCraft"
| },
| {
| "label": "玻璃位置",
| "value": "stuffPosition"
| },
| {
| "label": "lowe",
| "value": "stuffLowE"
| },
| {
| "label": "夹胶厚度",
| "value": "InterlayerThickness"
| },
| {
| "label": "夹胶类型",
| "value": "InterlayerType"
| },
| {
| "label": "夹胶颜色",
| "value": "InterlayerColor"
| },
| {
| "label": "工艺流程",
| "value": "process"
| },
| {
| "label": "中空厚度",
| "value": "hollowThickness"
| },
| {
| "label": "充气方式",
| "value": "hollowGasType"
| },
| {
| "label": "封胶",
| "value": "hollowType"
| },
| {
| "label": "默认胶深",
| "value": "hollowGlueDepth"
| }
| ]
| },
| {
| "children": [
| {
| "label": "付款条件",
| "value": "paymentTerms"
| },
| {
| "label": "收款方式",
| "value": "payMethod"
| }
| ],
| "label": "送货",
| "value": "delivery"
| }
| ])
|
| let props = defineProps({
| rowIndex:{
| Object,
| default: null
| }
| })
| onMounted(() =>{
| if(props.rowIndex){
| basic.value.basicType[0] = props.rowIndex.basicType
| basic.value.basicType[1] = props.rowIndex.basicCategory
| basic.value.input = props.rowIndex.basicName
| }
| })
|
| const emit = defineEmits(['gaveParent'])
| const saveBasicData = () =>{
| request.post(`/basicData/addBasicData`, basic.value).then(res => {
| if (res.data) {
| ElMessage.success('保存成功')
| emit('gaveParent', true)
| }
| })
| }
| const updateBasicData = () =>{
| let submitArr = props.rowIndex
| submitArr.basicType = basic.value.basicType[0]
| submitArr.basicCategory = basic.value.basicType[1]
| submitArr.basicName = basic.value.input
| request.post(`/basicData/updateBasicData`, submitArr).then(res => {
| if (res.data) {
| ElMessage.success('修改成功')
| emit('gaveParent', true)
| }
| })
|
| }
|
| const handleChange = (value) => {
| const filterArr = options.value.filter((item) =>item.value === value[0]
| ).map((item) =>item.children.filter((item) =>item.value === value[1]))
| console.log(filterArr)
| }
|
|
| </script>
|
| <template>
| <div>
| <el-row>
| <el-col :span="4">基础类型:</el-col>
| <el-col :span="12">
| <el-cascader
| v-model="basic.basicType"
| @change="handleChange"
| :options="options"
| clearable
| placeholder=""
| :disabled="props.rowIndex"
| />
| </el-col>
| </el-row>
| <el-row>
| <el-col :span="4">名称:</el-col>
| <el-col :span="12">
| <el-input v-model="basic.input"/>
| </el-col>
| </el-row>
| <el-row>
| <el-col :span="4"></el-col>
| <el-col :span="12">
| <el-button v-show="!props.rowIndex" @click="saveBasicData" type="primary">新增</el-button>
| <el-button v-show="props.rowIndex" @click="updateBasicData" type="primary">修改</el-button>
|
| </el-col>
| </el-row>
|
| </div>
| </template>
|
| <style scoped>
| div{
| text-align: center;
| }
| .el-row{
| margin-top: 10px;
| }
| </style>
|
|