var PostData = {}; var query_data = {}; $(function () { $(".datepicker").datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, showOtherMonths: true, selectOtherMonths: true }); PostData.QuoteSection = $("#QuoteSection").val(); PostData.QuoteDate = $("#DateQuoteDate").val(); PostData.FileName = $("#FileName").val(); grid = jQuery('#listGrid').jqGrid({ cmTemplate: { width: 80, align: 'center', sortable: false }, url: "/QuoteFile/Query", datatype: 'json', multiselect: false, height: 'auto', width: '96%', autowidth: false, shrinkToFit: false, viewrecords: true, jsonReader: { repeatitems: false }, caption: '', mtype: 'POST', postData: PostData, colModel: colModelGrid, pager: jQuery('#pagerGrid'), pagerpos: 'left', rowNum: 20, rowList: [20, 30, 50, 200, 10000], footerrow: false, loadComplete: gridComplete, }); }); function gridComplete() { var newHeight = $(window).height() - 250; $(".ui-jqgrid .ui-jqgrid-bdiv").css("cssText", "height: " + newHeight + "px!important;"); $('.ui-jqgrid-bdiv', '#gbox_listGrid').floatingScroll(); } var getColModelGrid = function () { var col = [ { name: 'id', hidden: true, optionHide: true }, { name: 'EncryptId', hidden: true, optionHide: true }, { name: 'QuoteSection', label: '报价板块', width: 90, align: 'center', }, { name: 'FileName', label: '文件名', width: 300, align: 'center' } , { name: 'QuoteDate', label: '报价日期', width: 100, align: 'center', formatter:"date" }, { name: 'OptTime', label: '操作时间', width: 140, align: 'center', formatter: DateFormat }, { name: 'OptName', label: '操作人', width: 90, align: 'center' }, { name: '', label: '操作', align: 'center', width: 200, formatter: showToolName } ]; return col; } var colModelGrid = getColModelGrid(); function showToolName(cellValue, options, rowObject) { var html; html = "" .template(rowObject.FilePath.replaceAll("\\","/")); html = html + "" .template(rowObject.EncryptId); html = html + "" .template(rowObject.EncryptId); return html; } function AddQuoteFile() { $("#quoteFieModal").modal('show'); } function getList(isSearchclick) { var listGrid = $('#listGrid'); listGrid.appendPostData({ QuoteSection: $("#QuoteSection").val() }); listGrid.appendPostData({ QuoteDate: $("#DateQuoteDate").val() }); listGrid.appendPostData({ FileName: $("#FileName").val() }); query_data = listGrid.jqGrid('getPostData') if (typeof isSearchclick !== "undefined" && isSearchclick) { //点击搜索时默认第一页 listGrid.jqGrid('setGridParam', { page: 1 }); } listGrid.trigger('reloadGrid'); } function DateFormat(cellValue, options, rowObject) { return MomentFormat(cellValue,"YYYY-MM-DD HH:mm:ss"); } function MomentFormat(v, f) { if (v == null || v == '') { return ''; } if (!f) { f = 'YYYY-MM-DD'; } var m = new moment(v); if (m.year() < 1910) { return ''; } return new moment(v).format(f); } var vue = new Vue({ el: "#vueDiv", data: { quoteSectionList: page.quoteSectionSelects, QuoteSection: page.quoteSectionSelects[0].Value, QuoteDate: "", Disclaimer: "", quoteFileId:"" }, mounted() { this.QuoteDate = this.getCurrentDate(); }, computed: { maxDate() { var now = this.getCurrentDate(); return now; }, }, methods: { getCurrentDate() { this.date = page.valueDate; //将1970/08/08转化成1970-08-08 return this.date; }, importQuoteFile() { if (this.QuoteDate.length==0) { return main.alert("请选择报价日期!"); } let fileName = $("#openFile").val(); if (!fileName) { return main.alert("请选择要导入的文件!"); } let index = fileName.lastIndexOf("."); let fileEx = index > 0 ? fileName.substr(index).toLowerCase() : ''; if (fileEx !== '.xlsx') { return main.alert("只能上传.xlsx类型的文件!"); } function success(data) { if (data.success) { main.alert('上传成功!'); $("#quoteFieModal").modal('hide'); getList(); } else { main.alert("上传失败:" + data.msg); } } var url = "/QuoteFile/AddQuoteFile"; var formdata = new FormData(); formdata.append("QuoteSection", this.QuoteSection); formdata.append("QuoteDate", this.QuoteDate); formdata.append("Disclaimer", this.Disclaimer); main.confirm("确定上传?", UploadFile.bind(null, { inputId: 'openFile', url: url, success: success, formData: formdata })); }, downLoadQuoteFile(filePath) { window.open("/"+filePath,"_blank"); }, uploadQuoteFile(id) { this.quoteFileId = id; $("#uploadModal").modal('show'); }, coverQuoteFile() { let fileName = $("#upFile").val(); if (!fileName) { return main.alert("请选择要导入的文件!"); } let index = fileName.lastIndexOf("."); let fileEx = index > 0 ? fileName.substr(index).toLowerCase() : ''; if (fileEx !== '.xlsx') { return main.alert("只能上传.xlsx类型的文件!"); } function success(data) { if (data.success) { main.alert('上传成功!'); $("#uploadModal").modal('hide'); getList(); } else { main.alert("上传失败:" + data.msg); } } var url = "/QuoteFile/UploadQuoteFile?enid=" + this.quoteFileId; main.confirm("确定上传?", UploadFile.bind(null, { inputId: 'upFile', url: url, success: success })); }, deleteQuoteFile(id) { main.confirm("确定要删除吗?", function () { main.post("/QuoteFile/DelteQuoteFile?enid=" + id).done(function (resp) { getList(); }) }); } }, components: { 'vue-datepicker': FastVue.vueDatePicker() } });