Commit f2191cbb by liuchenxi

update: 通道排序规则调整

parent 22ab90f6
<template>
<div class="content">
<el-form ref="form" :model="form" :rules="rules" label-width="140px">
<el-form-item label="短信签名ID" prop="smsSignId">
<el-input v-model="form.smsSignId" class="w180" />
</el-form-item>
<el-form-item label="短信签名" prop="smsSignText">
<el-input v-model="form.smsSignText" class="w180" />
</el-form-item>
<el-form-item label="签名应用通道" prop="channelSignList">
<el-checkbox-group v-model="form.channelSignList">
<el-checkbox v-for="v in channelList" :key="v.channelId" :label="v.channelId" :disabled="disabledCheckBox.includes(v.channelId)">{{ v.channelName }}</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="短信模板数量" prop="maxTemplateCount">
<el-input-number v-model="form.maxTemplateCount" controls-position="right" :min="form.limitTemplateCount" class="w90" />
<span class="tips">该商户在商户后台看到的短信模板数量</span>
</el-form-item>
<el-form-item label="短信发送优先级" prop="sendSmsType">
<el-radio-group v-model="form.sendSmsType">
<p class="send_sms">
<el-radio :label="0">多通道</el-radio>
<span class="channels">{{ channelSort }}</span>
</p>
<el-radio :label="1">
指定通道
<el-radio-group v-model="form.appointChannel" class="ml20" v-if="form.sendSmsType" style="vertical-align: top">
<el-radio v-for="item in channelList" :key="item.channelId" :label="item.channelId">{{ item.channelName }}</el-radio>
</el-radio-group>
</el-radio>
<div class="content">
<el-form ref="form" :model="form" :rules="rules" label-width="140px">
<el-form-item label="短信签名ID" prop="smsSignId">
<el-input v-model="form.smsSignId" class="w180" disabled />
</el-form-item>
<el-form-item label="短信签名" prop="smsSignText">
<el-input v-model="form.smsSignText" class="w180" disabled />
</el-form-item>
<el-form-item label="签名应用通道" prop="channelSignList">
<el-checkbox-group v-model="form.channelSignList">
<el-checkbox v-for="v in channelList" :key="v.channelId" :label="v.channelId" :disabled="disabledCheckBox.includes(v.channelId)">{{ v.channelName }}</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="短信模板数量" prop="maxTemplateCount">
<el-input-number v-model="form.maxTemplateCount" controls-position="right" :min="form.limitTemplateCount" class="w90" />
<span class="tips">该商户在商户后台看到的短信模板数量</span>
</el-form-item>
<el-form-item label="短信发送优先级" prop="sendSmsType">
<el-radio-group v-model="form.sendSmsType">
<p class="send_sms">
<el-radio :label="0">多通道</el-radio>
<span class="channels">{{ channelSortRes }}</span>
</p>
<el-radio :label="1">
指定通道
<el-radio-group v-model="form.appointChannel" class="ml20" v-if="form.sendSmsType" style="vertical-align: top">
<el-radio v-for="item in channelList" :key="item.channelId" :label="item.channelId">{{ item.channelName }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="短信AppID" prop="smsAppid">
{{ form.smsAppid }}
</el-form-item>
<el-form-item label="">
<el-button type="primary" style="margin-top: 30px" @click="submit">保存</el-button>
</el-form-item>
</el-form>
</div>
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="短信AppID" prop="smsAppid">
{{ form.smsAppid }}
</el-form-item>
<el-form-item label="">
<el-button type="primary" style="margin-top: 30px" @click="submit">保存</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
import requestApi from '@/api/operation';
const { getAllChannel, getSmsSetting, updateSms, getAppid } = requestApi;
const { getAllChannel, getSmsSetting, updateSms, getAppid } = requestApi;
export default {
data() {
const sendSmsTypeValidate = (_, val, cb) => {
if(val === 1 && !this.form.appointChannel) {
if (val === 1 && !this.form.appointChannel) {
cb(new Error('请选择指定通道'));
}
cb();
......@@ -61,10 +61,12 @@ export default {
smsSignText: '',
channelSignList: [],
maxTemplateCount: 0,
limitTemplateCount: 0, // 输入限制模板数量
limitTemplateCount: 0, // 输入限制模板数量
sendSmsType: 0,
appointChannel: null, // 指定通道时的类型
smsAppid: '',
channelSort: '', // 短信通道排序字符串
channelSortRes: '' // 短信排序后的结果
},
rules: {
smsSignId: { required: true, message: '请输入签名Id', trigger: 'blur' },
......@@ -83,25 +85,28 @@ export default {
async getDetail() {
let result = await getSmsSetting({ enterpriseId: this.$route.query.id });
result = result.result || {};
for(let key in result) {
if(this.form.hasOwnProperty(key)) {
for (let key in result) {
if (this.form.hasOwnProperty(key)) {
this.form[key] = result[key] || this.form[key];
if(key == 'channelSignList' && typeof this.form[key] == 'string') {
this.form[key] = this.form[key].split(',').map(el => +el);
if (key == 'channelSignList' && typeof this.form[key] == 'string') {
this.form[key] = this.form[key].split(',').map((el) => +el);
this.disabledCheckBox = this.form[key];
};
if(key == 'maxTemplateCount') this.form['limitTemplateCount'] = this.form[key] || 0;
if(key == 'sendSmsType' && this.form[key] != 0) {
}
if (key == 'maxTemplateCount') this.form['limitTemplateCount'] = this.form[key] || 0;
if (key == 'sendSmsType' && this.form[key] != 0) {
this.form['appointChannel'] = this.form[key];
this.form[key] = 1;
this.$emit('getTableChannelType', this.form['appointChannel']); // 触发table组件修改通道类型
} else if(key == 'sendSmsType' && this.form[key] == 0) {
this.$emit('getTableChannelType', 0); // 触发table组件修改通道类型
} else if (key == 'sendSmsType' && this.form[key] == 0) {
this.$emit('getTableChannelType', 0); // 触发table组件修改通道类型
}
if(key == 'smsAppid' && !this.form[key]) {
if (key == 'smsAppid' && !this.form[key]) {
const { result } = await getAppid();
this.form[key] = result;
};
}
if (key == 'channelSort' && this.form[key]) {
this.channelSortRes = this.channelSort(this.form[key]);
}
}
}
},
......@@ -112,9 +117,9 @@ export default {
// 表单提交
submit() {
this.$refs.form.validate(async val => {
if(val) {
if (val) {
const para = Object.assign({}, this.form);
if(para.sendSmsType == 1) para.sendSmsType = para.appointChannel;
if (para.sendSmsType == 1) para.sendSmsType = para.appointChannel;
para.channelSignList = para.channelSignList.toString();
delete para.appointChannel;
delete para.limitTemplateCount;
......@@ -123,18 +128,14 @@ export default {
this.getDetail();
}
});
}
},
computed: {
channelSort() {
let res = '';
const arr = [ ...this.channelList ];
arr
.sort((a, b) => b - a)
.forEach((el, index, arr) => {
res += (index > 0 ? ' > ' : '') + el.channelName;
});
return res;
},
channelSort(sortStr) {
const sort = sortStr.split(',');
let result = sort.map((el) => {
const res = this.channelList.find((els) => els.channelId == el);
return res ? res.channelName : null;
}).filter(el => !!el);
return result.join(' < ');
}
}
};
......@@ -147,20 +148,20 @@ export default {
.w90 {
width: 90px;
}
.content {
margin-top: 26px;
.send_sms {
height: 32px;
margin-bottom: 28px;
padding-top: 5px;
box-sizing: border-box;
}
.channels {
font-size: 14px;
color: #606266;
line-height: 20px;
}
.content {
margin-top: 26px;
.send_sms {
height: 32px;
margin-bottom: 28px;
padding-top: 5px;
box-sizing: border-box;
}
.channels {
font-size: 14px;
color: #606266;
line-height: 20px;
}
}
.tips {
margin-left: 14px;
font-size: 12px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment