|
|
@@ -1,528 +1,204 @@
|
|
1
|
1
|
<template>
|
|
2
|
2
|
<div>
|
|
3
|
|
- <el-card :body-style="cardBodyStyle">
|
|
4
|
|
- <el-form :model="query" label-width="auto" label-position="right">
|
|
5
|
|
- <el-row :gutter="10">
|
|
6
|
|
- <el-col :span="5">
|
|
7
|
|
- <el-form-item label="客户名称" style="margin-bottom: 0px;" >
|
|
8
|
|
- <el-input v-model="query.customerNm" clearable placeholder="请输入客户名称" style="width:100%;"></el-input>
|
|
9
|
|
- </el-form-item>
|
|
10
|
|
- </el-col>
|
|
11
|
|
- <el-col :span="4">
|
|
12
|
|
- <el-form-item label="" style="margin-bottom: 0px; margin-top: 5px;">
|
|
13
|
|
- <el-button type="primary" @click="handleSearch">查询</el-button>
|
|
14
|
|
- <el-button type="success" @click="insertDialog">新增</el-button>
|
|
15
|
|
- </el-form-item>
|
|
16
|
|
- </el-col>
|
|
17
|
|
- </el-row>
|
|
18
|
|
- </el-form>
|
|
19
|
|
- </el-card>
|
|
20
|
|
- <ButtonBox @search="handleSearch" @add="insertDialog"></ButtonBox>
|
|
21
|
|
- <el-card :body-style="cardBodyStyle">
|
|
22
|
|
- <el-table :data="tableData" border highlight-current-row @selection-change="handleSelectionChange" :height="height" >
|
|
23
|
|
- <el-table-column type="selection" fixed></el-table-column>
|
|
24
|
|
- <el-table-column type="index" label="序号" align="center" width="60">
|
|
25
|
|
- <template #default="scope">
|
|
26
|
|
- <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
|
|
27
|
|
- </template>
|
|
28
|
|
- </el-table-column>
|
|
29
|
|
- <el-table-column v-if="true" prop="customerNm" label="客户名称" width="150" header-align="center"
|
|
30
|
|
- align="center" show-overflow-tooltip>
|
|
31
|
|
- </el-table-column>
|
|
32
|
|
- <el-table-column v-if="true" prop="customerShortNm" label="客户简称" width="150" header-align="center"
|
|
33
|
|
- align="center" show-overflow-tooltip>
|
|
34
|
|
- </el-table-column>
|
|
35
|
|
- <el-table-column v-if="true" prop="contactPerson" label="联系人" width="150" header-align="center"
|
|
36
|
|
- align="center" show-overflow-tooltip>
|
|
37
|
|
- </el-table-column>
|
|
38
|
|
- <el-table-column v-if="true" prop="contactInfo" label="联系方式" width="150" header-align="center"
|
|
39
|
|
- align="center" show-overflow-tooltip>
|
|
40
|
|
- </el-table-column>
|
|
41
|
|
- <el-table-column v-if="true" prop="defaultAddress" label="默认地址" header-align="center"
|
|
42
|
|
- align="center" show-overflow-tooltip>
|
|
43
|
|
- </el-table-column>
|
|
44
|
|
- <el-table-column label="操作" header-align="center" align="center" width="200px" fixed="right">
|
|
45
|
|
- <template #default="scope">
|
|
46
|
|
- <el-button plain type="warning" @click="handleEdit(scope.row)">编辑</el-button>
|
|
47
|
|
- <el-button plain type="danger" @click="handleRemove(scope.row )">删除</el-button>
|
|
48
|
|
- </template>
|
|
49
|
|
- </el-table-column>
|
|
50
|
|
- </el-table>
|
|
51
|
|
- </el-card>
|
|
52
|
|
- <el-card :body-style="cardBodyStyle">
|
|
53
|
|
- <el-pagination :current-page="currentPage" :page-size="pageSize" :page-sizes="pageSizes" :total="totalRows"
|
|
54
|
|
- background="background" layout="total, sizes, prev, pager, next, jumper"
|
|
55
|
|
- @size-change="handleSizeChange"
|
|
56
|
|
- @current-change="handleCurrentChange">
|
|
57
|
|
- </el-pagination>
|
|
58
|
|
- </el-card>
|
|
59
|
|
-
|
|
60
|
|
- <el-dialog class="diaClass" :close-on-click-modal="false" draggable title="新增" v-model="dialogVisible" width="40%" top="5vh"
|
|
61
|
|
- @open="openDialog">
|
|
62
|
|
- <el-card >
|
|
63
|
|
- <el-form :model="form" label-width="120px" label-position="right" inline ref="ruleFormRef" :rules="rules">
|
|
64
|
|
- <el-row>
|
|
65
|
|
- <el-col :span="12">
|
|
66
|
|
- <el-form-item label="客户名称" prop="customerNm">
|
|
67
|
|
- <el-input v-model="form.customerNm" maxlength="100" placeholder="请输入客户名称"></el-input>
|
|
68
|
|
- </el-form-item>
|
|
69
|
|
- </el-col>
|
|
70
|
|
- <el-col :span="12">
|
|
71
|
|
- <el-form-item label="客户简称" prop="customerShortNm">
|
|
72
|
|
- <el-input v-model="form.customerShortNm" maxlength="100" placeholder="请输入客户简称"></el-input>
|
|
73
|
|
- </el-form-item>
|
|
74
|
|
- </el-col>
|
|
75
|
|
- <el-col :span="12">
|
|
76
|
|
- <el-form-item label="联系人" prop="contactPerson">
|
|
77
|
|
- <el-input v-model="form.contactPerson" maxlength="50" placeholder="请输入联系人"></el-input>
|
|
78
|
|
- </el-form-item>
|
|
79
|
|
- </el-col>
|
|
80
|
|
- <el-col :span="12">
|
|
81
|
|
- <el-form-item label="联系方式" prop="contactInfo">
|
|
82
|
|
- <el-input v-model="form.contactInfo" maxlength="50" placeholder="请输入联系方式"></el-input>
|
|
83
|
|
- </el-form-item>
|
|
84
|
|
- </el-col>
|
|
85
|
|
- <el-col :span="24">
|
|
86
|
|
- <el-form-item label="默认地址" prop="defaultAddress">
|
|
87
|
|
- <el-input
|
|
88
|
|
- v-model="form.defaultAddress"
|
|
89
|
|
- :autosize="{ minRows: 2, maxRows: 4 }"
|
|
90
|
|
- type="textarea"
|
|
91
|
|
- placeholder="请输入默认地址"
|
|
92
|
|
- maxlength="2"
|
|
93
|
|
- show-word-limit
|
|
94
|
|
- />
|
|
95
|
|
- </el-form-item>
|
|
96
|
|
- </el-col>
|
|
97
|
|
-
|
|
98
|
|
- </el-row>
|
|
99
|
|
- </el-form>
|
|
100
|
|
-
|
|
101
|
|
- </el-card>
|
|
102
|
|
- <template #footer>
|
|
103
|
|
- <div class="dialog-footer">
|
|
104
|
|
- <el-button type="success" plain @click="handleInsert(ruleFormRef)">保存</el-button>
|
|
105
|
|
- <el-button type="danger" plain @click="handleCancelSave">取消</el-button>
|
|
106
|
|
- </div>
|
|
107
|
|
- </template>
|
|
108
|
|
- </el-dialog>
|
|
109
|
|
- <el-dialog class="diaClass" :close-on-click-modal="false" draggable title="编辑" v-model="dialogVisibleEdit" width="40%" top="5vh"
|
|
110
|
|
- @open="openDialog">
|
|
111
|
|
- <el-card :body-style="cardBodyStyle">
|
|
112
|
|
- <el-form :model="form" label-width="120px" label-position="right" inline ref="ruleFormRef" :rules="rules">
|
|
113
|
|
- <el-row>
|
|
114
|
|
- <el-col :span="12">
|
|
115
|
|
- <el-form-item label="客户名称" prop="customerNm">
|
|
116
|
|
- <el-input v-model="form.customerNm" placeholder="请输入客户名称"></el-input>
|
|
117
|
|
- </el-form-item>
|
|
118
|
|
- </el-col>
|
|
119
|
|
- <el-col :span="12">
|
|
120
|
|
- <el-form-item label="客户简称" prop="customerShortNm">
|
|
121
|
|
- <el-input v-model="form.customerShortNm" placeholder="请输入客户简称"></el-input>
|
|
122
|
|
- </el-form-item>
|
|
123
|
|
- </el-col>
|
|
124
|
|
- <el-col :span="12">
|
|
125
|
|
- <el-form-item label="联系人" prop="contactPerson">
|
|
126
|
|
- <el-input v-model="form.contactPerson" placeholder="请输入联系人"></el-input>
|
|
127
|
|
- </el-form-item>
|
|
128
|
|
- </el-col>
|
|
129
|
|
- <el-col :span="12">
|
|
130
|
|
- <el-form-item label="联系方式" prop="contactInfo">
|
|
131
|
|
- <el-input v-model="form.contactInfo" placeholder="请输入联系方式"></el-input>
|
|
132
|
|
- </el-form-item>
|
|
133
|
|
- </el-col>
|
|
134
|
|
- <el-col :span="24">
|
|
135
|
|
- <el-form-item label="默认地址" prop="defaultAddress">
|
|
136
|
|
- <el-input
|
|
137
|
|
- v-model="form.defaultAddress"
|
|
138
|
|
- :autosize="{ minRows: 2, maxRows: 4 }"
|
|
139
|
|
- type="textarea"
|
|
140
|
|
- placeholder="请输入默认地址"
|
|
141
|
|
- />
|
|
142
|
|
- </el-form-item>
|
|
143
|
|
- </el-col>
|
|
144
|
|
-
|
|
145
|
|
- </el-row>
|
|
146
|
|
- </el-form>
|
|
147
|
|
-
|
|
148
|
|
- </el-card>
|
|
149
|
|
- <template #footer>
|
|
150
|
|
- <div class="dialog-footer">
|
|
151
|
|
- <el-button type="success" plain @click="handleSave(ruleFormRef)">保存</el-button>
|
|
152
|
|
- <el-button type="danger" plain @click="handleCancelSave2">取消</el-button>
|
|
153
|
|
- </div>
|
|
154
|
|
- </template>
|
|
155
|
|
- </el-dialog>
|
|
|
3
|
+ <SearchBox ref="SearchBoxRef" formName="selectTop" :formData="query" @showPop="showPop" @reset="reset"></SearchBox>
|
|
|
4
|
+ <ButtonBox @search="handleSearch" @add="insertDialog" @start="start('0')" @remove="shutdwon('1')" @edit="editDialog"></ButtonBox>
|
|
156
|
5
|
</div>
|
|
|
6
|
+ <div>
|
|
|
7
|
+ <TableBox ref="TableBoxRef" :tableData="tableDate" @edit="handleEdit" @remove="handleRemove" :page="pageType" :url="url" :param="query"></TableBox>
|
|
157
|
8
|
|
|
|
9
|
+ <FormBox ref="FormBoxRef" formName="input" :formData="form" :dialog="dialog" @save="handleSave"
|
|
|
10
|
+ @update:dialog="(val) => dialog = val" :title="dialogTitle"></FormBox>
|
|
|
11
|
+ </div>
|
|
158
|
12
|
</template>
|
|
159
|
13
|
|
|
160
|
14
|
<script setup>
|
|
161
|
|
-import {getCurrentInstance, onMounted, reactive, ref} from 'vue'
|
|
|
15
|
+import { getCurrentInstance, ref, watch } from 'vue'
|
|
|
16
|
+import { ElMessage, ElMessageBox } from 'element-plus'
|
|
162
|
17
|
import tools from '@/tools'
|
|
163
|
|
-import ButtonBox from "@/components/ButtonBox.vue";
|
|
164
|
|
-
|
|
165
|
|
-const {
|
|
166
|
|
- proxy
|
|
167
|
|
-} = getCurrentInstance()
|
|
|
18
|
+import ButtonBox from "@/components/ButtonBox.vue"
|
|
|
19
|
+import SearchBox from "@/components/SearchBox.vue"
|
|
|
20
|
+import FormBox from '@/components/FormBox.vue'
|
|
|
21
|
+import TableBox from '@/components/TableBox.vue'
|
|
168
|
22
|
|
|
169
|
|
-const cardBodyStyle = ref(tools.style.card)
|
|
170
|
|
-const inputStyle = ref(tools.style.input)
|
|
|
23
|
+const { proxy } = getCurrentInstance()
|
|
171
|
24
|
|
|
|
25
|
+// 查询参数
|
|
|
26
|
+const query = ref({
|
|
|
27
|
+ customerNm: ''
|
|
|
28
|
+})
|
|
172
|
29
|
|
|
173
|
|
-
|
|
174
|
|
-const url = ref('/sto/Customer/query')
|
|
175
|
|
-
|
|
176
|
|
-/**
|
|
177
|
|
- * 查询
|
|
178
|
|
- */
|
|
179
|
|
-
|
|
|
30
|
+// 表单数据 - 确保包含所有动态配置的字段
|
|
180
|
31
|
const form = ref({
|
|
181
|
|
- customerNm: '',
|
|
182
|
|
- customerShortNm: '',
|
|
183
|
|
- contactPerson: '',
|
|
184
|
|
- contactInfo: '',
|
|
185
|
|
- defaultAddress: ''
|
|
186
|
|
-});
|
|
187
|
|
-
|
|
188
|
|
-const query = ref({
|
|
|
32
|
+ id: '',
|
|
189
|
33
|
customerNm: '',
|
|
190
|
34
|
customerShortNm: '',
|
|
191
|
35
|
contactPerson: '',
|
|
192
|
36
|
contactInfo: '',
|
|
193
|
37
|
defaultAddress: ''
|
|
194
|
38
|
})
|
|
195
|
|
-const tableData = ref([])
|
|
196
|
|
-const TableBoxRef = ref(null)
|
|
197
|
|
-const handleSearch = () => {
|
|
198
|
|
- // TableBoxRef.value.search()
|
|
199
|
|
- getTableData()
|
|
200
|
|
-}
|
|
201
|
39
|
|
|
|
40
|
+// 控制弹窗显示
|
|
|
41
|
+const dialog = ref(false)
|
|
202
|
42
|
|
|
|
43
|
+// 弹窗标题
|
|
|
44
|
+const dialogTitle = ref('新增客户')
|
|
203
|
45
|
|
|
|
46
|
+// 表格相关配置
|
|
|
47
|
+const url = ref('sto/Customer/query')
|
|
|
48
|
+const tName = ref('sto_customer')
|
|
|
49
|
+const pageType = ref(true)
|
|
204
|
50
|
|
|
205
|
|
-/**
|
|
206
|
|
- * 分页
|
|
207
|
|
- */
|
|
208
|
|
-const currentPage = ref(1)
|
|
209
|
|
-const totalRows = ref(0)
|
|
210
|
|
-const pageSizes = ref([ 10, 20, 30, 40])
|
|
211
|
|
-const pageSize = ref(10)
|
|
212
|
|
-const handleSizeChange = (val) => {
|
|
213
|
|
- pageSize.value = val
|
|
214
|
|
- getTableData()
|
|
215
|
|
-}
|
|
216
|
|
-const handleCurrentChange = (val) => {
|
|
217
|
|
- currentPage.value = val
|
|
218
|
|
- getTableData()
|
|
219
|
|
-}
|
|
220
|
|
-/**
|
|
221
|
|
- * 分页
|
|
222
|
|
- */
|
|
223
|
|
-
|
|
224
|
|
-
|
|
225
|
|
-/**
|
|
226
|
|
- * 新增
|
|
227
|
|
- */
|
|
228
|
|
-const dialogVisible = ref(false)
|
|
229
|
|
-const dialogVisibleEdit = ref(false)
|
|
230
|
|
-
|
|
231
|
|
-const ruleFormRef = ref()
|
|
232
|
|
-
|
|
233
|
|
-const rules = reactive({
|
|
234
|
|
- customerNm: [
|
|
235
|
|
- {required: true, message: '不允许为空', trigger: 'blur'},
|
|
236
|
|
- ],
|
|
237
|
|
- customerShortNm: [
|
|
238
|
|
- {required: true, message: '不允许为空', trigger: 'blur'},
|
|
239
|
|
- ],
|
|
240
|
|
- contactPerson: [
|
|
241
|
|
- {required: true, message: '不允许为空', trigger: 'blur'},
|
|
242
|
|
- ],
|
|
243
|
|
- contactInfo: [
|
|
244
|
|
- {required: true, message: '不允许为空', trigger: 'blur'},
|
|
245
|
|
- ],
|
|
246
|
|
- // defaultAddress: [
|
|
247
|
|
- // {required: true, message: '不允许为空', trigger: 'blur'},
|
|
248
|
|
- // ],
|
|
|
51
|
+// 组件引用
|
|
|
52
|
+const TableBoxRef = ref(null)
|
|
|
53
|
+const FormBoxRef = ref(null)
|
|
249
|
54
|
|
|
|
55
|
+// 监听弹窗状态
|
|
|
56
|
+watch(dialog, (newVal) => {
|
|
|
57
|
+ console.log('弹窗状态变化:', newVal)
|
|
250
|
58
|
})
|
|
251
|
59
|
|
|
|
60
|
+// ========== 弹窗相关方法 ==========
|
|
|
61
|
+
|
|
|
62
|
+// 新增弹窗
|
|
252
|
63
|
const insertDialog = () => {
|
|
|
64
|
+ console.log('打开新增弹窗')
|
|
|
65
|
+
|
|
|
66
|
+ // 重置表单数据
|
|
253
|
67
|
form.value = {
|
|
|
68
|
+ id: '',
|
|
254
|
69
|
customerNm: '',
|
|
255
|
70
|
customerShortNm: '',
|
|
256
|
71
|
contactPerson: '',
|
|
257
|
72
|
contactInfo: '',
|
|
258
|
73
|
defaultAddress: ''
|
|
259
|
74
|
}
|
|
260
|
|
- dialogVisible.value = true
|
|
|
75
|
+
|
|
|
76
|
+ dialogTitle.value = '新增客户'
|
|
|
77
|
+ dialog.value = true
|
|
|
78
|
+
|
|
|
79
|
+ console.log('dialog.value:', dialog.value)
|
|
|
80
|
+ console.log('form.value:', form.value)
|
|
|
81
|
+}
|
|
|
82
|
+
|
|
|
83
|
+// 编辑弹窗(通过顶部按钮)
|
|
|
84
|
+const editDialog = () => {
|
|
|
85
|
+ if (TableBoxRef.value?.multipleSelection?.length > 0) {
|
|
|
86
|
+ const selectedRow = TableBoxRef.value.multipleSelection[0]
|
|
|
87
|
+ handleEdit(selectedRow)
|
|
|
88
|
+ } else {
|
|
|
89
|
+ ElMessage.warning('请先选择要编辑的行')
|
|
|
90
|
+ }
|
|
261
|
91
|
}
|
|
262
|
|
-/**
|
|
263
|
|
- * 新增
|
|
264
|
|
- */
|
|
265
|
|
-
|
|
266
|
|
-
|
|
267
|
|
-/**
|
|
268
|
|
- * 保存、修改、删除
|
|
269
|
|
- */
|
|
270
|
|
-const refUpload = ref()
|
|
271
|
|
-
|
|
272
|
|
-const openDialog = () => {
|
|
273
|
92
|
|
|
|
93
|
+// 表格行编辑(通过表格内的编辑按钮)
|
|
|
94
|
+const handleEdit = (row) => {
|
|
|
95
|
+ console.log('编辑行数据:', row)
|
|
|
96
|
+
|
|
|
97
|
+ // 确保所有字段都有值
|
|
|
98
|
+ form.value = {
|
|
|
99
|
+ id: row.id || '',
|
|
|
100
|
+ customerNm: row.customerNm || '',
|
|
|
101
|
+ customerShortNm: row.customerShortNm || '',
|
|
|
102
|
+ contactPerson: row.contactPerson || '',
|
|
|
103
|
+ contactInfo: row.contactInfo || '',
|
|
|
104
|
+ defaultAddress: row.defaultAddress || ''
|
|
|
105
|
+ }
|
|
|
106
|
+
|
|
|
107
|
+ dialogTitle.value = '编辑客户'
|
|
|
108
|
+ dialog.value = true
|
|
|
109
|
+
|
|
|
110
|
+ console.log('编辑弹窗已打开,form:', form.value)
|
|
274
|
111
|
}
|
|
275
|
112
|
|
|
276
|
|
-
|
|
277
|
|
-const handleSave = (ruleFormRef) => {
|
|
278
|
|
- if (!ruleFormRef) return
|
|
279
|
|
- ruleFormRef.validate((valid) => {
|
|
280
|
|
- if (valid) {
|
|
281
|
|
- console.log('submit!')
|
|
282
|
|
- var url = 'sto/Customer/save'
|
|
283
|
|
- var param = {
|
|
284
|
|
- json: JSON.stringify(form.value),
|
|
285
|
|
-
|
|
286
|
|
- }
|
|
287
|
|
- proxy.$axios.post(url, param).then(response => {
|
|
288
|
|
- if (response.data.code == 0) {
|
|
289
|
|
- ElMessage({
|
|
290
|
|
- message: '保存成功',
|
|
291
|
|
- type: 'success',
|
|
292
|
|
- })
|
|
293
|
|
- dialogVisibleEdit.value = false
|
|
294
|
|
- handleSearch()
|
|
295
|
|
- } else {
|
|
296
|
|
- ElMessage({
|
|
297
|
|
- type: 'error',
|
|
298
|
|
- message: '操作失败' + response.data.msg
|
|
299
|
|
- })
|
|
300
|
|
- }
|
|
301
|
|
- });
|
|
302
|
|
- } else {
|
|
303
|
|
- console.log('error submit!')
|
|
304
|
|
- return false
|
|
|
113
|
+// 保存表单
|
|
|
114
|
+const handleSave = async (formData) => {
|
|
|
115
|
+ try {
|
|
|
116
|
+ const url = 'sto/Customer/save'
|
|
|
117
|
+ var param = {
|
|
|
118
|
+ json: JSON.stringify(formData),
|
|
305
|
119
|
}
|
|
306
|
|
- })
|
|
307
|
|
-};
|
|
308
|
|
-const handleInsert = (ruleFormRef) => {
|
|
309
|
|
- if (!ruleFormRef) return
|
|
310
|
|
- ruleFormRef.validate((valid) => {
|
|
311
|
|
- if (valid) {
|
|
312
|
|
- console.log('submit!')
|
|
313
|
|
- var url = 'sto/Customer/save'
|
|
314
|
|
- var param = {
|
|
315
|
|
- json: JSON.stringify(form.value),
|
|
316
|
|
-
|
|
|
120
|
+ console.log(JSON.stringify(formData))
|
|
|
121
|
+
|
|
|
122
|
+ proxy.$axios.post(url, param).then(response => {
|
|
|
123
|
+ if (response.data.code == 0) {
|
|
|
124
|
+ ElMessage({
|
|
|
125
|
+ message: '保存成功',
|
|
|
126
|
+ type: 'success',
|
|
|
127
|
+ })
|
|
|
128
|
+ dialog.value = false
|
|
|
129
|
+ handleSearch()
|
|
|
130
|
+ } else {
|
|
|
131
|
+ ElMessage({
|
|
|
132
|
+ type: 'error',
|
|
|
133
|
+ message: '操作失败' + response.data.msg
|
|
|
134
|
+ })
|
|
317
|
135
|
}
|
|
318
|
|
- console.log('form.value!' ,form.value)
|
|
319
|
|
- proxy.$axios.post(url, param).then(response => {
|
|
320
|
|
- if (response.data.code == 0) {
|
|
321
|
|
- ElMessage({
|
|
322
|
|
- message: '保存成功',
|
|
323
|
|
- type: 'success',
|
|
324
|
|
- })
|
|
325
|
|
- dialogVisible.value = false
|
|
326
|
|
- handleSearch()
|
|
327
|
|
- } else {
|
|
328
|
|
- ElMessage({
|
|
329
|
|
- type: 'error',
|
|
330
|
|
- message: '操作失败' + response.data.msg
|
|
331
|
|
- })
|
|
332
|
|
- }
|
|
333
|
|
- });
|
|
334
|
|
- } else {
|
|
335
|
|
- console.log('error submit!')
|
|
336
|
|
- return false
|
|
337
|
|
- }
|
|
338
|
|
- })
|
|
339
|
|
-};
|
|
340
|
|
-
|
|
341
|
|
-const handleCancelSave = () => {
|
|
342
|
|
- dialogVisible.value = false
|
|
343
|
|
-}
|
|
344
|
|
-const handleCancelSave2 = () => {
|
|
345
|
|
- dialogVisibleEdit.value = false
|
|
|
136
|
+ });
|
|
|
137
|
+ } catch (error) {
|
|
|
138
|
+ ElMessage.error('操作失败: ' + error.message)
|
|
|
139
|
+ console.error('保存失败:', error)
|
|
|
140
|
+ }
|
|
346
|
141
|
}
|
|
347
|
142
|
|
|
348
|
|
-const handleEdit = (row) => {
|
|
349
|
|
- var url = 'sto/Customer/queryByPK'
|
|
350
|
|
- var param = {
|
|
351
|
|
- id: row.id
|
|
|
143
|
+// ========== 表格相关方法 ==========
|
|
|
144
|
+
|
|
|
145
|
+// 搜索
|
|
|
146
|
+const handleSearch = () => {
|
|
|
147
|
+ //console.log('执行搜索')
|
|
|
148
|
+ if (TableBoxRef.value?.search) {
|
|
|
149
|
+ TableBoxRef.value.search()
|
|
352
|
150
|
}
|
|
353
|
|
- proxy.$axios.get(url, param).then(response => {
|
|
354
|
|
- if (response.data.code == '0') {
|
|
355
|
|
- form.value = response.data.data
|
|
356
|
|
- console.log(form.value)
|
|
357
|
|
- dialogVisibleEdit.value = true
|
|
358
|
|
- } else {
|
|
359
|
|
- ElMessage.error('操作失败!' + response.data.msg)
|
|
360
|
|
- }
|
|
361
|
|
- })
|
|
362
|
151
|
}
|
|
363
|
152
|
|
|
|
153
|
+// 删除处理
|
|
364
|
154
|
const handleRemove = (row) => {
|
|
365
|
155
|
var url = 'sto/Customer/remove'
|
|
366
|
156
|
var param = {
|
|
367
|
157
|
id: row.id
|
|
368
|
158
|
}
|
|
369
|
|
- ElMessageBox.confirm(
|
|
370
|
|
- '确定删除本条记录?',
|
|
371
|
|
- '提示', {
|
|
372
|
|
- confirmButtonText: '确认',
|
|
373
|
|
- cancelButtonText: '取消',
|
|
374
|
|
- type: 'warning',
|
|
375
|
|
- draggable: true,
|
|
376
|
|
- }
|
|
377
|
|
- )
|
|
378
|
|
- .then(() => {
|
|
379
|
|
- proxy.$axios.get(url, param).then(response => {
|
|
380
|
|
- if (response.data.code == '0') {
|
|
381
|
|
- console.log(response.data.data)
|
|
382
|
|
- ElMessage({
|
|
383
|
|
- type: 'success',
|
|
384
|
|
- message: '删除成功!',
|
|
385
|
|
- });
|
|
386
|
|
- getTableData()
|
|
387
|
|
- } else {
|
|
388
|
|
- ElMessage.error('操作失败!' + response.data.msg)
|
|
389
|
|
- }
|
|
390
|
|
- })
|
|
391
|
|
- })
|
|
392
|
|
- .catch(() => {
|
|
393
|
|
- ElMessage({
|
|
394
|
|
- type: 'info',
|
|
395
|
|
- message: '已取消',
|
|
396
|
|
- })
|
|
397
|
|
- })
|
|
398
|
|
-
|
|
399
|
|
-
|
|
400
|
|
-}
|
|
401
|
|
-
|
|
402
|
|
-
|
|
403
|
|
-/**
|
|
404
|
|
- * 保存、修改、删除
|
|
405
|
|
- */
|
|
406
|
|
-
|
|
407
|
|
-const multipleSelection = ref([])
|
|
408
|
|
-const handleSelectionChange = (val) => {
|
|
409
|
|
- multipleSelection.value = val
|
|
410
|
|
-}
|
|
411
|
|
-
|
|
412
|
|
-const handleRemoveBatch = () => {
|
|
413
|
|
- console.log('handleRemoveBatch')
|
|
414
|
|
-
|
|
415
|
|
- if (multipleSelection.value.length < 1) {
|
|
416
|
|
- ElMessage({
|
|
417
|
|
- type: 'warning',
|
|
418
|
|
- message: '请选择要删除的数据!'
|
|
419
|
|
- })
|
|
420
|
|
- return
|
|
421
|
|
- }
|
|
422
|
|
-
|
|
423
|
|
- ElMessageBox.confirm('此操作将删除该数据, 是否继续?', '提示', {
|
|
|
159
|
+ ElMessageBox.confirm(`确定删除客户 "${row.customerNm}" 吗?`, '删除确认', {
|
|
424
|
160
|
confirmButtonText: '确定',
|
|
425
|
161
|
cancelButtonText: '取消',
|
|
426
|
162
|
type: 'warning'
|
|
427
|
|
- }).then(() => {
|
|
428
|
|
- var ids = []
|
|
429
|
|
- multipleSelection.value.forEach((item, index) => {
|
|
430
|
|
- ids.push(item.id)
|
|
431
|
|
- })
|
|
432
|
|
- /* var url = 'cot/SignRequest/removeBatch'*/
|
|
433
|
|
- var param = {
|
|
434
|
|
- ids: JSON.stringify(ids)
|
|
|
163
|
+ }).then(async () => {
|
|
|
164
|
+ try {
|
|
|
165
|
+ proxy.$axios.get(url, param).then(response => {
|
|
|
166
|
+ if (response.data.code == '0') {
|
|
|
167
|
+ console.log(response.data.data)
|
|
|
168
|
+ ElMessage({
|
|
|
169
|
+ type: 'success',
|
|
|
170
|
+ message: '删除成功!',
|
|
|
171
|
+ });
|
|
|
172
|
+ handleSearch()
|
|
|
173
|
+ } else {
|
|
|
174
|
+ ElMessage.error('操作失败!' + response.data.msg)
|
|
|
175
|
+ }
|
|
|
176
|
+ })
|
|
|
177
|
+ } catch (error) {
|
|
|
178
|
+ ElMessage.error('删除失败: ' + error.message)
|
|
435
|
179
|
}
|
|
436
|
|
- proxy.$axios.post(url, param).then(response => {
|
|
437
|
|
- if (response.data.code == '0') {
|
|
438
|
|
- ElMessage({
|
|
439
|
|
- type: 'success',
|
|
440
|
|
- message: '操作成功!',
|
|
441
|
|
- });
|
|
442
|
|
- getTableData()
|
|
443
|
|
- dialogVisible.value = false
|
|
444
|
|
- } else {
|
|
445
|
|
- ElMessage({
|
|
446
|
|
- type: 'error',
|
|
447
|
|
- message: '操作失败!' + response.data.msg
|
|
448
|
|
- });
|
|
449
|
|
- }
|
|
450
|
|
- })
|
|
451
|
|
- }).catch(() => {
|
|
452
|
|
- ElMessage({
|
|
453
|
|
- type: 'info',
|
|
454
|
|
- message: '已取消删除'
|
|
455
|
|
- })
|
|
456
|
180
|
})
|
|
457
|
181
|
}
|
|
458
|
182
|
|
|
459
|
|
-const handleEditBatch = () => {
|
|
460
|
|
- console.log('handleEditBatch')
|
|
461
|
|
- if (multipleSelection.value.length != 1) {
|
|
462
|
|
- ElMessage({
|
|
463
|
|
- type: 'warning',
|
|
464
|
|
- message: '请选择一条数据编辑!'
|
|
465
|
|
- })
|
|
466
|
|
- return
|
|
467
|
|
- }
|
|
468
|
|
- handleEdit(multipleSelection.value[0])
|
|
|
183
|
+// 行选择变化
|
|
|
184
|
+const handleSelectionChange = (selectedRows) => {
|
|
|
185
|
+ console.log('选中行:', selectedRows)
|
|
469
|
186
|
}
|
|
470
|
187
|
|
|
471
|
|
-const handleUpload = () => {
|
|
472
|
|
- console.log('handleUpload')
|
|
473
|
|
-}
|
|
|
188
|
+// ========== 其他方法 ==========
|
|
474
|
189
|
|
|
475
|
|
-const handleDownload = () => {
|
|
476
|
|
- console.log('handleDownload')
|
|
|
190
|
+const reset = () => {
|
|
|
191
|
+ query.value = { customerNm: '' }
|
|
|
192
|
+ handleSearch()
|
|
477
|
193
|
}
|
|
478
|
194
|
|
|
479
|
|
-const handleImport = () => {
|
|
480
|
|
- console.log('handleImport')
|
|
481
|
|
-}
|
|
482
|
|
-
|
|
483
|
|
-const handleExport = () => {
|
|
484
|
|
- console.log('handleExport')
|
|
485
|
|
-}
|
|
486
|
|
-const getTableData = () => {
|
|
487
|
|
- var url = 'sto/Customer/query'
|
|
488
|
|
- var param = {
|
|
489
|
|
- page: currentPage.value,
|
|
490
|
|
- rows: pageSize.value,
|
|
491
|
|
- customerNm: query.value.customerNm,
|
|
492
|
|
- customerShortNm: query.value.customerShortNm,
|
|
493
|
|
- contactPerson: query.value.contactPerson,
|
|
494
|
|
- contactInfo: query.value.contactInfo,
|
|
495
|
|
- defaultAddress: query.value.defaultAddress,
|
|
496
|
|
- json: JSON.stringify(query.value)
|
|
497
|
|
- }
|
|
498
|
|
- proxy.$axios.get(url, param).then(response => {
|
|
499
|
|
- if (response.data.code == '0') {
|
|
500
|
|
- tableData.value = response.data.data.records
|
|
501
|
|
- totalRows.value = response.data.data.total
|
|
502
|
|
- } else {
|
|
503
|
|
- ElMessage.error('操作失败!' + response.data.msg)
|
|
504
|
|
- }
|
|
505
|
|
- })
|
|
|
195
|
+const start = (type) => {
|
|
|
196
|
+ console.log('启用操作:', type)
|
|
|
197
|
+ // TODO: 实现启用逻辑
|
|
506
|
198
|
}
|
|
507
|
|
-const height = ref(600)
|
|
508
|
|
-const updateViewportHeight = () => {
|
|
509
|
|
- height.value = window.innerHeight * 0.65
|
|
510
|
|
- console.log( window.innerHeight);
|
|
511
|
|
-};
|
|
512
|
|
-onMounted(() => {
|
|
513
|
|
- getTableData()
|
|
514
|
|
- updateViewportHeight()
|
|
515
|
|
-})
|
|
516
|
|
-</script>
|
|
517
|
199
|
|
|
518
|
|
-<style scoped>
|
|
519
|
|
-::v-deep .diaClass .el-form-item {
|
|
520
|
|
- width: 100%
|
|
521
|
|
-}
|
|
522
|
|
-::v-deep .el-autocomplete{
|
|
523
|
|
- width: 100%;
|
|
524
|
|
-}
|
|
525
|
|
-::v-deep .el-dialog__body {
|
|
526
|
|
- background-color: #F2F6FC;
|
|
|
200
|
+const shutdwon = (type) => {
|
|
|
201
|
+ console.log('停用操作:', type)
|
|
|
202
|
+ // TODO: 实现停用逻辑
|
|
527
|
203
|
}
|
|
528
|
|
-</style>
|
|
|
204
|
+</script>
|