|
- /**
- * Created by Administrator on 2021/4/5.
- */
- define(['jquery', "template", "Tools", "demandApi", "paging"], function ($, template, Tools ) {
- //数据存储
- var module = {
- data: {
- //公告列表
- demandInformationList:'',
- //鉴证列表
- supplyInformationList:'',
- //页码
- pageNum: 1,
- //页码集合
- pageList: [],
- //每页数量
- pageSize: 50,
- //总页数
- pageCount:0,
- //选中卡ID
- clickType:'supply',
- //供求类型 1:供应 2:求购 (不传值获取两种类型混合数据)
- demandType:1
- },
- };
- var tools = new Tools();
-
- module.init = function (page) {
-
- //个人供应
- tools.doGet(
- demandList,
- {
- deptId:100,
- pageNum:module.data.pageNum,
- pageSize:module.data.pageSize,
- supplyDemandType:1
- },
- module.supplyInformation,true
- );
-
- //个人需求
- tools.doGet(
- demandList,
- {
- deptId:100,
- pageNum:module.data.pageNum,
- pageSize:module.data.pageSize,
- supplyDemandType:2
- },
- module.demandInformation,true
- );
-
- //网站配置信息(网站名称 底部联系方式 公安备案号 网站备案号)
- tools.getWebConfig();
- };
-
- //个人供求数据
- module.supplyInformation = function (data) {
- if (data.code == 200) {
- console.log(data)
- var content = data.rows;
- var pageCount = (data.total/module.data.pageSize).toFixed(0);
- if (pageCount < 1){
- pageCount = 1;
- }
- if(module.data.supplyInformationList == ''){
- // 初始化 分页器
- var page_s1=createPage('.page_s1');
- // 设置分页
- setPage(page_s1,{
- pageTotal: data.total, // 数据总条数
- pageSize: module.data.pageSize, // 每页显示条数
- pageCurrent: 1, // 当前页
- maxBtnNum: 5, // 最多按钮个数 (最少5个)
- })
- $('#page_s1').html('共'+pageCount+'页')
- }
- module.data.pageCount = pageCount;
- module.data.supplyInformationList = content;
- var supplyInformationData = template('supplyInformationData', module.data);
- $("#supply").html(supplyInformationData);
- }
- }
-
- //个人需求数据
- module.demandInformation = function (data) {
- if (data.code == 200) {
- var content = data.rows;
- var pageCount = (data.total/module.data.pageSize).toFixed(0);
- if (pageCount < 1){
- pageCount = 1;
- }
- if(module.data.demandInformationList == ''){
- // 初始化 分页器
- var page_s1=createPage('.page_s2');
- // 设置分页
- setPage(page_s1,{
- pageTotal: data.total, // 数据总条数
- pageSize: module.data.pageSize, // 每页显示条数
- pageCurrent: 1, // 当前页
- maxBtnNum: 5, // 最多按钮个数 (最少5个)
- })
- $('#page_s2').html('共'+pageCount+'页')
- }
- module.data.pageCount = pageCount;
- module.data.demandInformationList = content;
- var demandInformationData = template('demandInformationData', module.data);
- $("#demand").html(demandInformationData);
- }
- }
-
- tabCheck = function (type) {
- document.getElementById('supply').style.display = 'none';
- document.getElementById('demand').style.display = 'none';
- document.getElementById(type).style.display = 'inline-table';
- document.getElementById('supplyBtn').className = '';
- document.getElementById('demandBtn').className = '';
- document.getElementById(type+'Btn').className = 'active';
- module.data.clickType = type ;
- }
-
- turnThePage = function (pageNum) {
- module.data.pageNum = pageNum ;
- if(module.data.clickType == 'supply'){
- //个人供应
- tools.doGet(
- demandList,
- {
- deptId:100,
- pageNum:module.data.pageNum,
- pageSize:module.data.pageSize,
- supplyDemandType:1
- },
- module.supplyInformation,true
- );
- }
- if(module.data.clickType == 'demand'){
- //个人需求
- tools.doGet(
- demandList,
- {
- deptId:100,
- pageNum:module.data.pageNum,
- pageSize:module.data.pageSize,
- supplyDemandType:2
- },
- module.demandInformation,true
- );
- }
- }
- return module;
- });
|