Commit fb192c8d by xinla

Merge branch 'develop' of https://e.coding.net/linkwechat/linkwechat-cloud/linkw…

…echat-ui into develop
2 parents ca06f0ab 26de9290
<script> <script>
import { getList, add, remove, update } from '@/api/drainageCode/actual' import { getList, add, remove, update } from '@/api/drainageCode/actual'
import Customer from './customer' import Customer from './customer'
export default { export default {
components: { Customer }, components: { Customer },
props: { props: {
// 实际群活码 // 实际群活码
groupCodeId: { groupCodeId: {
type: String, type: String,
default: '' default: ''
},
// 检索状态
status: {
type: Number,
default: -1
}
}, },
// 检索状态 data () {
status: { const checkScanTimes = (rule, value, callback) => {
type: Number, if (value < 1 || value > 190) {
default: -1 callback(new Error('扫码次数必须在1-190之间'))
} } else {
}, callback()
data() { }
const checkScanTimes = (rule, value, callback) => {
if (value < 1 || value > 190) {
callback(new Error('扫码次数必须在1-190之间'))
} else {
callback()
} }
}
return { return {
// 搜索数据 // 搜索数据
query: { query: {
// 当前选择状态 // 当前选择状态
status: -1, status: -1,
// 当前页码 // 当前页码
pageNum: 1, pageNum: 1,
// 每页数据量 // 每页数据量
pageSize: 10 pageSize: 10
}, },
// 可选状态 // 可选状态
statusOptions: [ statusOptions: [
{ label: '全部状态', value: -1 }, { label: '全部状态', value: -1 },
{ label: '使用中', value: 0 }, { label: '使用中', value: 0 },
{ label: '已使用', value: 1 } { label: '已使用', value: 1 }
], ],
// 加载状态 // 加载状态
loading: false, loading: false,
// 多选实际群码 // 多选实际群码
multiRealCode: [], multiRealCode: [],
// 实际群码数据 // 实际群码数据
realCodes: [], realCodes: [],
// 新建实际群码dialog // 新建实际群码dialog
dialog: false, dialog: false,
// 选择客户群dialog // 选择客户群dialog
customerDialog: false, customerDialog: false,
// 示例dialog // 示例dialog
exampleDialog: false, exampleDialog: false,
// 实际群码表单 // 实际群码表单
form: { form: {
groupName: '', groupName: '',
actualGroupQrCode: '', actualGroupQrCode: '',
effectTime: '', effectTime: '',
scanCodeTimesLimit: '', scanCodeTimesLimit: '',
chatId: '', chatId: '',
chatGroupName: '' chatGroupName: ''
}, },
// 当前编辑的实际群码 // 当前编辑的实际群码
editedRealCodeId: null, editedRealCodeId: null,
// 客户群数据 // 客户群数据
customerGroup: [], customerGroup: [],
// 总数据量 // 总数据量
total: 0, total: 0,
// 表单验证 // 表单验证
rules: { rules: {
groupName: [{ required: true, message: '请输入群名称', trigger: 'blur' }], groupName: [{ required: true, message: '请输入群名称', trigger: 'blur' }],
actualGroupQrCode: [{ required: true, message: '请上传实际群码', trigger: 'blur' }], actualGroupQrCode: [{ required: true, message: '请上传实际群码', trigger: 'blur' }],
effectTime: [{ required: true, message: '请选择有效期', trigger: 'blur' }], effectTime: [{ required: true, message: '请选择有效期', trigger: 'blur' }],
scanCodeTimesLimit: [ scanCodeTimesLimit: [
{ required: true, message: '请输入扫码次数', trigger: 'blur' }, { required: true, message: '请输入扫码次数', trigger: 'blur' },
{ {
pattern: /^[1-9][0-9]*$/, pattern: /^[1-9][0-9]*$/,
message: '扫码次数必须为正整数', message: '扫码次数必须为正整数',
trigger: 'blur' trigger: 'blur'
}, },
{ validator: checkScanTimes, trigger: 'blur' } { validator: checkScanTimes, trigger: 'blur' }
] ]
}, },
// 日期选择器选项 // 日期选择器选项
datePickerOptions: { datePickerOptions: {
disabledDate(time) { disabledDate (time) {
return time.getTime() <= Date.now() - 8.64e7 return time.getTime() <= Date.now() - 8.64e7
}
} }
} }
} },
}, watch: {
watch: { dialog (val) {
dialog(val) { if (val === false) {
if (val === false) { this.$refs.form.resetFields()
this.$refs.form.resetFields() this.form.chatId = ''
this.form.chatId = '' this.form.chatGroupName = ''
this.form.chatGroupName = '' this.editedRealCodeId = null
this.editedRealCodeId = null }
} }
} },
}, created () {
created() { this.query.status = this.status
this.query.status = this.status
this.getRealCodes() this.getRealCodes()
}, },
methods: { methods: {
// 获取所有实际群码 // 获取所有实际群码
getRealCodes() { getRealCodes () {
let params = { let params = {
groupCodeId: this.groupCodeId groupCodeId: this.groupCodeId
} }
if (this.query.status !== -1) { if (this.query.status !== -1) {
params = Object.assign(params, this.query) params = Object.assign(params, this.query)
} else { } else {
params = Object.assign(params, { params = Object.assign(params, {
pageNum: this.query.pageNum, pageNum: this.query.pageNum,
pageSize: this.query.pageSize pageSize: this.query.pageSize
}) })
} }
this.loading = true this.loading = true
getList(params) getList(params)
.then((res) => { .then((res) => {
if (res.code === 200) { if (res.code === 200) {
this.realCodes = res.rows this.realCodes = res.rows
this.total = parseInt(res.total) this.total = parseInt(res.total)
} }
this.loading = false this.loading = false
}) })
.catch(() => { .catch(() => {
this.loading = false this.loading = false
}) })
}, },
// 新增实际群码 // 新增实际群码
add() { add () {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (!valid) return if (!valid) return
const data = Object.assign({}, this.form, { const data = Object.assign({}, this.form, {
groupCodeId: this.groupCodeId groupCodeId: this.groupCodeId
}) })
add(data).then((res) => { add(data).then((res) => {
this.dialog = false this.dialog = false
this.getRealCodes() this.getRealCodes()
})
}) })
}) },
}, // 编辑
// 编辑 edit (realCode) {
edit(realCode) { this.editedRealCodeId = realCode.id
this.editedRealCodeId = realCode.id
this.form = { this.form = {
groupName: realCode.groupName, groupName: realCode.groupName,
actualGroupQrCode: realCode.actualGroupQrCode, actualGroupQrCode: realCode.actualGroupQrCode,
effectTime: realCode.effectTime, effectTime: realCode.effectTime,
scanCodeTimesLimit: realCode.scanCodeTimesLimit, scanCodeTimesLimit: realCode.scanCodeTimesLimit,
chatId: realCode.chatId, chatId: realCode.chatId,
chatGroupName: realCode.chatGroupName chatGroupName: realCode.chatGroupName
} }
this.dialog = true this.dialog = true
}, },
// 更新实际群码 // 更新实际群码
update() { update () {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (!valid) return if (!valid) return
const data = Object.assign( const data = Object.assign(
{ {
id: this.editedRealCodeId id: this.editedRealCodeId
}, },
this.form this.form
) )
update(data).then((res) => { update(data).then((res) => {
this.dialog = false this.dialog = false
this.getRealCodes() this.getRealCodes()
})
}) })
}) },
}, handleSubmit () {
handleSubmit() { if (!this.editedRealCodeId) return this.add()
if (!this.editedRealCodeId) return this.add()
this.update() this.update()
}, },
// 批量删除 // 批量删除
handleBulkRemove() { handleBulkRemove () {
this.$confirm('确认删除当前实际群码?删除操作无法撤销,请谨慎操作。', '提示', { this.$confirm('确认删除当前实际群码?删除操作无法撤销,请谨慎操作。', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}) })
.then(() => { .then(() => {
const ids = this.multiRealCode.map((code) => code.id) const ids = this.multiRealCode.map((code) => code.id)
remove(ids + '').then((res) => { remove(ids + '').then((res) => {
if (res.code === 200) { if (res.code === 200) {
this.getRealCodes() this.getRealCodes()
} else { } else {
} }
})
}) })
.catch(() => { })
},
// 删除
handleRemove (id) {
this.$confirm('确认删除当前实际群码?删除操作无法撤销,请谨慎操作。', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}) })
.catch(() => {}) .then(() => {
}, remove(id).then((res) => {
// 删除 if (res.code === 200) {
handleRemove(id) { this.getRealCodes()
this.$confirm('确认删除当前实际群码?删除操作无法撤销,请谨慎操作。', '提示', { } else {
confirmButtonText: '确定', }
cancelButtonText: '取消', })
type: 'warning'
})
.then(() => {
remove(id).then((res) => {
if (res.code === 200) {
this.getRealCodes()
} else {
}
}) })
}) .catch(() => { })
.catch(() => {}) },
}, // checkbox选择变更
// checkbox选择变更 handleSelectionChange (val) {
handleSelectionChange(val) { this.multiRealCode = val
this.multiRealCode = val },
}, // 客户群dialog选中数据
// 客户群dialog选中数据 handleSelectCustomerGroup () {
handleSelectCustomerGroup() { this.$refs.customer.submit()
this.$refs.customer.submit() },
}, // 获取选中客户群
// 获取选中客户群 getSelectCustomerGroup (customerGroup) {
getSelectCustomerGroup(customerGroup) { this.form.chatId = customerGroup ? customerGroup.chatId : ''
this.form.chatId = customerGroup ? customerGroup.chatId : '' this.form.chatGroupName = customerGroup ? customerGroup.groupName : ''
this.form.chatGroupName = customerGroup ? customerGroup.groupName : '' this.customerDialog = false
this.customerDialog = false }
} }
} }
}
</script> </script>
<template> <template>
...@@ -250,12 +250,7 @@ export default { ...@@ -250,12 +250,7 @@ export default {
<div> <div>
<el-button type="primary" @click="dialog = true"> 新建实际群码 </el-button> <el-button type="primary" @click="dialog = true"> 新建实际群码 </el-button>
<el-select v-model="query.status" class="ml10" @change="getRealCodes"> <el-select v-model="query.status" class="ml10" @change="getRealCodes">
<el-option <el-option v-for="option in statusOptions" :key="option.value" :label="option.label" :value="option.value"></el-option>
v-for="option in statusOptions"
:key="option.value"
:label="option.label"
:value="option.value"
></el-option>
</el-select> </el-select>
</div> </div>
<div> <div>
...@@ -271,22 +266,14 @@ export default { ...@@ -271,22 +266,14 @@ export default {
<el-table-column prop="actualGroupQrCode" label="实际群码" align="center" width="80"> <el-table-column prop="actualGroupQrCode" label="实际群码" align="center" width="80">
<template #default="{ row }"> <template #default="{ row }">
<el-popover placement="bottom" trigger="hover"> <el-popover placement="bottom" trigger="hover">
<el-image <el-image slot="reference" :src="row.actualGroupQrCode" class="code-image--small"></el-image>
slot="reference"
:src="row.actualGroupQrCode"
class="code-image--small"
></el-image>
<el-image :src="row.actualGroupQrCode" class="code-image"></el-image> <el-image :src="row.actualGroupQrCode" class="code-image"></el-image>
</el-popover> </el-popover>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="chatGroupName" label="客户群" align="center"></el-table-column> <!-- <el-table-column prop="chatGroupName" label="客户群" align="center"></el-table-column> -->
<el-table-column prop="effectTime" label="有效期" align="center"></el-table-column> <el-table-column prop="effectTime" label="有效期" align="center"></el-table-column>
<el-table-column <el-table-column prop="scanCodeTimesLimit" label="扫码次数限制" align="center"></el-table-column>
prop="scanCodeTimesLimit"
label="扫码次数限制"
align="center"
></el-table-column>
<el-table-column prop="scanCodeTimes" label="已扫码入群数" align="center"></el-table-column> <el-table-column prop="scanCodeTimes" label="已扫码入群数" align="center"></el-table-column>
<el-table-column prop="status" label="使用状态" align="center"> <el-table-column prop="status" label="使用状态" align="center">
<template #default="{ row }"> <template #default="{ row }">
...@@ -316,24 +303,14 @@ export default { ...@@ -316,24 +303,14 @@ export default {
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="有效期" prop="effectTime"> <el-form-item label="有效期" prop="effectTime">
<el-date-picker <el-date-picker v-model="form.effectTime" type="date" placeholder="请选择有效期" value-format="yyyy-MM-dd" :picker-options="datePickerOptions">
v-model="form.effectTime"
type="date"
placeholder="请选择有效期"
value-format="yyyy-MM-dd"
:picker-options="datePickerOptions"
>
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="扫码次数限制" prop="scanCodeTimesLimit"> <el-form-item label="扫码次数限制" prop="scanCodeTimesLimit">
<el-input <el-input v-model="form.scanCodeTimesLimit" placeholder="请输入次数" type="Number"></el-input>
v-model="form.scanCodeTimesLimit"
placeholder="请输入次数"
type="Number"
></el-input>
<div class="tip">注: 不超过190</div> <div class="tip">注: 不超过190</div>
</el-form-item> </el-form-item>
<el-form-item label="客户群"> <!-- <el-form-item label="客户群">
<template v-if="form.chatId"> <template v-if="form.chatId">
<el-button @click="customerDialog = true" type="primary"> <el-button @click="customerDialog = true" type="primary">
{{ form.chatGroupName }} {{ form.chatGroupName }}
...@@ -343,16 +320,11 @@ export default { ...@@ -343,16 +320,11 @@ export default {
<el-button icon="el-icon-plus" @click="customerDialog = true"> 选择客户群 </el-button> <el-button icon="el-icon-plus" @click="customerDialog = true"> 选择客户群 </el-button>
</template> </template>
<div class="tip">注: 主要用于老客标签建群</div> <div class="tip">注: 主要用于老客标签建群</div>
</el-form-item> </el-form-item> -->
</el-form> </el-form>
<el-dialog title="选择客户群" append-to-body :visible.sync="customerDialog"> <el-dialog title="选择客户群" append-to-body :visible.sync="customerDialog">
<Customer <Customer v-if="customerDialog" ref="customer" :customerGroupId="form.chatId" @callback="getSelectCustomerGroup"></Customer>
v-if="customerDialog"
ref="customer"
:customerGroupId="form.chatId"
@callback="getSelectCustomerGroup"
></Customer>
<div slot="footer"> <div slot="footer">
<el-button @click="customerDialog = false"> 取消 </el-button> <el-button @click="customerDialog = false"> 取消 </el-button>
...@@ -379,67 +351,61 @@ export default { ...@@ -379,67 +351,61 @@ export default {
</div> </div>
</el-dialog> </el-dialog>
<pagination <pagination v-show="total > 0" :total="total" :page.sync="query.pageNum" :limit.sync="query.pageSize" @pagination="getRealCodes"></pagination>
v-show="total > 0"
:total="total"
:page.sync="query.pageNum"
:limit.sync="query.pageSize"
@pagination="getRealCodes"
></pagination>
</div> </div>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
.code-image { .code-image {
width: 200px; width: 200px;
height: 200px; height: 200px;
}
.code-image--small {
width: 50px;
height: 50px;
}
::v-deep .image-uploader {
.uploader-icon {
width: 80px;
height: 80px;
line-height: 80px;
} }
.upload-img { .code-image--small {
width: 80px; width: 50px;
height: 80px; height: 50px;
} }
} ::v-deep .image-uploader {
.tip { .uploader-icon {
color: #aaa; width: 80px;
font-size: 12px; height: 80px;
} line-height: 80px;
.green-text { }
color: #19be6b; .upload-img {
} width: 80px;
.red-text { height: 80px;
color: #ed4014; }
} }
.example-code-box { .tip {
margin: 0 5px; color: #aaa;
background-color: white;
padding: 10px;
font-weight: bold;
color: #666666;
.example-text {
font-size: 12px; font-size: 12px;
padding: 10px 0;
} }
.code-user { .green-text {
font-size: 30px; color: #19be6b;
color: #4185f4; }
.red-text {
color: #ed4014;
} }
.code-content { .example-code-box {
text-align: center; margin: 0 5px;
background-color: white;
padding: 10px;
font-weight: bold;
color: #666666;
.el-image { .example-text {
margin-top: 20px; font-size: 12px;
padding: 10px 0;
}
.code-user {
font-size: 30px;
color: #4185f4;
}
.code-content {
text-align: center;
.el-image {
margin-top: 20px;
}
} }
} }
}
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!