|
@@ -9,6 +9,9 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
$(document).ready(function () {
|
|
$(document).ready(function () {
|
|
|
|
+ let oldVal = null
|
|
|
|
+ let timer = null
|
|
|
|
+ handleFileList(fileList)
|
|
// 控制上报弹窗的文案
|
|
// 控制上报弹窗的文案
|
|
function checkModal(isHide) {
|
|
function checkModal(isHide) {
|
|
if (isHide) {
|
|
if (isHide) {
|
|
@@ -21,11 +24,6 @@ $(document).ready(function () {
|
|
$('#tm-submit').show()
|
|
$('#tm-submit').show()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // 获取审核相关url
|
|
|
|
- function getUrlPre () {
|
|
|
|
- const path = window.location.pathname.split('/');
|
|
|
|
- return _.take(path, 4).join('/') + '/' + advance.id;
|
|
|
|
- }
|
|
|
|
// 审批人分组选择
|
|
// 审批人分组选择
|
|
$('#account_group').change(function () {
|
|
$('#account_group').change(function () {
|
|
let account_html = '<option value="0">选择审批人</option>'
|
|
let account_html = '<option value="0">选择审批人</option>'
|
|
@@ -43,7 +41,7 @@ $(document).ready(function () {
|
|
let id = $(this).val()
|
|
let id = $(this).val()
|
|
id = parseInt(id)
|
|
id = parseInt(id)
|
|
if (id !== 0) {
|
|
if (id !== 0) {
|
|
- postData(getUrlPre() + '/audit/add', { auditorId: id }, (data) => {
|
|
|
|
|
|
+ postData(preUrl + '/audit/add', { auditorId: id }, (data) => {
|
|
// <p class="m-0 ml-2"><small class="text-muted">中交第一公路工程局有限公司国道311线满别公路施工一分部</small></p>
|
|
// <p class="m-0 ml-2"><small class="text-muted">中交第一公路工程局有限公司国道311线满别公路施工一分部</small></p>
|
|
const html = []
|
|
const html = []
|
|
html.push('<li class="list-group-item" auditorId="'+ data.audit_id +'"><a href="javascript: void(0)" class="text-danger pull-right">移除</a>')
|
|
html.push('<li class="list-group-item" auditorId="'+ data.audit_id +'"><a href="javascript: void(0)" class="text-danger pull-right">移除</a>')
|
|
@@ -76,7 +74,7 @@ $(document).ready(function () {
|
|
const data = {
|
|
const data = {
|
|
auditorId: parseInt(li.attr('auditorId')),
|
|
auditorId: parseInt(li.attr('auditorId')),
|
|
};
|
|
};
|
|
- postData(getUrlPre() + '/audit/delete', data, (result) => {
|
|
|
|
|
|
+ postData(preUrl + '/audit/delete', data, (result) => {
|
|
li.remove();
|
|
li.remove();
|
|
for (const rst of result) {
|
|
for (const rst of result) {
|
|
const aLi = $('li[auditorId=' + rst.audit_id + ']');
|
|
const aLi = $('li[auditorId=' + rst.audit_id + ']');
|
|
@@ -109,9 +107,9 @@ $(document).ready(function () {
|
|
}
|
|
}
|
|
const prev_amount = prevAdvance && prevAdvance.prev_total_amount || 0
|
|
const prev_amount = prevAdvance && prevAdvance.prev_total_amount || 0
|
|
const prev_total_amount = ZhCalc.add(cur_amount, prev_amount)
|
|
const prev_total_amount = ZhCalc.add(cur_amount, prev_amount)
|
|
- const remark = $('#ad-remark').val() || null
|
|
|
|
|
|
+ const remark = $('#ad-remark').val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ') || null
|
|
const data = {pay_ratio, cur_amount, prev_amount, prev_total_amount, remark, status: auditConst.status.checking}
|
|
const data = {pay_ratio, cur_amount, prev_amount, prev_total_amount, remark, status: auditConst.status.checking}
|
|
- postData(getUrlPre() + '/audit/start', data, (data) => {
|
|
|
|
|
|
+ postData(preUrl + '/audit/start', data, (data) => {
|
|
window.location.reload()
|
|
window.location.reload()
|
|
}, () => {
|
|
}, () => {
|
|
window.location.reload()
|
|
window.location.reload()
|
|
@@ -163,36 +161,151 @@ $(document).ready(function () {
|
|
const data = {
|
|
const data = {
|
|
pay_ratio,
|
|
pay_ratio,
|
|
cur_amount,
|
|
cur_amount,
|
|
- prev_amount: p_amount,
|
|
|
|
- prev_total_amount: ZhCalc.add(cur_amount, p_amount),
|
|
|
|
}
|
|
}
|
|
- update(data)
|
|
|
|
|
|
+ oldVal = {
|
|
|
|
+ cur_amount: parseInt($(`.pay-input[data-type=${1}]`).val()),
|
|
|
|
+ remark: filterText($('#ad-remark').val())
|
|
|
|
+ }
|
|
|
|
+ clearTimeout(timer)
|
|
|
|
+ timer = setTimeout(() => {
|
|
|
|
+ if (checkInput()) {
|
|
|
|
+ update(data)
|
|
|
|
+ clearTimeout(timer)
|
|
|
|
+ }
|
|
|
|
+ }, 2000);
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ function checkInput() {
|
|
|
|
+ const newVal = {
|
|
|
|
+ cur_amount: parseInt($(`.pay-input[data-type=${1}]`).val()),
|
|
|
|
+ remark: filterText($('#ad-remark').val())
|
|
|
|
+ }
|
|
|
|
+ return newVal.pay_ratio === oldVal.pay_ratio && newVal.remark === oldVal.remark
|
|
|
|
+ }
|
|
|
|
+
|
|
$('#ad-remark').on('input propertychange', function(e) {
|
|
$('#ad-remark').on('input propertychange', function(e) {
|
|
- const data = { remark: e.target.value || ''}
|
|
|
|
- update(data)
|
|
|
|
|
|
+ const remark = filterText(e.target.value);
|
|
|
|
+ const data = { remark }
|
|
|
|
+ oldVal = {
|
|
|
|
+ cur_amount: parseInt($(`.pay-input[data-type=${1}]`).val()),
|
|
|
|
+ remark
|
|
|
|
+ }
|
|
|
|
+ clearTimeout(timer)
|
|
|
|
+ timer = setTimeout(() => {
|
|
|
|
+ if (checkInput()) {
|
|
|
|
+ update(data)
|
|
|
|
+ clearTimeout(timer)
|
|
|
|
+ }
|
|
|
|
+ }, 2000);
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ function filterText(text) {
|
|
|
|
+ if (!text) return null
|
|
|
|
+ return text.replace(/(\r\n)|(\n)/g, '<br/>').replace(/\s/g, ' ')
|
|
|
|
+ }
|
|
function update(data) {
|
|
function update(data) {
|
|
- postData(getUrlPre() + '/update', data)
|
|
|
|
|
|
+ postData(preUrl + '/update', data)
|
|
}
|
|
}
|
|
|
|
|
|
- function reverse(num){
|
|
|
|
- return 1^num
|
|
|
|
|
|
+ $('#file-modal-target').click(function () {
|
|
|
|
+ $('#file-modal').trigger('click')
|
|
|
|
+ })
|
|
|
|
+ $('#file-ok').click(function () {
|
|
|
|
+ const files = Array.from($('#file-modal')[0].files)
|
|
|
|
+ const valiData = files.map(v => {
|
|
|
|
+ const ext = v.name.substring(v.name.lastIndexOf('.') + 1)
|
|
|
|
+ return {
|
|
|
|
+ size: v.size,
|
|
|
|
+ ext
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ if (validateFiles(valiData)) {
|
|
|
|
+ if (files.length) {
|
|
|
|
+ const formData = new FormData()
|
|
|
|
+ files.forEach(file => {
|
|
|
|
+ formData.append('name', file.name)
|
|
|
|
+ formData.append('size', file.size)
|
|
|
|
+ formData.append('file', file)
|
|
|
|
+ })
|
|
|
|
+ postDataWithFile(preUrl + '/file/upload', formData, function (result) {
|
|
|
|
+ handleFileList(result)
|
|
|
|
+ $('#file-cancel').click()
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ function handleFileList(files) {
|
|
|
|
+ $('#file-content').empty()
|
|
|
|
+ const { uncheck, checkNo } = auditConst
|
|
|
|
+ const newFiles = files.map(file => {
|
|
|
|
+ let showDel = false;
|
|
|
|
+ if (file.uid === cur_uid) {
|
|
|
|
+ if (!curAuditor) {
|
|
|
|
+ advance.status === uncheck && cur_uid === advance.uid && (showDel = true)
|
|
|
|
+ advance.status === checkNo && cur_uid === advance.uid && (showDel = true)
|
|
|
|
+ } else {
|
|
|
|
+ curAuditor.audit_id === cur_uid && (showDel = true)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {...file, showDel}
|
|
|
|
+ })
|
|
|
|
+ let html = `<tr><td colspan="3"><a href="#addfujian" data-toggle="modal" class="btn btn-sm btn-light text-primary" data-placement="bottom" title="" data-original-title="添加清单"><i class="fa fa-cloud-upload" aria-hidden="true"></i> 上传附件</a></td></tr>`
|
|
|
|
+ newFiles.forEach((file, idx) => {
|
|
|
|
+ if (file.showDel) {
|
|
|
|
+ html += `<tr><td width="70">${idx + 1}</td><td><a href="/${file.filepath}" target="_blank">${file.filename}</a></td><td width="90"><a href="javascript: void(0);" class="text-danger file-del" data-id="${file.id}">移除</a></td></tr>`
|
|
|
|
+ } else {
|
|
|
|
+ html += `<tr><td width="70">${idx + 1}</td><td><a href="/${file.filepath}" target="_blank">${file.filename}</a></td><td width="90"></td></tr>`
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ $('#file-content').append(html)
|
|
}
|
|
}
|
|
|
|
|
|
- function formatMoney(s, dot = ',') {
|
|
|
|
- if (!s) return '0.00';
|
|
|
|
- s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(2) + '';
|
|
|
|
- let l = s.split('.')[0].split('').reverse(),
|
|
|
|
- r = s.split('.')[1];
|
|
|
|
- let t = '';
|
|
|
|
- for (let i = 0; i < l.length; i++) {
|
|
|
|
- t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? dot : '');
|
|
|
|
|
|
+ $('#file-content').on('click', 'a', function () {
|
|
|
|
+ if ($(this).hasClass('file-del')) {
|
|
|
|
+ const id = $(this).data('id')
|
|
|
|
+ postData(preUrl + '/file/del', {id}, (result) => {
|
|
|
|
+ handleFileList(result)
|
|
|
|
+ })
|
|
}
|
|
}
|
|
- return t.split('').reverse().join('') + '.' + r;
|
|
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 校验文件大小、格式
|
|
|
|
+ * @param {Array} files 文件数组
|
|
|
|
+ */
|
|
|
|
+function validateFiles(files) {
|
|
|
|
+ if (files.length > 10) {
|
|
|
|
+ toastr.error('至多同时上传10个文件');
|
|
|
|
+ return false
|
|
}
|
|
}
|
|
|
|
+ return files.every(file => {
|
|
|
|
+ if (file.size > 1024 * 1024 * 30) {
|
|
|
|
+ toastr.error('文件大小限制为30MB');
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if (whiteList.indexOf('.' + file.ext) === -1) {
|
|
|
|
+ toastr.error('请上传正确的格式文件');
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
})
|
|
})
|
|
|
|
+}
|
|
|
|
|
|
|
|
+function reverse(num){
|
|
|
|
+ return 1^num
|
|
|
|
+}
|
|
|
|
|
|
|
|
+function formatMoney(s, dot = ',') {
|
|
|
|
+ if (!s) return '0.00';
|
|
|
|
+ s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(2) + '';
|
|
|
|
+ let l = s.split('.')[0].split('').reverse(),
|
|
|
|
+ r = s.split('.')[1];
|
|
|
|
+ let t = '';
|
|
|
|
+ for (let i = 0; i < l.length; i++) {
|
|
|
|
+ t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? dot : '');
|
|
|
|
+ }
|
|
|
|
+ return t.split('').reverse().join('') + '.' + r;
|
|
|
|
+}
|