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