|
@@ -28,7 +28,7 @@ $(function () {
|
|
|
//初始化所有附件列表
|
|
|
getAllList();
|
|
|
|
|
|
- $('#rpt-form input').on('change', function () {
|
|
|
+ $('#rpt-form input[type!="radio"]').on('change', function () {
|
|
|
let newVal = $(this).val();
|
|
|
const index = parseInt($(this).data('index'));
|
|
|
const type = $(this).attr('type');
|
|
@@ -44,10 +44,61 @@ $(function () {
|
|
|
newVal = ZhCalc.round(val, 6);
|
|
|
$(this).val(newVal);
|
|
|
}
|
|
|
+ // find link(大写转换)
|
|
|
+ const linkList = _.filter(tesRpttData.items[0].interact_cells, { link: index });
|
|
|
+ if (linkList.length > 0) {
|
|
|
+ const chineseNum = numberToChinese(newVal);
|
|
|
+ // 赋值到input框并展示在报表里
|
|
|
+ for (const cell of linkList) {
|
|
|
+ $('#rpt-form input[data-index="'+ cell.index +'"]').val(chineseNum);
|
|
|
+ tesRpttData.items[0].interact_cells[cell.index].Value =
|
|
|
+ tesRpttData.items[0].interact_cells[cell.index].Prefix ? tesRpttData.items[0].interact_cells[cell.index].Prefix + chineseNum : chineseNum;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
checkAndUpdate(index, newVal, $(this));
|
|
|
});
|
|
|
|
|
|
+ $(".link-dropdown").on("click",function (e) {
|
|
|
+ e.stopPropagation();
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.change-link').on('click', function () {
|
|
|
+ const link = $(this).parents('.link-dropdown').find('input:checked').val();
|
|
|
+ const index = parseInt($(this).attr('item-index'));
|
|
|
+ const old_link = $(this).attr('old-link');
|
|
|
+ if (old_link !== link) {
|
|
|
+ let showTips = '';
|
|
|
+ if (link !== '') {
|
|
|
+ const numberInfo = _.find(tesRpttData.items[0].interact_cells, { index: parseInt(link) });
|
|
|
+ if (numberInfo) showTips = '关联数据:' + numberInfo.Label;
|
|
|
+ }
|
|
|
+ $(this).parents('.link-dropdown').siblings('.show-link').html(showTips);
|
|
|
+ $(this).attr('old-link', link);
|
|
|
+ const info = link !== '' ? tesRpttData.items[0].interact_cells[link] : null;
|
|
|
+ const linkValue = removePreFix(info.Prefix, info.Value);
|
|
|
+ const chineseNum = linkValue ? numberToChinese(linkValue) : '';
|
|
|
+ tesRpttData.items[0].interact_cells[index].link = link !== '' ? parseInt(link) : '';
|
|
|
+ tesRpttData.items[0].interact_cells[index].Value = tesRpttData.items[0].interact_cells[index].Prefix ? tesRpttData.items[0].interact_cells[index].Prefix + chineseNum : chineseNum;
|
|
|
+ postData('/payment/' + tenderId + '/detail/' + detailId + '/save', { type: 'update_rpt', report_json: tesRpttData }, function (result) {
|
|
|
+ $('#rpt-form input[data-index="'+ index +'"]').val(chineseNum);
|
|
|
+ auditRptPrintHelper.showPage();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ function removePreFix(prefix, value) {
|
|
|
+ const result = prefix ? _.replace(value, prefix, '') : value;
|
|
|
+ return result ? parseFloat(result) : '';
|
|
|
+ }
|
|
|
+
|
|
|
+ $('.show-link-dropdown').on('show.bs.dropdown', function () {
|
|
|
+ const link = $(this).find('button').attr('old-link');
|
|
|
+ const index = $(this).find('button').attr('item-index');
|
|
|
+ $('input:radio[name="radio_'+ index +'"][value="'+ link + '"]').prop('checked', true);
|
|
|
+ });
|
|
|
+
|
|
|
$('#rpt-form textarea').on('change', function () {
|
|
|
const newVal = $(this).val();
|
|
|
const index = parseInt($(this).data('index'));
|
|
@@ -143,7 +194,6 @@ $(function () {
|
|
|
if (tesRpttData.items[0].interact_cells[index].DataType === 'intact_type_number' && _.indexOf(tesRpttData.items[0].interact_cells[index].Value, '元') !== -1) {
|
|
|
newVal = newVal + '元';
|
|
|
}
|
|
|
- console.log(index, newVal);
|
|
|
clearTimeout(timer);
|
|
|
timer = setTimeout(() => {
|
|
|
tesRpttData.items[0].interact_cells[index].Value = tesRpttData.items[0].interact_cells[index].Prefix ? tesRpttData.items[0].interact_cells[index].Prefix + newVal : newVal;
|
|
@@ -355,3 +405,52 @@ function bytesToSize(bytes) {
|
|
|
// return (bytes / Math.pow(k, i)) + ' ' + sizes[i];
|
|
|
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
|
|
|
}
|
|
|
+// 大写转换
|
|
|
+// 向右移位
|
|
|
+function shiftRight(number, digit) {
|
|
|
+ digit = parseInt(digit, 10);
|
|
|
+ var value = number.toString().split('e');
|
|
|
+ return +(value[0] + 'e' + (value[1] ? +value[1] + digit : digit));
|
|
|
+}
|
|
|
+// 向左移位
|
|
|
+function shiftLeft(number, digit) {
|
|
|
+ digit = parseInt(digit, 10);
|
|
|
+ var value = number.toString().split('e');
|
|
|
+ return +(value[0] + 'e' + (value[1] ? +value[1] - digit : -digit));
|
|
|
+}
|
|
|
+
|
|
|
+var numberToChinese = function (n) {
|
|
|
+ var fraction = ['角', '分'];
|
|
|
+ var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
|
|
|
+ var unit = [
|
|
|
+ ['元', '万', '亿'],
|
|
|
+ ['', '拾', '佰', '仟'],
|
|
|
+ ];
|
|
|
+ var head = n < 0 ? '负' : '';
|
|
|
+ n = Math.abs(n);
|
|
|
+ var s = '';
|
|
|
+ for (var i = 0; i < fraction.length; i++) {
|
|
|
+ s += (digit[Math.floor(shiftRight(n, 1 + i)) % 10] + fraction[i]).replace(
|
|
|
+ /零./,
|
|
|
+ ''
|
|
|
+ );
|
|
|
+ }
|
|
|
+ s = s || '';
|
|
|
+ n = Math.floor(n);
|
|
|
+ for (var i = 0; i < unit[0].length && n > 0; i++) {
|
|
|
+ var p = '';
|
|
|
+ for (var j = 0; j < unit[1].length && n > 0; j++) {
|
|
|
+ p = digit[n % 10] + unit[1][j] + p;
|
|
|
+ n = Math.floor(shiftLeft(n, 1));
|
|
|
+ }
|
|
|
+ s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ head +
|
|
|
+ s
|
|
|
+ .replace(/(零.)*零元/, '元')
|
|
|
+ .replace(/(零.)+/g, '零')
|
|
|
+ // .replace(/^整$/, '零元整')
|
|
|
+ );
|
|
|
+};
|
|
|
+
|