123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- $(function () {
- $("#jqGrid").jqGrid({
- url: '../freight/list',
- datatype: "json",
- colModel: [
- {label: 'ID', name: 'id', index: 'id', width: 20, key: true},
- {label: '所属商户', name: 'merchName', index: 'merchName', width: 100, align: 'center'},
- {label: '所属门店', name: 'storeName', index: 'storeName', width: 80, align: 'center'},
- {label: '模版名称', name: 'name', index: 'name'},
- {
- label: '模版类型', name: 'templateType', index: 'template_type', width: 100,
- formatter: function (value) {
- return transTemplateType(value);
- }
- },
- {
- label: '计价方式', name: 'pricingManner', index: 'pricing_manner', width: 100,
- formatter: function (value) {
- return transPricingManner(value);
- }
- },
- {label: '操作', width: 90, align: 'center', sortable: false,
- formatter: function (value, col, row) {
- return " <button class='btn btn-primary' " +
- "onclick='vm.copyFreight(" + row.id + ")'>复制运费</button>";
- }
- }],
- viewrecords: true,
- height: 675,
- rowNum: 10,
- rowList: [10, 30, 50],
- rownumbers: true,
- rownumWidth: 25,
- autowidth: true,
- multiselect: true,
- pager: "#jqGridPager",
- jsonReader: {
- root: "page.list",
- page: "page.currPage",
- total: "page.totalPage",
- records: "page.totalCount"
- },
- prmNames: {
- page: "page",
- rows: "limit",
- order: "order"
- },
- gridComplete: function () {
- $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
- }
- });
- });
- function transTemplateType(value) {
- if (value == 1) {
- return '卖家包邮';
- }
- return '买家承担运费';
- };
- function transPricingManner(value) {
- if (value == 1) {
- return '按重量';
- } else if (value == 2) {
- return '按体积';
- }
- return '按件数';
- };
- let vm = new Vue({
- el: '#rrapp',
- data: {
- showList: true,
- title: null,
- freight: {},
- ruleValidate: {
- name: [
- {required: true, message: '名称不能为空', trigger: 'blur'}
- ]
- },
- q: {
- name: ''
- },
- freightItemEntityList: [{
- id: '',
- freId: '',
- deliveryArea: true,
- firstPiece: '',
- freight: '',
- continuePiece: '',
- renew: '',
- isDelete: 0
- }],
- storeList: [],
- merchList: [],
- copyFreightDto:{
- freightId: '',
- storeList: ''
- },
- showCopyList: true,
- showViewList: false,
- },
- methods: {
- copyFreight: function(id){
- vm.copyFreightDto.freightId = id;
- vm.copyFreightDto.storeList = "";
- vm.showCopyList = false;
- vm.showList = true;
- vm.showViewList = true;
- vm.title = "复制运费";
- },
- handleSubmitCopyFreight: function () {
- if(vm.copyFreightDto.freightId == ""){
- alert('运费id不能为空');
- return;
- }
- if(vm.copyFreightDto.storeList == ""){
- alert('门店id批量上传数据没有上传或未上传成功');
- return;
- }
- var url = "../freight/saveCopyFreight";
- $.ajax({
- type: "POST",
- url: url,
- contentType: "application/json",
- data: JSON.stringify(vm.copyFreightDto),
- success: function (r) {
- if (r.code === 0) {
- alert('操作成功', function (index) {
- vm.showCopyList = true;
- vm.showList = true;
- vm.showViewList = false;
- vm.reload();
- });
- } else {
- alert(r.msg);
- }
- }
- });
- },
- uploadExcelSuccess: function (data) {
- if(data.code==0){
- alert(data.msg, function (index) {
- vm.copyFreightDto.storeList = data.storeIds;
- });
- }else{
- alert(data.msg);
- }
- },
- uploadExcelError: function (data) {
- console.log(data);
- alert('上传出现异常,请重试!');
- },
- uploadExcelFormatError: function (file) {
- this.$Notice.warning({
- title: '文件格式不正确',
- desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
- });
- },
- changeUnit: function(value) {
- if (value == '0') {
- $('#first').html('首件(个)');
- $('#continue').html('续件(个)');
- } else if (value == '1') {
- $('#first').html('首件(kg)');
- $('#continue').html('续件(kg)');
- } else if (value == '2') {
- $('#first').html('首件(m³)');
- $('#continue').html('续件(m³)');
- }
- },
- delItemRow: function (index) {
- //最后一行时禁止删除
- if (vm.freightItemEntityList.length == 1) {
- return;
- }
- vm.freightItemEntityList[index].isDelete = 1;
- },
- addItemRow: function () {
- let id = '';
- if (vm.freight) {
- id = vm.freight.id;
- }
- vm.freightItemEntityList.push({
- id: '',
- freId: '',
- firstPiece: '',
- freight: '',
- continuePiece: '',
- renew: '',
- isDelete: 0
- })
- },
- query: function () {
- vm.reload();
- },
- add: function () {
- vm.showList = false;
- vm.showCopyList = true;
- vm.showViewList = true;
- vm.title = "新增";
- vm.freight = {
- name: '',
- templateType: 0,
- pricingManner: 0,
- isDefault: false
- };
- vm.freightItemEntityList = [{
- id: '',
- freId: '',
- deliveryArea: true,
- firstPiece: '',
- freight: '',
- continuePiece: '',
- renew: '',
- isDelete: 0
- }];
- vm.storeList = [];
- vm.merchList = [];
- vm.getMerchList();
- },
- getStoresByMerch: function (opt) {
- var value = opt.value;
- $.get("../store/getStoresByMerch?merchSn=" + value, function (r) {
- vm.storeList = r.list;
- });
- },
- getMerchList: function() {
- $.get("../merch/queryAll", function (r) {
- vm.merchList = r.list;
- });
- },
- update: function (event) {
- let id = getSelectedRow();
- if (id == null) {
- return;
- }
- vm.showList = false;
- vm.showCopyList = true;
- vm.showViewList = true;
- vm.title = "修改";
- vm.freight = {
- name: '',
- templateType: 0,
- pricingManner: 0,
- isDefault: false
- };
- vm.freightItemEntityList = [{
- id: '',
- freId: '',
- deliveryArea: true,
- firstPiece: '',
- freight: '',
- continuePiece: '',
- renew: '',
- isDelete: 0
- }];
- vm.storeList = [];
- vm.merchList = [];
- vm.getInfo(id)
- vm.getMerchList();
- vm.getStoresByMerch();
- },
- saveOrUpdate: function (event) {
- let url = vm.freight.id == null ? "../freight/save" : "../freight/update";
- vm.freight.freightItemEntityList = vm.freightItemEntityList;
- $.ajax({
- type: "POST",
- url: url,
- contentType: "application/json",
- data: JSON.stringify(vm.freight),
- success: function (r) {
- if (r.code === 0) {
- alert('操作成功', function (index) {
- vm.reload();
- });
- } else {
- alert(r.msg);
- }
- }
- });
- },
- del: function (event) {
- let ids = getSelectedRows();
- if (ids == null){
- return;
- }
- confirm('确定要删除选中的记录?', function () {
- $.ajax({
- type: "POST",
- url: "../freight/delete",
- contentType: "application/json",
- data: JSON.stringify(ids),
- success: function (r) {
- if (r.code == 0) {
- alert('操作成功', function (index) {
- $("#jqGrid").trigger("reloadGrid");
- });
- } else {
- alert(r.msg);
- }
- }
- });
- });
- },
- getInfo: function(id){
- $.get("../freight/info/"+id, function (r) {
- vm.freight = r.freight;
- if (vm.freight.isDefault == "1") {
- vm.freight.isDefault = true;
- }
- if (r.freight.freightItemEntityList.length > 0) {
- vm.freightItemEntityList = r.freight.freightItemEntityList;
- for (var item in vm.freightItemEntityList) {
- if (item.deliveryArea == "ALL") {
- item.deliveryArea = true;
- }
- }
- } else {
- vm.freightItemEntityList = [{
- id: '',
- freId: '',
- deliveryArea: true,
- firstPiece: '',
- freight: '',
- continuePiece: '',
- renew: '',
- isDelete: 0
- }];
- }
- });
- },
- reloadSearch: function() {
- vm.q = {
- name: ''
- }
- vm.reload();
- },
- reload: function (event) {
- vm.showViewList = false;
- vm.showList = true;
- vm.showCopyList = true;
- let page = $("#jqGrid").jqGrid('getGridParam', 'page');
- $("#jqGrid").jqGrid('setGridParam', {
- postData: {'name': vm.q.name},
- page: page
- }).trigger("reloadGrid");
- vm.handleReset('formValidate');
- },
- handleSubmit: function (name) {
- handleSubmitValidate(this, name, function () {
- vm.saveOrUpdate()
- });
- },
- handleReset: function (name) {
- handleResetForm(this, name);
- }
- }
- });
|