|
- $(document).ready(function() {
- $(".form_date").datetimepicker({
- format: 'yyyy-mm-dd',
- autoclose: true,
- minView: 2,
- pickerPosition: "bottom-left"
- });
- });
-
- var start_date = '';
- var end_date = '';
- var org_id = '';
- var date_type = '1';
- var more_search = '';
- var page_size = '10';
- var currpage_page = '1';
-
- window.onload = function() {
- httpBaseInfo();
- }
-
- function httpBaseInfo() {
- let data = {
- type: 'des_ordersource',
- ordersource: ''
- }
- $.ajax({
- url: $$.base_api + 'st-xm/control.php',
- data: data,
- dataType: 'json',
- type: 'post',
- async: false,
- success: res_data => {
- $$.ZZLog(res_data);
- if(0 != res_data.code) {
- $$.alert(res_data.info);
- } else {
- let org_list = res_data.list;
- let temp_html = `<option value="0">请选择</option>`;
- org_list.forEach((dict, index) => {
- temp_html += `<option value="${dict.org_id}">${dict.org_name}</option>`
- });
- $('#org_list').html(temp_html);
- $('#org_list').comboSelect();
- // $$.loading();
- $$.delay(httpFirstData, 10);
- // httpFirstData();
- }
- },
- error: (error) => {
- $$.alert($$.infoApiError);
- }
- });
-
- let data1 = { tp: 'reparations_getMemoArr' };
- $.ajax({
- url: $$.base_api + 'application/financeManager/index.php',
- data: data1,
- dataType: 'json',
- type: 'post',
- async: false,
- success: res_data => {
- $$.ZZLog(res_data);
- if(0 != res_data.code) {
- $$.alert(res_data.info);
- } else {
- let list = res_data.list;
- let temp_html = `<option value="0">请选择</option>`;
- list.forEach((dict, index) => {
- temp_html += `<option value="${dict.memo_id}" info="${dict.memo}">${dict.memo_title}</option>`
- });
- $('#cancel_reason').html(temp_html);
- $('#cancel_reason').comboSelect();
- }
- },
- error: (error) => {
- $$.alert($$.infoApiError);
- }
- });
- }
-
- function httpFirstData() {
- start_date = $('#beforeDate').val();
- end_date = $('#currentDate').val();
- org_id = $('#org_list').val();
- more_search = $('#more_search').val();
- let first_current = '1';
- let tp = 'reparations_getList';
- let data = { start_date, end_date, org_id, more_search, current_page: first_current, page_size, tp, date_type }
- $.ajax({
- type: "post",
- url: $$.base_api + 'application/financeManager/index.php',
- async: false,
- dataType: 'json',
- data: data,
- success: res_data => {
- $$.closeLoading();
- $$.ZZLog(res_data);
- if('0' != res_data.code) {
- $$.alert(res_data.info);
- } else {
- let total_page = res_data.data.page.total_page;
- let order_list = res_data.data.order_list;
-
- let temp_html = '';
- order_list.forEach((dict, index) => {
- temp_html += replaceOrderList(dict);
- });
-
- if(order_list.length <= 0) {
- var html = `<tr style="text-align: center;">
- <td style="color: #666;" colspan="8">无查询结果</td>
- </tr>`;
- $('#order_list').html(html);
- } else {
- $('#order_list').html(temp_html);
- }
-
- if(total_page == '0') {
- $('#page_order_list').hide();
- } else {
- createPage(first_current, total_page);
- $('#page_order_list').show();
- }
- $('#order_list').show();
- }
- },
- error: error => {
- $$.closeLoading();
- $$.alert($$.infoApiError);
- }
- });
- }
-
- function createPage(currpage, totalpage) {
- $('#page_order_list').createPage({
- pageCount: totalpage,
- current: currpage,
- turndown: 'true',
- backFn: function(p) {
- currpage_page = p;
- $$.loading();
- $$.delay(httpData, 10);
- }
- });
- }
-
- function httpData() {
- let tp = 'reparations_getList';
- let data = { start_date, end_date, org_id, more_search, current_page: currpage_page, page_size, tp, date_type }
- $.ajax({
- type: "post",
- url: $$.base_api + 'application/financeManager/index.php',
- async: false,
- dataType: 'json',
- data: data,
- success: res_data => {
- $$.ZZLog(res_data);
- $$.closeLoading();
- if('0' != res_data.code) {
- $$.alert(res_data.info);
- } else {
- let order_list = res_data.data.order_list;
-
- let temp_html = '';
- order_list.forEach((dict, index) => {
- temp_html += replaceOrderList(dict);
- });
- if(order_list.length <= 0) {
- var html = `<tr style="text-align: center;">
- <td style="color: #666;" colspan="8">无查询结果</td>
- </tr>`;
- $('#order_list').html(html);
- } else {
- $('#order_list').html(temp_html);
- }
- $('#order_list').show();
- }
- },
- error: error => {
- $$.closeLoading();
- $$.alert($$.infoApiError);
- }
- });
- }
-
- function searchDidClick() {
- $$.loading();
- $$.delay(httpFirstData, 10);
- }
-
- function replaceOrderList(dict) {
- let n_dict = JSON.stringify(dict);
- let html = `<tr dict='${n_dict}'>
- <td>${dict.create_time}</td>
- <td>${dict.order_id}</td>
- <td>${dict.PARENT_PROD_NAME}</td>
- <td>${dict.SUPPLIER_NAME}</td>
- <td>${dict.reparations}</td>
- <td>${dict.date}</td>
- <td>${dict.memo}</td>
- <td><div><button type="button" class="btn btn-link btn-xs" data-toggle="modal" data-target=".bs-example-modal-lg" onclick="addIndemnity(${dict.order_id},'edit')">编辑</button><button type="button" class="btn btn-link btn-xs" onclick="delDidClick(${dict.order_id})">删除</button></div></td>
- </tr>`
-
- return html;
- }
-
- function addIndemnity(id, status) {
- if(status == 'add') {
- $('#div_title').text('添加赔款');
- $('#prod_info').html('请输入订单号进行查询');
- $('#reparation_div').val('');
- $('#reparation_date').val('');
- $('#order_div').val('');
- $('#reason').val('');
- $('#div_search').show();
- $('#order_div').removeAttr('readonly');
- $('#order_div').css('border-width', '2');
- $('#cancel_reason').val('0');
- $('#cancel_reason').comboSelect();
-
- } else {
- $('#div_title').text('编辑赔款');
- // $('#cancel_reason').val('0');
- // $('#cancel_reason').comboSelect();
- searchOrderById(id);
- $('#div_search').hide();
- $('#order_div').val(id);
- $('#order_div').attr('readonly', 'readonly');
- $('#order_div').css('border-width', '0');
- }
- }
-
- //赔款订单查询 -- 新增
- function divSearchDidClick() {
- let order_id = $('#order_div').val();
- searchOrderById(order_id);
- }
-
- //根据订单查询
- function searchOrderById(order_id) {
- let tp = 'reparations_getOrderInfo';
- let data = { order_id, tp };
- $.ajax({
- type: "post",
- url: $$.base_api + 'application/financeManager/index.php',
- async: false,
- dataType: 'json',
- data: data,
- success: res_data => {
- $$.ZZLog(res_data);
- if('0' != res_data.code) {
- $$.alert('未查询到订单');
- } else {
- $('#m_save').show();
- let data = res_data.data;
- $('#prod_info').html(data.PARENT_PROD_NAME);
- $('#reparation_div').val(data.reparations);
- $('#reparation_date').val(data.date);
- $('#reason').val(data.memo);
- // console.log(data.memo_title);
- // if (data.memo_title == '') {
- // console.log($('#cancel_reason').find("option:selected").text());
- // $('#cancel_reason option[text=请选择]').attr("selected",'selected');
- // } else{
- //
- // console.log($('#cancel_reason').find("option:selected").text());
- // $("#cancel_reason option[text="+data.memo_title+"]").attr("selected",'selected');
- // }
- // $("#cancel_reason option[value="+data.memo_id+"]").attr("selected",true);
- $('#cancel_reason').val(data.memo_id);
- $('#cancel_reason').comboSelect();
- }
- },
- error: error => {
- $$.alert('未查询到订单');
- }
- });
- }
-
- //保存
- function saveDidClick() {
- let order_id = $('#order_div').val();
- let reparations = $('#reparation_div').val();
- let m_date = $('#reparation_date').val();
- let memo = $('#reason').val();
- let memo_title = $('#cancel_reason').find("option:selected").text();
- let memo_id = $('#cancel_reason').val();
- let tp = 'reparations_setReparations';
- if(memo == '') {
- $$.alert('赔款原因不能为空');
- return;
- }
-
- let data = { tp, order_id, reparations, date: m_date, memo, memo_id, memo_title };
- $.ajax({
- type: "post",
- url: $$.base_api + 'application/financeManager/index.php',
- async: false,
- dataType: 'json',
- data: data,
- success: res_data => {
- $$.ZZLog(res_data);
- if('0' != res_data.code) {
- $$.alert('设置赔款失败');
-
- } else {
- $('#indemnity_info').modal('hide');
- httpData();
- $$.alert('设置赔款成功');
- }
- },
- error: error => {
- $$.alert('设置赔款成功');
- }
- });
- }
-
- function changeOrder() {
- $('#m_save').hide();
- $('#prod_info').html('请输入订单号进行查询');
- $('#reparation_div').val('');
- $('#reparation_date').val('');
- $('#reason').val('');
- }
-
- function delDidClick(order_id) {
-
- $$.confirm('是否确定删除赔款?', function() {
- let tp = 'reparations_del';
- let data = { order_id, tp };
- $.ajax({
- type: "post",
- url: $$.base_api + 'application/financeManager/index.php',
- async: false,
- dataType: 'json',
- data: data,
- success: res_data => {
- $$.ZZLog(res_data);
- if('0' != res_data.code) {
- $$.alert('删除失败');
- } else {
- $$.alert('删除成功');
- httpData();
- }
- },
- error: error => {
- $$.alert('删除失败');
- }
- });
- }, function() {
-
- }, function() {
-
- })
- }
|