This commit is contained in:
yangduo 2024-08-07 17:29:29 +08:00
parent b5c13420a5
commit 54e7baa6e8
2 changed files with 778 additions and 29 deletions

650
src/constant/itemids.js Normal file
View File

@ -0,0 +1,650 @@
export const ItemList = [
'10001',
'10002',
'10003',
'10004',
'10005',
'10006',
'10009',
'10010',
'10011',
'10012',
'10013',
'10014',
'10015',
'10016',
'10017',
'10018',
'20001',
'20002',
'20003',
'20004',
'20005',
'20006',
'20007',
'20008',
'20009',
'20010',
'30100',
'30200',
'30300',
'30400',
'30500',
'30600',
'30700',
'30800',
'30900',
'31000',
'40101',
'40102',
'40201',
'40202',
'40301',
'40302',
'40401',
'40501',
'40601',
'40602',
'40701',
'40702',
'40801',
'40802',
'40901',
'40902',
'41001',
'50001',
'50002',
'50003',
'50004',
'50005',
'50006',
'50007',
'50008',
'50009',
'50010',
'60000',
'60003',
'70001',
'70002',
'70003',
'70004',
'70005',
'70006',
'70007',
'70008',
'70009',
'70010',
'80001',
'80002',
'80003',
'80004',
'80005',
'80006',
'80007',
'90001',
'90002',
'90003',
'900004',
'900005',
'900006',
'101001',
'100001',
'100002',
'100003',
'100004',
'100005',
'100006',
'100007',
'91000',
'90004',
'90005',
'90006',
'110001',
'130001',
'130002',
'130003',
'130004',
'130011',
'130012',
'130013',
'130014',
'130021',
'130022',
'130023',
'130024',
'140001',
'110290',
'110291',
'110292',
'110293',
'110294',
'110295',
'110296',
'110297',
'110298',
'110299',
'110101',
'110111',
'110121',
'110131',
'110141',
'110151',
'110161',
'110171',
'110181',
'110201',
'110211',
'110221',
'110231',
'110241',
'110251',
'110261',
'110271',
'110281',
'170001',
'170002',
'150101',
'150102',
'150103',
'150201',
'150202',
'150203',
'160001',
'160002',
'160003',
'160004',
'160005',
'160006',
'160007',
'160008',
'160009',
'160010',
'190001',
'190002',
'190003',
'200001',
'200002',
'200003',
'200004',
'200005',
'200006',
'200007',
'200008',
'200009',
'200010',
'200011',
'210001',
'210002',
'210003',
'210011',
'210012',
'900001',
'900002',
'900003',
'240001',
'250001',
'260001',
'260002',
'260003',
'260004',
'260010',
'27010001',
'27020001',
'280001',
'280002',
'280003',
'280004',
'280005',
'280006',
'280007',
'280008',
'280009',
'280010',
'280011',
'280012',
'280013',
'280014',
'280015',
'280016',
'280017',
'280018',
'280019',
'280020',
'280021',
'280022',
'280023',
'280024',
'280025',
'280026',
'280027',
'280028',
'280029',
'280030',
'280031',
'280032',
'280033',
'280034',
'280035',
'280036',
'280037',
'280038',
'280039',
'280040',
'280041',
'280042',
'280043',
'280044',
'280045',
'280046',
'280047',
'280048',
'280049',
'280050',
'280051',
'280052',
'280053',
'280054',
'280055',
'280056',
'280057',
'280058',
'280059',
'280060',
'280061',
'280062',
'280063',
'280064',
'280065',
'280066',
'280067',
'280068',
'280069',
'280070',
'280071',
'280072',
'280073',
'280074',
'280075',
'280076',
'280077',
'280078',
'280079',
'280080',
'280081',
'280082',
'280083',
'280084',
'280085',
'280086',
'280087',
'280088',
'280089',
'280090',
'280091',
'280092',
'280093',
'280094',
'280095',
'280096',
'280097',
'280098',
'280099',
'280100',
'280101',
'280102',
'280103',
'280104',
'280105',
'280106',
'280107',
'280108',
'280109',
'280110',
'280111',
'280112',
'280113',
'280114',
'280115',
'280116',
'280117',
'280118',
'280119',
'280120',
'280121',
'280122',
'280123',
'280124',
'280125',
'280126',
'280127',
'280128',
'280129',
'280130',
'280131',
'280132',
'280133',
'280134',
'280135',
'280136',
'280137',
'280138',
'280139',
'280140',
'280141',
'280142',
'280143',
'280144',
'280145',
'280146',
'280147',
'280148',
'280149',
'280150',
'280151',
'280152',
'280153',
'280154',
'280155',
'280156',
'280157',
'280158',
'280159',
'280160',
'280161',
'280162',
'280163',
'280164',
'280165',
'280166',
'280167',
'280168',
'280169',
'280170',
'280171',
'280172',
'280173',
'280174',
'280175',
'280176',
'280177',
'280178',
'280179',
'280180',
'280181',
'280182',
'280183',
'280184',
'280185',
'280186',
'280187',
'280188',
'280189',
'280190',
'280191',
'280192',
'280193',
'280194',
'280195',
'280196',
'280197',
'280198',
'280199',
'280200',
'280201',
'280202',
'280203',
'280204',
'280205',
'280206',
'280207',
'280208',
'280209',
'280210',
'280211',
'280212',
'280213',
'280214',
'280215',
'280216',
'280217',
'280218',
'280219',
'280220',
'280221',
'280222',
'280223',
'280224',
'280225',
'280226',
'280227',
'280228',
'280229',
'280230',
'280231',
'280232',
'280233',
'280234',
'280235',
'280236',
'280237',
'280238',
'280239',
'280240',
'280241',
'280242',
'280243',
'280244',
'280245',
'280246',
'280247',
'280248',
'280249',
'280250',
'280251',
'280252',
'280253',
'280254',
'280255',
'280256',
'280257',
'280258',
'280259',
'280260',
'280261',
'280262',
'280263',
'280264',
'280265',
'280266',
'280267',
'280268',
'280269',
'280270',
'280271',
'280272',
'280273',
'280274',
'280275',
'280276',
'280277',
'280278',
'280279',
'280280',
'280281',
'280282',
'280283',
'280284',
'280285',
'280286',
'280287',
'280288',
'280289',
'280290',
'280291',
'280292',
'280293',
'280294',
'280295',
'280296',
'280297',
'280298',
'280299',
'280300',
'290001',
'300000',
'300001',
'300002',
'300003',
'300004',
'300005',
'400101',
'400102',
'400103',
'400104',
'400105',
'400106',
'400201',
'400202',
'400203',
'400204',
'400205',
'400206',
'400301',
'400302',
'400303',
'11130100',
'11230100',
'11330100',
'11430100',
'11530100',
'11630100',
'11130200',
'11230200',
'11330200',
'11430200',
'11530200',
'11630200',
'11130300',
'11230300',
'11330300',
'11430300',
'11530300',
'11630300',
'11130400',
'11230400',
'11330400',
'11430400',
'11530400',
'11630400',
'11130500',
'11230500',
'11330500',
'11430500',
'11530500',
'11630500',
'11130600',
'11230600',
'11330600',
'11430600',
'11530600',
'11630600',
'11130700',
'11230700',
'11330700',
'11430700',
'11530700',
'11630700',
'11130800',
'11230800',
'11330800',
'11430800',
'11530800',
'11630800',
'11130900',
'11230900',
'11330900',
'11430900',
'11530900',
'11630900',
'11131000',
'11231000',
'11331000',
'11431000',
'11531000',
'11631000',
'11213001',
'11213002',
'11213003',
'11213004',
'11213005',
'11213006',
'11213007',
'11213008',
'11213009',
'11213010',
'11213011',
'11213012',
'11213013',
'11213014',
'11213015',
'11213016',
'11213017',
'11213018',
'11213019',
'11213020',
'11213021',
'11213022',
'11213023',
'11213024',
'11213025',
'11213026',
'11213027',
'11213028',
'11213029',
'11213030',
'11213031',
'11213032',
'11213033',
'11213034',
'11213035',
'11213036',
'11213037',
'11213038',
'11213039',
'11213040',
'11213041',
'11213042',
'11213043',
'11213044',
'11213045',
'11213046',
'11213047',
'11213048',
'11213049',
'11213050',
'11213051',
'11213052',
'11213053',
'11213054',
'11213055',
'11213056',
'11213057',
'11213058',
'11213059',
'11213060',
'11213061',
'11213062',
'11213063',
'11213064',
'11213065',
'11213066',
'11213067',
'11213068',
'11213069',
'11213070',
'11213071',
'11213072',
'11510017',
'11610018',
'30000001'
]

View File

@ -8,6 +8,13 @@
</el-button>
</sticky>
<div class="createPost-main-container">
<el-row>
<el-col :span="10">
<el-form-item label-width="120px" label="unikey:" class="postInfo-container-item" prop="unikey" required>
<el-input v-model="postForm.unikey" :maxlength="100" placeholder="max 100 char" required :readonly="isupdate" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="10">
<el-form-item label-width="120px" label="发送时间:" class="postInfo-container-item" prop="sendtime">
@ -21,12 +28,12 @@
</el-col>
<el-col v-show="userRegVisible" :span="10">
<el-form-item label-width="120px" label="注册时间>=:" class="postInfo-container-item" prop="user_reg_start_time">
<el-date-picker v-model.number="postForm.user_reg_start_time" type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="timestamp" placeholder="Select date and time" required />
<el-date-picker v-model.number="postForm.user_reg_start_time" type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="timestamp" placeholder="Select date and time" :required="userRegVisible" />
</el-form-item>
</el-col>
<el-col v-show="userRegVisible" :span="10">
<el-form-item label-width="120px" label="注册时间<=:" class="postInfo-container-item" prop="user_reg_end_time">
<el-date-picker v-model.number="postForm.user_reg_end_time" type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="timestamp" placeholder="Select date and time" required />
<el-date-picker v-model.number="postForm.user_reg_end_time" type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="timestamp" placeholder="Select date and time" :required="userRegVisible" />
</el-form-item>
</el-col>
</el-row>
@ -34,15 +41,15 @@
<el-row>
<el-col :span="24">
<el-form-item style="margin-bottom: 40px;" prop="subject">
<MDinput v-model="postForm.subject" :maxlength="100" name="subject" required>
<MDinput v-model="postForm.subject" :maxlength="100" name="subject" placeholder="max 100 chars" required>
邮件标题
</MDinput>
</el-form-item>
<el-form-item prop="content" style="margin-bottom: 30px;" label="邮件正文:">
<el-input v-model="postForm.content" type="textarea" :rows="6" />
<el-input v-model="postForm.content" type="textarea" :maxlength="1024" placeholder="max 1024 chars" :rows="6" />
</el-form-item>
<el-form-item style="margin-bottom: 30px;" label="附件:">
<el-input v-model="postForm.attachments" type="textarea" :rows="6" />
<el-input v-model="postForm.attachments" type="textarea" :maxlength="256" placeholder="max 256 chars" :rows="6" />
</el-form-item>
</el-col>
</el-row>
@ -67,6 +74,7 @@ import MDinput from '@/components/MDinput/index.vue'
import { addMail, updateEmail } from '@/api/mail'
import { parseTime } from '@/utils'
import { MAIL_TYPE_GROUP, MAIL_TYPE_ALL } from '@/constant/constant'
import { ItemList } from '@/constant/itemids'
export default {
name: 'Email',
@ -75,6 +83,7 @@ export default {
return {
postForm: {
mailtype: MAIL_TYPE_GROUP,
unikey: '',
sendtime: '',
expiretime: '',
user_reg_start_time: '',
@ -113,17 +122,18 @@ export default {
}
]
},
userRegVisible: true,
userRegVisible: false,
groupMailVisible: true,
mailTypeVisible: true,
dialogStatus: 'create'
dialogStatus: 'create',
isupdate: false
}
},
watch: {
'postForm.mailtype'(val) {
switch (val) {
case MAIL_TYPE_GROUP:
this.userRegVisible = true
this.userRegVisible = false
this.groupMailVisible = true
break
case MAIL_TYPE_ALL:
@ -141,6 +151,7 @@ export default {
if (mailid) {
this.mailTypeVisible = false
this.dialogStatus = 'update'
this.isupdate = true
const editEmail = JSON.parse(sessionStorage.getItem('editEmail' + mailid))
this.postForm = editEmail
@ -156,8 +167,10 @@ export default {
this.postForm.user_reg_start_time = editEmail.user_reg_start_time * 1000
this.postForm.user_reg_end_time = editEmail.user_reg_end_time * 1000
this.postForm.recipients = editEmail.recipients.join('\n')
this.postForm.unikey = editEmail.unikey
} else {
this.dialogStatus = 'create'
this.isupdate = false
sessionStorage.removeItem('editEmail' + mailid)
}
},
@ -167,22 +180,64 @@ export default {
const data = JSON.parse(JSON.stringify(this.postForm))
data.sendtime = data.sendtime / 1000
data.expiretime = data.expiretime / 1000
data.user_reg_start_time = data.user_reg_start_time / 1000
data.user_reg_end_time = data.user_reg_end_time / 1000
if (data.mailtype === MAIL_TYPE_GROUP) {
data.user_reg_start_time = 0
data.user_reg_end_time = 0x7FFFFFFF
this.postForm.user_reg_start_time = 0
this.postForm.user_reg_end_time = 0x7FFFFFFF * 1000
} else {
data.user_reg_start_time = data.user_reg_start_time / 1000
data.user_reg_end_time = data.user_reg_end_time / 1000
}
console.log('valid begin')
data.recipients = data.recipients.split('\n')
var arr = data.attachments.split('\n')
arr.forEach((item, index) => {
var recipientsArr = {}
var itemArr = item.split(':')
recipientsArr['itemid'] = parseInt(itemArr[0])
recipientsArr['itemnum'] = parseInt(itemArr[1])
arr[index] = recipientsArr
})
var list = []
if (data.recipients != null && data.recipients !== '') {
var j = 0
data.recipients.split('\n').forEach((item, index) => {
if (item != null && item !== '') {
list[j] = item
j++
}
})
}
data.recipients = list
var arr = []
if (data.attachments != null && data.attachments !== '') {
j = 0
var itemerr = false
data.attachments.split('\n').some(item => {
var itemArr = item.split(':')
if (itemArr[0] != null && itemArr[0] !== '' && itemArr[1] != null && itemArr[1] !== '') {
if (!this.checkItem(itemArr[0])) {
this.$message({
message: 'unknown item id ' + itemArr[0],
type: 'error',
duration: 2000
})
itemerr = true
return true
}
var recipientsArr = {}
recipientsArr['itemid'] = parseInt(itemArr[0])
recipientsArr['itemnum'] = parseInt(itemArr[1])
arr[j] = recipientsArr
j++
}
})
if (itemerr) {
return
}
}
data.attachments = arr
try {
this.$refs['postForm'].validate((valid) => {
console.log('valid end', valid)
if (this.postForm.mailtype === MAIL_TYPE_GROUP) {
this.postForm.user_reg_start_time = ''
this.postForm.user_reg_end_time = ''
}
if (valid) {
addMail(data).then(response => {
if (response.code === 0) {
@ -208,16 +263,50 @@ export default {
data.expiretime = data.expiretime / 1000
data.user_reg_start_time = data.user_reg_start_time / 1000
data.user_reg_end_time = data.user_reg_end_time / 1000
console.log('valid begin')
data.recipients = data.recipients.split('\n')
var arr = data.attachments.split('\n')
arr.forEach((item, index, arr) => {
var recipientsArr = {}
var itemArr = item.split(':')
recipientsArr['itemid'] = parseInt(itemArr[0])
recipientsArr['itemnum'] = parseInt(itemArr[1])
arr[index] = recipientsArr
})
if (data.mailtype === MAIL_TYPE_GROUP) {
data.user_reg_start_time = 0
data.user_reg_end_time = 0xFFFFFFFF
}
var list = []
if (data.recipients != null && data.recipients !== '') {
var j = 0
data.recipients.split('\n').forEach((item, index) => {
if (item != null && item !== '') {
list[j] = item
j++
}
})
}
data.recipients = list
var arr = []
if (data.attachments != null && data.attachments !== '') {
j = 0
var itemerr = false
data.attachments.split('\n').some(item => {
var itemArr = item.split(':')
if (itemArr[0] != null && itemArr[0] !== '' && itemArr[1] != null && itemArr[1] !== '') {
if (!this.checkItem(itemArr[0])) {
this.$message({
message: 'unknown item id ' + itemArr[0],
type: 'error',
duration: 2000
})
itemerr = true
return
}
var recipientsArr = {}
recipientsArr['itemid'] = parseInt(itemArr[0])
recipientsArr['itemnum'] = parseInt(itemArr[1])
arr[j] = recipientsArr
j++
}
})
if (itemerr) {
return
}
}
data.attachments = arr
this.$refs['postForm'].validate((valid) => {
if (valid) {
@ -236,6 +325,16 @@ export default {
})
}
})
},
checkItem(itemid) {
var found = false
ItemList.some(item => {
if (item === itemid) {
found = true
return true
}
})
return found
}
}
}