1
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-alert
|
||||
title="命中规则:企微发送「开」或「慢开」且含11位手机号时,若本库中存在该号码(启用状态)且备注非空,将直接回复备注,不请求 Telegram。"
|
||||
title="命中规则:企微发送「开」或「慢开」且含11位手机号时,若本库中任一启用记录的 phones 数组含该号码且备注非空,将直接回复备注,不请求 Telegram。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
@@ -9,8 +9,8 @@
|
||||
/>
|
||||
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="queryParams.phone" placeholder="手机号" clearable style="width: 200px" @keyup.enter.native="handleQuery" />
|
||||
<el-form-item label="手机号" prop="phoneQuery">
|
||||
<el-input v-model="queryParams.phoneQuery" placeholder="匹配任一条内的号码" clearable style="width: 200px" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="queryParams.remark" placeholder="备注关键词" clearable style="width: 200px" @keyup.enter.native="handleQuery" />
|
||||
@@ -75,7 +75,11 @@
|
||||
|
||||
<el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="50" align="center" />
|
||||
<el-table-column label="手机号" align="center" prop="phone" width="120" />
|
||||
<el-table-column label="手机号" align="center" prop="phones" min-width="180" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ formatPhonesCell(scope.row.phones) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="left" prop="remark" min-width="260" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="状态" align="center" prop="status" width="100">
|
||||
<template slot-scope="scope">
|
||||
@@ -118,8 +122,13 @@
|
||||
|
||||
<el-dialog :title="title" :visible.sync="open" width="560px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="88px">
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="form.phone" placeholder="11位手机号" maxlength="11" />
|
||||
<el-form-item label="手机号" prop="phonesText">
|
||||
<el-input
|
||||
v-model="form.phonesText"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
placeholder="每行一个11位号,或用英文逗号 / 中文逗号 / 分号分隔"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" :rows="5" placeholder="命中时直接回复企微的内容" />
|
||||
@@ -151,14 +160,22 @@ import {
|
||||
export default {
|
||||
name: 'TgScalperPhone',
|
||||
data() {
|
||||
const checkPhone = (rule, value, callback) => {
|
||||
if (!value) {
|
||||
callback(new Error('请输入手机号'))
|
||||
} else if (!/^1\d{10}$/.test(value)) {
|
||||
callback(new Error('请输入11位手机号'))
|
||||
} else {
|
||||
callback()
|
||||
const checkPhonesText = (rule, value, callback) => {
|
||||
if (!value || !String(value).trim()) {
|
||||
callback(new Error('请至少填写一个手机号'))
|
||||
return
|
||||
}
|
||||
const lines = String(value)
|
||||
.split(/[\n,,;;]+/)
|
||||
.map(s => s.trim())
|
||||
.filter(Boolean)
|
||||
for (const p of lines) {
|
||||
if (!/^1\d{10}$/.test(p)) {
|
||||
callback(new Error('须为11位数字:' + p))
|
||||
return
|
||||
}
|
||||
}
|
||||
callback()
|
||||
}
|
||||
return {
|
||||
loading: true,
|
||||
@@ -173,13 +190,13 @@ export default {
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
phone: null,
|
||||
phoneQuery: null,
|
||||
remark: null,
|
||||
status: null
|
||||
},
|
||||
form: {},
|
||||
rules: {
|
||||
phone: [{ required: true, validator: checkPhone, trigger: 'blur' }],
|
||||
phonesText: [{ required: true, validator: checkPhonesText, trigger: 'blur' }],
|
||||
remark: [{ required: true, message: '备注不能为空', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }]
|
||||
}
|
||||
@@ -189,6 +206,38 @@ export default {
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
formatPhonesCell(jsonStr) {
|
||||
if (!jsonStr) return '-'
|
||||
try {
|
||||
const arr = JSON.parse(jsonStr)
|
||||
return Array.isArray(arr) ? arr.join('、') : String(jsonStr)
|
||||
} catch (e) {
|
||||
return String(jsonStr)
|
||||
}
|
||||
},
|
||||
phonesJsonToText(jsonStr) {
|
||||
if (!jsonStr) return ''
|
||||
try {
|
||||
const arr = JSON.parse(jsonStr)
|
||||
return Array.isArray(arr) ? arr.join('\n') : ''
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
},
|
||||
textToPhonesJson(text) {
|
||||
const lines = String(text)
|
||||
.split(/[\n,,;;]+/)
|
||||
.map(s => s.trim())
|
||||
.filter(Boolean)
|
||||
const seen = new Set()
|
||||
const out = []
|
||||
for (const p of lines) {
|
||||
if (seen.has(p)) continue
|
||||
seen.add(p)
|
||||
out.push(p)
|
||||
}
|
||||
return JSON.stringify(out)
|
||||
},
|
||||
getList() {
|
||||
this.loading = true
|
||||
listTgScalperPhone(this.queryParams).then(response => {
|
||||
@@ -206,7 +255,7 @@ export default {
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
phone: null,
|
||||
phonesText: '',
|
||||
remark: null,
|
||||
status: 1
|
||||
}
|
||||
@@ -234,7 +283,13 @@ export default {
|
||||
this.reset()
|
||||
const id = row.id || this.ids[0]
|
||||
getTgScalperPhone(id).then(response => {
|
||||
this.form = { ...response.data, status: parseInt(response.data.status, 10) }
|
||||
const d = response.data
|
||||
this.form = {
|
||||
id: d.id,
|
||||
phonesText: this.phonesJsonToText(d.phones),
|
||||
remark: d.remark,
|
||||
status: parseInt(d.status, 10)
|
||||
}
|
||||
this.open = true
|
||||
this.title = '修改黄牛电话'
|
||||
})
|
||||
@@ -242,14 +297,21 @@ export default {
|
||||
submitForm() {
|
||||
this.$refs['form'].validate(valid => {
|
||||
if (valid) {
|
||||
const phones = this.textToPhonesJson(this.form.phonesText)
|
||||
const payload = {
|
||||
id: this.form.id,
|
||||
phones,
|
||||
remark: this.form.remark,
|
||||
status: this.form.status
|
||||
}
|
||||
if (this.form.id != null) {
|
||||
updateTgScalperPhone(this.form).then(() => {
|
||||
updateTgScalperPhone(payload).then(() => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addTgScalperPhone(this.form).then(() => {
|
||||
addTgScalperPhone(payload).then(() => {
|
||||
this.$modal.msgSuccess('新增成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
|
||||
Reference in New Issue
Block a user