需求修改回显

This commit is contained in:
a0049873 2022-11-30 15:23:19 +08:00
parent 95d27d57e0
commit baebd9f62b
1 changed files with 364 additions and 266 deletions

View File

@ -9,38 +9,83 @@
<div class="form-container">
<div v-if="applySuccess">
<div class="title">申请人信息</div>
<a-form ref="formRef" :model="formName" name="basic" :label-col="{ style: { width: '106px' } }"
:wrapper-col="{ style: { width: '230px' } }" labelAlign="left" autocomplete="off">
<a-form
ref="formRef"
:model="formName"
name="basic"
:label-col="{ style: { width: '106px' } }"
:wrapper-col="{ style: { width: '230px' } }"
labelAlign="left"
autocomplete="off"
>
<div class="base-info">
<a-form-item label="申请人" name="applyUserName" :rules="[{ required: true, message: '请输入申请人' }]">
<a-input placeholder="请输入申请人" v-model:value="formName.applyUserName" />
<a-form-item
label="申请人"
name="applyUserName"
:rules="[{ required: true, message: '请输入申请人' }]"
>
<a-input
placeholder="请输入申请人"
v-model:value="formName.applyUserName"
/>
</a-form-item>
<a-form-item style="margin: 0 22px" label="申请人电话" name="applyUserPhone" :rules="[
{
required: true,
pattern: /^1[3456789]\d{9}$/,
message: '请输入正确的电话号码',
},
]">
<a-input placeholder="请输入申请人电话" v-model:value="formName.applyUserPhone" />
<a-form-item
style="margin: 0 22px"
label="申请人电话"
name="applyUserPhone"
:rules="[
{
required: true,
pattern: /^1[3456789]\d{9}$/,
message: '请输入正确的电话号码',
},
]"
>
<a-input
placeholder="请输入申请人电话"
v-model:value="formName.applyUserPhone"
/>
</a-form-item>
<a-form-item label="申请单位" name="applyUserDeptName" :rules="[{ required: true, message: '请输入申请单位' }]">
<a-input placeholder="请输入申请单位" v-model:value="formName.applyUserDeptName" />
<a-form-item
label="申请单位"
name="applyUserDeptName"
:rules="[{ required: true, message: '请输入申请单位' }]"
>
<a-input
placeholder="请输入申请单位"
v-model:value="formName.applyUserDeptName"
/>
</a-form-item>
</div>
<div class="title">需求信息</div>
<a-form-item style="margin-bottom: 10px" label="需求标题" name="demandSubject"
:rules="[{ required: true, message: '请输入需求标题' }]">
<a-input style="width: 350px" v-model:value="formName.demandSubject" />
<a-form-item
style="margin-bottom: 10px"
label="需求标题"
name="demandSubject"
:rules="[{ required: true, message: '请输入需求标题' }]"
>
<a-input
style="width: 350px"
v-model:value="formName.demandSubject"
/>
</a-form-item>
<a-form-item style="margin-bottom: 10px" label="需求类型" name="detailsType"
:rules="[{ required: true, message: '请选择需求类型' }]">
<a-select ref="select" v-model:value="formName.detailsType" @focus="focus" style="width: 200px">
<a-form-item
style="margin-bottom: 10px"
label="需求类型"
name="detailsType"
:rules="[{ required: true, message: '请选择需求类型' }]"
>
<a-select
ref="select"
v-model:value="formName.detailsType"
@focus="focus"
style="width: 200px"
>
<a-select-option value="基础设施">基础设施</a-select-option>
<a-select-option value="数据资源">数据资源</a-select-option>
<a-select-option value="组件服务">组件服务</a-select-option>
@ -49,24 +94,44 @@
</a-select>
</a-form-item>
<a-form-item label="应用领域" v-if="formName.detailsType === '应用资源' ||
formName.detailsType === '组件服务'" name="detailsField" style="width: 6.93rem" :rules="[
{
required: true,
message: '请选择应用领域',
},
]">
<a-select v-model:value="formName.detailsField" :options="applicationSceneOpthion" mode="tags"
:size="size" placeholder="请选择应用领域" :filterOption="false" :searchValue="false" style="width: 5.87rem">
</a-select>
<a-form-item
label="应用领域"
v-if="
formName.detailsType === '应用资源' ||
formName.detailsType === '组件服务'
"
name="detailsField"
style="width: 6.93rem"
:rules="[
{
required: true,
message: '请选择应用领域',
},
]"
>
<a-select
v-model:value="formName.detailsField"
:options="applicationSceneOpthion"
mode="tags"
:size="size"
placeholder="请选择应用领域"
:filterOption="false"
:searchValue="false"
style="width: 5.87rem"
></a-select>
</a-form-item>
<!-- <a-form-item label="应用领域" name="detailsField" style="width: 350px"
:rules="[{ required: true, message: '请输入应用领域' }]">
<a-input placeholder="请输入应用领域" v-model:value="formName.detailsField" />
</a-form-item> -->
<a-form-item style="margin-bottom: 10px" label="需求描述" name="demandDetails"
:rules="[{ required: true, message: '请输入需求描述' }]">
<a-textarea style="
<a-form-item
style="margin-bottom: 10px"
label="需求描述"
name="demandDetails"
:rules="[{ required: true, message: '请输入需求描述' }]"
>
<a-textarea
style="
width: 500px;
height: 150px;
font-size: 16px;
@ -76,12 +141,25 @@
border-radius: 6px;
padding: 10px;
resize: none;
" v-model:value="formName.demandDetails" />
"
v-model:value="formName.demandDetails"
/>
</a-form-item>
<a-form-item style="color: #666; font-size: 16px" label="附件上传" name="applyDoc">
<a-upload v-model:file-list="fileList" name="file" :action="upLoadUrl" :headers="headers"
@change="handleChange" :maxCount="1">
<a-button style="
<a-form-item
style="color: #666; font-size: 16px"
label="附件上传"
name="applyDoc"
>
<a-upload
v-model:file-list="fileList"
name="file"
:action="upLoadUrl"
:headers="headers"
@change="handleChange"
:maxCount="1"
>
<a-button
style="
width: 100px;
height: 30px;
margin-right: 10px;
@ -92,7 +170,8 @@
border: 1px solid #bbd3ef;
padding: 0;
text-align: center;
">
"
>
<upload-outlined></upload-outlined>
文件上传
</a-button>
@ -103,7 +182,8 @@
</a-form-item>
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
<a-button style="
<a-button
style="
width: 80px;
height: 38px;
margin-right: 20px;
@ -114,10 +194,15 @@
border: none;
padding: 0;
text-align: center;
" type="primary" html-type="cancle" @click="signOut">
"
type="primary"
html-type="cancle"
@click="signOut"
>
退出申请
</a-button>
<a-button style="
<a-button
style="
width: 80px;
height: 38px;
background: #0087ff;
@ -127,7 +212,11 @@
border: none;
padding: 0;
text-align: center;
" type="primary" html-type="submit" @click="processStartHandle()">
"
type="primary"
html-type="submit"
@click="processStartHandle()"
>
提交申请
</a-button>
</a-form-item>
@ -139,7 +228,7 @@
</div>
<p>
您已成功申请{{
formName.demandSubject || ''
formName.demandSubject || ''
}},请耐心等待审批结果结果会第一时间通知您
</p>
</div>
@ -150,248 +239,257 @@
</template>
<script>
import HomeHeader from '@/views/home/components/header'
import { reactive, ref } from 'vue'
import { message } from 'ant-design-vue'
// import { UploadOutlined } from '@ant-design/icons-vue'
import { getUser, getUserInfo, relaunch } from '@/api/home'
import {
demandApply,
getDemandForm,
updateDemandForm,
getCategoryTreePage,
} from '@/api/personalCenter'
// import { baseURL } from '@/config'
import { useRouter } from 'vue-router'
import HomeHeader from '@/views/home/components/header'
import { reactive, ref } from 'vue'
import { message } from 'ant-design-vue'
// import { UploadOutlined } from '@ant-design/icons-vue'
import { getUser, getUserInfo, relaunch } from '@/api/home'
import {
demandApply,
getDemandForm,
updateDemandForm,
getCategoryTreePage,
} from '@/api/personalCenter'
// import { baseURL } from '@/config'
import { useRouter } from 'vue-router'
export default {
name: '',
props: {},
components: {
HomeHeader,
// UploadOutlined,
},
setup() {
const disabled = ref(false)
const upLoadUrl = ref(window.SITE_CONFIG.apiURL + '/upload')
const formName = reactive({
applyUserDeptId: '',
applyUserDeptName: '',
applyUserId: '',
applyUserName: '',
applyUserPhone: '',
demandDetails: '',
demandSubject: '',
detailsField: [],
detailsType: '',
enclosure: '',
})
// console.log(formName.demandSubject)
const router = useRouter()
const id = ref(router.currentRoute.value.query.id)
const taskId = ref(router.currentRoute.value.query.taskId)
if (id.value) {
getDemandForm(id.value).then((res) => {
console.log('回填数据===============>', res)
formName.applyUserPhone = res.data.data.applyUserPhone
formName.demandSubject = res.data.data.demandSubject
formName.detailsType = res.data.data.detailsType
formName.detailsField = res.data.data.detailsField
formName.demandDetails = res.data.data.demandDetails
formName.enclosure = res.data.data.enclosure
export default {
name: '',
props: {},
components: {
HomeHeader,
// UploadOutlined,
},
setup() {
const disabled = ref(false)
const upLoadUrl = ref(window.SITE_CONFIG.apiURL + '/upload')
const formName = reactive({
applyUserDeptId: '',
applyUserDeptName: '',
applyUserId: '',
applyUserName: '',
applyUserPhone: '',
demandDetails: '',
demandSubject: '',
detailsField: [],
detailsType: '',
enclosure: '',
})
}
const applicationSceneOpthion = ref([])
getCategoryTreePage({
page: 1,
limit: 20,
dictTypeId: '1513712507692818433',
deFlage: 0,
}).then((res) => {
res.data.data.list.map((val) => {
applicationSceneOpthion.value.push({
value: val.dictLabel,
label: val.dictLabel,
})
})
// console.log('========>', applicationSceneOpthion.value)
})
getUser().then((res) => {
formName.applyUserName = res.data.data.realName
formName.applyUserId = res.data.data.id
getUserInfo(formName.applyUserId).then((res) => {
if (res.data.data.mobile) {
formName.applyUserPhone = res.data.data.mobile
}
formName.applyUserDeptName = res.data.data.deptName
formName.applyUserDeptId = res.data.data.deptId
})
})
const formRef = ref()
const applySuccess = ref(true)
// 退
const signOut = () => {
window.close()
}
const handleChange = (info) => {
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList)
}
if (info.file.status === 'done') {
message.success(`${info.file.name} 文件上传成功`)
formName.enclosure = info.file.response.data
} else if (info.file.status === 'error') {
message.error(`${info.file.name} 文件上传失败`)
}
}
const fileList = ref([])
const processStartHandle = () => {
let detailsField = '';
if (formName.detailsField.length > 0) {
formName.detailsField.map((item) => {
detailsField += item + ';'
})
}
// copy
let _postData = JSON.parse(JSON.stringify(formName))
_postData.detailsField = detailsField;
// console.log(formName.demandSubject)
const router = useRouter()
const id = ref(router.currentRoute.value.query.id)
const taskId = ref(router.currentRoute.value.query.taskId)
if (id.value) {
updateDemandForm(_postData).then((upres) => {
if (upres.data.code == 0) {
relaunch({ data: _postData, taskId: taskId.value }).then((res) => {
console.log('驳回================>', res)
if (res.data.code == 0) {
message.success('重新发起流程成功!')
window.setTimeout(() => {
window.close()
}, 1000)
} else {
message.error('重新发起流程失败!')
}
})
} else {
message.error('数据更新失败!')
}
getDemandForm(id.value).then((res) => {
console.log('回填数据===============>', res)
formName.applyUserPhone = res.data.data.applyUserPhone
formName.demandSubject = res.data.data.demandSubject
formName.detailsType = res.data.data.detailsType
formName.detailsField = res.data.data.detailsField
formName.demandDetails = res.data.data.demandDetails
formName.enclosure = res.data.data.enclosure
fileList.value = [
{
uid: res.data.data.id,
name: '附件',
staus: 'done',
},
]
})
} else {
formRef.value.validate().then((valid) => {
const detString = String(_postData.detailsField)
_postData.detailsField = detString
console.log(detString, _postData.detailsField, 'detString')
demandApply(_postData).then((res) => {
applySuccess.value = false
message.success('操作成功!')
console.log('能力申请================>', res)
}
const applicationSceneOpthion = ref([])
getCategoryTreePage({
page: 1,
limit: 20,
dictTypeId: '1513712507692818433',
deFlage: 0,
}).then((res) => {
res.data.data.list.map((val) => {
applicationSceneOpthion.value.push({
value: val.dictLabel,
label: val.dictLabel,
})
})
}
}
// console.log('========>', applicationSceneOpthion.value)
})
getUser().then((res) => {
formName.applyUserName = res.data.data.realName
formName.applyUserId = res.data.data.id
getUserInfo(formName.applyUserId).then((res) => {
if (res.data.data.mobile) {
formName.applyUserPhone = res.data.data.mobile
}
formName.applyUserDeptName = res.data.data.deptName
formName.applyUserDeptId = res.data.data.deptId
})
})
return {
formRef,
formName,
fileList,
headers: {
authorization: 'authorization-text',
},
handleChange,
applySuccess,
disabled,
signOut,
processStartHandle,
upLoadUrl,
// baseURL,
applicationSceneOpthion,
}
},
}
const formRef = ref()
const applySuccess = ref(true)
// 退
const signOut = () => {
window.close()
}
const handleChange = (info) => {
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList)
}
if (info.file.status === 'done') {
message.success(`${info.file.name} 文件上传成功`)
formName.enclosure = info.file.response.data
} else if (info.file.status === 'error') {
message.error(`${info.file.name} 文件上传失败`)
}
}
const fileList = ref([])
const processStartHandle = () => {
let detailsField = ''
if (formName.detailsField.length > 0) {
formName.detailsField.map((item) => {
detailsField += item + ';'
})
}
// copy
let _postData = JSON.parse(JSON.stringify(formName))
_postData.detailsField = detailsField
if (id.value) {
updateDemandForm(_postData).then((upres) => {
if (upres.data.code == 0) {
relaunch({ data: _postData, taskId: taskId.value }).then(
(res) => {
console.log('驳回================>', res)
if (res.data.code == 0) {
message.success('重新发起流程成功!')
window.setTimeout(() => {
window.close()
}, 1000)
} else {
message.error('重新发起流程失败!')
}
}
)
} else {
message.error('数据更新失败!')
}
})
} else {
formRef.value.validate().then((valid) => {
const detString = String(_postData.detailsField)
_postData.detailsField = detString
console.log(detString, _postData.detailsField, 'detString')
demandApply(_postData).then((res) => {
applySuccess.value = false
message.success('操作成功!')
console.log('能力申请================>', res)
})
})
}
}
return {
formRef,
formName,
fileList,
headers: {
authorization: 'authorization-text',
},
handleChange,
applySuccess,
disabled,
signOut,
processStartHandle,
upLoadUrl,
// baseURL,
applicationSceneOpthion,
}
},
}
</script>
<style scoped lang="less">
#apply-container {
background-color: #f5f8fc;
height: 100%;
width: 100%;
margin: 90px auto 0;
display: flex;
justify-content: space-between;
aside {
width: 282px;
height: 96%;
overflow-y: auto;
background-color: #fff;
margin: 1% 0 3%;
}
article {
width: 1090px;
height: 99%;
overflow-y: auto;
background-color: #fff;
margin: 5% auto;
}
.form-container {
padding: 20px 20px 30px 20px;
.title {
font-size: 20px;
color: #000;
font-weight: bold;
margin-bottom: 20px;
}
}
.base-info {
#apply-container {
background-color: #f5f8fc;
height: 100%;
width: 100%;
margin: 90px auto 0;
display: flex;
}
justify-content: space-between;
:deep(.ant-form-item-label) {
label {
color: #666;
font-size: 16px;
aside {
width: 282px;
height: 96%;
overflow-y: auto;
background-color: #fff;
margin: 1% 0 3%;
}
&::after {
content: '';
article {
width: 1090px;
height: 99%;
overflow-y: auto;
background-color: #fff;
margin: 5% auto;
}
.form-container {
padding: 20px 20px 30px 20px;
.title {
font-size: 20px;
color: #000;
font-weight: bold;
margin-bottom: 20px;
}
}
}
:deep(.ant-form-item-required) {
&::before {
font-size: 8px;
margin-right: 10px;
}
}
:deep(.ant-input) {
border: 1px solid #e0e0e0;
border-radius: 6px;
}
.success {
div {
width: 100px;
margin: 80px auto 40px;
.base-info {
display: flex;
}
text-align: center;
font-size: 20px;
font-weight: bold;
color: #000;
:deep(.ant-form-item-label) {
label {
color: #666;
font-size: 16px;
&::after {
content: '';
}
}
}
:deep(.ant-form-item-required) {
&::before {
font-size: 8px;
margin-right: 10px;
}
}
:deep(.ant-input) {
border: 1px solid #e0e0e0;
border-radius: 6px;
}
.success {
div {
width: 100px;
margin: 80px auto 40px;
}
text-align: center;
font-size: 20px;
font-weight: bold;
color: #000;
}
}
}
</style>
<style>
body,
html {
height: unset;
}
body,
html {
height: unset;
}
</style>