tb-notices-add.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <!-- 所有的 css js 资源 -->
  8. <link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
  9. <link rel="stylesheet" href="../../static/sa.css">
  10. <script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
  11. <script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
  12. <script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
  13. <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
  14. <script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
  15. <script src="../../static/sa.js"></script>
  16. <script src="../../static/kj/upload-util.js"></script>
  17. <script src="https://unpkg.com/wangeditor@4.7.8/dist/wangEditor.min.js"></script>
  18. <style type="text/css">
  19. .c-panel .el-form .c-label{width: 7em !important;}
  20. .c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner{width: 250px;}
  21. /* 普通文本和富文本一起变长 */
  22. .c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner{width: 800px;}
  23. .c-item-mline{width: 800px;}
  24. .editor-box{display: inline-block;}
  25. .c-item .editor-box, .editor-box #editor{width: 800px;}
  26. </style>
  27. </head>
  28. <body>
  29. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  30. <!-- ------- 内容部分 ------- -->
  31. <div class="s-body">
  32. <div class="c-panel">
  33. <div class="c-title" v-if="id == 0">数据添加</div>
  34. <div class="c-title" v-else>数据修改</div>
  35. <el-form v-if="m">
  36. <sa-item type="text" name="主题" v-model="m.text" br></sa-item>
  37. <div class="c-item br" >
  38. <label class="c-label">客户:</label>
  39. <el-select v-model="m.customerIdList" multiple placeholder="请选择客户" filterable >
  40. <el-option label='全选' @click.native='selectAllCustomer'></el-option>
  41. <el-option v-for="(item,index) in customerList" :key="index" :label="item.name"
  42. :value="item.id">
  43. </el-option>
  44. </el-select>
  45. </div>
  46. <sa-item type="richtext" name="详情内容" v-model="m.content" br></sa-item>
  47. <!-- <sa-item type="enum" name="接收类型" v-model="m.receiverType" :jv="{1: '管理员', 2: '企业用户'}" jtype="3" br></sa-item>-->
  48. <!-- <sa-item type="enum" name="类型" v-model="m.type" :jv="{0:'公告', 1: '业务消息'}" jtype="3" br></sa-item>-->
  49. <sa-item name="" class="s-ok" br>
  50. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  51. </sa-item>
  52. </el-form>
  53. </div>
  54. </div>
  55. <!-- ------- 底部按钮 ------- -->
  56. <div class="s-foot">
  57. <el-button type="primary" @click="ok()">确定</el-button>
  58. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  59. </div>
  60. </div>
  61. <script>
  62. var app = new Vue({
  63. components: {
  64. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  65. },
  66. el: '.vue-box',
  67. data: {
  68. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  69. m: null, // 实体对象
  70. customerList: [],
  71. },
  72. methods: {
  73. // 创建一个 默认Model
  74. createModel: function() {
  75. return {
  76. id: '', // 主键
  77. businessId: null, //业务id
  78. customerId: '', // 客户id
  79. text: '', // 标题
  80. content: '', // 详情内容
  81. type: 0, // 类型(1=业务消息)
  82. // updateTime: '', // 更新时间
  83. customerIdList: [], //商家IdList
  84. }
  85. },
  86. // 提交数据
  87. ok: function(){
  88. // 表单校验
  89. let m = this.m;
  90. sa.checkNull(m.text, '请输入 [主题]');
  91. let customerIds = m.customerIdList.join(',');
  92. m.customerIds = customerIds;
  93. sa.checkNull(m.customerIds, '请选择 [客户]');
  94. // 开始增加或修改
  95. this.m.updateTime = undefined; // 不提交属性:更新时间
  96. if(this.id <= 0) { // 添加
  97. sa.ajax('/TbNotices/add', m, function(res){
  98. sa.alert('增加成功', this.clean);
  99. }.bind(this));
  100. } else { // 修改
  101. sa.ajax('/TbNotices/update', m, function(res){
  102. sa.alert('修改成功', this.clean);
  103. }.bind(this));
  104. }
  105. },
  106. // 添加/修改 完成后的动作
  107. clean: function() {
  108. if(this.id == 0) {
  109. this.m = this.createModel();
  110. } else {
  111. parent.app.f5(); // 刷新父页面列表
  112. sa.closeCurrIframe(); // 关闭本页
  113. }
  114. },
  115. getCustomerList(){
  116. sa.ajax('/TbCostomer/getAll', function(res) {
  117. this.customerList = res.data; // 数据
  118. }.bind(this));
  119. },
  120. selectAllCustomer(){
  121. let customerIdList = [];
  122. this.customerList.map((item) => {
  123. customerIdList.push(item.id);
  124. })
  125. this.m.customerIdList = customerIdList;
  126. },
  127. },
  128. mounted: function(){
  129. // 初始化数据
  130. this.getCustomerList();
  131. if(this.id <= 0) {
  132. this.m = this.createModel();
  133. } else {
  134. sa.ajax('/TbNotices/getById?id=' + this.id, function(res) {
  135. let m = res.data;
  136. console.log(m);
  137. m.customerIdList = m.customerIds.split(",");
  138. this.m = m;
  139. if(res.data == null) {
  140. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  141. }
  142. }.bind(this))
  143. }
  144. }
  145. })
  146. </script>
  147. </body>
  148. </html>