123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- $(function () {
- autoFlashHeight();
- $('.to-log-link').on('click', function () {
- const status = parseInt($(this).data('status'));
- const uid = parseInt($('#curReportUid').data('uid'));
- const queryArr = [];
- if (status) {
- queryArr.push('status=' + status);
- }
- if (uid) {
- queryArr.push('uid=' + uid);
- }
- const queryStr = queryArr.length > 0 ? '?' + queryArr.join('&') : '';
- const link = '/construction/' + tender_id + '/list' + queryStr;
- window.location.href = link;
- });
- $('.to-log-link2').on('click', function () {
- const status = parseInt($('#curReportStatus').data('status'));
- const uid = parseInt($(this).data('uid'));
- const queryArr = [];
- if (status) {
- queryArr.push('status=' + status);
- }
- if (uid) {
- queryArr.push('uid=' + uid);
- }
- const queryStr = queryArr.length > 0 ? '?' + queryArr.join('&') : '';
- const link = '/construction/' + tender_id + '/list' + queryStr;
- window.location.href = link;
- });
- if (reportFlag) {
- const codeDate = $('#code-date').datepicker({
- onSelect: function (formattedDate, date, inst) {
- const showDate = date ? moment(date[date.length - 1]).format('YYYYMMDD') : '';
- const showCode = showDate ? showDate + getCodeByDate(showDate) : '';
- if (!showCode) {
- $('#existMsg').hide();
- }
- $('#show-code').val(showCode);
- }
- }).data('datepicker');
- codeDate.selectDate(new Date());
- $('#show-code').val(moment().format('YYYYMMDD') + getCodeByDate(moment().format('YYYYMMDD')));
- $('#add-log input[name="log-type"]').on('click', function () {
- const type = parseInt($(this).val());
- if (type) {
- $('#code-date').val('');
- codeDate.clear();
- $('#show-code').val('');
- $('#existMsg').hide();
- } else {
- codeDate.clear();
- $('#code-date').val(moment().format('YYYY-MM-DD'));
- codeDate.selectDate(new Date());
- $('#show-code').val(moment().format('YYYYMMDD') + getCodeByDate(moment().format('YYYYMMDD')));
- }
- });
- $('#add-log-btn').click(function () {
- if (_.trim($('#code-date').val()) === '') {
- toastr.error('请选择日期/周期');
- return false;
- }
- const newData = {
- type: parseInt($('#add-log input[name="log-type"]:checked').val()),
- code: $('#show-code').val(),
- period: _.trim($('#code-date').val()),
- };
- postData('/construction/' + tender_id + '/list/add', newData, function (result) {
- console.log(result);
- window.location.href = '/construction/' + tender_id + '/log/' + result;
- })
- });
- // 批量提交
- $('#confirm-uncheck-btn').click(function () {
- // 获取选中值
- const checkedIds = [];
- $('#uncheck-list input[type="checkbox"]:checked').each(function () {
- checkedIds.push(parseInt($(this).data('id')));
- });
- if (checkedIds.length === 0) {
- toastr.error('请勾选日志再批量提交');
- return false;
- }
- postData('/construction/' + tender_id + '/list/startmulti', { ids: checkedIds }, function (result) {
- window.location.reload();
- });
- });
- $('.delete-log-a').on('click', function () {
- $('#delete-log-id').val($(this).data('id'));
- });
- // 删除
- $('#delete-log-btn').click(function () {
- const log_id = $('#delete-log-id').val();
- if (!log_id) {
- toastr.error('删除的日志id为空');
- return false;
- }
- postData('/construction/' + tender_id + '/log/' + log_id + '/delete', {}, function (result) {
- window.location.reload();
- })
- });
- function getCodeByDate(date) {
- let num = '001';
- if (date) {
- const dateInfo = _.find(dateCodeList, { date_code: date });
- if (dateInfo) {
- num = convertToThreeDigits(dateInfo.num + 1);
- $('#existMsg').show();
- } else {
- $('#existMsg').hide();
- }
- } else {
- $('#existMsg').hide();
- }
- return num;
- }
- function convertToThreeDigits(number) {
- // 将数字转换为字符串
- let numStr = String(number);
- // 检查数字是否不足3位
- if (numStr.length < 3) {
- // 在前面添加足够的零使其成为3位数
- numStr = numStr.padStart(3, '0');
- }
- return numStr;
- }
- }
- });
|