123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- define(function (require) {
- return function (context) {
- var $dlg, $form;
- return {
- xtype: 'dialog',
- dialogId: 'dialogSysUnit',
- title: '单位信息维护',
- width: 650,
- height: 350,
- onOpen: function () {
- $dlg = $(this);
- if (context.isEdit) {
- $.yvan.ajax({
- loadingMask: false,
- url: api('/sys/sysUnit/getById'),
- type: 'GET',
- data: {
- unitId: context.unitId
- },
- success: function (data) {
- $dlg.find('form');
- if (!isNotNull(data) || !isNotNull(data.data)) {
- return;
- }
- $form.formSet(data.data);
- }
- });
- } else {
- $form.formSet({
- beActive: 'Y',
- status: 1,
- isBase: 0,
- unitType: context.unitType
- });
- }
- },
- center: {
- items: {
- xtype: 'formgroup',
- subLabelWidth: '100',
- subControlWidth: '200',
- onRender: function () {
- $form = $(this);
- },
- items: [[
- {name: 'unitId', xtype: 'hidden'}, // no hidden: true
- {
- name: 'unitType', label: '单位类型', xtype: 'yvselect', required: true,
- data: $.yvan.sysDict('unitType').combo(),
- onChange: function (data) {
- var apiData = {
- unitType: $form.formGet().unitType
- };
- $.yvan.ajax({
- method: 'get',
- url: api('/sys/sysUnit/getUnitBase'),
- data: apiData,
- success: function (data) {
- var unitName = "";
- if (data.data != null) {
- unitName = data.data.unitName;
- $form.formSet({
- unitBase: unitName,
- isBase: 0
- });
- }
- }
- });
- }
- },
- {
- name: 'isBase', label: '基础单位', xtype: 'yvselect', required: true,
- data: $.yvan.sysDict('yesOrNo').combo()
- },
- {name: 'unitName', label: '单位名称', required: true, ff: 500},
- {name: 'unitMark', label: '符号', required: true, ff: 500},
- {name: 'unitVal', label: '转换值'},
- {name: 'unitBase', label: '基础单位', readonly: true},
- {name: 'sort', label: '排序'},
- {
- name: 'status', label: '状态', xtype: 'yvselect', required: true,
- data: $.yvan.sysDict('status').combo()
- },
- {name: 'remark', label: '备注', span: 2, height: 45, multiline: true, ff: 500},
- ]]
- }
- },
- buttons: [
- {
- text: "提交", iconCls: "fa fa-save", onClick: function () {
- $.yvan.postForm($form, {
- url: (context.isEdit ? api('/sys/sysUnit/update') : api('/sys/sysUnit/insert')),
- success: function () {
- $.yvan.msg('操作成功');
- if (context.isEdit) {
- $dlg.window('close');
- }
- if ($.type(context.confirm) === 'function') {
- context.confirm();
- }
- },
- error: function (data) {
- }
- });
- }
- }, {
- text: "关闭", iconCls: "fa fa-times", onClick: function () {
- $dlg.dialog('close');
- }
- }
- ]
- };
- };
- });
|