123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- define(function (require) {
- return function (context) {
- var $dlg, $grid;
- // 查询列表
- function queryGrid1() {
- var queryUrl = '/sys/sysUnit/queryAll';// 自行替换此参数
- $grid.jqGrid("clearGridData");
- $grid.reload({
- mtype: 'POST',
- url: api(queryUrl),
- queryParams: {"unitType": context.unitType}
- });
- }
- //编辑工具栏
- var gridToolbarTitle = '单位列表';// 自行替换此参数
- var gridToolbar = {
- xtype: 'toolbar', title: gridToolbarTitle, items: [
- {
- text: '上移', iconCls: 'fa fa-arrow-up', onClick: function () {
- $grid.moveUp();
- }
- },
- {
- text: '下移', iconCls: 'fa fa-arrow-down', onClick: function () {
- $grid.moveDown();
- }
- },
- {
- text: '保存排序', iconCls: 'fa fa-check-square', onClick: function () {
- moveGrid();
- }
- }
- ]
- }
- //保存排序
- function moveGrid() {
- var gridData = $grid.jqGrid("getRowData");
- var list = [];
- for (var i = 0; i < gridData.length; i++) {
- list.push(gridData[i].unitId);
- }
- saveSort("sysUnit", list);
- }
- function saveSort(name, ids) {
- var data = {
- "ids": "",
- "name": name
- };
- for (var i = 0; i < ids.length; i++) {
- data.ids += ids[i] + ","
- }
- data.ids = data.ids.substr(0, data.ids.length - 1);
- if (data.ids == "") {
- return;
- }
- $.yvan.ajax({
- url: api('/core/app/updateCoreSort'),
- method: 'post',
- data: data,
- beforeSend: function () {
- $.yvan.progress();
- },
- success: function () {
- $.yvan.msg('操作成功');
- $dlg.window('close');
- if ($.type(context.confirm) === 'function') {
- context.confirm();
- }
- },
- complete: function () {
- $.yvan.closep();
- }
- });
- }
- return {
- xtype: 'dialog',
- dialogId: 'dialogSysUnitSort',
- title: '维护单位排序',
- width: 700,
- height: 600,
- onOpen: function () {
- $dlg = $(this);
- },
- center: {
- border: false,
- items: {
- onRender: function () {
- $grid = $(this);
- queryGrid1();
- },
- xtype: 'grid',
- pagination: false,
- idField: "sysUnitSort",
- toolbar: {
- xtype: 'div',
- items: [
- gridToolbar
- ]
- },
- columns: [[
- {title: '单位Id', field: 'unitId', hidden: true},
- {title: '单位类型', field: 'unitType', hidden: true},
- {title: '单位名称', field: 'unitName'},
- {title: '单位编码', field: 'unitMark'},
- {title: '基础单位', field: 'isBase', align: 'center', formatter: $.fn.fmatter.yesOrNo},
- {title: '启用状态', field: 'status', align: 'center', formatter: $.fn.fmatter.statusView}, //增加字典,显示正常
- {title: '备注', field: 'remark'},
- ]]
- }
- }
- };
- };
- });
|