|
@@ -1,14 +1,12 @@
|
|
|
<template>
|
|
|
- <div class="hc-task-form">
|
|
|
+ <div v-loading="isLoading" class="hc-task-form white relative">
|
|
|
<!-- 基础表单 -->
|
|
|
<hc-card-item>
|
|
|
- <el-form ref="baseFormRef" :model="baseForm" :rules="baseFormRules" label-position="left" label-width="auto">
|
|
|
+ <el-form :model="baseForm" label-position="left" label-width="auto">
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="计量期:">
|
|
|
- <el-select v-model="baseForm.contractPeriodId" placeholder="选择计量期" disabled block>
|
|
|
- <el-option v-for="item in periods" :key="item.id" :label="item.periodNumber" :value="item.id" />
|
|
|
- </el-select>
|
|
|
+ <div class="form-item-div disabled">{{ baseForm.periodName }}</div>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
@@ -17,18 +15,18 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="计量金额:">
|
|
|
- <el-input v-model="baseForm.meterMoney" />
|
|
|
+ <el-form-item v-loading="meterMoneyLoading" label="计量金额:">
|
|
|
+ <el-input v-model="baseForm.meterMoney" @blur="meterMoneyInputBlur" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="预付款总额:">
|
|
|
- <el-input v-model="baseForm.meterMoney1" placeholder="开工预付款总额" />
|
|
|
+ <el-input v-model="baseForm.startPayAmount" placeholder="开工预付款总额" disabled />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="24">
|
|
|
- <el-form-item label="申请依据:">
|
|
|
- <el-input v-model="baseForm.calculateFormula" :autosize="{ minRows: 4, maxRows: 8 }" type="textarea" />
|
|
|
+ <el-form-item v-loading="applyCauseLoading" label="申请依据:">
|
|
|
+ <el-input v-model="baseForm.applyCause" :autosize="{ minRows: 4, maxRows: 8 }" type="textarea" @blur="applyCauseInputBlur" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -41,20 +39,21 @@
|
|
|
</template>
|
|
|
<el-form :model="baseForm" label-position="left" label-width="auto">
|
|
|
<el-form-item label="上传附件">
|
|
|
- <hc-form-upload type="list" :src="baseForm.fileList" :h-props="uploadFormProps" @upload="attachmentUpload" @change="attachmentUploadChange" />
|
|
|
+ <hc-form-upload type="list" :src="baseForm.fileList" :h-props="uploadFormProps" is-del @upload="attachmentUpload" @change="attachmentUploadChange" @del="attachmentUploadDel" />
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</hc-card-item>
|
|
|
<!-- 文件上传组件 -->
|
|
|
- <hc-upload-file ref="uploadFileRef" :echo-params="uploadFileParams" :options="uploadFileOptions" @success="uploadFileSuccess" />
|
|
|
+ <hc-upload-file ref="uploadFileRef" :options="uploadFileOptions" @success="uploadFileSuccess" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { getArrValue } from 'js-fast-way'
|
|
|
-import { onMounted, ref, watch } from 'vue'
|
|
|
+import { nextTick, onMounted, ref, watch } from 'vue'
|
|
|
+import { useAppStore } from '~src/store'
|
|
|
+import { delMessage, isNumberReg } from '~uti/tools'
|
|
|
+import { getArrValue, getObjVal, getObjValue, isNullES } from 'js-fast-way'
|
|
|
import { getHeader } from 'hc-vue3-ui'
|
|
|
-
|
|
|
import mainApi from '~api/tasks/hc-data'
|
|
|
|
|
|
const props = defineProps({
|
|
@@ -62,17 +61,19 @@ const props = defineProps({
|
|
|
type: Boolean,
|
|
|
default: true,
|
|
|
},
|
|
|
- type: {
|
|
|
- type: [String, Number],
|
|
|
- default: '',
|
|
|
+ info: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({}),
|
|
|
+ },
|
|
|
+ table: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({}),
|
|
|
},
|
|
|
})
|
|
|
|
|
|
-//双向绑定
|
|
|
-// eslint-disable-next-line no-undef
|
|
|
-const rowInfo = defineModel('modelValue', {
|
|
|
- default: () => ({}),
|
|
|
-})
|
|
|
+const useAppState = useAppStore()
|
|
|
+const projectId = ref(useAppState.getProjectId || '')
|
|
|
+const contractId = ref(useAppState.getContractId || '')
|
|
|
|
|
|
//监听可否编辑
|
|
|
const isEdits = ref(props.isEdit)
|
|
@@ -80,66 +81,151 @@ watch(() => props.isEdit, (val) => {
|
|
|
isEdits.value = val
|
|
|
}, { immediate: true, deep: true })
|
|
|
|
|
|
-//监听类型
|
|
|
-const isType = ref(props.type)
|
|
|
-watch(() => props.type, (val) => {
|
|
|
- isType.value = val
|
|
|
-}, { immediate: true, deep: true })
|
|
|
-
|
|
|
//监听数据
|
|
|
-watch(() => rowInfo, (val) => {
|
|
|
- setTaskInfo(val.value)
|
|
|
+watch(() => [
|
|
|
+ props.table,
|
|
|
+ props.info,
|
|
|
+], ([table, row]) => {
|
|
|
+ setTaskInfo(table, row)
|
|
|
}, { deep: true })
|
|
|
|
|
|
//渲染完成
|
|
|
onMounted(() => {
|
|
|
- setTaskInfo(rowInfo.value)
|
|
|
+ setTaskInfo(props.table, props.info)
|
|
|
})
|
|
|
|
|
|
//设置任务信息
|
|
|
const taskInfo = ref({})
|
|
|
-const setTaskInfo = async (info) => {
|
|
|
- taskInfo.value = info
|
|
|
- getStartWorkPeriod(info.contractId).then()
|
|
|
-}
|
|
|
-
|
|
|
-//获取开工计量期列表
|
|
|
-const periods = ref([])
|
|
|
-const getStartWorkPeriod = async (cid) => {
|
|
|
- if (cid === '') return
|
|
|
- const { data } = await mainApi.getMeterPeriod({
|
|
|
- contractId: cid,
|
|
|
- type: 2,
|
|
|
- })
|
|
|
- periods.value = getArrValue(data)
|
|
|
+const tableInfo = ref({})
|
|
|
+const setTaskInfo = (table, row) => {
|
|
|
+ tableInfo.value = table
|
|
|
+ taskInfo.value = row
|
|
|
+ if (getObjVal(table) && getObjVal(row)) {
|
|
|
+ getDataDetail()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//基础表单
|
|
|
-const baseFormRef = ref(null)
|
|
|
const baseForm = ref({ fileList: [] })
|
|
|
-const baseFormRules = {}
|
|
|
-
|
|
|
-const uploadFormProps = ref({})
|
|
|
-
|
|
|
-const attachmentUpload = () => {
|
|
|
|
|
|
+//获取任务数据信息详情
|
|
|
+const isLoading = ref(false)
|
|
|
+const getDataDetail = async () => {
|
|
|
+ const id = taskInfo.value.id
|
|
|
+ const dataId = tableInfo.value.id
|
|
|
+ const { data } = await mainApi.getDataDetail({ id, dataId })
|
|
|
+ //转换数据
|
|
|
+ const { attachmentFormTask, basicsInfo } = getObjValue(data)
|
|
|
+ baseForm.value = getObjValue(basicsInfo) //表单信息
|
|
|
+ baseForm.value.fileList = getArrValue(attachmentFormTask) //附件列表
|
|
|
}
|
|
|
|
|
|
-const attachmentUploadChange = () => {
|
|
|
+//计量金额输入框失去焦点
|
|
|
+const meterMoneyLoading = ref(false)
|
|
|
+const meterMoneyInputBlur = async () => {
|
|
|
+ let { id, meterMoney } = baseForm.value
|
|
|
+ const isMeter = isNumberReg(meterMoney)
|
|
|
+ let meterMoneyValue = meterMoney
|
|
|
+ if (isNullES(meterMoney) || !isMeter) {
|
|
|
+ meterMoneyValue = 0
|
|
|
+ }
|
|
|
+ await nextTick(() => {
|
|
|
+ baseForm.value.meterMoney = meterMoneyValue
|
|
|
+ })
|
|
|
+ //发起请求
|
|
|
+ meterMoneyLoading.value = true
|
|
|
+ const { error, code, msg } = await mainApi.taskStartPayUpdate({
|
|
|
+ projectId: projectId.value,
|
|
|
+ contractId: contractId.value,
|
|
|
+ meterMoney: meterMoneyValue,
|
|
|
+ id,
|
|
|
+ })
|
|
|
+ meterMoneyLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window.$message.success('修改成功')
|
|
|
+ } else {
|
|
|
+ window.$message.error(msg ?? '修改失败')
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+//单价输入框失去焦点
|
|
|
+const applyCauseLoading = ref(false)
|
|
|
+const applyCauseInputBlur = async () => {
|
|
|
+ let { id, applyCause } = baseForm.value
|
|
|
+ //发起请求
|
|
|
+ applyCauseLoading.value = true
|
|
|
+ const { error, code, msg } = await mainApi.taskMaterialUpdate({
|
|
|
+ projectId: projectId.value,
|
|
|
+ contractId: contractId.value,
|
|
|
+ applyCause: applyCause ?? '',
|
|
|
+ id,
|
|
|
+ })
|
|
|
+ applyCauseLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window.$message.success('修改成功')
|
|
|
+ } else {
|
|
|
+ window.$message.error(msg ?? '修改失败')
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//文件上传
|
|
|
const uploadFileRef = ref(null)
|
|
|
-const uploadFileParams = ref({})
|
|
|
-const uploadFileOptions = ref({})
|
|
|
-const uploadFileSuccess = () => {
|
|
|
+const uploadFileOptions = ref({
|
|
|
+ headers: getHeader(),
|
|
|
+ multiple: false,
|
|
|
+})
|
|
|
+const uploadFormProps = {
|
|
|
+ url: 'fileUrl',
|
|
|
+ name: 'fileName',
|
|
|
+}
|
|
|
|
|
|
+const attachmentUpload = () => {
|
|
|
+ uploadFileRef.value?.selectFile()
|
|
|
+}
|
|
|
+const attachmentUploadChange = (a, b, fileList) => {
|
|
|
+ baseForm.value.fileList = getArrValue(fileList)
|
|
|
}
|
|
|
-</script>
|
|
|
|
|
|
-<style lang="scss" scoped>
|
|
|
-.hc-task-form {
|
|
|
+// 文件上传成功的回调
|
|
|
+const uploadFileSuccess = async ({ resData }) => {
|
|
|
+ baseForm.value.fileList.push({
|
|
|
+ contractId: contractId.value,
|
|
|
+ fileName: resData.originalName ?? '',
|
|
|
+ filePdfUrl: resData.pdfUrl ?? '',
|
|
|
+ fileUrl: resData.link ?? '',
|
|
|
+ })
|
|
|
+ uploadFileRef.value?.setModalShow(false)
|
|
|
+ //发起请求
|
|
|
+ const dataId = tableInfo.value.id
|
|
|
+ const { error, code, msg } = await mainApi.taskUploadFile({
|
|
|
+ projectId: projectId.value,
|
|
|
+ contractId: contractId.value,
|
|
|
+ fileList: baseForm.value.fileList,
|
|
|
+ dataId,
|
|
|
+ })
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window.$message.success('上传成功')
|
|
|
+ } else {
|
|
|
+ window.$message.error(msg ?? '上传失败')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//删除文件
|
|
|
+const attachmentUploadDel = ({ file }, resolve) => {
|
|
|
+ delMessage(async () => {
|
|
|
+ const { error, code, msg } = await mainApi.removeFile(file.id)
|
|
|
+ if (!error && code === 200) {
|
|
|
+ resolve(true)
|
|
|
+ } else {
|
|
|
+ window.$message.error(msg ?? '删除失败')
|
|
|
+ resolve(false)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+</script>
|
|
|
|
|
|
+<style lang="scss">
|
|
|
+.hc-task-form.white .hc-card-item-box {
|
|
|
+ background: white !important;
|
|
|
}
|
|
|
</style>
|