tb-notices-add.html 6.7 KB

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