Commit 9ba1e2b8 authored by honghy's avatar honghy Committed by wux

短信节点添加目的仓

parent 4a649662
......@@ -159,13 +159,28 @@
</el-select>
</el-form-item>
<el-form-item :label="$t('运输方式')" prop="transportId" @change="handleChangeTransportId">
<el-select v-model="form.transportId" :placeholder="$t('请选择运输方式类型')">
<el-form-item label="是否匹配运输方式" prop="isTransport">
<el-select v-model="form.isTransport" @change="handleChangeIsTransport">
<el-option key="0" label="否" :value="parseInt(0)" />
<el-option key="1" label="是" :value="parseInt(1)" />
</el-select>
</el-form-item>
<el-form-item :label="$t('运输方式')" prop="transportId">
<el-select v-model="form.transportId" :placeholder="$t('请选择运输方式类型')" @change="handleChangeTransportId">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.ECW_TRANSPORT_TYPE)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
<el-option key="0" label="其他" :value="parseInt(0)" />
</el-select>
</el-form-item>
<el-form-item label="多订单" prop="isOrders">
<el-select v-model="form.isOrders">
<el-option key="0" label="否" :value="parseInt(0)" />
<el-option key="1" label="是" :value="parseInt(1)" />
</el-select>
</el-form-item>
<el-form-item label="国家" prop="countryIds">
<el-select filterable clearable multiple v-model="form.countryIds" :placeholder="$t('请选择国家')">
<el-option key="0" label="全部" :value="parseInt(0)" />
......@@ -177,24 +192,26 @@
<el-form-item label="国家区号" prop="countryCode">
{{form.countryCode}}
</el-form-item>
<el-form-item label="目的仓" prop="receiveAddrList">
<el-cascader
:disabled="cascaderState"
style="width: 300px"
:options="regionTreeList"
@change="selectHandle"
collapse-tags
v-model="form.receiveAddrList"
:props="cascaderProps"
clearable>
</el-cascader>
</el-form-item>
<el-form-item :label="$t('开启状态')" prop="status">
<el-radio-group v-model="form.status">
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="是否匹配运输方式" prop="isTransport">
<el-select v-model="form.isTransport">
<el-option key="0" label="否" :value="parseInt(0)" />
<el-option key="1" label="是" :value="parseInt(1)" />
</el-select>
</el-form-item>
<el-form-item label="多订单" prop="isOrders">
<el-select v-model="form.isOrders">
<el-option key="0" label="否" :value="parseInt(0)" />
<el-option key="1" label="是" :value="parseInt(1)" />
</el-select>
</el-form-item>
<el-form-item label="模板1" prop="templateIdOne">
<el-select filterable clearable v-model="form.templateIdOne" placeholder="请选择模板1">
<el-option v-for="dict in smsTemplateList2"
......@@ -227,99 +244,109 @@
</el-dialog>
<!-- 对话框(发送短信) -->
<el-dialog :title="$t('测试发送短信')" :visible.sync="sendSmsOpen" width="500px" append-to-body>
<el-form ref="sendSmsForm" :model="sendSmsForm" :rules="sendSmsRules" label-width="140px">
<el-form-item :label="$t('发送类型')" prop="messageType">
<el-select v-model="sendSmsForm.messageType" placeholder="请选择发送类型">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_TEMPLATE_MESSAGE_TYPE)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
<el-form-item :label="$t('区号')" prop="countryCode">
<el-input v-model="sendSmsForm.countryCode" :placeholder="$t('请输入区号')" />
</el-form-item>
<el-form-item :label="$t('手机号')" prop="mobile">
<el-input v-model="sendSmsForm.mobile" :placeholder="$t('请输入手机号')" />
</el-form-item>
<el-form-item label="模板序号" prop="nodeTemplateSn">
<el-input v-model="sendSmsForm.nodeTemplateSn" placeholder="请输入模板序号" />
</el-form-item>
<el-form-item label="参数(JSON)" prop="templateParams">
<el-input v-model="sendSmsForm.templateParams" type="textarea"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitSendSmsForm">{{ $t('确 定') }}</el-button>
<el-button @click="cancelSendSms">{{ $t('取 消') }}</el-button>
</div>
</el-dialog>
<el-dialog :title="$t('测试发送短信')" :visible.sync="sendSmsOpen" width="500px" append-to-body>
<el-form ref="sendSmsForm" :model="sendSmsForm" :rules="sendSmsRules" label-width="140px">
<el-form-item :label="$t('发送类型')" prop="messageType">
<el-select v-model="sendSmsForm.messageType" placeholder="请选择发送类型">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_TEMPLATE_MESSAGE_TYPE)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
<el-form-item :label="$t('区号')" prop="countryCode">
<el-input v-model="sendSmsForm.countryCode" :placeholder="$t('请输入区号')" />
</el-form-item>
<el-form-item :label="$t('手机号')" prop="mobile">
<el-input v-model="sendSmsForm.mobile" :placeholder="$t('请输入手机号')" />
</el-form-item>
<el-form-item label="模板序号" prop="nodeTemplateSn">
<el-input v-model="sendSmsForm.nodeTemplateSn" placeholder="请输入模板序号" />
</el-form-item>
<el-form-item label="参数(JSON)" prop="templateParams">
<el-input v-model="sendSmsForm.templateParams" type="textarea"/>
</el-form-item>
<el-form-item label="目的仓" prop="receiveAddrList">
<el-cascader
style="width: 300px"
:options="regionTreeList"
collapse-tags
v-model="sendSmsForm.receiveAddrList"
:props="cascaderProps"
clearable>
</el-cascader>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitSendSmsForm">{{ $t('确 定') }}</el-button>
<el-button @click="cancelSendSms">{{ $t('取 消') }}</el-button>
</div>
</el-dialog>
<!-- 预览模板 -->
<el-dialog :visible.sync="open2" width="500px" append-to-body>
<el-form label-width="140px">
<el-form-item :label="$t('短信渠道编号')" prop="channelId">
<el-select v-model="form2.channelId" :placeholder="$t('请选择短信渠道编号')">
<el-option v-for="channel in channelOptions"
:key="channel.id" :value="channel.id"
:label="channel.signature + '【' + getDictDataLabel(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE, channel.code) + '】'" />
</el-select>
</el-form-item>
<el-form-item :label="$t('发送类型')" prop="messageType">
<el-select v-model="form2.messageType" placeholder="请选择发送类型">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_TEMPLATE_MESSAGE_TYPE)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
<el-form-item :label="$t('短信类型')" prop="type">
<el-select v-model="form2.type" :placeholder="$t('请选择短信类型')">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
<el-form-item label="节点" prop="nodeValue">
<el-select v-model="form2.nodeValue" placeholder="请选择节点类型">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_NODE_NODE)"
:key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('运输方式')" prop="transportId">
<el-select v-model="form2.transportId" :placeholder="$t('请选择运输方式类型')">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.ECW_TRANSPORT_TYPE)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
<el-option key="0" label="无" :value="parseInt(0)" />
</el-select>
</el-form-item>
<el-form-item :label="$t('模板编号')" prop="code">
<el-input v-model="form2.code" :placeholder="$t('请输入模板编号')" />
</el-form-item>
<el-form-item :label="$t('模板名称')" prop="name">
<el-input v-model="form2.name" :placeholder="$t('请输入模板名称')" />
</el-form-item>
<!-- 预览模板 -->
<el-dialog :visible.sync="open2" width="500px" append-to-body>
<el-form label-width="140px">
<el-form-item :label="$t('短信渠道编号')" prop="channelId">
<el-select v-model="form2.channelId" :placeholder="$t('请选择短信渠道编号')">
<el-option v-for="channel in channelOptions"
:key="channel.id" :value="channel.id"
:label="channel.signature + '【' + getDictDataLabel(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE, channel.code) + '】'" />
</el-select>
</el-form-item>
<el-form-item :label="$t('发送类型')" prop="messageType">
<el-select v-model="form2.messageType" placeholder="请选择发送类型">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_TEMPLATE_MESSAGE_TYPE)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
<el-form-item :label="$t('短信类型')" prop="type">
<el-select v-model="form2.type" :placeholder="$t('请选择短信类型')">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
<el-form-item label="节点" prop="nodeValue">
<el-select v-model="form2.nodeValue" placeholder="请选择节点类型">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_NODE_NODE)"
:key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('运输方式')" prop="transportId">
<el-select v-model="form2.transportId" :placeholder="$t('请选择运输方式类型')">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.ECW_TRANSPORT_TYPE)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
<el-option key="0" label="无" :value="parseInt(0)" />
</el-select>
</el-form-item>
<el-form-item :label="$t('模板编号')" prop="code">
<el-input v-model="form2.code" :placeholder="$t('请输入模板编号')" />
</el-form-item>
<el-form-item :label="$t('模板名称')" prop="name">
<el-input v-model="form2.name" :placeholder="$t('请输入模板名称')" />
</el-form-item>
<el-form-item :label="$t('开启状态')" prop="status">
<el-radio-group v-model="form2.status">
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="短信API模板编号" prop="apiTemplateId">
<el-input v-model="form2.apiTemplateId" placeholder="请输入短信 API 的模板编号" />
</el-form-item>
<el-form-item :label="$t('模板内容')" prop="content">
<el-input type="textarea" v-model="form2.content" :placeholder="$t('请输入模板内容')" />
</el-form-item>
<el-form-item :label="$t('备注')" prop="remark">
<el-input v-model="form2.remark" :placeholder="$t('请输入备注')" />
</el-form-item>
<el-form-item label="语言" prop="language">
<el-select v-model="form2.language" placeholder="请选择语言">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_TEMPLATE_LANGUAGE)"
:key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
</el-form>
</el-dialog>
<el-form-item :label="$t('开启状态')" prop="status">
<el-radio-group v-model="form2.status">
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="短信API模板编号" prop="apiTemplateId">
<el-input v-model="form2.apiTemplateId" placeholder="请输入短信 API 的模板编号" />
</el-form-item>
<el-form-item :label="$t('模板内容')" prop="content">
<el-input type="textarea" v-model="form2.content" :placeholder="$t('请输入模板内容')" />
</el-form-item>
<el-form-item :label="$t('备注')" prop="remark">
<el-input v-model="form2.remark" :placeholder="$t('请输入备注')" />
</el-form-item>
<el-form-item label="语言" prop="language">
<el-select v-model="form2.language" placeholder="请选择语言">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_TEMPLATE_LANGUAGE)"
:key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
</el-form>
</el-dialog>
</div>
......@@ -330,6 +357,8 @@ import { createSmsNode, updateSmsNode, deleteSmsNode, getSmsNode, getSmsNodePage
import {getCountryListAll} from '@/api/ecw/country'
import {getSmsTemplateList} from '@/api/system/sms/smsTemplate'
import { getSimpleSmsChannels } from "@/api/system/sms/smsChannel";
import { getRegionTreeList } from "@/api/ecw/memberManagement"
import { deepClone } from "@/utils/index"
export default {
name: "SmsNode",
......@@ -398,7 +427,11 @@ export default {
nodeTemplateSn: [{ required: true, message: "模板序号不能为空", trigger: "blur" }],
templateParams: [{ required: true, message: "参数(JSON)不能为空", trigger: "blur" }],
},
node: {}
node: {},
cascaderState: true,
regionTreeList: [],
lastSelectedList: [], //上一次选中数据
oneDimensionalList: [],
};
},
created() {
......@@ -423,6 +456,14 @@ export default {
getSimpleSmsChannels().then(response => {
this.channelOptions = response.data;
})
getRegionTreeList().then((res) => {
this.regionTreeList = res.data
this.regionTreeList.unshift({
id: "000",
labelZh: "全选",
labelEn: "select ALL"
})
})
},
filters: {
guojia: function(value,countryMap) {
......@@ -439,7 +480,124 @@ export default {
return text
}
},
computed: {
isChinese() {
return this.$i18n.locale === "zh_CN"
},
cascaderProps() {
const label = this.isChinese ? "labelZh" : "labelEn"
return { multiple: true, value: "id", label }
}
},
methods: {
selectHandle(val, defaultStatus = false) {
this.form.receiveAddrList = []
let current = [] // 获取当前选中的哪个数据
if (val.length >= this.lastSelectedList.length) {
let keys = this.lastSelectedList.map((item) => JSON.stringify(item))
current = val.filter((item) => !keys.includes(JSON.stringify(item)))
} else {
// 取消选中
let keys = val.map((item) => JSON.stringify(item))
current = this.lastSelectedList.filter((item) => !keys.includes(JSON.stringify(item)))
}
const currentValue = current.length > 0 ? current[0][0] || "" : ""
if (currentValue == "000") {
if (this.judgetAllSelected(val)) {
this.traverseTree(this.regionTreeList) //获取全选时回显的数据
} else {
this.form.receiveAddrList = [] //不选
}
} else {
this.form.receiveAddrList = val //半选
}
if (!defaultStatus) {
this.checkIsAddAllSelected()
}
// this.$nextTick(() => {
//
this.lastSelectedList = this.form.receiveAddrList
// });
},
checkIsAddAllSelected() {
//这里你要判断好你的dom是否正确
let label1 = document.querySelectorAll(".el-cascader-panel")[0].querySelector(".el-cascader-menu__wrap").querySelectorAll("li")[0].querySelectorAll("label")[0]
let span1 = document.querySelectorAll(".el-cascader-panel")[0].querySelector(".el-cascader-menu__wrap").querySelectorAll("li")[0].querySelectorAll("label")[0].querySelectorAll("span")[0]
// 获取所有的数据
let list = this.regionTreeList // 原始数据列表
if (this.oneDimensionalList.length === 0) {
this.getTreeList(list) // 把所有的父子级平铺成一个一级列表
}
let origin = [...this.oneDimensionalList].filter((item) => !item.children) //获取所有的叶子节点
let nowList = [...this.form.receiveAddrList].filter((item) => item[0] !== "000")
// 半选时, 如果有之前选过全选,要把全选过滤掉
if (origin.length > nowList.length && nowList.length != 0) {
this.form.receiveAddrList = deepClone(this.form.receiveAddrList.filter((item) => item[0] !== "000"))
//设置半选样式,setTimeout可以解决样式渲染不上的问题
setTimeout(function () {
label1.className = "el-checkbox"
span1.className = "el-checkbox__input is-indeterminate"
}, 1)
} else if (nowList.length == 0) {
//不选时, 如果有之前选过全选,要把全选过滤掉
this.form.receiveAddrList = deepClone(this.form.receiveAddrList.filter((item) => item[0] !== "000"))
label1.className = "el-checkbox"
span1.className = "el-checkbox__input"
} else {
// 当所有的数据都选择时, 要自动把全选勾选上 最后这种是:origin.length == nowList.length
if (this.form.receiveAddrList[0] && this.form.receiveAddrList[0][0] !== "000") {
this.form.receiveAddrList = [["000"], ...this.form.receiveAddrList]
label1.className = "el-checkbox"
span1.className = "el-checkbox__input is-checked"
}
}
},
getTreeList(list) {
let _this = this
for (let i = 0; i < list.length; i++) {
let a = list[i]
if (a.id !== "000") {
this.oneDimensionalList.push(list[i])
}
if (a.children && a.children.length > 0) {
let res = _this.getTreeList(a.children)
if (res) {
return res
}
}
}
},
judgetAllSelected(node) {
// 判断是否是全选,也就是看已选择的选中中包不包含"全选"
let isAllSelected = false
for (let i = 0; i < node.length; i++) {
if (node[i][0] == "000") {
isAllSelected = true
break
}
}
return isAllSelected
},
traverseTree(list, parentNode = []) {
list.length > 0 &&
list.forEach((e) => {
let pNode = deepClone(parentNode)
if (e.children && e.children.length > 0) {
pNode.push(e.id) // 1 11
this.traverseTree(e.children, pNode)
} else {
if (parentNode.length > 0) {
this.form.receiveAddrList.push([...parentNode, e.id])
} else {
this.form.receiveAddrList.push([e.id])
}
}
})
},
/** 查询列表 */
getList() {
this.loading = true;
......@@ -460,6 +618,7 @@ export default {
},
/** 表单重置 */
reset() {
this.cascaderState = true
this.form = {
id: undefined,
nodeValue: undefined,
......@@ -472,7 +631,9 @@ export default {
templateIdThree: undefined,
templateIdFour: undefined,
isTransport: undefined,
isOrders: undefined
isOrders: undefined,
receiveAddrList: [],
extra: undefined
};
this.resetForm("form");
},
......@@ -500,9 +661,15 @@ export default {
const id = row.id;
getSmsNode(id).then(response => {
this.smsTemplateList2 = this.smsTemplateList.filter(a=>(a.nodeValue == response.data.nodeValue)&&(a.transportId == response.data.transportId))
if (response.data.receiveAddrList!=null&&response.data.receiveAddrList.length>0&&response.data.receiveAddrList[0].toString() == "0,0,0") {
response.data.receiveAddrList = [["000"]]
}
this.form = response.data;
this.open = true;
this.title = "修改短信节点";
if(this.form.isTransport==1) {
this.cascaderState = false
}
});
},
/** 提交按钮 */
......@@ -518,6 +685,9 @@ export default {
}
this.form.countryId = [...this.form.countryIds].join(',')
this.form.countryCode = [...countryCodes].join(',')
if (this.form.receiveAddrList.length>0 &&this.form.receiveAddrList[0][0] == "000") {
this.form.receiveAddrList = [[0, 0, 0]]
}
// 修改的提交
if (this.form.id != null) {
updateSmsNode(this.form).then(response => {
......@@ -565,6 +735,14 @@ export default {
handleChangeNode(val) {
this.smsTemplateList2 = this.smsTemplateList.filter(a=>(a.nodeValue == this.form.nodeValue)&&(a.transportId == this.form.transportId))
},
handleChangeIsTransport(val) {
this.form.receiveAddrList = []
if(val==1) {
this.cascaderState = false
} else {
this.cascaderState = true
}
},
handleChangeTransportId(val) {
this.smsTemplateList2 = this.smsTemplateList.filter(a=>(a.nodeValue == this.form.nodeValue)&&(a.transportId == this.form.transportId))
},
......@@ -574,7 +752,8 @@ export default {
countryCode: '',
templateParams: '',
messageType: null,
nodeTemplateSn: 1
nodeTemplateSn: 1,
receiveAddrList: []
}
this.node = row
this.sendSmsOpen = true
......@@ -589,14 +768,24 @@ export default {
if (!valid) {
return;
}
var node = this.node
var node = JSON.parse(JSON.stringify(this.node))
node['countryCode'] = this.sendSmsForm.countryCode
node['mobile'] = this.sendSmsForm.countryCode +''+this.sendSmsForm.mobile
node['templateParams'] = JSON.parse(this.sendSmsForm.templateParams)
node['messageType'] = this.sendSmsForm.messageType
node['nodeTemplateSn'] = this.sendSmsForm.nodeTemplateSn
if (this.sendSmsForm.receiveAddrList.length>0) {
if(this.sendSmsForm.receiveAddrList[0][0] == "000") {
node['receiveAddrList'] = [[0, 0, 0]]
} else {
node['receiveAddrList'] = this.sendSmsForm.receiveAddrList
}
} else {
node['receiveAddrList'] = [[1, 1, 1]]
}
// 添加的提交
testSms(this.node).then(response => {
testSms(node).then(response => {
this.$modal.msgSuccess("提交发送成功!");
this.sendSmsOpen = false;
});
......
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