qa-prevention-xgf-vue/src/views/train/synInfo/components/sendUtil.vue

270 lines
8.0 KiB
Vue
Raw Normal View History

2023-12-18 18:54:49 +08:00
<template>
<div>
2023-12-21 16:59:50 +08:00
<el-dialog
v-loading="loading"
2023-12-21 16:59:50 +08:00
:visible.sync="visible"
:append-to-body="appendToBody"
:before-close="beforeClose"
2024-01-27 16:09:30 +08:00
title="推送"
width="1100px"
2023-12-21 16:59:50 +08:00
destroy-on-close>
<el-form ref="form" :model="form" :rules="rules" label-width="200px" label-position="right" type="flex">
2024-01-19 18:35:26 +08:00
<el-row>
<el-col :span="12">
<el-form-item prop="APPOINT_CORP_ID" label="单位 ">
<el-select v-model="corp_id" filterable placeholder="请选择单位 " style="width: 300px" @change="getInfo">
2024-01-19 18:35:26 +08:00
<el-option
v-for="item in jituanDanweiTreeData"
:key="item.CORPINFO_ID"
:label="item.CORP_NAME"
:value="JSON.stringify(item)"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="APPOINT_DEPARTMENT_ID" label="指定部门:">
2024-01-19 18:35:26 +08:00
<Treeselect
:options="departmentTree"
:normalizer="normalizer"
:default-expand-level="3"
2024-01-19 18:35:26 +08:00
v-model="form.APPOINT_DEPARTMENT_ID"
placeholder="请选择部门"
no-options-text="暂无数据"
no-children-text="暂无数据"
2024-01-27 16:09:30 +08:00
style="width: 300px"
2024-01-19 18:35:26 +08:00
@select="getPeopleList($event)"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item prop="APPOINT_USER_ID" label="指定审批人:">
2024-01-19 18:35:26 +08:00
<el-select v-model="form.user" style="width: 300px" placeholder="请选择" @change="chooseUser">
<el-option v-for="item in peopleList" :key="item.USER_ID" :value="JSON.stringify(item)" :label="item.NAME"/>
</el-select>
</el-form-item>
</el-col>
2024-02-04 11:03:10 +08:00
<el-col :span="12">
<el-form-item prop="APPOINT_ANNEX" label="承诺书:">
<upload-file
:file-list.sync="form.APPOINT_ANNEX"
:multiple="false"
:accept="'.pdf,.jpg,.png,doc,docx'"
:limit="20"
2024-02-04 11:03:10 +08:00
:size="1024"
:upload-type="1"/>
</el-form-item>
</el-col>
2024-01-19 18:35:26 +08:00
</el-row>
2023-12-18 18:54:49 +08:00
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="visible = false"> </el-button>
<el-button type="primary" @click="sendMessage()"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import vueQr from 'vue-qr'
import Treeselect from '@riophae/vue-treeselect'
import { requestFN } from '@/utils/request'
2024-02-04 11:03:10 +08:00
import uploadFile from '../../../util/uploadFile/index.vue'
import { upload } from '@/utils/upload'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
2023-12-18 18:54:49 +08:00
export default {
2024-02-04 11:03:10 +08:00
components: { Treeselect, vueQr, uploadFile },
2023-12-18 18:54:49 +08:00
props: {
appendToBody: {
type: Boolean,
default: false
}
},
data() {
return {
visible: false,
jituanDanwei: '',
loading: false,
jituanDanweiTreeData: [],
corp_id: null,
corp_name: '',
2023-12-21 16:59:50 +08:00
heirloom: {},
2024-01-19 18:35:26 +08:00
listFlag: false,
departmentTree: [],
peopleList: [],
sendType:'',
2024-01-19 18:35:26 +08:00
normalizer(node) {
return {
id: node.id,
label: node.name,
children: node.nodes
}
},
form: {
STATUS: null,
APPOINT_CORP_ID: '',
APPOINT_CORP_NAME: '',
APPOINT_DEPARTMENT_ID: null,
APPOINT_DEPARTMENT_NAME: '',
APPOINT_USER_ID: '',
APPOINT_USER_NAME: '',
2024-02-04 11:03:10 +08:00
APPOINT_ANNEX: [],
2024-01-19 18:35:26 +08:00
user: '',
tm: new Date().getTime(),
list: []
},
rules: {
APPOINT_DEPARTMENT_ID: [
{ required: true, message: '请选择指定部门', trigger: 'change' }
],
APPOINT_USER_ID: [
{ required: true, message: '请选择指定审批人', trigger: 'change' }
],
APPOINT_CORP_ID: [
{ required: true, message: '请选择企业', trigger: 'change' }
],
APPOINT_ANNEX: [
{ required: true, message: '请上传文件', trigger: 'change' }
]
2024-01-19 18:35:26 +08:00
}
2023-12-18 18:54:49 +08:00
}
},
methods: {
init(e,sendType) {
2023-12-18 18:54:49 +08:00
this.visible = true
2023-12-21 16:59:50 +08:00
this.listFlag = false
2023-12-18 18:54:49 +08:00
this.getCorpinfo()
this.heirloom = JSON.stringify(e)
this.sendType = sendType
2023-12-18 18:54:49 +08:00
},
getCorpinfo() {
requestFN(
'/corpinfo/getDataForEditByCorpInfoId',
{
CORPINFO_ID: JSON.parse(sessionStorage.getItem('user')).CORPINFO_ID,
tm: new Date().getTime()
}
).then((data) => {
this.corpinfo = data.pd
this.getTreeData()
})
},
getTreeData() {
2023-12-21 16:59:50 +08:00
requestFN(
'/department/getPreventCrop',
).then((data) => {
this.jituanDanweiTreeData = data.data
this.jituanDanweiTreeData.push({ CORPINFO_ID: '1', CORP_NAME: '秦皇岛港股份有限公司' })
2023-12-21 16:59:50 +08:00
}).catch((e) => {
})
2023-12-18 18:54:49 +08:00
},
getInfo(e) {
2023-12-21 16:59:50 +08:00
const info = JSON.parse(e)
2024-01-19 18:35:26 +08:00
this.form.APPOINT_CORP_ID = info.CORPINFO_ID
this.form.APPOINT_CORP_NAME = info.CORP_NAME
this.form.APPOINT_DEPARTMENT_ID = null
this.form.APPOINT_DEPARTMENT_NAME = ''
this.form.APPOINT_USER_ID = ''
this.form.APPOINT_USER_NAME = ''
this.form.user = ''
2024-01-19 18:35:26 +08:00
this.getDepartmentTree()
2023-12-18 18:54:49 +08:00
},
beforeClose() {
this.corp_id = null
2023-12-23 10:27:03 +08:00
this.visible = false
this.form = {
STATUS: null,
APPOINT_CORP_ID: '',
APPOINT_CORP_NAME: '',
APPOINT_DEPARTMENT_ID: null,
APPOINT_DEPARTMENT_NAME: '',
APPOINT_USER_ID: '',
APPOINT_USER_NAME: '',
user: '',
tm: new Date().getTime(),
list: []
}
2023-12-18 18:54:49 +08:00
},
2023-12-21 16:59:50 +08:00
sendMessage() {
this.$refs.form.validate((valid) => {
if (!valid) {
this.$message.error('请填写完整信息')
2023-12-22 15:49:11 +08:00
} else {
if (this.form.APPOINT_CORP_ID === this.form.APPOINT_DEPARTMENT_ID) {
this.$message.error('不能选择主部门或主账号')
return
}
this.form.list = this.heirloom
2024-02-04 11:03:10 +08:00
const formData = new FormData()
Object.keys(this.form).map(key => {
formData.append(key, this.form[key])
})
for (let i = 0; i < this.form.APPOINT_ANNEX.length; i++) {
formData.append('chenNuoShu', this.form.APPOINT_ANNEX[i].raw)
}
this.loading = true
console.log(this.heirloom)
if (this.sendType != null){
formData.append('sendType',1)
}
console.log(formData)
2024-02-04 11:03:10 +08:00
upload('/trainingbatch/sendMessage', formData
).then((data) => {
if (data.code !== '0') {
this.$message.error(data.msg)
} else {
this.$message.success('推送成功')
this.visible = false
this.$emit('refresh', '')
this.beforeClose()
this.loading = false
}
})
2023-12-22 15:49:11 +08:00
}
2023-12-18 18:54:49 +08:00
})
2024-01-19 18:35:26 +08:00
},
getDepartmentTree() {
requestFN(
'/companyApi/department/listTree',
{ CORPINFO_ID: this.form.APPOINT_CORP_ID }
).then((data) => {
this.departmentTree = this.removeEmptyChildren(JSON.parse(data.zTreeNodes))
}).catch((e) => {
console.log(e)
})
},
getPeopleList(e) {
this.form.APPOINT_DEPARTMENT_NAME = e.name
requestFN(
'/companyApi/user/listAll',
{
DEPARTMENT_ID: e.id,
CORPINFO_ID: JSON.parse(this.corp_id).CORPINFO_ID
2024-01-19 18:35:26 +08:00
}
).then((data) => {
this.form.APPOINT_USER_ID = ''
this.form.APPOINT_USER_NAME = ''
this.form.user = ''
2024-01-19 18:35:26 +08:00
this.peopleList = data.userList
}).catch((e) => {
console.log(e)
})
},
chooseUser(e) {
const entity = JSON.parse(e)
this.form.APPOINT_USER_ID = entity.USER_ID
this.form.APPOINT_USER_NAME = entity.NAME
2023-12-18 18:54:49 +08:00
}
2024-01-19 18:35:26 +08:00
2023-12-18 18:54:49 +08:00
}
}
</script>
<style lang="scss" scoped>
</style>