Browse Source

合同材料

ZaiZai 10 months ago
parent
commit
d90e9c0b46
1 changed files with 60 additions and 24 deletions
  1. 60 24
      src/views/debit-pay/material/components/material/dataModal.vue

+ 60 - 24
src/views/debit-pay/material/components/material/dataModal.vue

@@ -7,7 +7,7 @@
                         <hc-info-table-td is-title width="10%">计量期:</hc-info-table-td>
                         <hc-info-table-td>
                             <el-form-item prop="key1">
-                                <el-select v-model="formModel.key1" placeholder="选择计量期" filterable block>
+                                <el-select v-model="formModel.meterPeriodId" placeholder="选择计量期" filterable block>
                                     <el-option v-for="item in measurement" :key="item.id" :label="item.periodName" :value="item.id" />
                                 </el-select>
                             </el-form-item>
@@ -25,7 +25,7 @@
                         <hc-info-table-td is-title width="10%">材料名称:</hc-info-table-td>
                         <hc-info-table-td>
                             <el-form-item prop="contractMaterialId">
-                                <el-select v-model="formModel.contractMaterialId" placeholder="选择材料名称" filterable block>
+                                <el-select v-model="formModel.contractMaterialId" placeholder="选择材料名称" filterable block @change="materialNameChange">
                                     <el-option v-for="item in materialName" :key="item.id" :label="item.materialName" :value="item.id" />
                                 </el-select>
                             </el-form-item>
@@ -141,8 +141,8 @@
             <div class="realTime-price-table">
                 <hc-table :column="tableColumn3" :datas="tableData3" :index-style="{ width: 60 }" :loading="tableLoading3">
                     <template #action="{ row }">
-                        <el-link type="primary">选择</el-link>
-                        <el-link type="danger">取消选择</el-link>
+                        <el-link v-if="formModel.currentPriceId === row.id" type="danger">取消选择</el-link>
+                        <el-link v-else type="primary" @click="rowRealTimePrice(row)">选择</el-link>
                     </template>
                 </hc-table>
             </div>
@@ -150,17 +150,7 @@
     </hc-new-dialog>
     <!-- 上传附件 -->
     <hc-new-dialog v-model="isAttachment" title="上传文件" is-footer-center widths="30rem" @close="attachmentClose">
-        <el-form ref="formUploadRef" :model="formUploadModel" :rules="formUploadRules" label-position="top" label-width="auto">
-            <el-form-item label="选择附件类型" prop="key1">
-                <el-select v-model="formUploadModel.key1" placeholder="选择附件类型" filterable block>
-                    <el-option label="第一期" value="1" />
-                    <el-option label="第二期" value="2" />
-                </el-select>
-            </el-form-item>
-            <el-form-item label="选择文件" prop="key2">
-                <hc-form-upload v-model="formModel.key2" :options="{ num: 0, type: 'list', drop: true }" />
-            </el-form-item>
-        </el-form>
+        <hc-form-upload v-model="formUploadFile" is-res :options="{ type: 'list', props: uploadFormProps, isArr: true, num: 0 }" @success="fileUploadSuccess" />
         <template #footer>
             <el-button hc-btn @click="attachmentClose">取消</el-button>
             <el-button hc-btn type="primary" @click="attachmentSave">确认</el-button>
@@ -173,7 +163,7 @@ import { 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, isNullES } from 'js-fast-way'
+import { arrToKey, formValidate, getArrValue, getObjValue, isNullES } from 'js-fast-way'
 
 const props = defineProps({
     ids: {
@@ -214,7 +204,7 @@ const tab_key = ref('材料明细')
 const formRef = ref(null)
 const formModel = ref({})
 const formRules = {
-    key1: {
+    meterPeriodId: {
         required: true,
         trigger: 'blur',
         message: '请选择计量期',
@@ -269,9 +259,14 @@ const getMaterialName = async () => {
     const { data } = await mainApi.materialName(contractId.value)
     materialName.value = getArrValue(data)
 }
+const materialNameChange = () => {
+    const { contractMaterialId } = formModel.value
+    const info = materialName.value.find((item) => item.id === contractMaterialId)
+    formModel.value.materialPrice = info.price ?? ''
+}
 
 //材料实时发布价格表格
-const yearMonth = ref('')
+const yearMonth = ref(null)
 const tableColumn3 = [
     { key: 'nodeName', name: '有效时间' },
     { key: 'materialNumber', name: '材料编号', width: 100, align: 'center' },
@@ -307,6 +302,28 @@ const realTimePriceClick = () => {
     getMaterialCurrentPrice()
 }
 
+//选择实时发布价格
+const isAdjusts = ref(1) //0不允许,1允许
+const rowRealTimePrice = async (row) => {
+    const { id, currentPrice, startDate } = row
+    const { code, msg, data } = await mainApi.getMaterialRangePrice({
+        priceId: id,
+    })
+    const { isAdjust, rangePriceRatio, adjustCalculation, materialValidityId } = getObjValue(data)
+    if (code !== 200) {
+        window.$message.error(msg ?? '操作失败')
+        return
+    }
+    isAdjusts.value = isAdjust ?? 0
+    formModel.value.currentPriceId = id
+    formModel.value.currentPrice = currentPrice
+    formModel.value.adjustMonth = startDate
+    formModel.value.rangePriceRatio = rangePriceRatio
+    formModel.value.adjustCalculation = adjustCalculation
+    formModel.value.materialValidityId = materialValidityId
+    realTimePriceClose()
+}
+
 //关闭材料实时发布价格
 const realTimePriceClose = () => {
     isRealTimePrice.value = false
@@ -348,17 +365,19 @@ const getMaterialDetail = async () => {
 const tableColumn2 = [
     { key: 'fileName', name: '文件名称' },
     { key: 'fileSizeName', name: '文件大小', align: 'center' },
-    { key: 'updateTime', name: '更新时间', align: 'center' },
+    { key: 'fileUpTime', name: '更新时间', align: 'center' },
     { key: 'fileSuffix', name: '文件类型', align: 'center' },
     { key: 'action', name: '操作', width: 120, align: 'center' },
 ]
 const tableData2 = ref([])
 const tableLoading2 = ref(false)
 
-//上传表单
-const formUploadRef = ref(null)
-const formUploadModel = ref({})
-const formUploadRules = {}
+//附件上传
+const formUploadFile = ref([])
+const uploadFormProps = {
+    url: 'link',
+    name: 'originalName',
+}
 
 //点击上传附件
 const isAttachment = ref(false)
@@ -366,8 +385,25 @@ const uploadAttachmentClick = () => {
     isAttachment.value = true
 }
 
+//附件上传成功的回调
+const fileUploadSuccess = ({ res }, resolve) => {
+    resolve(res)
+}
+
 //提交确定
-const attachmentSave = () => {
+const attachmentSave = async () => {
+    const list = formUploadFile.value
+    for (let i = 0; i < list.length; i++) {
+        tableData2.value.push({
+            fileName: list[i].originalName,
+            filePdfUrl: list[i].pdfUrl,
+            fileSizeName: list[i].fileSizeName,
+            fileSuffix: list[i].fileSuffix,
+            fileType: list[i].fileType,
+            fileUpTime: list[i].fileDate,
+            fileUrl: list[i].link,
+        })
+    }
     attachmentClose()
 }