master
lynn 6 months ago
parent c614c0141f
commit 4c23f43c6e

@ -228,6 +228,47 @@
} from "@/utils";
import { getContractTemplateContext } from '@/api/businessConfig/businessConfig';
//
function numberToChinese(num) {
const units = ['', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿'];
const digits = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
//
const [integer, decimal] = num.toString().split('.');
let result = '';
//
let intNum = parseInt(integer);
if (intNum === 0) {
result = '零';
} else {
let i = 0;
while (intNum > 0) {
const digit = intNum % 10;
if (digit !== 0) {
result = digits[digit] + units[i] + result;
} else if (result.charAt(0) !== '零') {
result = '零' + result;
}
intNum = Math.floor(intNum / 10);
i++;
}
}
//
if (decimal) {
const decimalNum = parseInt(decimal);
if (decimalNum > 0) {
result += '点';
for (let i = 0; i < decimal.length; i++) {
result += digits[parseInt(decimal[i])];
}
}
}
return result + '元整';
}
// DOMHTML
function syncFormDomToHtml(dom, contractTemplateFields) {
if (!dom) return '';
@ -308,30 +349,58 @@
form: {
audit_money: 0
},
// paymentRegistrationRules: {
// applyMoney: [{
// required: true,
// message: ""
// },
// {
// pattern: /(^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d{1,2})?$)/,
// message: ''
// }
// ],
// deductionMoney: [{
// required: true,
// message: ""
// },
// {
// pattern: /(^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d{1,2})?$)/,
// message: ''
// }
// ],
// type: [{
// required: true,
// message: ""
// }]
// },
paymentRegistrationRules: {
applyMoney: [
{
required: false,
message: '必填'
},
{
pattern: /(^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d{1,2})?$)/,
message: '必须为数字'
}
],
deductionMoney: [
{
required: false,
message: '必填'
},
{
pattern: /(^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d{1,2})?$)/,
message: '必须为数字'
}
],
audit_money: [
{
required: false,
message: '必填'
}
],
type: [
{
required: false,
message: '必选'
}
],
isLast: [
{
required: false,
message: '必选'
}
],
remark: [
{
required: false,
message: '必填'
}
],
act_date: [
{
required: false,
message: '必填'
}
]
},
planTable: [{
sortable: false,
width: 36,
@ -538,6 +607,7 @@
this.contractTemplate = null;
this.forms = null;
}
//
if (this.contract && this.contract.id) {
getContractTemplateContext({
@ -545,7 +615,57 @@
model: 'Contract'
}).then(res => {
this.templateContextData = res;
//
this.initTemplateFields(res);
});
}
},
//
initTemplateFields(contextData) {
if (!contextData || !contextData.other_data_fill) return;
//
if (this.contract.contract_template && this.contract.contract_template.contract_template_fields) {
const fields = this.contract.contract_template.contract_template_fields;
//
fields.forEach(field => {
// link_typeother_data_fill
if (field.link_field && contextData.other_data_fill[field.link_field]) {
let value = contextData.other_data_fill[field.link_field];
// upper_money
if (field.link_field === 'upper_money') {
value = numberToChinese(Number(value));
}
//
field.value = value;
// DOM
const dom = this.$refs.zoomedForms || this.$refs.zoomedTemplate;
if (dom) {
const input = dom.querySelector(`[data-field="${field.field}"]`);
if (input) {
if (input.type === 'checkbox' || input.type === 'radio') {
// checked
if (field.value === input.value) {
input.checked = true;
}
} else {
// value
input.value = field.value;
}
}
}
}
});
// forms
if (this.$refs.zoomedForms) {
this.forms = syncFormDomToHtml(this.$refs.zoomedForms, fields);
}
}
},
@ -590,12 +710,12 @@
let data = {
contract_id: this.contract.id,
apply_money: this.paymentRegistrationForm.applyMoney,
discount_money: this.paymentRegistrationForm.deductionMoney,
type: this.paymentRegistrationForm.type,
apply_money: this.paymentRegistrationForm.applyMoney?this.paymentRegistrationForm.applyMoney:0,
discount_money: this.paymentRegistrationForm.deductionMoney?this.paymentRegistrationForm.deductionMoney:0,
type: this.paymentRegistrationForm.type?this.paymentRegistrationForm.type:0,
is_end: this.paymentRegistrationForm.isLast ? 1 : 0,
remark: this.paymentRegistrationForm.remark,
audit_money: this.paymentRegistrationForm.audit_money,
audit_money: this.paymentRegistrationForm.audit_money?this.paymentRegistrationForm.audit_money:0,
end_time:this.paymentRegistrationForm.end_time,
is_check:this.paymentRegistrationForm.isCheck ? 1 : 0,
// HTML

@ -1227,7 +1227,10 @@ export default {
minWidth: 200,
prop: "contract_carry_department",
customFn: row => {
return row.contract_carry_department.map(i => i.carry_department.name).join('')
if (!row.contract_carry_department || !row.contract_carry_department.length) {
return '未设置'
}
return row.contract_carry_department.map(i => i.carry_department?.name || '未设置').join('')
}
}
],

Loading…
Cancel
Save