浏览代码

合同材料

ZaiZai 10 月之前
父节点
当前提交
e3e1d92403

+ 1 - 1
src/api/modules/debit-pay/material/material.js

@@ -19,7 +19,7 @@ export default {
     //材料名称
     async materialName(contractId) {
         return HcApi({
-            url: '/api/blade-meter/contractMaterial/get-all-material2',
+            url: '/api/blade-meter/contractMaterial/get-all-material3',
             method: 'post',
             data: { contractId },
         }, false)

+ 67 - 7
src/views/debit-pay/material/components/material/dataModal.vue

@@ -51,7 +51,7 @@
                         <hc-info-table-td is-title width="10%">调差月份:</hc-info-table-td>
                         <hc-info-table-td>
                             <el-form-item>
-                                <el-date-picker v-model="formModel.adjustMonth" class="block" type="month" format="YYYY-MM" value-format="YYYY-MM" />
+                                <el-date-picker v-if="isAdjustDate" v-model="formModel.adjustMonth" class="block" type="month" format="YYYY-MM" value-format="YYYY-MM" :disabled="isNullES(formModel.currentPriceId)" :disabled-date="disabledDate" />
                             </el-form-item>
                         </hc-info-table-td>
                         <hc-info-table-td is-title width="10%">材料基准价格:</hc-info-table-td>
@@ -142,7 +142,7 @@
             <div class="realTime-price-table">
                 <hc-table :column="tableColumn3" :datas="tableData3" :index-style="{ width: 60 }" :loading="tableLoading3">
                     <template #action="{ row }">
-                        <el-link v-if="formModel.currentPriceId === row.id" type="danger">取消选择</el-link>
+                        <el-link v-if="formModel.currentPriceId === row.id" type="danger" @click="deselectTimePrice">取消选择</el-link>
                         <el-link v-else type="primary" @click="rowRealTimePrice(row)">选择</el-link>
                     </template>
                 </hc-table>
@@ -160,11 +160,12 @@
 </template>
 
 <script setup>
-import { ref, watch } from 'vue'
+import dayjs from 'dayjs'
+import { nextTick, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
 import { isNumberReg } from '~uti/tools'
 import mainApi from '~api/debit-pay/material/material'
-import { formValidate, getArrValue, getObjValue, isNullES, newWindow } from 'js-fast-way'
+import { deepClone, formValidate, getArrValue, getObjValue, isNullES, newWindow } from 'js-fast-way'
 
 const props = defineProps({
     ids: {
@@ -251,6 +252,11 @@ const getDetailData = async () => {
         formModel.value = obj
         tableData1.value = obj.details
         tableData2.value = obj.files
+        try {
+            adjustStartDate.value = dayjs(obj.startDate).format('YYYY-MM') ?? ''
+            adjustEndDate.value = dayjs(obj.endDate).format('YYYY-MM') ?? ''
+        } catch { /* empty */ }
+        isAdjustDate.value = true
     } else {
         window.$message.error(msg ?? '数据异常')
         modalClose()
@@ -300,6 +306,26 @@ const materialNameChange = () => {
     tableLoading1.value = false
 }
 
+//禁用时间
+const isAdjustDate = ref(false)
+const disabledDate = (time) => {
+    if (isNullES(adjustStartDate.value) || isNullES(adjustEndDate.value)) {
+        return true
+    }
+    //处理时间
+    const date = dayjs(time).format('YYYY-MM') //当前时间
+    const isStart = dayjs(date).isSame(dayjs(adjustStartDate.value)) //是否等于开始时间
+    const isEnd = dayjs(date).isSame(dayjs(adjustEndDate.value)) //是否等于结束时间
+    const isBefore = dayjs(date).isBefore(dayjs(adjustEndDate.value)) //是否在结束时间之前
+    const isAfter = dayjs(date).isAfter(dayjs(adjustStartDate.value)) //是否在开始时间之后
+    //如果当前时间,大于等于开始时间,小于等于结束时间,则可用,否则禁用
+    if ((isStart || isAfter) && (isEnd || isBefore)) {
+        return false
+    } else {
+        return true
+    }
+}
+
 //材料实时发布价格表格
 const yearMonth = ref(null)
 const tableColumn3 = [
@@ -338,9 +364,11 @@ const realTimePriceClick = () => {
 }
 
 //选择实时发布价格
+const adjustStartDate = ref('')
+const adjustEndDate = ref('')
 const isAdjusts = ref(1) //0不允许,1允许
 const rowRealTimePrice = async (row) => {
-    const { id, currentPrice, startDate, materialValidityId } = row
+    const { id, currentPrice, startDate, endDate, materialValidityId } = row
     const { code, msg, data } = await mainApi.getMaterialRangePrice({
         priceId: id,
     })
@@ -349,14 +377,27 @@ const rowRealTimePrice = async (row) => {
         window.$message.error(msg ?? '操作失败')
         return
     }
+    isAdjustDate.value = false
+    let startDate1 = '', endDate1 = ''
+    try {
+        startDate1 = dayjs(startDate).format('YYYY-MM') ?? ''
+        endDate1 = dayjs(endDate).format('YYYY-MM') ?? ''
+    } catch { /* empty */ }
     isAdjusts.value = isAdjust ?? 0
+    formModel.value.startDate = startDate1
+    formModel.value.endDate = endDate1
     formModel.value.currentPriceId = id
     formModel.value.currentPrice = currentPrice
-    formModel.value.adjustMonth = startDate
+    formModel.value.adjustMonth = startDate1
     formModel.value.rangePriceRatio = rangePriceRatio
     formModel.value.adjustCalculation = adjustCalculation
     formModel.value.materialValidityId = materialValidityId
-    realTimePriceClose()
+    adjustStartDate.value = startDate1
+    adjustEndDate.value = endDate1
+    await nextTick(() => {
+        isAdjustDate.value = true
+        realTimePriceClose()
+    })
 }
 
 //关闭材料实时发布价格
@@ -411,6 +452,25 @@ const getMaterialDetail = async () => {
     }
 }
 
+//价格取消选择
+const deselectTimePrice = () => {
+    isAdjustDate.value = false
+    const form = deepClone(formModel.value)
+    tableData1.value = []
+    formModel.value = {
+        id: form.id,
+        meterPeriodId: form.meterPeriodId,
+        materialPrice: form.materialPrice,
+        materialName: form.materialName,
+        contractPeriodId: form.contractPeriodId,
+        contractMaterialId: form.contractMaterialId,
+        contractPeriodNumber: form.contractPeriodNumber,
+        materialTotal: form.materialTotal,
+    }
+    isAdjustDate.value = true
+    realTimePriceClose()
+}
+
 //可调量失去焦点
 const changeTotalBlur = (row) => {
     const { meterTotal, changeTotal } = row

+ 1 - 1
src/views/debit-pay/material/material.vue

@@ -93,7 +93,7 @@ const tableColumn = [
     { key: 'materialName', name: '材料名称' },
     { key: 'materialPrice', name: '基准价格(元)', width: 140, align: 'center' },
     { key: 'currentPrice', name: '施工期价格(元)', width: 140, align: 'center' },
-    { key: 'key6', name: '调差数量', width: 140, align: 'center' },
+    { key: 'adjustTotal', name: '调差数量', width: 140, align: 'center' },
     { key: 'adjustMoney', name: '调差金额', width: 140, align: 'center' },
     { key: 'approveStatus', name: '状态', width: 120, align: 'center' },
     { key: 'action', name: '操作', width: 100, align: 'center' },