sys-dict-add.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>字典表-添加/修改</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <meta name="viewport"
  7. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
  8. <!-- 所有的 css js 资源 -->
  9. <link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
  10. <link rel="stylesheet" href="../../static/sa.css">
  11. <script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
  12. <script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
  13. <script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
  14. <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
  15. <script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
  16. <script src="../../static/sa.js"></script>
  17. <style type="text/css">
  18. .c-panel .el-form .c-label {
  19. width: 7em !important;
  20. }
  21. .c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner {
  22. width: 250px;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  28. <!-- ------- 内容部分 ------- -->
  29. <div class="s-body">
  30. <div class="c-panel">
  31. <div class="c-title" v-if="id == 0">数据添加</div>
  32. <div class="c-title" v-else>数据修改</div>
  33. <el-form v-if="m">
  34. <sa-item type="text" name="字典名称" v-model="m.name" br></sa-item>
  35. <sa-item type="text" name="编号" v-model="m.code" br></sa-item>
  36. <sa-item type="text" name="描述" v-model="m.des" br></sa-item>
  37. <sa-item name="" class="s-ok" br>
  38. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  39. </sa-item>
  40. </el-form>
  41. </div>
  42. </div>
  43. <!-- ------- 底部按钮 ------- -->
  44. <div class="s-foot">
  45. <el-button type="primary" @click="ok()">确定</el-button>
  46. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  47. </div>
  48. </div>
  49. <script>
  50. var app = new Vue({
  51. components: {
  52. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  53. },
  54. el: '.vue-box',
  55. data: {
  56. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  57. m: null, // 实体对象
  58. },
  59. methods: {
  60. // 创建一个 默认Model
  61. createModel: function () {
  62. return {
  63. id: '', // 主键
  64. name: '', // 字典名称
  65. code: '', // 编号
  66. des: '', // 描述
  67. }
  68. },
  69. // 提交数据
  70. ok: function () {
  71. // 表单校验
  72. let m = this.m;
  73. // sa.checkNull(m.id, '请输入 [主键]');
  74. sa.checkNull(m.name, '请输入 [字典名称]');
  75. sa.checkNull(m.code, '请输入 [编号]');
  76. sa.checkNull(m.des, '请输入 [描述]');
  77. // 开始增加或修改
  78. if (this.id <= 0) { // 添加
  79. sa.ajax('/SysDict/add', m, function (res) {
  80. sa.alert('增加成功', this.clean);
  81. }.bind(this));
  82. } else { // 修改
  83. sa.ajax('/SysDict/update', m, function (res) {
  84. sa.alert('修改成功', this.clean);
  85. }.bind(this));
  86. }
  87. },
  88. // 添加/修改 完成后的动作
  89. clean: function () {
  90. if (this.id == 0) {
  91. this.m = this.createModel();
  92. } else {
  93. parent.app.f5(); // 刷新父页面列表
  94. sa.closeCurrIframe(); // 关闭本页
  95. }
  96. }
  97. },
  98. mounted: function () {
  99. // 初始化数据
  100. if (this.id <= 0) {
  101. this.m = this.createModel();
  102. } else {
  103. sa.ajax('/SysDict/getById?id=' + this.id, function (res) {
  104. this.m = res.data;
  105. if (res.data == null) {
  106. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  107. }
  108. }.bind(this))
  109. }
  110. }
  111. })
  112. </script>
  113. </body>
  114. </html>