dytyqx
2026-03-31 9620ca5caed59bd206dce701a04a5a4e4cfb9dc5
src/views/component/printList/hBarPlanPrint.vue
@@ -1,98 +1,115 @@
<template>
    <div>
        <div id="report_holder"> </div>
    </div>
  <div>
    <div id="report_holder"></div>
  </div>
</template>
<script>
import { webapp_ws_ajax_run, webapp_urlprotocol_startup, urlAddRandomNo } from "@/utils/grwebapp";
import axios from 'axios'
import {
  webapp_ws_ajax_run,
  webapp_urlprotocol_startup,
  urlAddRandomNo,
} from "@/utils/grwebapp";
import axios from "axios";
export default {
    name: 'HBarPlanPrint',
    data() {
        return {
            handleMessage: this.$route.query,
            baseURL: 'http://47.96.97.237/API',
            //实际应用中,data应该为程序中通过各种途径获取到的数据,最后要将数据转换为报表需要的XML或JSON格式的字符串数据
            json_data: {
                recordset: []
            },
        }
  name: "HBarPlanPrint",
  data() {
    return {
      handleMessage: this.$route.query,
      baseURL: process.env.VUE_APP_BASE_API,
      //实际应用中,data应该为程序中通过各种途径获取到的数据,最后要将数据转换为报表需要的XML或JSON格式的字符串数据
      json_data: {
        recordset: [],
      },
    };
  },
  mounted() {
    this.ws_both_from_object();
  },
  // created() {
  //     this.ws_both_from_object()
  // },
  methods: {
    // 获取参数_传递的JSON格式参数
    getUrlVars_JSON() {
      var datajson;
      var str = this.propsData; //获取链接中传递的参数
      var arr = str.substring(str.lastIndexOf("=") + 1);
      datajson = JSON.parse(decodeURI(arr));
      return datajson;
    },
    mounted() {
        this.ws_both_from_object()
    ws_both_from_object() {
      console.log(this.$route.query.Type)
      let OpenTmp = decodeURIComponent(this.$route.query.OpenTmp);
      let sql = "";
      if (this.$route.query.Type == "Kf_SellOutBillList") {
        sql =
          "exec h_p_Kf_SellOutBillList_PrintSellOutBill " +
          this.handleMessage.linterid.toString();
      } else if (this.$route.query.Type == "HGy_BarCodeBill") {
        sql =
          "select * from h_v_IF_BarCodeBillList where hmainid in(" +
          this.handleMessage.linterid.toString() +
          ") order by hmainid desc";
      } else if (this.$route.query.Type == "HPOInStockBill") {
        sql =
          "select * from h_v_Sc_PrintMouldProdOutBillList where hmainid=" +
          this.handleMessage.linterid.toString() +
          " order by hmainid";
      } else if (this.$route.query.Type == "HGyStockPlaceBarCode") {
        let condition = decodeURI(this.handleMessage.linterid.toString());
        sql = `SELECT
                CEILING(CAST(t.row_num AS FLOAT) / 2) AS orderid,
                MAX(CASE WHEN t.row_num % 2 = 1 THEN t.条码编号 END) AS 条码编号1,
                MAX(CASE WHEN t.row_num % 2 = 1 THEN t.仓位名称 END) AS 仓位名称1,
                MAX(CASE WHEN t.row_num % 2 = 0 THEN t.条码编号 END) AS 条码编号2,
                MAX(CASE WHEN t.row_num % 2 = 0 THEN t.仓位名称 END) AS 仓位名称2
              FROM (
                SELECT
                  条码编号, 仓位名称,
                  ROW_NUMBER() OVER (ORDER BY t1.HItemID) AS row_num
                FROM h_v_IF_StockPlaceList t1 where 条码编号 in (${condition})
              ) AS t
              GROUP BY CEILING(CAST(t.row_num AS FLOAT) / 2)
              ORDER BY orderid;`;
      } else if (this.$route.query.Type == "WL_YayBill") {
        sql = "select * from h_v_WL_YayBilllist where hmainid in(" +
          this.handleMessage.linterid.toString() +
          ") order by hmainid desc";
      }
      this.$nextTick(() => {
        axios.get(this.$baseUrl + "/CommonModel/searchMethod", {
          params: {
            sql: sql,
            user: sessionStorage["HUserName"],
            ModRightNameCheck: "",
            // , "HSubID": data[i].hsubid
          },
        })
          .then((response) => {
            console.log(111, OpenTmp, response)
            let result = response.data;
            this.json_data.recordset = result.data;
            //参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分
            var args = {
              type: "preview", //设置不同的属性可以执行不同的任务,如:preview print pdf xls csv txt rtf img grd
              // report: this.json_report, //report: JSON.stringify(json_report),
              report: urlAddRandomNo("./static/grf/" + OpenTmp + ".grf"),
              data: this.json_data, //data: JSON.stringify(json_data)
            };
            console.log(args, this.json_data);
            webapp_ws_ajax_run(args);
            // var reportViewer = rubylong.grhtml5.insertReportViewer("report_holder", "./static/grf/销售出库单.grf", this.json_data);
            // reportViewer.start();
          })
          .catch((error) => {
            console.log(22222, error);
            this.$modal.msgError("接口请求失败!");
          });
      })
    },
    // created() {
    //     this.ws_both_from_object()
    // },
    methods: {
        // 获取参数_传递的JSON格式参数
        getUrlVars_JSON() {
            var datajson;
            var str = this.propsData; //获取链接中传递的参数
            var arr = str.substring(str.lastIndexOf("=") + 1);
            datajson = JSON.parse(decodeURI(arr));
            return datajson;
        },
        ws_both_from_object() {
            let OpenTmp = decodeURIComponent(this.$route.query.OpenTmp)
            let apIUrl = ''
            if (this.$route.query.Type == 'Kf_SellOutBillList') {
                apIUrl = '/Kf_SellOutBill/cx'
                axios.get(this.baseURL + apIUrl, {
                    params: {
                        "HInterID": this.handleMessage.linterid
                        // , "HSubID": data[i].hsubid
                    },
                }).then(response => {
                    let result = response.data
                    this.json_data.recordset = result.data
                    //参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分
                    var args = {
                        type: "preview", //设置不同的属性可以执行不同的任务,如:preview print pdf xls csv txt rtf img grd
                        // report: this.json_report, //report: JSON.stringify(json_report),
                        report: urlAddRandomNo('./static/grf/' + OpenTmp + '.grf'),
                        data: this.json_data //data: JSON.stringify(json_data)
                    };
                    webapp_ws_ajax_run(args);
                    // var reportViewer = rubylong.grhtml5.insertReportViewer("report_holder", "./static/grf/销售出库单.grf", this.json_data);
                    // reportViewer.start();
                }).catch(error => {
                    this.$modal.msgError("接口请求失败!");
                });
            } else if (this.$route.query.Type == 'HGy_BarCodeBill') {
                apIUrl = '/CommonModel/searchMethod'
                axios.get(this.baseURL + apIUrl, {
                    params: {
                        "sql": "select * from h_v_IF_BarCodeBillList where hmainid in(" + this.handleMessage.linterid.toString() + ") order by hmainid desc",
                        "user": sessionStorage["HUserName"],
                        "ModRightNameCheck": ''
                        // , "HSubID": data[i].hsubid
                    },
                }).then(response => {
                    let result = response.data
                    this.json_data.recordset = result.data
                    //参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分
                    var args = {
                        type: "preview", //设置不同的属性可以执行不同的任务,如:preview print pdf xls csv txt rtf img grd
                        // report: this.json_report, //report: JSON.stringify(json_report),
                        report: urlAddRandomNo('./static/grf/' + OpenTmp + '.grf'),
                        data: this.json_data //data: JSON.stringify(json_data)
                    };
                    console.log(args,this.json_data)
                    webapp_ws_ajax_run(args);
                    // var reportViewer = rubylong.grhtml5.insertReportViewer("report_holder", "./static/grf/销售出库单.grf", this.json_data);
                    // reportViewer.start();
                }).catch(error => {
                    console.log(22222, error)
                    this.$modal.msgError("接口请求失败!");
                });
            }
        }
    },
}
</script>
  },
};
</script>