You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
4.4 KiB
150 lines
4.4 KiB
1 year ago
|
<template>
|
||
|
<ProjectDetails :isEdit="false" :projectid="projectid" />
|
||
|
<el-divider content-position="left">项目信息变更字段</el-divider>
|
||
|
选择变更字段:<a-select v-model:value="selectValue" style="width: 30%" placeholder="选择变更字段" :options="options"
|
||
|
@change="changeOptions" />
|
||
|
<div v-if="showupload">
|
||
|
<el-divider content-position="left">上传文件</el-divider>
|
||
|
<el-form-item label="上传文件:">
|
||
|
<el-upload class="upload-demo" ref="upload" action :http-request="httpRequest" :before-upload="beforeUpload"
|
||
|
:on-exceed="handleExceed" :limit="1" :on-remove="removeFile">
|
||
|
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
||
|
<div slot="tip" class="el-upload__tip">文件大小且不超过5M</div>
|
||
|
</el-upload>
|
||
|
</el-form-item>
|
||
|
</div>
|
||
|
<el-divider content-position="left">字段新值</el-divider>
|
||
|
<BasicForm @register="registerchangeFieldForm" @submit="handleSubmit" />
|
||
|
|
||
|
</template>
|
||
|
<script lang="ts" name="Detailpage" setup>
|
||
|
import { defineProps, onMounted, ref, reactive } from 'vue'
|
||
|
import { } from './projectInfo.data';
|
||
|
|
||
|
import { getChangeFieldManageDict, submitFieldchange, getRemainingMoneyinfo } from './projectInfo.api'
|
||
|
import ProjectDetails from "../../ProcessApprovalSubPage/component/ProjectDetails.vue"
|
||
|
import { useForm, BasicForm } from '@/components/Form';
|
||
|
import { formSchemas } from './projectInfo.data';
|
||
|
import { message } from 'ant-design-vue';
|
||
|
let dataTo = defineProps(["projectid", "stage", "IsModify", "fatherid"])
|
||
|
let emit = defineEmits(["close"])
|
||
|
console.log("dataTo11111", dataTo)
|
||
|
let selectValue = ref()
|
||
|
let options = ref()
|
||
|
let showupload = ref(false)
|
||
|
let fileList = reactive<Array<any>>([]);
|
||
|
|
||
|
onMounted(async () => {
|
||
|
options.value = await getChangeFieldManageDict()
|
||
|
})
|
||
|
//
|
||
|
const [registerchangeFieldForm, { getFieldsValue, validate, setFieldsValue, resetSchema, appendSchemaByField }] = useForm({
|
||
|
|
||
|
resetButtonOptions: { text: '取消' },
|
||
|
|
||
|
submitButtonOptions: { text: '提交' },
|
||
|
//查询列占比 24代表一行 取值范围 0-24
|
||
|
actionColOptions: { span: 14 },
|
||
|
|
||
|
resetFunc: customResetFunc,
|
||
|
labelCol: { style: { width: '120px' } },
|
||
|
wrapperCol: { style: { width: 'auto' } },
|
||
|
// disabled:true
|
||
|
})
|
||
|
|
||
|
function httpRequest(option) {
|
||
|
fileList.push(option)
|
||
|
}
|
||
|
function removeFile(option) {
|
||
|
for (let i = 0; i < fileList.length; i++) {
|
||
|
if (fileList[i].file.name == option.name) {
|
||
|
fileList.splice(i, 1)
|
||
|
}
|
||
|
}
|
||
|
console.log(fileList, option)
|
||
|
|
||
|
}
|
||
|
// 上传前处理
|
||
|
function beforeUpload(file) {
|
||
|
let fileSize = file.size
|
||
|
const FIVE_M = 5 * 1024 * 1024;
|
||
|
//大于5M,不允许上传
|
||
|
if (fileSize > FIVE_M) {
|
||
|
message.error("最大上传5M")
|
||
|
return false
|
||
|
}
|
||
|
//判断文件类型,必须是xlsx格式
|
||
|
// let fileName = file.name
|
||
|
// let reg = /^.+(\.xlsx)$/
|
||
|
// if(!reg.test(fileName)){
|
||
|
// ElMessage.error("只能上传xlsx!")
|
||
|
// return false
|
||
|
// }
|
||
|
return true
|
||
|
}
|
||
|
// 文件数量过多时提醒
|
||
|
function handleExceed() {
|
||
|
message.warning("最多只能上传一个文件")
|
||
|
}
|
||
|
|
||
|
|
||
|
async function handleSubmit(record) {
|
||
|
const params = new FormData()
|
||
|
// 将上传文件数组依次添加到参数paramsData中
|
||
|
if (fileList.length > 0) {
|
||
|
fileList.forEach((x) => {
|
||
|
console.log("xxxxxxxxxx", x, x.file)
|
||
|
params.append('file', x.file)
|
||
|
});
|
||
|
}
|
||
|
params.append("projectid", dataTo.projectid)
|
||
|
params.append("fieldValue", selectValue.value)
|
||
|
if (await validate) {
|
||
|
let newValue = await getFieldsValue()
|
||
|
params.append("newValue", newValue[selectValue.value])
|
||
|
console.log("params", params)
|
||
|
await submitFieldchange(params)
|
||
|
emit("close")
|
||
|
}
|
||
|
}
|
||
|
async function customResetFunc() {
|
||
|
emit("close")
|
||
|
}
|
||
|
async function changeOptions(value, option) {
|
||
|
|
||
|
let formSchemasTemp = JSON.parse(JSON.stringify(formSchemas))
|
||
|
if (dataTo.fatherid) {
|
||
|
let subres = await getRemainingMoneyinfo({
|
||
|
projectId: dataTo.fatherid,//主项目id
|
||
|
id: dataTo.projectid//子项目id
|
||
|
|
||
|
})
|
||
|
formSchemasTemp.forEach(item => {
|
||
|
if (item.field == value) {
|
||
|
if (item.field.includes("Money")) {
|
||
|
item.componentProps["max"] = subres[item.field]
|
||
|
resetSchema(item)
|
||
|
}
|
||
|
|
||
|
}
|
||
|
})
|
||
|
} else {
|
||
|
formSchemasTemp.forEach(item => {
|
||
|
if (item.field == value) {
|
||
|
resetSchema(item)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
if (option.upload == "1") {
|
||
|
showupload.value = true
|
||
|
} else {
|
||
|
showupload.value = false
|
||
|
fileList.pop()
|
||
|
|
||
|
}
|
||
|
selectValue.value
|
||
|
}
|
||
|
</script>
|
||
|
<style></style>
|