diff --git a/src/utils/bonus.js b/src/utils/bonus.js index 309cff4f..efeb96e3 100644 --- a/src/utils/bonus.js +++ b/src/utils/bonus.js @@ -13,12 +13,15 @@ export function parseTime(time, pattern) { if (typeof time === 'object') { date = time } else { - if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { + if (typeof time === 'string' && /^[0-9]+$/.test(time)) { time = parseInt(time) } else if (typeof time === 'string') { - time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm), '') + time = time + .replace(new RegExp(/-/gm), '/') + .replace('T', ' ') + .replace(new RegExp(/\.[\d]{3}/gm), '') } - if ((typeof time === 'number') && (time.toString().length === 10)) { + if (typeof time === 'number' && time.toString().length === 10) { time = time * 1000 } date = new Date(time) @@ -56,9 +59,10 @@ export function resetForm(refName) { // 添加日期范围 export function addDateRange(params, dateRange, propName) { let search = params - search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {} + search.params = + typeof search.params === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {} dateRange = Array.isArray(dateRange) ? dateRange : [] - if (typeof (propName) === 'undefined') { + if (typeof propName === 'undefined') { search.params['beginTime'] = dateRange[0] search.params['endTime'] = dateRange[1] } else { @@ -74,8 +78,8 @@ export function selectDictLabel(datas, value) { return '' } var actions = [] - Object.keys(datas).some((key) => { - if (datas[key].value == ('' + value)) { + Object.keys(datas).some(key => { + if (datas[key].value == '' + value) { actions.push(datas[key].label) return true } @@ -97,10 +101,10 @@ export function selectDictLabels(datas, value, separator) { var actions = [] var currentSeparator = undefined === separator ? ',' : separator var temp = value.split(currentSeparator) - Object.keys(value.split(currentSeparator)).some((val) => { + Object.keys(value.split(currentSeparator)).some(val => { var match = false - Object.keys(datas).some((key) => { - if (datas[key].value == ('' + temp[val])) { + Object.keys(datas).some(key => { + if (datas[key].value == '' + temp[val]) { actions.push(datas[key].label + currentSeparator) match = true } @@ -114,8 +118,10 @@ export function selectDictLabels(datas, value, separator) { // 字符串格式化(%s ) export function sprintf(str) { - var args = arguments, flag = true, i = 1 - str = str.replace(/%s/g, function() { + var args = arguments, + flag = true, + i = 1 + str = str.replace(/%s/g, function () { var arg = args[i++] if (typeof arg === 'undefined') { flag = false @@ -211,10 +217,10 @@ export function tansParams(params) { for (const propName of Object.keys(params)) { const value = params[propName] var part = encodeURIComponent(propName) + '=' - if (value !== null && value !== '' && typeof (value) !== 'undefined') { + if (value !== null && value !== '' && typeof value !== 'undefined') { if (typeof value === 'object') { for (const key of Object.keys(value)) { - if (value[key] !== null && value[key] !== '' && typeof (value[key]) !== 'undefined') { + if (value[key] !== null && value[key] !== '' && typeof value[key] !== 'undefined') { let params = propName + '[' + key + ']' var subPart = encodeURIComponent(params) + '=' result += subPart + encodeURIComponent(value[key]) + '&' @@ -237,3 +243,41 @@ export function blobValidate(data) { export function indexContinuation(num, size) { return (num - 1) * size + 1 } + +export function toChineseAmount(n) { + const fraction = ['角', '分'] + const digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'] + const unit = [ + ['元', '万', '亿'], + ['', '拾', '佰', '仟'] + ] + let head = n < 0 ? '负' : '' + n = Math.abs(n) + + let s = '' + + // 处理小数部分 + for (let i = 0; i < fraction.length; i++) { + s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '') + } + s = s || '整' + + // 处理整数部分 + n = Math.floor(n) + for (let i = 0; i < unit[0].length && n > 0; i++) { + let p = '' + for (let j = 0; j < unit[1].length && n > 0; j++) { + p = digit[n % 10] + unit[1][j] + p + n = Math.floor(n / 10) + } + s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s + } + + return ( + head + + s + .replace(/(零.)*零元/, '元') + .replace(/(零.)+/g, '零') + .replace(/^整$/, '零元整') + ) +} diff --git a/src/views/material/cost/component/applyHome.vue b/src/views/material/cost/component/applyHome.vue index 61406154..2f009516 100644 --- a/src/views/material/cost/component/applyHome.vue +++ b/src/views/material/cost/component/applyHome.vue @@ -87,13 +87,13 @@ @click="handleApplyList" >批量结算 - 协议书 + > --> @@ -106,7 +106,7 @@ }} - + @@ -135,9 +135,14 @@ @click="handleApply(scope.row)" v-if="scope.row.sltStatus == '0' || (scope.row.sltStatus == '3')" >结算申请 - + + 协议书 @@ -162,42 +167,46 @@
- 协议号: + 协议号:{{ agreementContent.agreementCode }}
工程名称:
-
金上-湖北线路工程(川12标)
+
{{ agreementContent.projectName }}
承租单位:
-
金上-湖北线路工程(川12标)项目部
+
{{ agreementContent.unitName }}
日期:
-
2024-12-01
+
{{ agreementContent.applyTime || newData }}
结算项目及金额(元)
一、施工机具有偿使用费:
-
¥ 13144247. 44
+
¥ {{ agreementContent.leaseCost }}
二、施工机具维修费:
-
¥ 13144247. 44
+
¥ {{ agreementContent.repairCost }}
三、施工机具丢失费:
-
¥ 13144247. 44
+
¥ {{ agreementContent.loseCost }}
四、施工机具损坏赔偿费:
-
¥ 13144247. 44
+
¥ {{ agreementContent.scrapCost }}
+
+
+
五、施工机具租赁减免费:
+
¥ {{ agreementContent.reductionCost }}
费用合计金额(大写):
-
贰仟肆佰伍拾陆万伍仟肆佰捌拾玖元肆角伍分
-
¥ 24565489.45
+
{{ agreementContent.costAllUpper }}
+
¥ {{ agreementContent.costAll }}
说明:
@@ -247,7 +256,8 @@ import { getUnitList, // getAgreementInfoById, } from '@/api/back/index.js' -import { getSltAgreementInfo,getProjectListByUnitIds,getAgreementInfoById } from '@/api/cost/cost' +import { getSltAgreementInfo,getProjectListByUnitIds,getAgreementInfoById, getSltInfo } from '@/api/cost/cost' +import { toChineseAmount } from '@/utils/bonus.js' import vueEasyPrint from "vue-easy-print"; import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; @@ -299,7 +309,21 @@ export default { agreementId: [], agreementCode: '', }, - openPrint:false + openPrint:false, + // 协议书内容 + agreementContent: { + agreementCode: '', + projectName: '', + unitName: '', + leaseCost: '', // 租赁费用 + repairCost: '', // 维修费用 + loseCost: '', // 丢失费用 + scrapCost: '', // 报废费用 + reductionCost: '', // 减免费用 + costAll: '', // 合计费用 + costAllUpper: '', // 合计费用大写 + }, + newData: new Date().toISOString().split('T')[0], } }, // updated() { @@ -474,8 +498,20 @@ export default { this.single = selection.length != 1 this.multiple = !selection.length }, - openPrintDialog(){ + async openPrintDialog(row){ this.openPrint = true + try { + const res = await getSltInfo([row]) + console.log('🚀 ~ openPrintDialog ~ res:', res) + if (!res.data) return + this.agreementContent = res.data + this.agreementContent.agreementCode = row.agreementCode + this.agreementContent.costAll = Number(res.data.leaseCost) + Number(res.data.repairCost) + Number(res.data.scrapCost) + Number(res.data.loseCost) - Number(res.data.reductionCost) + // costAllUpper 中文大写 + this.agreementContent.costAllUpper = toChineseAmount(this.agreementContent.costAll.toFixed(2)) + } catch (error) { + console.log('🚀 ~ openPrintDialog ~ error:', error) + } }, //维修任务单打印 print() { diff --git a/src/views/material/cost/component/examHome.vue b/src/views/material/cost/component/examHome.vue index 85047ea1..c0630b4a 100644 --- a/src/views/material/cost/component/examHome.vue +++ b/src/views/material/cost/component/examHome.vue @@ -55,13 +55,13 @@ 查询 重置 - 协议书 + > --> @@ -74,7 +74,7 @@ }} - + @@ -102,6 +102,13 @@ + 协议书 @@ -143,42 +150,46 @@
- 协议号: + 协议号:{{ agreementContent.agreementCode }}
-
+
工程名称:
-
金上-湖北线路工程(川12标)
+
{{ agreementContent.projectName }}
-
+
承租单位:
-
金上-湖北线路工程(川12标)项目部
+
{{ agreementContent.unitName }}
日期:
-
2024-12-01
+
{{ agreementContent.applyTime }}
-
+
结算项目及金额(元)
-
+
一、施工机具有偿使用费:
-
¥ 13144247. 44
+
¥ {{ agreementContent.leaseCost }}
-
+
二、施工机具维修费:
-
¥ 13144247. 44
+
¥ {{ agreementContent.repairCost }}
-
+
三、施工机具丢失费:
-
¥ 13144247. 44
+
¥ {{ agreementContent.loseCost }}
-
+
四、施工机具损坏赔偿费:
-
¥ 13144247. 44
+
¥ {{ agreementContent.scrapCost }}
-
+
+
五、施工机具租赁减免费:
+
¥ {{ agreementContent.reductionCost }}
+
+
费用合计金额(大写):
-
贰仟肆佰伍拾陆万伍仟肆佰捌拾玖元肆角伍分
-
¥ 24565489.45
+
{{ agreementContent.costAllUpper }}
+
¥ {{ agreementContent.costAll }}
说明:
@@ -226,7 +237,8 @@ import { getUnitList, getAgreementInfoById, } from '@/api/back/index.js' -import { getSltList,costExamine } from '@/api/cost/cost' +import { getSltList,costExamine, getSltInfo } from '@/api/cost/cost' +import { toChineseAmount } from '@/utils/bonus.js' import vueEasyPrint from "vue-easy-print"; import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; @@ -286,6 +298,19 @@ export default { applyVisible: false, id: '', agreementIdTemp: '', + // 协议书内容 + agreementContent: { + agreementCode: '', + projectName: '', + unitName: '', + leaseCost: '', // 租赁费用 + repairCost: '', // 维修费用 + loseCost: '', // 丢失费用 + scrapCost: '', // 报废费用 + reductionCost: '', // 减免费用 + costAll: '', // 合计费用 + costAllUpper: '', // 合计费用大写 + }, } }, created() { @@ -439,8 +464,20 @@ export default { this.aform = { status: '2' }; }, - openPrintDialog(){ + async openPrintDialog(row){ this.openPrint = true + try { + const res = await getSltInfo([row]) + console.log('🚀 ~ openPrintDialog ~ res:', res) + if (!res.data) return + this.agreementContent = res.data + this.agreementContent.agreementCode = row.agreementCode + this.agreementContent.costAll = Number(res.data.leaseCost) + Number(res.data.repairCost) + Number(res.data.scrapCost) + Number(res.data.loseCost) - Number(res.data.reductionCost) + // costAllUpper 中文大写 + this.agreementContent.costAllUpper = toChineseAmount(this.agreementContent.costAll.toFixed(2)) + } catch (error) { + console.log('🚀 ~ openPrintDialog ~ error:', error) + } }, //维修任务单打印 print() {