|
|
@@ -1,60 +1,53 @@
|
|
|
<template>
|
|
|
- <PagingTable url="/channel" :where="where" ref="table">
|
|
|
- <template #filter>
|
|
|
- <ElButton :icon="Refresh" @click="table.refresh()"></ElButton>
|
|
|
- <ElButton :icon="Plus" @click="onEdit()">添加</ElButton>
|
|
|
- </template>
|
|
|
- <ElTableColumn prop="id" label="#" width="80" />
|
|
|
- <ElTableColumn prop="mcc" label="MCC" />
|
|
|
- <ElTableColumn prop="mnc" label="MNC" />
|
|
|
- <ElTableColumn prop="country" label="国家" />
|
|
|
- <ElTableColumn prop="operator" label="运营商" />
|
|
|
- <ElTableColumn prop="scope" label="IMSI范围" />
|
|
|
- <ElTableColumn prop="platform" label="平台" />
|
|
|
- <ElTableColumn prop="remark" label="备注" />
|
|
|
- <ElTableColumn prop="createdAt" label="创建时间" :formatter="timeFormatter" width="150" />
|
|
|
- <ElTableColumn label="开关" align="center" width="100">
|
|
|
- <template #default="{ row }">
|
|
|
- <ElSwitch v-model="row.switch" @change="updateSwitch(row)" />
|
|
|
- </template>
|
|
|
- </ElTableColumn>
|
|
|
- <ElTableColumn label="操作" align="center" width="200">
|
|
|
- <template #default="{ row }">
|
|
|
- <ElButton type="danger" size="small" @click="del(row)">删除</ElButton>
|
|
|
- </template>
|
|
|
- </ElTableColumn>
|
|
|
- </PagingTable>
|
|
|
- <EditDialog v-model="showEditDialog" :model="model" :rules="rules" :on-submit="submit" @success="table.refresh()">
|
|
|
- <ElFormItem prop="mcc" label="MCC">
|
|
|
- <ElInput v-model="model.mcc" placeholder="请输入MCC" />
|
|
|
- </ElFormItem>
|
|
|
- <ElFormItem prop="mnc" label="MNC">
|
|
|
- <ElInput v-model="model.mnc" placeholder="请输入MNC" />
|
|
|
- </ElFormItem>
|
|
|
- <ElFormItem prop="country" label="国家">
|
|
|
- <ElInput v-model="model.country" placeholder="请输入国家" />
|
|
|
- </ElFormItem>
|
|
|
- <ElFormItem prop="operator" label="运营商">
|
|
|
- <ElInput v-model="model.operator" placeholder="请输入运营商" />
|
|
|
- </ElFormItem>
|
|
|
- <ElFormItem prop="scope" label="IMSI范围">
|
|
|
- <ElInput v-model="model.scope" placeholder="IMSI范围" type="textarea" />
|
|
|
- </ElFormItem>
|
|
|
- <ElFormItem prop="platform" label="平台">
|
|
|
- <ElSelect v-model="model.platform" placeholder="请选择平台">
|
|
|
- <ElOption v-for="item in platformList" :key="item.value" :label="item.value" :value="item.value" />
|
|
|
+ <div>
|
|
|
+ <ElButton type="primary" @click="onEdit" :icon="Plus"> 新增 </ElButton>
|
|
|
+ <div v-for="item in channels" :key="item.id" class="p-4 rounded-lg mt-4 bg-white dark:bg-neutral-800">
|
|
|
+ <div class="flex items-center">
|
|
|
+ <div class="font-bold text-md w-[100px]">{{ item.source }}</div>
|
|
|
+ <ElButton :icon="Edit" @click="onEdit(item)" circle class="ml-4" type="primary" size="small"></ElButton>
|
|
|
+ </div>
|
|
|
+ <div class="flex flex-wrap mt-4">
|
|
|
+ <div v-for="(countryConfig, i) in item.countryConfig" :key="i" class="flex items-center">
|
|
|
+ <div class="w-20 text-right text-sm text-neutral-800 dark:text-neutral-200">
|
|
|
+ {{ countryConfig.countryCode }}
|
|
|
+ </div>
|
|
|
+ <ElSwitch v-model="countryConfig.enabled" class="ml-2" @change="saveCountryConfig(item)" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <EditDialog v-model="showEditDialog" :model="model" :rules="rules" :on-submit="submit" @success="getData">
|
|
|
+ <ElFormItem prop="source" label="平台">
|
|
|
+ <ElSelect v-model="model.source" placeholder="请选择平台">
|
|
|
+ <ElOption lable="mwze167" value="mwze167"></ElOption>
|
|
|
+ <ElOption lable="durian" value="durian"></ElOption>
|
|
|
</ElSelect>
|
|
|
</ElFormItem>
|
|
|
<ElFormItem prop="remark" label="备注">
|
|
|
<ElInput v-model="model.remark" placeholder="请输入备注" />
|
|
|
</ElFormItem>
|
|
|
+ <ElFormItem prop="countryConfig" label="国家配置">
|
|
|
+ <div v-for="(item, i) in model.countryConfig" :key="i" class="w-full mb-2">
|
|
|
+ <ElInput v-model="item.countryCode" placeholder="国家代码" class="!w-[80px]" />
|
|
|
+ <ElSwitch v-model="item.enabled" class="ml-4" />
|
|
|
+ <ElButton
|
|
|
+ type="danger"
|
|
|
+ @click="removeCountryConfig(i)"
|
|
|
+ :icon="Trash"
|
|
|
+ circle
|
|
|
+ class="ml-4"
|
|
|
+ size="small"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <ElButton type="primary" @click="addCountryConfig" :icon="Plus" />
|
|
|
+ </ElFormItem>
|
|
|
</EditDialog>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
-import { ref } from 'vue'
|
|
|
+import { onMounted, ref } from 'vue'
|
|
|
import PagingTable from '@/components/PagingTable.vue'
|
|
|
import { useTimeFormatter } from '@/utils/formatter'
|
|
|
-import { Plus, Refresh } from '@vicons/tabler'
|
|
|
+import { Plus, Refresh, Trash, Edit } from '@vicons/tabler'
|
|
|
import EditDialog from '@/components/EditDialog.vue'
|
|
|
import { setupEditDialog } from '@/utils/editDialog'
|
|
|
import EnumSelect from '@/components/EnumSelect.vue'
|
|
|
@@ -63,93 +56,38 @@ import { http } from '@/plugins/http'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import { useClipboard } from '@vueuse/core'
|
|
|
|
|
|
-const where = ref({})
|
|
|
-const timeFormatter = useTimeFormatter()
|
|
|
-const table = ref(null)
|
|
|
-const model = ref({})
|
|
|
-const rules = {
|
|
|
- mcc: [{ required: true, message: '请输入MCC', trigger: 'blur' }],
|
|
|
- mnc: [{ required: true, message: '请输入MNC', trigger: 'blur' }],
|
|
|
- country: [{ required: true, message: '请输入国家码', trigger: 'blur' }],
|
|
|
- platform: [{ required: true, message: '请输入平台名称', trigger: 'blur' }]
|
|
|
+const channels = ref([])
|
|
|
+function getData() {
|
|
|
+ http.post('/channel').then((res) => {
|
|
|
+ channels.value = res.items
|
|
|
+ })
|
|
|
}
|
|
|
-const platformList = [
|
|
|
- {
|
|
|
- value: 'mwze167',
|
|
|
- },
|
|
|
- {
|
|
|
- value: 'durian',
|
|
|
- },
|
|
|
-]
|
|
|
+onMounted(async () => {
|
|
|
+ getData()
|
|
|
+})
|
|
|
|
|
|
+const model = ref({
|
|
|
+ countryConfig: []
|
|
|
+})
|
|
|
const { showEditDialog, onEdit } = setupEditDialog(model)
|
|
|
-
|
|
|
+const rules = {
|
|
|
+ source: [{ required: true, message: '请输入平台名称', trigger: 'blur' }]
|
|
|
+}
|
|
|
async function submit() {
|
|
|
- if (model.value.scope) {
|
|
|
- model.value.scope = model.value.scope.split('\n').map(Number)
|
|
|
- } else {
|
|
|
- model.value.scope = []
|
|
|
- }
|
|
|
await http.put('/channel', model.value)
|
|
|
ElMessage.success('保存成功')
|
|
|
}
|
|
|
-
|
|
|
-function del(row) {
|
|
|
- ElMessageBox.confirm('确定删除吗?', '提示', {
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- http.delete(`/channel/${row.id}`).then(() => {
|
|
|
- ElMessage.success('删除成功')
|
|
|
- table.value.refresh()
|
|
|
- })
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-function updateSwitch(row) {
|
|
|
- http.get(`/channel/updateSwitch/${row.id}`).then(() => {
|
|
|
- table.value.refresh()
|
|
|
+function addCountryConfig() {
|
|
|
+ model.value.countryConfig = model.value.countryConfig || []
|
|
|
+ model.value.countryConfig.push({
|
|
|
+ countryCode: '',
|
|
|
+ enabled: true
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
-const selectedRow = ref(null)
|
|
|
-const showDetailDialog = ref(false)
|
|
|
-const phoneTable = ref(null)
|
|
|
-
|
|
|
-const phoneModel = ref({})
|
|
|
-const phoneRules = {
|
|
|
- number: [{ required: true, message: '请输入号码', trigger: 'blur' }]
|
|
|
-}
|
|
|
-const { showEditDialog: showPhoneEditDialog, onEdit: onPhoneEdit } = setupEditDialog(phoneModel)
|
|
|
-
|
|
|
-async function submitPhone() {
|
|
|
- phoneModel.value.listId = selectedRow.value.id
|
|
|
- await http.put('/phone-list/phone', phoneModel.value)
|
|
|
- ElMessage.success('保存成功')
|
|
|
-}
|
|
|
-
|
|
|
-function delPhone(row) {
|
|
|
- ElMessageBox.confirm('确定删除吗?', '提示', {
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- http.delete(`/phone-list/phone/${row.id}`).then(() => {
|
|
|
- ElMessage.success('删除成功')
|
|
|
- phoneTable.value.refresh()
|
|
|
- })
|
|
|
- })
|
|
|
+function removeCountryConfig(index) {
|
|
|
+ model.value.countryConfig.splice(index, 1)
|
|
|
}
|
|
|
-
|
|
|
-function importList() {
|
|
|
- const input = document.createElement('input')
|
|
|
- input.type = 'file'
|
|
|
- input.accept = '.txt'
|
|
|
- input.onchange = async () => {
|
|
|
- const file = input.files[0]
|
|
|
- const formData = new FormData()
|
|
|
- formData.append('file', file)
|
|
|
- await http.post(`/phone-list/${selectedRow.value.id}/import`, formData)
|
|
|
- ElMessage.success('导入成功')
|
|
|
- phoneTable.value.refresh()
|
|
|
- }
|
|
|
- input.click()
|
|
|
+function saveCountryConfig(item) {
|
|
|
+ http.put('/channel', item)
|
|
|
}
|
|
|
</script>
|