NotificationPanel.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <div>
  3. <div class="row box">
  4. <div class="col-md-12">
  5. <button
  6. class="btn btn-primary btn-xs"
  7. @click="addUser"
  8. >
  9. 添加接收人
  10. </button>
  11. </div>
  12. </div>
  13. <div class="row box">
  14. <div class="col-md-12">
  15. <div class="table-box">
  16. <table class="table table-condensed table-bordered table-user">
  17. <thead>
  18. <tr>
  19. <th>名称</th>
  20. <th>编号</th>
  21. <th>操作</th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. <tr
  26. v-for="(item,index) in users"
  27. :key="item.id"
  28. >
  29. <td>{{ item.data.name.displayValue[0] }}</td>
  30. <td>{{ item.data.no.displayValue[0] }}</td>
  31. <td>
  32. <button
  33. class="btn btn-danger btn-xs"
  34. @click="removeUser(index)"
  35. >
  36. 删除
  37. </button>
  38. </td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="row box">
  46. <div class="col-md-2">
  47. 主题:
  48. </div>
  49. <div class="col-md-10">
  50. <input
  51. v-model="theme"
  52. autocomplete="off"
  53. type="text"
  54. class="form-control"
  55. />
  56. </div>
  57. </div>
  58. <div class="row">
  59. <div class="col-md-2">
  60. 正文:
  61. </div>
  62. <div class="col-md-10">
  63. <textarea
  64. v-model="content"
  65. class="form-control"
  66. rows="5"
  67. />
  68. </div>
  69. </div>
  70. <Modal
  71. v-model:show="modal"
  72. :full="true"
  73. >
  74. <InfoWindow
  75. ref="info"
  76. :info-window-no="userinfoWindowNo"
  77. :where-clause-source="whereClauseSource"
  78. :is-search-widget="true"
  79. @data-selected="dataSelected"
  80. />
  81. <template #header>
  82. 用户查询
  83. </template>
  84. </Modal>
  85. </div>
  86. </template>
  87. <script>
  88. import Common from '../common/Common.js';
  89. import UserStorageResource from '../api/base/UserStorageResource.js';
  90. import { Notify, Uuid } from 'pc-component-v3';
  91. export default {
  92. components: {
  93. },
  94. data: function () {
  95. return {
  96. userinfoWindowNo: 11531,
  97. whereClauseSource: {
  98. customerDataDimensions:[{
  99. fieldName: 'client.id',
  100. dataDimensionTypeNo: '202201191757',
  101. defaultDataDimensionTypeValueNo: '1',
  102. }],
  103. },
  104. users: [],
  105. theme: '',
  106. content: '',
  107. modal: false,
  108. };
  109. },
  110. mounted: function () {
  111. var _self = this;
  112. UserStorageResource.uniqueByKey('notification-users').then(usersStr => {
  113. // if(usersStr.errorCode != 0) {
  114. // Notify.error('提示', usersStr.errorMessage, false);
  115. // return;
  116. // }
  117. if (usersStr.data != null && usersStr.data != '') {
  118. _self.users = JSON.parse(usersStr.data);
  119. }
  120. }, errorData => {
  121. Common.processException(errorData);
  122. });
  123. },
  124. methods: {
  125. // 添加消息接收人
  126. addUser: function () {
  127. var _self = this;
  128. _self.modal = true;
  129. },
  130. // 删除用户
  131. removeUser: function (index) {
  132. this.users.splice(index, 1);
  133. this.restoreUsers();
  134. },
  135. // 接收人用户选择后
  136. dataSelected: function (modelData) {
  137. var _self = this;
  138. this.modal = false;
  139. var flag = true;
  140. _self.users.forEach(function (item) {
  141. if (item.id == modelData.id) {
  142. flag = false;
  143. }
  144. });
  145. if (flag) {
  146. _self.users.push(modelData);
  147. _self.restoreUsers();
  148. }
  149. },
  150. // 缓存用户数据到localStorage
  151. restoreUsers: function () {
  152. var _self = this;
  153. let userStorageDtos = [
  154. {
  155. key: 'notification-users',
  156. value: JSON.stringify(_self.users),
  157. },
  158. ];
  159. UserStorageResource.uploadUserStorage(userStorageDtos).then(successData => {
  160. console.log('#notification-users上传成功');
  161. }, errorData => {
  162. Common.processException(errorData);
  163. });
  164. },
  165. // 获取通知(供外部调用)
  166. getNotification: function () {
  167. var _self = this;
  168. var userIds = [];
  169. _self.users.forEach(function (item) {
  170. userIds.push(item.id);
  171. });
  172. var notification = {
  173. userIds: userIds,
  174. theme: _self.theme,
  175. content: _self.content,
  176. };
  177. return notification;
  178. },
  179. },
  180. };
  181. </script>
  182. <style scoped>
  183. .table-user th,
  184. td {
  185. text-align: center;
  186. }
  187. .box {
  188. margin-bottom: 10px;
  189. }
  190. .table-box {
  191. height: 150px;
  192. overflow-y: auto;
  193. border: 1px solid #dfdbdb;
  194. }
  195. </style>