add.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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="汇报标题"></Input>
  7. </div>
  8. <ButtonGroup>
  9. <Button :disabled="id > 0" :type="`${type=='日报'?'primary':'default'}`" @click="type='日报'">日报</Button>
  10. <Button :disabled="id > 0" :type="`${type=='周报'?'primary':'default'}`" @click="type='周报'">周报</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. <userid-input v-model="dataDetail.ccuser" placeholder="输入关键词搜索" multiple><span slot="prepend">抄送人</span></userid-input>
  16. </div>
  17. <div class="add-footer">
  18. <Button :loading="loadIng > 0" type="primary" @click="handleSubmit" style="margin-right:6px">保 存</Button>
  19. <Button v-if="dataDetail.status=='已发送'" :loading="loadIng > 0" type="success" icon="md-checkmark-circle-outline" ghost @click="handleSubmit(true)">已发送</Button>
  20. <Button v-else :loading="loadIng > 0" @click="handleSubmit(true)">保存并发送</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. mounted() {
  92. if (this.canload) {
  93. this.loadYet = true;
  94. this.getData();
  95. }
  96. },
  97. watch: {
  98. canload(val) {
  99. if (val && !this.loadYet) {
  100. this.loadYet = true;
  101. this.getData();
  102. }
  103. },
  104. type() {
  105. if (this.loadYet) {
  106. this.getData();
  107. }
  108. },
  109. id() {
  110. if (this.loadYet) {
  111. this.dataDetail = {};
  112. this.getData();
  113. }
  114. },
  115. },
  116. methods: {
  117. getData() {
  118. this.loadIng++;
  119. $A.aAjax({
  120. url: 'report/template?id=' + this.id + '&type=' + this.type,
  121. complete: () => {
  122. this.loadIng--;
  123. },
  124. success: (res) => {
  125. if (res.ret === 1) {
  126. this.dataDetail = res.data;
  127. }
  128. }
  129. });
  130. },
  131. handleSubmit(send = false) {
  132. this.loadIng++;
  133. $A.aAjax({
  134. url: 'report/template?act=submit&id=' + this.id + '&type=' + this.type + '&send=' + (send === true ? 1 : 0),
  135. method: 'post',
  136. data: {
  137. D: this.dataDetail
  138. },
  139. complete: () => {
  140. this.loadIng--;
  141. },
  142. error: () => {
  143. alert(this.$L('网络繁忙,请稍后再试!'));
  144. },
  145. success: (res) => {
  146. if (res.ret === 1) {
  147. this.dataDetail = res.data;
  148. this.$Message.success(res.msg);
  149. this.$emit("on-success", res.data);
  150. } else {
  151. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  152. }
  153. }
  154. });
  155. }
  156. }
  157. }
  158. </script>