Browse Source

任务管理

ZaiZai 1 year ago
parent
commit
feefcc8f7d

+ 16 - 0
src/api/modules/tasks/hc-data.js

@@ -121,4 +121,20 @@ export default {
             data: form,
         }, false)
     },
+    //材料数据修改
+    async taskMaterialUpdate(form) {
+        return HcApi({
+            url: '/api/blade-meter/task/data/materialMeterFormServiceTask/update',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    //开工预付款数据修改
+    async taskStartPayUpdate(form) {
+        return HcApi({
+            url: '/api/blade-meter/task/data/startPayMeterFormServiceTask/update',
+            method: 'post',
+            data: form,
+        }, false)
+    },
 }

+ 7 - 0
src/styles/app/element.scss

@@ -201,3 +201,10 @@
         }
     }
 }
+
+//伪表单
+.el-form-item .el-form-item__content .form-item-div.disabled {
+    background: #f5f7fa;
+    color: #a9abb2;
+    cursor: not-allowed;
+}

+ 151 - 39
src/views/tasks/components/hc-data/material-form.vue

@@ -1,5 +1,5 @@
 <template>
-    <div class="hc-task-form">
+    <div v-loading="isLoading" class="hc-task-form white relative">
         <!-- 基础表单 -->
         <hc-card-item>
             <hc-info-table>
@@ -11,18 +11,18 @@
                 </tr>
                 <tr>
                     <hc-info-table-td center is-title>计量期:</hc-info-table-td>
-                    <hc-info-table-td width="120px">{{ baseForm?.meterPeriodName }}</hc-info-table-td>
+                    <hc-info-table-td width="120px">{{ baseForm?.periodName }}</hc-info-table-td>
                     <hc-info-table-td center is-title>业务日期:</hc-info-table-td>
                     <hc-info-table-td width="120px">{{ baseForm?.businessDate }}</hc-info-table-td>
                 </tr>
                 <tr>
                     <hc-info-table-td center is-title>单价:</hc-info-table-td>
-                    <hc-info-table-td width="120px">
-                        <el-input v-model="baseForm.price" />
+                    <hc-info-table-td v-loading="priceLoading" width="120px">
+                        <el-input v-model="baseForm.price" @blur="priceInputBlur" />
                     </hc-info-table-td>
                     <hc-info-table-td center is-title>计量数量:</hc-info-table-td>
-                    <hc-info-table-td width="120px">
-                        <el-input v-model="baseForm.meterAmount" />
+                    <hc-info-table-td v-loading="meterLoading" width="120px">
+                        <el-input v-model="baseForm.meterAmount" @blur="meterAmountInputBlur" />
                     </hc-info-table-td>
                 </tr>
                 <tr>
@@ -60,17 +60,20 @@
             </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 { onMounted, ref, watch } from 'vue'
+import { nextTick, onMounted, ref, watch } from 'vue'
+import { useAppStore } from '~src/store'
+import { getArrValue, getObjVal, getObjValue, isNullES } from 'js-fast-way'
+import { delMessage, isNumberReg } from '~uti/tools'
 import { getHeader } from 'hc-vue3-ui'
 import mainApi from '~api/tasks/hc-data'
 
@@ -79,17 +82,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)
@@ -97,52 +102,159 @@ 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
+const tableInfo = ref({})
+const setTaskInfo = (table, row) => {
+    tableInfo.value = table
+    taskInfo.value = row
+    if (getObjVal(table) && getObjVal(row)) {
+        getDataDetail()
+    }
 }
 
 //基础表单
 const baseForm = ref({ fileList: [] })
 
-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 priceLoading = ref(false)
+const priceInputBlur = async () => {
+    let { id, price } = baseForm.value
+    const isMeter = isNumberReg(price)
+    let priceValue = price
+    if (isNullES(price) || !isMeter) {
+        priceValue = 0
+    }
+    await nextTick(() => {
+        baseForm.value.price = priceValue
+    })
+    //发起请求
+    priceLoading.value = true
+    const { error, code, msg } = await mainApi.taskMaterialUpdate({
+        projectId: projectId.value,
+        contractId: contractId.value,
+        price: priceValue,
+        id,
+    })
+    priceLoading.value = false
+    if (!error && code === 200) {
+        window.$message.success('修改成功')
+    } else {
+        window.$message.error(msg ?? '修改失败')
+    }
+}
 
+//单价输入框失去焦点
+const meterLoading = ref(false)
+const meterAmountInputBlur = async () => {
+    let { id, meterAmount } = baseForm.value
+    const isMeter = isNumberReg(meterAmount)
+    let meterAmountValue = meterAmount
+    if (isNullES(meterAmount) || !isMeter) {
+        meterAmountValue = 0
+    }
+    await nextTick(() => {
+        baseForm.value.meterAmount = meterAmountValue
+    })
+    //发起请求
+    meterLoading.value = true
+    const { error, code, msg } = await mainApi.taskMaterialUpdate({
+        projectId: projectId.value,
+        contractId: contractId.value,
+        meterAmount: meterAmountValue,
+        id,
+    })
+    meterLoading.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>

+ 145 - 59
src/views/tasks/components/hc-data/start-work-form.vue

@@ -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>

+ 1 - 1
src/views/tasks/components/hc-data/task-review.vue

@@ -208,7 +208,7 @@ const alterTableColumn = ref([
 //材料计量单的表格数据
 const materialTableColumn = ref([
     { key: 'action', name: '批注', width: 45, align: 'center' },
-    { key: 'key1', name: '计量期', minWidth: 100, align: 'center' },
+    { key: 'periodName', name: '计量期', minWidth: 100, align: 'center' },
     { key: 'contractMaterialName', name: '合同材料', minWidth: 120, align: 'center' },
     { key: 'materialArriveNumber', name: '材料到场编号', width: 120, align: 'center' },
     { key: 'meterMoney', name: '计量金额', width: 100, align: 'center' },