yuan
22 小时以前 7726b6cdab80596d2e2f7dd3fe1ec3dfbdeee155
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<template>
  <FormDialog v-model="visible" title="采购台账详情" width="70%" operation-type="detail" @close="handleClose">
    <el-form :model="form" label-width="140px" label-position="top">
      <el-row :gutter="30">
        <el-col :span="12">
          <el-form-item label="采购合同号:">
            <span class="readonly-text">{{ form.purchaseContractNumber || '--' }}</span>
          </el-form-item>
        </el-col>
        <el-col v-if="showSalesContractBinding" :span="12">
          <el-form-item label="销售合同号:">
            <span class="readonly-text">{{ form.salesContractNo || '--' }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="30">
        <el-col :span="12">
          <el-form-item label="供应商名称:">
            <span class="readonly-text">{{ form.supplierName || '--' }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目名称:">
            <span class="readonly-text">{{ form.projectName || '--' }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="30">
        <el-col :span="12">
          <el-form-item label="付款方式:">
            <span class="readonly-text">{{ form.paymentMethod || '--' }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="签订日期:">
            <span class="readonly-text">{{ form.executionDate || '--' }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="30">
        <el-col :span="12">
          <el-form-item label="录入人:">
            <span class="readonly-text">{{ form.recorderName || '--' }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="录入日期:">
            <span class="readonly-text">{{ form.entryDate || '--' }}</span>
          </el-form-item>
        </el-col>
      </el-row>
 
      <div style="font-weight: bold; margin: 10px 0; color: #f56c6c">
        * 产品信息:
      </div>
      <el-table :data="productData" border>
        <el-table-column type="index" label="序号" width="60" align="center" />
        <el-table-column label="产品大类" prop="productCategory" />
        <el-table-column label="规格型号" prop="specificationModel" />
        <el-table-column label="单位" prop="unit" />
        <el-table-column label="数量" prop="quantity" />
        <el-table-column label="库存预留数量" prop="stockReservedQuantity" />
        <el-table-column label="税率(%)" prop="taxRate" />
        <el-table-column label="含税单价(元)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber" width="150" />
        <el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" width="150" />
        <el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" width="150" />
        <template #append>
          <div class="summary-row" v-if="productData.length > 0">
            <div class="summary-label">合计</div>
            <div class="summary-value" style="width: 150px">
              {{ formattedNumber(null, null, sumTaxInclusiveUnitPrice) }}
            </div>
            <div class="summary-value" style="width: 150px">
              {{ formattedNumber(null, null, sumTaxInclusiveTotalPrice) }}
            </div>
            <div class="summary-value" style="width: 150px">
              {{ formattedNumber(null, null, sumTaxExclusiveTotalPrice) }}
            </div>
          </div>
        </template>
      </el-table>
 
      <el-row :gutter="30" style="margin-top: 20px;">
        <el-col :span="24">
          <el-form-item label="备注:">
            <div class="readonly-text-area">{{ form.remarks || '--' }}</div>
          </el-form-item>
        </el-col>
      </el-row>
 
      <el-row :gutter="30">
        <el-col :span="24">
          <el-form-item label="附件材料:">
            <div class="table-container" style="width: 100%;">
              <el-table :data="fileList" border class="attachment-table" style="width: 100%;"
                :height="fileList.length > 0 ? 'auto' : '120px'">
                <el-table-column label="附件名称" prop="originalFilename" show-overflow-tooltip min-width="200">
                  <template #default="scope">
                    {{ scope.row.name || scope.row.originalFilename || ('附件' + (scope.$index + 1)) }}
                  </template>
                </el-table-column>
                <el-table-column fixed="right" label="操作" :width="150" align="center">
                  <template #default="scope">
                    <el-button link type="primary" size="small" class="download-link"
                      @click="previewFile(scope.row.previewURL || scope.row.url)">
                      预览
                    </el-button>
                    <el-button link type="primary" size="small" class="download-link"
                      @click="downloadFile(scope.row.downloadURL || scope.row.url)">
                      下载
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </FormDialog>
  <filePreview ref="filePreviewRef" />
</template>
 
<script setup>
import { ref, computed } from 'vue'
import { ElMessage } from 'element-plus'
import FormDialog from "@/components/Dialog/FormDialog.vue"
import filePreview from '@/components/filePreview/index.vue'
import { getPurchaseById } from "@/api/procurementManagement/procurementLedger"
 
const visible = ref(false)
// 是否显示销售合同号绑定
const showSalesContractBinding = false
const form = ref({})
const productData = ref([])
const fileList = ref([])
const filePreviewRef = ref()
 
const open = (id) => {
  visible.value = true
  getPurchaseById({ id: id, type: 2 }).then(res => {
    form.value = res.data ? res.data : res || {}
    productData.value = form.value.purchaseLedgerProductList || form.value.productData || []
    fileList.value = form.value.storageBlobVOS || []
  })
}
 
// 暴露 open 方法给父组件调用
defineExpose({
  open
})
 
const handleClose = () => {
  visible.value = false
  form.value = {}
  productData.value = []
  fileList.value = []
}
 
const formattedNumber = (row, column, cellValue) => {
  if (cellValue != null && !isNaN(cellValue)) {
    return Number(cellValue).toFixed(2)
  }
  return cellValue
}
 
const sumTaxInclusiveUnitPrice = computed(() => {
  return productData.value.reduce((sum, item) => {
    return sum + (Number(item.taxInclusiveUnitPrice) || 0)
  }, 0)
})
 
const sumTaxInclusiveTotalPrice = computed(() => {
  return productData.value.reduce((sum, item) => {
    return sum + (Number(item.taxInclusiveTotalPrice) || 0)
  }, 0)
})
 
const sumTaxExclusiveTotalPrice = computed(() => {
  return productData.value.reduce((sum, item) => {
    return sum + (Number(item.taxExclusiveTotalPrice) || 0)
  }, 0)
})
 
const previewFile = (url) => {
  if (url) {
    filePreviewRef.value.open(url)
  } else {
    ElMessage.warning('文件地址无效,无法预览')
  }
}
 
const downloadFile = (url) => {
  window.open(url, "_blank")
}
</script>
 
<style scoped>
.readonly-text {
  width: 100%;
  padding: 0 12px;
  background-color: #f5f7fa;
  color: #606266;
  border-radius: 4px;
  border: 1px solid #e4e7ed;
  box-sizing: border-box;
  min-height: 32px;
  line-height: 32px;
  display: inline-block;
}
 
.readonly-text-area {
  width: 100%;
  padding: 8px 12px;
  background-color: #f5f7fa;
  color: #606266;
  border-radius: 4px;
  border: 1px solid #e4e7ed;
  box-sizing: border-box;
  min-height: 64px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}
 
.summary-row {
  display: flex;
  background-color: #f5f7fa;
  font-weight: bold;
  border-top: 1px solid #ebeef5;
}
 
.summary-label {
  flex: 1;
  text-align: right;
  padding: 12px;
  color: #606266;
}
 
.summary-value {
  padding: 12px;
  color: #606266;
  border-left: 1px solid #ebeef5;
}
 
.table-container {
  overflow-y: auto;
  box-sizing: border-box;
}
</style>