|
|
@@ -24,6 +24,7 @@
|
|
24
|
24
|
<el-button type="danger" @click="toAdd">{{ T('Add') }}</el-button>
|
|
25
|
25
|
<el-button type="success" @click="toExport">{{ T('Export') }}</el-button>
|
|
26
|
26
|
<el-button type="danger" @click="toBatchDelete">{{ T('BatchDelete') }}</el-button>
|
|
|
27
|
+ <el-button type="primary" @click="toBatchAddToAB">{{ T('BatchAddToAB') }}</el-button>
|
|
27
|
28
|
</el-form-item>
|
|
28
|
29
|
</el-form>
|
|
29
|
30
|
</el-card>
|
|
|
@@ -157,6 +158,42 @@
|
|
157
|
158
|
</el-form-item>
|
|
158
|
159
|
</el-form>
|
|
159
|
160
|
</el-dialog>
|
|
|
161
|
+
|
|
|
162
|
+
|
|
|
163
|
+ <el-dialog v-model="batchABFormVisible" width="800" :title="T('Create')">
|
|
|
164
|
+ <el-form class="dialog-form" ref="form" :model="batchABFormData" label-width="120px">
|
|
|
165
|
+ <el-form-item :label="T('Owner')" prop="user_id" required>
|
|
|
166
|
+ <el-select v-model="batchABFormData.user_id" @change="changeUser">
|
|
|
167
|
+ <el-option
|
|
|
168
|
+ v-for="item in allUsers"
|
|
|
169
|
+ :key="item.id"
|
|
|
170
|
+ :label="item.username"
|
|
|
171
|
+ :value="item.id"
|
|
|
172
|
+ ></el-option>
|
|
|
173
|
+ </el-select>
|
|
|
174
|
+ </el-form-item>
|
|
|
175
|
+ <el-form-item :label="T('AddressBookName')" required prop="collection_id">
|
|
|
176
|
+ <el-select v-model="batchABFormData.collection_id" clearable @change="changeCollection">
|
|
|
177
|
+ <el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
|
|
178
|
+ <el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
|
|
179
|
+ </el-select>
|
|
|
180
|
+ </el-form-item>
|
|
|
181
|
+ <!-- <el-form-item :label="T('Tags')" prop="tags">
|
|
|
182
|
+ <el-select v-model="batchABFormData.tags" multiple>
|
|
|
183
|
+ <el-option
|
|
|
184
|
+ v-for="item in tagListRes.list"
|
|
|
185
|
+ :key="item.name"
|
|
|
186
|
+ :label="item.name"
|
|
|
187
|
+ :value="item.name"
|
|
|
188
|
+ ></el-option>
|
|
|
189
|
+ </el-select>
|
|
|
190
|
+ </el-form-item>-->
|
|
|
191
|
+ <el-form-item>
|
|
|
192
|
+ <el-button @click="batchABFormVisible = false">{{ T('Cancel') }}</el-button>
|
|
|
193
|
+ <el-button @click="submitBatchAddToAB" type="primary">{{ T('Submit') }}</el-button>
|
|
|
194
|
+ </el-form-item>
|
|
|
195
|
+ </el-form>
|
|
|
196
|
+ </el-dialog>
|
|
160
|
197
|
</div>
|
|
161
|
198
|
</template>
|
|
162
|
199
|
|
|
|
@@ -176,6 +213,7 @@
|
|
176
|
213
|
import { connectByClient } from '@/utils/peer'
|
|
177
|
214
|
import { CopyDocument } from '@element-plus/icons'
|
|
178
|
215
|
import { handleClipboard } from '@/utils/clipboard'
|
|
|
216
|
+ import { batchCreateFromPeers } from '@/api/address_book'
|
|
179
|
217
|
|
|
180
|
218
|
const appStore = useAppStore()
|
|
181
|
219
|
const listRes = reactive({
|
|
|
@@ -312,11 +350,14 @@
|
|
312
|
350
|
formVisible: ABFormVisible,
|
|
313
|
351
|
formData: ABFormData,
|
|
314
|
352
|
fromPeer,
|
|
|
353
|
+ changeCollection,
|
|
|
354
|
+ collectionListRes,
|
|
|
355
|
+ collectionListQuery,
|
|
|
356
|
+ getCollectionList,
|
|
315
|
357
|
} = useABRepositories()
|
|
316
|
358
|
const toAddressBook = (peer) => {
|
|
317
|
359
|
fromPeer(peer)
|
|
318
|
360
|
ABFormVisible.value = true
|
|
319
|
|
-
|
|
320
|
361
|
}
|
|
321
|
362
|
const ABSubmit = async () => {
|
|
322
|
363
|
const res = await batchCreate(ABFormData).catch(_ => false)
|
|
|
@@ -367,6 +408,42 @@
|
|
367
|
408
|
getList()
|
|
368
|
409
|
}
|
|
369
|
410
|
}
|
|
|
411
|
+
|
|
|
412
|
+ // 批量添加到地址簿
|
|
|
413
|
+ const changeUser = (val) => {
|
|
|
414
|
+ collectionListQuery.user_id = val
|
|
|
415
|
+ batchABFormData.value.collection_id = 0
|
|
|
416
|
+ getCollectionList()
|
|
|
417
|
+ }
|
|
|
418
|
+ const batchABFormVisible = ref(false)
|
|
|
419
|
+ const toBatchAddToAB = () => {
|
|
|
420
|
+ batchABFormVisible.value = true
|
|
|
421
|
+ }
|
|
|
422
|
+ const batchABFormData = ref({
|
|
|
423
|
+ collection_id: 0,
|
|
|
424
|
+ tags: [],
|
|
|
425
|
+ peer_ids: [],
|
|
|
426
|
+ user_id: null,
|
|
|
427
|
+ })
|
|
|
428
|
+ const submitBatchAddToAB = async () => {
|
|
|
429
|
+ if (multipleSelection.value.length === 0) {
|
|
|
430
|
+ ElMessage.warning(T('PleaseSelectData'))
|
|
|
431
|
+ return false
|
|
|
432
|
+ }
|
|
|
433
|
+ batchABFormData.value.peer_ids = multipleSelection.value.map(i => i.row_id)
|
|
|
434
|
+ if (!batchABFormData.value.peer_ids.length) {
|
|
|
435
|
+ ElMessage.warning(T('PleaseSelectData'))
|
|
|
436
|
+ return false
|
|
|
437
|
+ }
|
|
|
438
|
+
|
|
|
439
|
+ const res = await batchCreateFromPeers(batchABFormData.value).catch(_ => false)
|
|
|
440
|
+ if (res) {
|
|
|
441
|
+ ElMessage.success(T('OperationSuccess'))
|
|
|
442
|
+ batchABFormVisible.value = false
|
|
|
443
|
+ getList()
|
|
|
444
|
+ }
|
|
|
445
|
+ }
|
|
|
446
|
+
|
|
370
|
447
|
</script>
|
|
371
|
448
|
|
|
372
|
449
|
<style scoped lang="scss">
|