add.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <drawer-tabs-container>
  3. <div class="report-add">
  4. <div class="add-header">
  5. <div class="add-title">
  6. <Input v-model="dataDetail.title" :placeholder="$L('汇报标题')"></Input>
  7. </div>
  8. <ButtonGroup>
  9. <Button :disabled="id > 0" :type="`${type=='日报'?'primary':'default'}`" @click="type='日报'">{{$L('日报')}}</Button>
  10. <Button :disabled="id > 0" :type="`${type=='周报'?'primary':'default'}`" @click="type='周报'">{{$L('周报')}}</Button>
  11. </ButtonGroup>
  12. </div>
  13. <t-editor class="add-edit" v-model="dataDetail.content" height="100%"></t-editor>
  14. <div class="add-input">
  15. <user-input v-model="dataDetail.ccuser" :nousername="$A.getUserName()" :placeholder="$L('输入关键词搜索')" multiple><span slot="prepend">{{$L('抄送人')}}</span></user-input>
  16. </div>
  17. <div class="add-footer">
  18. <Button :loading="loadIng > 0" type="primary" @click="handleSubmit" style="margin-right:6px">{{$L('保存')}}</Button>
  19. <Button v-if="dataDetail.status=='已发送'" :loading="loadIng > 0" type="success" icon="md-checkmark-circle-outline" ghost @click="handleSubmit(true)">{{$L('已发送')}}</Button>
  20. <Button v-else :loading="loadIng > 0" @click="handleSubmit(true)">{{$L('保存并发送')}}</Button>
  21. </div>
  22. </div>
  23. </drawer-tabs-container>
  24. </template>
  25. <style lang="scss">
  26. .report-add {
  27. .add-edit {
  28. .teditor-loadedstyle {
  29. height: 100%;
  30. }
  31. }
  32. }
  33. </style>
  34. <style lang="scss" scoped>
  35. .report-add {
  36. display: flex;
  37. flex-direction: column;
  38. height: 100%;
  39. padding: 0 24px;
  40. .add-header {
  41. display: flex;
  42. align-items: center;
  43. margin-top: 22px;
  44. margin-bottom: 14px;
  45. .add-title {
  46. flex: 1;
  47. padding-right: 36px;
  48. }
  49. }
  50. .add-edit {
  51. width: 100%;
  52. flex: 1;
  53. }
  54. .add-input,
  55. .add-footer {
  56. margin-top: 14px;
  57. }
  58. }
  59. </style>
  60. <script>
  61. import DrawerTabsContainer from "../DrawerTabsContainer";
  62. import TEditor from "../TEditor";
  63. /**
  64. * 新建汇报
  65. */
  66. export default {
  67. name: 'ReportAdd',
  68. components: {TEditor, DrawerTabsContainer},
  69. props: {
  70. id: {
  71. default: 0
  72. },
  73. canload: {
  74. type: Boolean,
  75. default: true
  76. },
  77. },
  78. data () {
  79. return {
  80. loadYet: false,
  81. loadIng: 0,
  82. dataDetail: {
  83. title: '',
  84. content: '',
  85. ccuser: '',
  86. status: '',
  87. },
  88. type: '日报'
  89. }
  90. },
  91. created() {
  92. this.dataDetail.content = this.$L('数据加载中.....')
  93. },
  94. mounted() {
  95. if (this.canload) {
  96. this.loadYet = true;
  97. this.getData();
  98. }
  99. },
  100. watch: {
  101. canload(val) {
  102. if (val && !this.loadYet) {
  103. this.loadYet = true;
  104. this.getData();
  105. }
  106. },
  107. type() {
  108. if (this.loadYet) {
  109. this.getData();
  110. }
  111. },
  112. id() {
  113. if (this.loadYet) {
  114. this.dataDetail = {};
  115. this.getData();
  116. }
  117. },
  118. },
  119. methods: {
  120. getData() {
  121. this.loadIng++;
  122. $A.apiAjax({
  123. url: 'report/template?id=' + this.id + '&type=' + this.type,
  124. complete: () => {
  125. this.loadIng--;
  126. },
  127. success: (res) => {
  128. if (res.ret === 1) {
  129. this.dataDetail = res.data;
  130. }
  131. }
  132. });
  133. },
  134. handleSubmit(send = false) {
  135. this.loadIng++;
  136. $A.apiAjax({
  137. url: 'report/template?act=submit&id=' + this.id + '&type=' + this.type + '&send=' + (send === true ? 1 : 0),
  138. method: 'post',
  139. data: {
  140. D: this.dataDetail
  141. },
  142. complete: () => {
  143. this.loadIng--;
  144. },
  145. error: () => {
  146. alert(this.$L('网络繁忙,请稍后再试!'));
  147. },
  148. success: (res) => {
  149. if (res.ret === 1) {
  150. this.dataDetail = res.data;
  151. this.$Message.success(res.msg);
  152. this.$emit("on-success", res.data);
  153. //
  154. if (this.dataDetail.status === '已发送') {
  155. let userInfo = $A.getUserInfo();
  156. let msgData = {
  157. type: 'report',
  158. username: userInfo.username,
  159. userimg: userInfo.userimg,
  160. indate: Math.round(new Date().getTime() / 1000),
  161. text: this.dataDetail.ccuserAgain ? this.$L('修改了工作报告') : this.$L('发送了工作报告'),
  162. other: {
  163. id: this.dataDetail.id,
  164. type: this.dataDetail.type,
  165. title: this.dataDetail.title,
  166. }
  167. };
  168. this.dataDetail.ccuserArray.forEach((username) => {
  169. if (username != msgData.username) {
  170. $A.WSOB.sendTo('user', username, msgData, 'special');
  171. }
  172. });
  173. }
  174. } else {
  175. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  176. }
  177. }
  178. });
  179. }
  180. }
  181. }
  182. </script>