add.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. <UserInput v-model="dataDetail.ccuser" :nousername="$A.getUserName()" :placeholder="$L('输入关键词搜索')" multiple><span slot="prepend">{{$L('抄送人')}}</span></UserInput>
  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',
  124. method: 'post',
  125. data: {
  126. id: this.id,
  127. type: this.type,
  128. },
  129. complete: () => {
  130. this.loadIng--;
  131. },
  132. success: (res) => {
  133. if (res.ret === 1) {
  134. this.dataDetail = res.data;
  135. }
  136. }
  137. });
  138. },
  139. handleSubmit(send = false) {
  140. this.loadIng++;
  141. $A.apiAjax({
  142. url: 'report/template',
  143. method: 'post',
  144. data: Object.assign(this.dataDetail, {
  145. act: 'submit',
  146. id: this.id,
  147. type: this.type,
  148. send: (send === true ? 1 : 0),
  149. }),
  150. complete: () => {
  151. this.loadIng--;
  152. },
  153. error: () => {
  154. alert(this.$L('网络繁忙,请稍后再试!'));
  155. },
  156. success: (res) => {
  157. if (res.ret === 1) {
  158. this.dataDetail = res.data;
  159. this.$Message.success(res.msg);
  160. this.$emit("on-success", res.data);
  161. //
  162. if (this.dataDetail.status === '已发送') {
  163. let userInfo = $A.getUserInfo();
  164. let msgData = {
  165. type: 'report',
  166. username: userInfo.username,
  167. userimg: userInfo.userimg,
  168. indate: Math.round(new Date().getTime() / 1000),
  169. text: this.dataDetail.ccuserAgain ? this.$L('修改了工作报告') : this.$L('发送了工作报告'),
  170. other: {
  171. id: this.dataDetail.id,
  172. type: this.dataDetail.type,
  173. title: this.dataDetail.title,
  174. }
  175. };
  176. this.dataDetail.ccuserArray.forEach((username) => {
  177. if (username != msgData.username) {
  178. $A.WSOB.sendTo('user', username, msgData, 'special');
  179. }
  180. });
  181. }
  182. } else {
  183. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  184. }
  185. }
  186. });
  187. }
  188. }
  189. }
  190. </script>