|
|
@@ -1,356 +1,521 @@
|
|
1
|
1
|
<template>
|
|
2
|
2
|
|
|
3
|
|
- <el-row>
|
|
4
|
|
- <div>
|
|
5
|
|
- <el-button @click="addInfo">添加产品</el-button>
|
|
|
3
|
+ <el-row>
|
|
|
4
|
+ <div>
|
|
|
5
|
+ <el-button @click="addInfo">添加产品</el-button>
|
|
|
6
|
+ </div>
|
|
|
7
|
+ </el-row>
|
|
|
8
|
+
|
|
|
9
|
+ <el-row>
|
|
|
10
|
+ <el-table :data="filterTableData" @expand-change="loadTypes" style="width: 100%">
|
|
|
11
|
+ <el-table-column type="expand">
|
|
|
12
|
+ <template #default="scope">
|
|
|
13
|
+ <div m="4" style="margin-left: 50px;">
|
|
|
14
|
+ <h3>产品型号</h3>
|
|
|
15
|
+ <el-table :data="typeObject[`${scope.row.id}`]" :border="false">
|
|
|
16
|
+
|
|
|
17
|
+ <el-table-column label="型号图片" width="120">
|
|
|
18
|
+ <template #default="scope">
|
|
|
19
|
+ <el-image style="width: 50px; height: 30px"
|
|
|
20
|
+ :src="baseApiUrl + scope.row.typeFileInfo[scope.row.typeFile.split(',')[0]]" :fit="'scale-down'" />
|
|
|
21
|
+ </template>
|
|
|
22
|
+ </el-table-column>
|
|
|
23
|
+ <el-table-column label="型号名称" prop="type" width="120" />
|
|
|
24
|
+ <el-table-column label="型号说明" prop="typeContent" />
|
|
|
25
|
+
|
|
|
26
|
+ <el-table-column label="创建时间" prop="createTime" width="120" />
|
|
|
27
|
+
|
|
|
28
|
+ <el-table-column align="right" width="250">
|
|
|
29
|
+
|
|
|
30
|
+ <template #default="scope">
|
|
|
31
|
+ <el-button size="small" @click="handleEditType(scope.row, '')">修改</el-button>
|
|
|
32
|
+ <el-button size="small" type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
|
|
33
|
+ </template>
|
|
|
34
|
+ </el-table-column>
|
|
|
35
|
+ </el-table>
|
|
|
36
|
+ </div>
|
|
|
37
|
+ </template>
|
|
|
38
|
+ </el-table-column>
|
|
|
39
|
+ <el-table-column label="产品图片" width="120">
|
|
|
40
|
+ <template #default="scope">
|
|
|
41
|
+ <el-image style="width: 50px; height: 30px" :src="baseApiUrl + scope.row.nameFileInfo[scope.row.nameFile.split(',')[0]]"
|
|
|
42
|
+ :fit="'scale-down'" />
|
|
|
43
|
+ </template>
|
|
|
44
|
+ </el-table-column>
|
|
|
45
|
+ <el-table-column label="产品名称" prop="name" width="120" />
|
|
|
46
|
+ <el-table-column label="产品说明" prop="nameContent" />
|
|
|
47
|
+
|
|
|
48
|
+ <el-table-column label="创建时间" prop="createTime" width="120" />
|
|
|
49
|
+
|
|
|
50
|
+ <el-table-column align="right" width="250">
|
|
|
51
|
+ <template #header>
|
|
|
52
|
+ <el-input v-model="search" size="small" placeholder="请输入产品名称" />
|
|
|
53
|
+ </template>
|
|
|
54
|
+ <template #default="scope">
|
|
|
55
|
+ <el-button size="small" @click="handleEditType(scope.row, 'add')">添加型号</el-button>
|
|
|
56
|
+ <el-button size="small" @click="handleEdit(scope.row)">修改</el-button>
|
|
|
57
|
+ <el-button size="small" type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
|
|
58
|
+ </template>
|
|
|
59
|
+ </el-table-column>
|
|
|
60
|
+ </el-table>
|
|
|
61
|
+ </el-row>
|
|
|
62
|
+
|
|
|
63
|
+
|
|
|
64
|
+ <el-dialog v-model="centerDialogVisible" title="产品信息" width="500" center>
|
|
|
65
|
+
|
|
|
66
|
+ <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="auto" class="demo-ruleForm"
|
|
|
67
|
+ :size="'default'" status-icon>
|
|
|
68
|
+ <el-form-item label="产品名称" prop="name">
|
|
|
69
|
+ <el-input v-model="ruleForm.name" />
|
|
|
70
|
+ </el-form-item>
|
|
|
71
|
+ <el-form-item label="产品说明" prop="nameContent">
|
|
|
72
|
+ <el-input v-model="ruleForm.nameContent" type="textarea" />
|
|
|
73
|
+ </el-form-item>
|
|
|
74
|
+
|
|
|
75
|
+ <el-form-item label="产品图片" prop="nameFile">
|
|
|
76
|
+ <el-upload v-model:file-list="fileList" :action="uploadUrl" list-type="picture-card"
|
|
|
77
|
+ :on-preview="handlePictureCardPreview" :on-remove="handleRemove" :on-success="handeUploadSuccess" limit="8"
|
|
|
78
|
+ accept="image/*">
|
|
|
79
|
+ <el-icon>
|
|
|
80
|
+ <Plus />
|
|
|
81
|
+ </el-icon>
|
|
|
82
|
+ </el-upload>
|
|
|
83
|
+
|
|
|
84
|
+ <!-- <el-dialog v-model="dialogVisible">
|
|
|
85
|
+ <img w-full :src="dialogImageUrl" alt="Preview Image" />
|
|
|
86
|
+ </el-dialog> -->
|
|
|
87
|
+ </el-form-item>
|
|
|
88
|
+
|
|
|
89
|
+ <el-form-item>
|
|
|
90
|
+ </el-form-item>
|
|
|
91
|
+ </el-form>
|
|
|
92
|
+
|
|
|
93
|
+ <template #footer>
|
|
|
94
|
+ <div class="dialog-footer">
|
|
|
95
|
+ <el-button @click="centerDialogVisible = false">取消</el-button>
|
|
|
96
|
+ <el-button type="primary" @click="submitForm(ruleFormRef)">
|
|
|
97
|
+ 提交
|
|
|
98
|
+ </el-button>
|
|
6
|
99
|
</div>
|
|
7
|
|
- </el-row>
|
|
8
|
|
-
|
|
9
|
|
- <el-row>
|
|
10
|
|
- <el-table :data="filterTableData" style="width: 100%">
|
|
11
|
|
- <el-table-column label="产品名称" prop="name" />
|
|
12
|
|
- <el-table-column label="产品型号" prop="type" />
|
|
13
|
|
- <!-- <el-table-column label="活动" width="120">
|
|
14
|
|
- <template #default="scope">
|
|
15
|
|
- <el-image style="width: 100px; height: 50px" :src="baseApiUrl + scope.row.fileInfo[scope.row.file]"
|
|
16
|
|
- :fit="'scale-down'" />
|
|
17
|
|
- </template>
|
|
18
|
|
- </el-table-column> -->
|
|
19
|
|
-
|
|
20
|
|
- <el-table-column label="产品说明" prop="nameContent" />
|
|
21
|
|
- <el-table-column label="型号说明" prop="typeContent" />
|
|
22
|
|
- <el-table-column label="创建时间" prop="createTime" style="width: 100px;" />
|
|
23
|
|
-
|
|
24
|
|
- <el-table-column align="right" style="width: 100px;">
|
|
25
|
|
- <template #header>
|
|
26
|
|
- <el-input v-model="search" size="small" placeholder="请输入产品名称" />
|
|
27
|
|
- </template>
|
|
28
|
|
- <template #default="scope">
|
|
29
|
|
- <el-button size="small" @click="handleEdit(scope.row)">Edit</el-button>
|
|
30
|
|
- <el-button size="small" type="danger" @click="handleDelete(scope.row.id)">Delete</el-button>
|
|
31
|
|
- </template>
|
|
32
|
|
- </el-table-column>
|
|
33
|
|
- </el-table>
|
|
34
|
|
- </el-row>
|
|
35
|
|
-
|
|
36
|
|
-
|
|
37
|
|
- <el-dialog v-model="centerDialogVisible" title="产品信息" width="500" center>
|
|
38
|
|
-
|
|
39
|
|
- <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="auto" class="demo-ruleForm"
|
|
40
|
|
- :size="'default'" status-icon>
|
|
41
|
|
- <el-form-item label="产品名称" prop="name">
|
|
42
|
|
- <el-input v-model="ruleForm.name" />
|
|
43
|
|
- </el-form-item>
|
|
44
|
|
- <el-form-item label="产品说明" prop="nameContent">
|
|
45
|
|
- <el-input v-model="ruleForm.nameContent" type="textarea" />
|
|
46
|
|
- </el-form-item>
|
|
47
|
|
-
|
|
48
|
|
- <el-form-item label="产品图片" prop="nameFile">
|
|
49
|
|
- <el-upload v-model:file-list="fileList" :action="uploadUrl" list-type="picture-card"
|
|
50
|
|
- :on-preview="handlePictureCardPreview" :on-remove="handleRemove" :on-success="handeUploadSuccess" limit="8"
|
|
51
|
|
- accept="image/*">
|
|
52
|
|
- <el-icon>
|
|
53
|
|
- <Plus />
|
|
54
|
|
- </el-icon>
|
|
55
|
|
- </el-upload>
|
|
56
|
|
-
|
|
57
|
|
- <el-dialog v-model="dialogVisible">
|
|
58
|
|
- <img w-full :src="dialogImageUrl" alt="Preview Image" />
|
|
59
|
|
- </el-dialog>
|
|
60
|
|
- </el-form-item>
|
|
61
|
|
-
|
|
62
|
|
-
|
|
63
|
|
- <el-form-item label="型号名称" prop="type">
|
|
64
|
|
- <el-input v-model="ruleForm.type" />
|
|
65
|
|
- </el-form-item>
|
|
66
|
|
- <el-form-item label="型号说明" prop="typeContent">
|
|
67
|
|
- <el-input v-model="ruleForm.typeContent" type="textarea" />
|
|
68
|
|
- </el-form-item>
|
|
69
|
|
-
|
|
70
|
|
- <el-form-item label="型号图片" prop="typeFile">
|
|
71
|
|
- <el-upload v-model:file-list="typeFileList" :action="uploadUrl" list-type="picture-card"
|
|
72
|
|
- :on-preview="handlePictureCardPreview" :on-remove="handleRemove" :on-success="handeTypeUploadSuccess" limit="8"
|
|
73
|
|
- accept="image/*">
|
|
74
|
|
- <el-icon>
|
|
75
|
|
- <Plus />
|
|
76
|
|
- </el-icon>
|
|
77
|
|
- </el-upload>
|
|
78
|
|
-
|
|
79
|
|
- <el-dialog v-model="dialogVisible">
|
|
80
|
|
- <img w-full :src="dialogImageUrl" alt="Preview Image" />
|
|
81
|
|
- </el-dialog>
|
|
82
|
|
- </el-form-item>
|
|
83
|
|
-
|
|
84
|
|
- <el-form-item>
|
|
85
|
|
- </el-form-item>
|
|
86
|
|
- </el-form>
|
|
87
|
|
-
|
|
88
|
|
- <template #footer>
|
|
89
|
|
- <div class="dialog-footer">
|
|
90
|
|
- <el-button @click="centerDialogVisible = false">取消</el-button>
|
|
91
|
|
- <el-button type="primary" @click="submitForm(ruleFormRef)">
|
|
92
|
|
- 提交
|
|
93
|
|
- </el-button>
|
|
94
|
|
- </div>
|
|
95
|
|
- </template>
|
|
96
|
|
- </el-dialog>
|
|
97
|
|
- </template>
|
|
98
|
|
-
|
|
99
|
|
- <script lang="ts" setup>
|
|
100
|
|
- import { onMounted, ref, computed, reactive, toRaw } from 'vue'
|
|
101
|
|
- import request from '../../utils/request'
|
|
102
|
|
- import { Plus } from '@element-plus/icons-vue'
|
|
103
|
|
-
|
|
104
|
|
- import type { UploadProps, FormInstance } from 'element-plus'
|
|
105
|
|
- import { ElMessage, ElMessageBox } from 'element-plus'
|
|
106
|
|
- const baseApiUrl = process.env.VUE_APP_BASE_API_URL;
|
|
107
|
|
-
|
|
108
|
|
- const uploadUrl = baseApiUrl + '/system/accessories/upload'
|
|
109
|
|
-
|
|
|
100
|
+ </template>
|
|
|
101
|
+ </el-dialog>
|
|
|
102
|
+
|
|
|
103
|
+ <el-dialog v-model="dialogVisible">
|
|
|
104
|
+ <img w-full :src="dialogImageUrl" alt="Preview Image" />
|
|
|
105
|
+ </el-dialog>
|
|
|
106
|
+
|
|
|
107
|
+ <el-dialog v-model="typeDialogVisible" title="型号信息" width="500" center>
|
|
110
|
108
|
|
|
111
|
|
- const centerDialogVisible = ref(false)
|
|
112
|
|
- let ruleForm = reactive<any>({
|
|
113
|
|
- id: 0,
|
|
114
|
|
- name: '',
|
|
115
|
|
- nameContent: '',
|
|
116
|
|
- nameFile: [],
|
|
117
|
|
- type: '',
|
|
118
|
|
- typeContent: '',
|
|
119
|
|
- typeFile: [],
|
|
120
|
|
- })
|
|
121
|
|
- const fileList = ref([] as Array<any>);
|
|
|
109
|
+ <el-form ref="typeRuleFormRef" :model="typeRuleForm" :rules="typeRules" label-width="auto" class="demo-ruleForm"
|
|
|
110
|
+ :size="'default'" status-icon>
|
|
|
111
|
+
|
|
|
112
|
+ <el-form-item label="型号名称" prop="type">
|
|
|
113
|
+ <el-input v-model="typeRuleForm.type" />
|
|
|
114
|
+ </el-form-item>
|
|
|
115
|
+ <el-form-item label="型号说明" prop="typeContent">
|
|
|
116
|
+ <el-input v-model="typeRuleForm.typeContent" type="textarea" />
|
|
|
117
|
+ </el-form-item>
|
|
|
118
|
+
|
|
|
119
|
+ <el-form-item label="型号图片" prop="typeFile">
|
|
|
120
|
+ <el-upload v-model:file-list="typeFileList" :action="uploadUrl" list-type="picture-card"
|
|
|
121
|
+ :on-preview="handlePictureCardPreview" :on-remove="handleRemove" :on-success="handeTypeUploadSuccess" limit="8"
|
|
|
122
|
+ accept="image/*">
|
|
|
123
|
+ <el-icon>
|
|
|
124
|
+ <Plus />
|
|
|
125
|
+ </el-icon>
|
|
|
126
|
+ </el-upload>
|
|
|
127
|
+
|
|
|
128
|
+ </el-form-item>
|
|
|
129
|
+
|
|
|
130
|
+ <el-form-item>
|
|
|
131
|
+ </el-form-item>
|
|
|
132
|
+ </el-form>
|
|
|
133
|
+
|
|
|
134
|
+ <template #footer>
|
|
|
135
|
+ <div class="dialog-footer">
|
|
|
136
|
+ <el-button @click="typeDialogVisible = false">取消</el-button>
|
|
|
137
|
+ <el-button type="primary" @click="typeSubmitForm(typeRuleFormRef)">
|
|
|
138
|
+ 提交
|
|
|
139
|
+ </el-button>
|
|
|
140
|
+ </div>
|
|
|
141
|
+ </template>
|
|
|
142
|
+ </el-dialog>
|
|
|
143
|
+</template>
|
|
|
144
|
+
|
|
|
145
|
+<script lang="ts" setup>
|
|
|
146
|
+import { onMounted, ref, computed, reactive, toRaw } from 'vue'
|
|
|
147
|
+import request from '../../utils/request'
|
|
|
148
|
+import { Plus } from '@element-plus/icons-vue'
|
|
|
149
|
+
|
|
|
150
|
+import type { UploadProps, FormInstance } from 'element-plus'
|
|
|
151
|
+import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
152
|
+const baseApiUrl = process.env.VUE_APP_BASE_API_URL;
|
|
|
153
|
+const typeObject = ref({} as any);
|
|
|
154
|
+
|
|
|
155
|
+const uploadUrl = baseApiUrl + '/system/accessories/upload'
|
|
|
156
|
+
|
|
|
157
|
+
|
|
|
158
|
+const centerDialogVisible = ref(false)
|
|
|
159
|
+const typeDialogVisible = ref(false)
|
|
|
160
|
+let ruleForm = reactive<any>({
|
|
|
161
|
+ id: 0,
|
|
|
162
|
+ name: '',
|
|
|
163
|
+ nameContent: '',
|
|
|
164
|
+ nameFile: [],
|
|
|
165
|
+ type: '',
|
|
|
166
|
+ typeContent: '',
|
|
|
167
|
+ typeFile: [],
|
|
|
168
|
+})
|
|
|
169
|
+let typeRuleForm = reactive<any>({
|
|
|
170
|
+ id: 0,
|
|
|
171
|
+ productId: 0,
|
|
|
172
|
+ type: '',
|
|
|
173
|
+ typeContent: '',
|
|
|
174
|
+ typeFile: [],
|
|
|
175
|
+})
|
|
|
176
|
+const fileList = ref([] as Array<any>);
|
|
122
|
177
|
const typeFileList = ref([] as Array<any>);
|
|
123
|
|
- const ruleFormRef = ref<FormInstance>()
|
|
124
|
|
-
|
|
125
|
|
- const rules = reactive<any>({
|
|
126
|
|
- name: [
|
|
127
|
|
- { required: true, message: '请输入信息', trigger: 'blur' },
|
|
128
|
|
- { max: 15, message: '长度不能超过15', trigger: 'blur' },
|
|
129
|
|
- ],
|
|
130
|
|
- nameContent: [
|
|
131
|
|
- {
|
|
132
|
|
- required: true,
|
|
133
|
|
- message: '请输入内容',
|
|
134
|
|
- trigger: 'blur',
|
|
135
|
|
- },
|
|
136
|
|
- { max: 1000, message: '长度不能超过1000', trigger: 'blur' },
|
|
137
|
|
- ],
|
|
138
|
|
- nameFile: [
|
|
139
|
|
- {
|
|
140
|
|
- type: 'Array',
|
|
141
|
|
- required: true,
|
|
142
|
|
- message: '请上传图片',
|
|
143
|
|
- },
|
|
144
|
|
- ],
|
|
145
|
|
- type: [
|
|
146
|
|
- { required: true, message: '请输入信息', trigger: 'blur' },
|
|
147
|
|
- { max: 15, message: '长度不能超过15', trigger: 'blur' },
|
|
148
|
|
- ],
|
|
149
|
|
- typeContent: [
|
|
150
|
|
- {
|
|
151
|
|
- required: true,
|
|
152
|
|
- message: '请输入内容',
|
|
153
|
|
- trigger: 'blur',
|
|
154
|
|
- },
|
|
155
|
|
- { max: 1000, message: '长度不能超过1000', trigger: 'blur' },
|
|
156
|
|
- ],
|
|
157
|
|
- typeFile: [
|
|
158
|
|
- {
|
|
159
|
|
- type: 'Array',
|
|
160
|
|
- required: true,
|
|
161
|
|
- message: '请上传图片',
|
|
162
|
|
- },
|
|
163
|
|
- ],
|
|
164
|
|
- })
|
|
165
|
|
-
|
|
166
|
|
- const handeUploadSuccess = (res: any, uploadFile: any) => {
|
|
167
|
|
- const { Id } = res.data;
|
|
168
|
|
- if (Id) {
|
|
169
|
|
- ruleForm.nameFile.push(Id);
|
|
170
|
|
-
|
|
171
|
|
- uploadFile.uid = Id;
|
|
172
|
|
- uploadFile.name = Id;
|
|
173
|
|
- fileList.value[fileList.value.length -1] = uploadFile;
|
|
174
|
|
- }
|
|
|
178
|
+const ruleFormRef = ref<FormInstance>()
|
|
|
179
|
+const typeRuleFormRef = ref<FormInstance>()
|
|
|
180
|
+
|
|
|
181
|
+const rules = reactive<any>({
|
|
|
182
|
+ name: [
|
|
|
183
|
+ { required: true, message: '请输入信息', trigger: 'blur' },
|
|
|
184
|
+ { max: 15, message: '长度不能超过15', trigger: 'blur' },
|
|
|
185
|
+ ],
|
|
|
186
|
+ nameContent: [
|
|
|
187
|
+ {
|
|
|
188
|
+ required: true,
|
|
|
189
|
+ message: '请输入内容',
|
|
|
190
|
+ trigger: 'blur',
|
|
|
191
|
+ },
|
|
|
192
|
+ { max: 1000, message: '长度不能超过1000', trigger: 'blur' },
|
|
|
193
|
+ ],
|
|
|
194
|
+ nameFile: [
|
|
|
195
|
+ {
|
|
|
196
|
+ type: 'Array',
|
|
|
197
|
+ required: true,
|
|
|
198
|
+ message: '请上传图片',
|
|
|
199
|
+ },
|
|
|
200
|
+ ],
|
|
|
201
|
+ // type: [
|
|
|
202
|
+ // { required: true, message: '请输入信息', trigger: 'blur' },
|
|
|
203
|
+ // { max: 15, message: '长度不能超过15', trigger: 'blur' },
|
|
|
204
|
+ // ],
|
|
|
205
|
+ // typeContent: [
|
|
|
206
|
+ // {
|
|
|
207
|
+ // required: true,
|
|
|
208
|
+ // message: '请输入内容',
|
|
|
209
|
+ // trigger: 'blur',
|
|
|
210
|
+ // },
|
|
|
211
|
+ // { max: 1000, message: '长度不能超过1000', trigger: 'blur' },
|
|
|
212
|
+ // ],
|
|
|
213
|
+ // typeFile: [
|
|
|
214
|
+ // {
|
|
|
215
|
+ // type: 'Array',
|
|
|
216
|
+ // required: true,
|
|
|
217
|
+ // message: '请上传图片',
|
|
|
218
|
+ // },
|
|
|
219
|
+ // ],
|
|
|
220
|
+})
|
|
|
221
|
+
|
|
|
222
|
+const typeRules = reactive<any>({
|
|
|
223
|
+ type: [
|
|
|
224
|
+ { required: true, message: '请输入信息', trigger: 'blur' },
|
|
|
225
|
+ { max: 15, message: '长度不能超过15', trigger: 'blur' },
|
|
|
226
|
+ ],
|
|
|
227
|
+ typeContent: [
|
|
|
228
|
+ {
|
|
|
229
|
+ required: true,
|
|
|
230
|
+ message: '请输入内容',
|
|
|
231
|
+ trigger: 'blur',
|
|
|
232
|
+ },
|
|
|
233
|
+ { max: 1000, message: '长度不能超过1000', trigger: 'blur' },
|
|
|
234
|
+ ],
|
|
|
235
|
+ typeFile: [
|
|
|
236
|
+ {
|
|
|
237
|
+ type: 'Array',
|
|
|
238
|
+ required: true,
|
|
|
239
|
+ message: '请上传图片',
|
|
|
240
|
+ },
|
|
|
241
|
+ ],
|
|
|
242
|
+})
|
|
|
243
|
+
|
|
|
244
|
+const handeUploadSuccess = (res: any, uploadFile: any) => {
|
|
|
245
|
+ const { Id } = res.data;
|
|
|
246
|
+ if (Id) {
|
|
|
247
|
+ ruleForm.nameFile.push(Id);
|
|
|
248
|
+
|
|
|
249
|
+ uploadFile.uid = Id;
|
|
|
250
|
+ uploadFile.name = Id;
|
|
|
251
|
+ fileList.value[fileList.value.length - 1] = uploadFile;
|
|
175
|
252
|
}
|
|
|
253
|
+}
|
|
176
|
254
|
|
|
177
|
|
- const handeTypeUploadSuccess = (res: any, uploadFile: any) => {
|
|
178
|
|
- const { Id } = res.data;
|
|
179
|
|
- if (Id) {
|
|
180
|
|
- ruleForm.typeFile.push(Id);
|
|
|
255
|
+const loadTypes = async (clickRow: any, row: any) => {
|
|
181
|
256
|
|
|
182
|
|
- uploadFile.uid = Id;
|
|
183
|
|
- uploadFile.name = Id;
|
|
184
|
|
- typeFileList.value[typeFileList.value.length -1] = uploadFile;
|
|
185
|
|
- }
|
|
|
257
|
+ // 获取型号列表信息
|
|
|
258
|
+ if (row && row.length > 0) {
|
|
|
259
|
+ const res = await request.get(`/Type/type?productId=${clickRow.id}`);
|
|
|
260
|
+
|
|
|
261
|
+ if (res.data.length > 0) typeObject.value[`${clickRow.id}`] = res.data;
|
|
186
|
262
|
}
|
|
187
|
|
-
|
|
188
|
|
- const submitForm = async (formEl: FormInstance | undefined) => {
|
|
189
|
|
- if (!formEl) return
|
|
190
|
|
- const valRes = await formEl.validate((valid) => {
|
|
191
|
|
- if (valid) {
|
|
192
|
|
- return true;
|
|
193
|
|
- } else {
|
|
194
|
|
- return true;
|
|
195
|
|
- }
|
|
196
|
|
- })
|
|
197
|
|
-
|
|
198
|
|
- if (!valRes) return;
|
|
199
|
|
-
|
|
200
|
|
- // console.log(toRaw(ruleForm), 'ruleForm')
|
|
201
|
263
|
|
|
202
|
|
- const params = toRaw(ruleForm);
|
|
203
|
264
|
|
|
204
|
|
- params.nameFile = params.nameFile.join(',');
|
|
205
|
|
- params.typeFile = params.typeFile.join(',');
|
|
206
|
265
|
|
|
207
|
|
- // 提交
|
|
208
|
|
- let res: any;
|
|
209
|
|
- if (ruleForm.id) {
|
|
210
|
|
- res = await request.put('/Product/product', params);
|
|
|
266
|
+}
|
|
|
267
|
+
|
|
|
268
|
+const handeTypeUploadSuccess = (res: any, uploadFile: any) => {
|
|
|
269
|
+ const { Id } = res.data;
|
|
|
270
|
+ if (Id) {
|
|
|
271
|
+ typeRuleForm.typeFile.push(Id);
|
|
|
272
|
+
|
|
|
273
|
+ uploadFile.uid = Id;
|
|
|
274
|
+ uploadFile.name = Id;
|
|
|
275
|
+ typeFileList.value[typeFileList.value.length - 1] = uploadFile;
|
|
|
276
|
+ }
|
|
|
277
|
+}
|
|
|
278
|
+
|
|
|
279
|
+const typeSubmitForm = async (formEl: FormInstance | undefined) => {
|
|
|
280
|
+ if (!formEl) return
|
|
|
281
|
+ const valRes = await formEl.validate((valid) => {
|
|
|
282
|
+ if (valid) {
|
|
|
283
|
+ return true;
|
|
211
|
284
|
} else {
|
|
212
|
|
- delete params.id;
|
|
213
|
|
- res = await request.post('/Product/product', params);
|
|
|
285
|
+ return true;
|
|
214
|
286
|
}
|
|
215
|
|
-
|
|
216
|
|
- await alterRes(res);
|
|
217
|
|
-
|
|
218
|
|
-
|
|
|
287
|
+ })
|
|
|
288
|
+
|
|
|
289
|
+ if (!valRes) return;
|
|
|
290
|
+
|
|
|
291
|
+ const params = toRaw(typeRuleForm);
|
|
|
292
|
+
|
|
|
293
|
+ params.typeFile = params.typeFile.filter((o: string) => {
|
|
|
294
|
+ return !!o;
|
|
|
295
|
+ }).join(',');
|
|
|
296
|
+
|
|
|
297
|
+ // 提交
|
|
|
298
|
+ let res: any;
|
|
|
299
|
+ if (typeRuleForm.id) {
|
|
|
300
|
+ res = await request.put('/Type/type', params);
|
|
|
301
|
+ } else {
|
|
|
302
|
+ delete params.id;
|
|
|
303
|
+ res = await request.post('/Type/type', params);
|
|
219
|
304
|
}
|
|
220
|
|
-
|
|
221
|
|
- const alterRes = async (res: any) => {
|
|
222
|
|
- if (res.state === 'success') {
|
|
223
|
|
- ElMessage({
|
|
224
|
|
- message: '操作成功',
|
|
225
|
|
- type: 'success',
|
|
226
|
|
- })
|
|
227
|
|
- await getList();
|
|
228
|
|
- centerDialogVisible.value = false;
|
|
|
305
|
+
|
|
|
306
|
+ await alterRes(res);
|
|
|
307
|
+
|
|
|
308
|
+}
|
|
|
309
|
+
|
|
|
310
|
+const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
311
|
+ if (!formEl) return
|
|
|
312
|
+ const valRes = await formEl.validate((valid) => {
|
|
|
313
|
+ if (valid) {
|
|
|
314
|
+ return true;
|
|
229
|
315
|
} else {
|
|
230
|
|
- ElMessage({
|
|
231
|
|
- message: res.message,
|
|
232
|
|
- type: 'error',
|
|
233
|
|
- })
|
|
|
316
|
+ return true;
|
|
234
|
317
|
}
|
|
|
318
|
+ })
|
|
|
319
|
+
|
|
|
320
|
+ if (!valRes) return;
|
|
|
321
|
+
|
|
|
322
|
+
|
|
|
323
|
+ const params = toRaw(ruleForm);
|
|
|
324
|
+
|
|
|
325
|
+ params.nameFile = params.nameFile.join(',');
|
|
|
326
|
+
|
|
|
327
|
+ // 提交
|
|
|
328
|
+ let res: any;
|
|
|
329
|
+ if (ruleForm.id) {
|
|
|
330
|
+ res = await request.put('/Product/product', params);
|
|
|
331
|
+ } else {
|
|
|
332
|
+ delete params.id;
|
|
|
333
|
+ res = await request.post('/Product/product', params);
|
|
235
|
334
|
}
|
|
236
|
|
-
|
|
237
|
|
- const search = ref('')
|
|
238
|
|
- const filterTableData = computed(() =>
|
|
239
|
|
- tableData.value.filter(
|
|
240
|
|
- (data: any) =>
|
|
|
335
|
+
|
|
|
336
|
+ await alterRes(res);
|
|
|
337
|
+
|
|
|
338
|
+
|
|
|
339
|
+}
|
|
|
340
|
+
|
|
|
341
|
+const alterRes = async (res: any) => {
|
|
|
342
|
+ if (res.state === 'success') {
|
|
|
343
|
+ ElMessage({
|
|
|
344
|
+ message: '操作成功',
|
|
|
345
|
+ type: 'success',
|
|
|
346
|
+ })
|
|
|
347
|
+ await getList();
|
|
|
348
|
+ centerDialogVisible.value = false;
|
|
|
349
|
+ typeDialogVisible.value = false;
|
|
|
350
|
+ } else {
|
|
|
351
|
+ ElMessage({
|
|
|
352
|
+ message: res.message,
|
|
|
353
|
+ type: 'error',
|
|
|
354
|
+ })
|
|
|
355
|
+ }
|
|
|
356
|
+}
|
|
|
357
|
+
|
|
|
358
|
+const search = ref('')
|
|
|
359
|
+const filterTableData = computed(() =>
|
|
|
360
|
+ tableData.value.filter(
|
|
|
361
|
+ (data: any) =>
|
|
241
|
362
|
!search.value ||
|
|
242
|
|
- (data.name && data.name.toLowerCase().includes(search.value.toLowerCase()))
|
|
243
|
|
- )
|
|
|
363
|
+ (data.name && data.name.toLowerCase().includes(search.value.toLowerCase()))
|
|
244
|
364
|
)
|
|
245
|
|
-
|
|
246
|
|
- const handleEdit = (row: any) => {
|
|
247
|
|
- ruleForm.name = row.name;
|
|
248
|
|
- ruleForm.nameContent = row.nameContent;
|
|
249
|
|
- ruleForm.nameFile = row.nameFile.split(',');
|
|
250
|
|
- ruleForm.type = row.type;
|
|
251
|
|
- ruleForm.typeContent = row.typeContent;
|
|
252
|
|
- ruleForm.typeFile = row.typeFile.split(',');
|
|
253
|
|
- ruleForm.id = row.id;
|
|
254
|
|
- fileList.value = [];
|
|
255
|
|
- typeFileList.value = [];
|
|
256
|
|
- console.log(toRaw(ruleForm).nameFile, 'ruleForm.nameFile')
|
|
257
|
|
- if (ruleForm.nameFile) {
|
|
258
|
|
-
|
|
259
|
|
- toRaw(ruleForm).nameFile.forEach((o: any) => {
|
|
260
|
|
- fileList.value.push({
|
|
261
|
|
- uid: o,
|
|
262
|
|
- name: o,
|
|
263
|
|
- url: baseApiUrl + (row.nameFileInfo as any)[`${o}`],
|
|
264
|
|
- });
|
|
265
|
|
- })
|
|
266
|
|
-
|
|
267
|
|
- }
|
|
|
365
|
+)
|
|
268
|
366
|
|
|
269
|
|
- if (ruleForm.typeFile) {
|
|
270
|
|
- toRaw(ruleForm).typeFile.forEach((o: any) => {
|
|
271
|
|
- typeFileList.value.push({
|
|
272
|
|
- uid: o,
|
|
273
|
|
- name: o,
|
|
274
|
|
- url: baseApiUrl + (row.typeFileInfo as any)[`${o}`],
|
|
275
|
|
- });
|
|
276
|
|
- })
|
|
277
|
|
- }
|
|
278
|
|
-
|
|
279
|
|
-
|
|
280
|
|
- centerDialogVisible.value = true;
|
|
281
|
|
-
|
|
282
|
|
- }
|
|
283
|
|
- const handleDelete = (id: number) => {
|
|
284
|
|
- ElMessageBox.confirm(
|
|
285
|
|
- '确定删除该活动吗?',
|
|
286
|
|
- 'Warning',
|
|
287
|
|
- {
|
|
288
|
|
- confirmButtonText: '确定',
|
|
289
|
|
- cancelButtonText: '取消',
|
|
290
|
|
- type: 'warning',
|
|
291
|
|
- }
|
|
292
|
|
- )
|
|
293
|
|
- .then(async () => {
|
|
294
|
|
-
|
|
295
|
|
- const res: any = await request.delete('/Product/product/' + id);
|
|
296
|
|
-
|
|
297
|
|
- await alterRes(res);
|
|
|
367
|
+const handleEditType = (row: any, type: string) => {
|
|
|
368
|
+ typeRuleForm.type = type === 'add' ? '' : row.type;
|
|
|
369
|
+ typeRuleForm.typeContent = type === 'add' ? '' : row.typeContent;
|
|
|
370
|
+ typeRuleForm.typeFile = type === 'add' ? [] : row.typeFile.split(',');
|
|
|
371
|
+ typeRuleForm.id = type === 'add' ? 0 : row.id;
|
|
|
372
|
+ typeRuleForm.productId = type === 'add' ? row.id : row.productId;
|
|
|
373
|
+ typeFileList.value = [];
|
|
|
374
|
+
|
|
|
375
|
+
|
|
|
376
|
+ if (typeRuleForm.typeFile) {
|
|
|
377
|
+ toRaw(typeRuleForm).typeFile.forEach((o: any) => {
|
|
|
378
|
+ typeFileList.value.push({
|
|
|
379
|
+ uid: o,
|
|
|
380
|
+ name: o,
|
|
|
381
|
+ url: baseApiUrl + (row.typeFileInfo as any)[`${o}`],
|
|
298
|
382
|
});
|
|
|
383
|
+ })
|
|
299
|
384
|
}
|
|
300
|
|
-
|
|
301
|
|
- let tableData = ref([]);
|
|
302
|
|
-
|
|
303
|
|
- const getList = async () => {
|
|
304
|
|
- const res = await request.get('/Product/product');
|
|
305
|
|
-
|
|
306
|
|
- if (res.data.length > 0) tableData.value = res.data;
|
|
|
385
|
+
|
|
|
386
|
+
|
|
|
387
|
+ typeDialogVisible.value = true;
|
|
|
388
|
+
|
|
|
389
|
+}
|
|
|
390
|
+
|
|
|
391
|
+const handleEdit = (row: any) => {
|
|
|
392
|
+ ruleForm.name = row.name;
|
|
|
393
|
+ ruleForm.nameContent = row.nameContent;
|
|
|
394
|
+ ruleForm.nameFile = row.nameFile.split(',');
|
|
|
395
|
+ ruleForm.id = row.id;
|
|
|
396
|
+ fileList.value = [];
|
|
|
397
|
+ if (ruleForm.nameFile) {
|
|
|
398
|
+
|
|
|
399
|
+ toRaw(ruleForm).nameFile.forEach((o: any) => {
|
|
|
400
|
+ fileList.value.push({
|
|
|
401
|
+ uid: o,
|
|
|
402
|
+ name: o,
|
|
|
403
|
+ url: baseApiUrl + (row.nameFileInfo as any)[`${o}`],
|
|
|
404
|
+ });
|
|
|
405
|
+ })
|
|
|
406
|
+
|
|
307
|
407
|
}
|
|
308
|
|
-
|
|
309
|
|
- onMounted(async () => {
|
|
310
|
|
-
|
|
311
|
|
- await getList();
|
|
312
|
|
- })
|
|
313
|
|
-
|
|
314
|
|
-
|
|
315
|
|
-
|
|
316
|
|
-
|
|
317
|
|
-
|
|
318
|
|
- const handleRemove: UploadProps['onRemove'] = (uploadFile: any, uploadFiles: any) => {
|
|
319
|
|
- console.log(uploadFile, uploadFiles)
|
|
320
|
408
|
|
|
321
|
|
- ruleForm.nameFile = ruleForm.nameFile.filter((o: string) => {
|
|
322
|
|
- return o !== uploadFile.uid;
|
|
323
|
|
- });
|
|
|
409
|
+ centerDialogVisible.value = true;
|
|
|
410
|
+
|
|
|
411
|
+}
|
|
|
412
|
+
|
|
|
413
|
+
|
|
|
414
|
+const handleDelete = (id: number) => {
|
|
|
415
|
+ ElMessageBox.confirm(
|
|
|
416
|
+ '确定删除该活动吗?',
|
|
|
417
|
+ 'Warning',
|
|
|
418
|
+ {
|
|
|
419
|
+ confirmButtonText: '确定',
|
|
|
420
|
+ cancelButtonText: '取消',
|
|
|
421
|
+ type: 'warning',
|
|
|
422
|
+ }
|
|
|
423
|
+ )
|
|
|
424
|
+ .then(async () => {
|
|
324
|
425
|
|
|
325
|
|
- ruleForm.typeFile = ruleForm.typeFile.filter((o: string) => {
|
|
326
|
|
- return o !== uploadFile.uid;
|
|
|
426
|
+ const res: any = await request.delete('/Product/product/' + id);
|
|
|
427
|
+
|
|
|
428
|
+ await alterRes(res);
|
|
327
|
429
|
});
|
|
328
|
|
- }
|
|
329
|
|
-
|
|
330
|
|
- const dialogImageUrl = ref('')
|
|
331
|
|
- const dialogVisible = ref(false)
|
|
332
|
|
- const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile: any) => {
|
|
333
|
|
- dialogImageUrl.value = uploadFile.url
|
|
334
|
|
- dialogVisible.value = true
|
|
335
|
|
- }
|
|
336
|
|
-
|
|
337
|
|
- const addInfo = () => {
|
|
338
|
|
- centerDialogVisible.value = true
|
|
339
|
|
-
|
|
340
|
|
- //
|
|
341
|
|
- ruleForm = reactive<any>({
|
|
342
|
|
- id: 0,
|
|
343
|
|
- name: '',
|
|
344
|
|
- nameContent: '',
|
|
345
|
|
- nameFile: [],
|
|
346
|
|
- type: '',
|
|
347
|
|
- typeContent: '',
|
|
348
|
|
- typeFile: [],
|
|
349
|
|
- })
|
|
|
430
|
+}
|
|
|
431
|
+
|
|
|
432
|
+let tableData = ref([]);
|
|
350
|
433
|
|
|
351
|
|
- fileList.value = [];
|
|
|
434
|
+const getList = async () => {
|
|
|
435
|
+ const res = await request.get('/Product/product');
|
|
352
|
436
|
|
|
353
|
|
- typeFileList.value = [];
|
|
|
437
|
+ if (res.data.length > 0) tableData.value = res.data;
|
|
354
|
438
|
}
|
|
355
|
|
-
|
|
356
|
|
- </script>
|
|
|
439
|
+
|
|
|
440
|
+onMounted(async () => {
|
|
|
441
|
+
|
|
|
442
|
+ await getList();
|
|
|
443
|
+})
|
|
|
444
|
+
|
|
|
445
|
+
|
|
|
446
|
+
|
|
|
447
|
+
|
|
|
448
|
+
|
|
|
449
|
+const handleRemove: UploadProps['onRemove'] = (uploadFile: any, uploadFiles: any) => {
|
|
|
450
|
+
|
|
|
451
|
+ ruleForm.nameFile = ruleForm.nameFile.filter((o: string) => {
|
|
|
452
|
+ return o !== uploadFile.uid;
|
|
|
453
|
+ });
|
|
|
454
|
+
|
|
|
455
|
+ typeRuleForm.typeFile = typeRuleForm.typeFile.filter((o: string) => {
|
|
|
456
|
+ return o !== uploadFile.uid;
|
|
|
457
|
+ });
|
|
|
458
|
+}
|
|
|
459
|
+
|
|
|
460
|
+
|
|
|
461
|
+const dialogImageUrl = ref('')
|
|
|
462
|
+const dialogVisible = ref(false)
|
|
|
463
|
+const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile: any) => {
|
|
|
464
|
+ dialogImageUrl.value = uploadFile.url
|
|
|
465
|
+ dialogVisible.value = true
|
|
|
466
|
+}
|
|
|
467
|
+
|
|
|
468
|
+const addInfo = () => {
|
|
|
469
|
+ centerDialogVisible.value = true
|
|
|
470
|
+
|
|
|
471
|
+ //
|
|
|
472
|
+ ruleForm = reactive<any>({
|
|
|
473
|
+ id: 0,
|
|
|
474
|
+ name: '',
|
|
|
475
|
+ nameContent: '',
|
|
|
476
|
+ nameFile: [],
|
|
|
477
|
+ // type: '',
|
|
|
478
|
+ // typeContent: '',
|
|
|
479
|
+ // typeFile: [],
|
|
|
480
|
+ })
|
|
|
481
|
+
|
|
|
482
|
+ fileList.value = [];
|
|
|
483
|
+
|
|
|
484
|
+ // typeFileList.value = [];
|
|
|
485
|
+}
|
|
|
486
|
+
|
|
|
487
|
+</script>
|
|
|
488
|
+
|
|
|
489
|
+<style scoped lang="scss">
|
|
|
490
|
+/deep/.el-upload-list--picture-card {
|
|
|
491
|
+ width: 350px;
|
|
|
492
|
+}
|
|
|
493
|
+
|
|
|
494
|
+/deep/.el-upload--picture-card {
|
|
|
495
|
+ width: 5px;
|
|
|
496
|
+ height: 50px;
|
|
|
497
|
+}
|
|
|
498
|
+
|
|
|
499
|
+/deep/.el-upload {
|
|
|
500
|
+ width: 50px;
|
|
|
501
|
+ height: 50px;
|
|
|
502
|
+ // line-height: 50px;
|
|
|
503
|
+}
|
|
|
504
|
+
|
|
|
505
|
+/deep/.el-upload-list--picture-card .el-upload-list__item {
|
|
|
506
|
+ width: 50px;
|
|
|
507
|
+ height: 50px;
|
|
|
508
|
+ line-height: 50px;
|
|
|
509
|
+}
|
|
|
510
|
+
|
|
|
511
|
+/deep/.el-upload-list--picture-card .el-upload-list__item-thumbnail {
|
|
|
512
|
+ width: 50px;
|
|
|
513
|
+ height: 50px;
|
|
|
514
|
+ line-height: 50px;
|
|
|
515
|
+}
|
|
|
516
|
+
|
|
|
517
|
+/deep/.avatar {
|
|
|
518
|
+ width: 50px;
|
|
|
519
|
+ height: 50px;
|
|
|
520
|
+}
|
|
|
521
|
+</style>
|