add.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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="usrName" :placeholder="$L('输入关键词搜索')" multiple><span slot="prepend">{{$L('抄送人')}}</span></UserInput>
  16. <div class="add-prev-btn" @click="getPrevCc">{{$L('使用我上次抄送的人')}}</div>
  17. </div>
  18. <div class="add-footer">
  19. <Button :loading="loadIng > 0" type="primary" @click="handleSubmit" style="margin-right:6px">{{$L('保存')}}</Button>
  20. <Button v-if="dataDetail.status=='已发送'" :loading="loadIng > 0" type="success" icon="md-checkmark-circle-outline" ghost @click="handleSubmit(true)">{{$L('已发送')}}</Button>
  21. <Button v-else :loading="loadIng > 0" @click="handleSubmit(true)">{{$L('保存并发送')}}</Button>
  22. </div>
  23. </div>
  24. </drawer-tabs-container>
  25. </template>
  26. <style lang="scss">
  27. .report-add {
  28. .add-edit {
  29. .teditor-loadedstyle {
  30. height: 100%;
  31. }
  32. }
  33. }
  34. </style>
  35. <style lang="scss" scoped>
  36. .report-add {
  37. display: flex;
  38. flex-direction: column;
  39. height: 100%;
  40. padding: 0 24px;
  41. .add-header {
  42. display: flex;
  43. align-items: center;
  44. margin-top: 22px;
  45. margin-bottom: 14px;
  46. .add-title {
  47. flex: 1;
  48. padding-right: 36px;
  49. }
  50. }
  51. .add-edit {
  52. width: 100%;
  53. flex: 1;
  54. }
  55. .add-input,
  56. .add-footer {
  57. margin-top: 14px;
  58. }
  59. .add-prev-btn {
  60. cursor: pointer;
  61. opacity: 0.9;
  62. margin-top: 8px;
  63. text-decoration: underline;
  64. &:hover {
  65. opacity: 1;
  66. color: #2d8cf0;
  67. }
  68. }
  69. }
  70. </style>
  71. <script>
  72. import DrawerTabsContainer from "../DrawerTabsContainer";
  73. import TEditor from "../TEditor";
  74. /**
  75. * 新建汇报
  76. */
  77. export default {
  78. name: 'ReportAdd',
  79. components: {TEditor, DrawerTabsContainer},
  80. props: {
  81. id: {
  82. default: 0
  83. },
  84. canload: {
  85. type: Boolean,
  86. default: true
  87. },
  88. },
  89. data () {
  90. return {
  91. loadYet: false,
  92. loadIng: 0,
  93. dataDetail: {
  94. title: '',
  95. content: '',
  96. ccuser: '',
  97. status: '',
  98. },
  99. type: '日报'
  100. }
  101. },
  102. mounted() {
  103. if (this.canload) {
  104. this.loadYet = true;
  105. this.getData();
  106. }
  107. },
  108. watch: {
  109. canload(val) {
  110. if (val && !this.loadYet) {
  111. this.loadYet = true;
  112. this.getData();
  113. }
  114. },
  115. type() {
  116. if (this.loadYet) {
  117. this.getData();
  118. }
  119. },
  120. id() {
  121. if (this.loadYet) {
  122. this.dataDetail = {};
  123. this.getData();
  124. }
  125. },
  126. },
  127. methods: {
  128. initLanguage() {
  129. this.dataDetail.content = this.$L('数据加载中.....')
  130. },
  131. getData() {
  132. this.loadIng++;
  133. $A.apiAjax({
  134. url: 'report/template',
  135. method: 'post',
  136. data: {
  137. id: this.id,
  138. type: this.type,
  139. },
  140. complete: () => {
  141. this.loadIng--;
  142. },
  143. success: (res) => {
  144. if (res.ret === 1) {
  145. this.dataDetail = res.data;
  146. }
  147. }
  148. });
  149. },
  150. getPrevCc() {
  151. this.loadIng++;
  152. $A.apiAjax({
  153. url: 'report/prevcc',
  154. complete: () => {
  155. this.loadIng--;
  156. },
  157. success: (res) => {
  158. if (res.ret === 1) {
  159. this.dataDetail.ccuser = res.data.lists.join(',');
  160. } else {
  161. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  162. }
  163. }
  164. });
  165. },
  166. handleSubmit(send = false) {
  167. this.loadIng++;
  168. $A.apiAjax({
  169. url: 'report/template',
  170. method: 'post',
  171. data: Object.assign(this.dataDetail, {
  172. act: 'submit',
  173. id: this.id,
  174. type: this.type,
  175. send: (send === true ? 1 : 0),
  176. }),
  177. complete: () => {
  178. this.loadIng--;
  179. },
  180. error: () => {
  181. alert(this.$L('网络繁忙,请稍后再试!'));
  182. },
  183. success: (res) => {
  184. if (res.ret === 1) {
  185. this.dataDetail = res.data;
  186. this.$Message.success(res.msg);
  187. this.$emit("on-success", res.data);
  188. //
  189. if (this.dataDetail.status === '已发送') {
  190. let msgData = {
  191. type: 'report',
  192. username: this.usrInfo.username,
  193. userimg: this.usrInfo.userimg,
  194. indate: Math.round(new Date().getTime() / 1000),
  195. text: this.dataDetail.ccuserAgain ? this.$L('修改了工作报告') : this.$L('发送了工作报告'),
  196. other: {
  197. id: this.dataDetail.id,
  198. type: this.dataDetail.type,
  199. title: this.dataDetail.title,
  200. }
  201. };
  202. this.dataDetail.ccuserArray.forEach((username) => {
  203. if (username != msgData.username) {
  204. $A.WSOB.sendTo('user', username, msgData, 'special');
  205. }
  206. });
  207. }
  208. } else {
  209. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  210. }
  211. }
  212. });
  213. }
  214. }
  215. }
  216. </script>