my.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <drawer-tabs-container>
  3. <div class="report-my">
  4. <!-- 按钮 -->
  5. <Button :loading="loadIng > 0" type="primary" icon="md-add" @click="[addDrawerId=0,addDrawerShow=true]">新建汇报</Button>
  6. <!-- 列表 -->
  7. <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
  8. <!-- 分页 -->
  9. <Page class="pageBox" :total="listTotal" :current="listPage" :disabled="loadIng > 0" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total transfer></Page>
  10. </div>
  11. <Drawer v-model="addDrawerShow" width="70%">
  12. <report-add :canload="addDrawerShow" :id="addDrawerId" @on-success="addDrawerSuccess"></report-add>
  13. </Drawer>
  14. <Modal
  15. v-model="contentShow"
  16. :title="contentTitle"
  17. width="80%"
  18. :styles="{top: '35px', paddingBottom: '35px'}"
  19. footerHide>
  20. <report-content :content="contentText"></report-content>
  21. </Modal>
  22. </drawer-tabs-container>
  23. </template>
  24. <style lang="scss" scoped>
  25. .report-my {
  26. padding: 0 12px;
  27. .tableFill {
  28. margin: 12px 0 20px;
  29. }
  30. }
  31. </style>
  32. <script>
  33. import DrawerTabsContainer from "../DrawerTabsContainer";
  34. import ReportAdd from "./add";
  35. import ReportContent from "./content";
  36. /**
  37. * 我的汇报
  38. */
  39. export default {
  40. name: 'ReportMy',
  41. components: {ReportContent, ReportAdd, DrawerTabsContainer},
  42. props: {
  43. canload: {
  44. type: Boolean,
  45. default: true
  46. },
  47. },
  48. data () {
  49. return {
  50. loadYet: false,
  51. loadIng: 0,
  52. columns: [],
  53. lists: [],
  54. listPage: 1,
  55. listTotal: 0,
  56. noDataText: "数据加载中.....",
  57. addDrawerId: 0,
  58. addDrawerShow: false,
  59. contentShow: false,
  60. contentTitle: '',
  61. contentText: '内容加载中.....',
  62. }
  63. },
  64. created() {
  65. this.columns = [{
  66. "title": "标题",
  67. "key": 'title',
  68. "minWidth": 120,
  69. }, {
  70. "title": "创建日期",
  71. "width": 160,
  72. "align": 'center',
  73. render: (h, params) => {
  74. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  75. }
  76. }, {
  77. "title": "类型",
  78. "key": 'type',
  79. "width": 80,
  80. "align": 'center',
  81. }, {
  82. "title": "状态",
  83. "key": 'status',
  84. "width": 80,
  85. "align": 'center',
  86. }, {
  87. "title": "操作",
  88. "key": 'action',
  89. "width": 140,
  90. "align": 'center',
  91. render: (h, params) => {
  92. let arr = [];
  93. arr.push(h('a', {
  94. style: {padding: '0 2px', fontSize: '12px'},
  95. on: {
  96. click: () => {
  97. this.contentReport(params.row);
  98. }
  99. }
  100. }, '查看'));
  101. arr.push(h('a', {
  102. style: {padding: '0 2px', fontSize: '12px'},
  103. on: {
  104. click: () => {
  105. this.addDrawerId = params.row.id;
  106. this.addDrawerShow = true
  107. }
  108. }
  109. }, '编辑'));
  110. if (params.row.status == '未发送') {
  111. arr.push(h('a', {
  112. style: {padding: '0 2px', fontSize: '12px'},
  113. on: {
  114. click: () => {
  115. this.deleteReport(params.row);
  116. }
  117. }
  118. }, '删除'));
  119. arr.push(h('a', {
  120. style: {padding: '0 2px', fontSize: '12px'},
  121. on: {
  122. click: () => {
  123. this.sendReport(params.row);
  124. }
  125. }
  126. }, '发送'));
  127. }
  128. return h('div', arr);
  129. }
  130. }];
  131. },
  132. mounted() {
  133. if (this.canload) {
  134. this.loadYet = true;
  135. this.getLists(true);
  136. }
  137. },
  138. watch: {
  139. canload(val) {
  140. if (val && !this.loadYet) {
  141. this.loadYet = true;
  142. this.getLists(true);
  143. }
  144. }
  145. },
  146. methods: {
  147. setPage(page) {
  148. this.listPage = page;
  149. this.getLists();
  150. },
  151. setPageSize(size) {
  152. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  153. this.listPageSize = size;
  154. this.getLists();
  155. }
  156. },
  157. getLists(resetLoad) {
  158. if (resetLoad === true) {
  159. this.listPage = 1;
  160. }
  161. this.loadIng++;
  162. this.noDataText = "数据加载中.....";
  163. $A.aAjax({
  164. url: 'report/my',
  165. data: {
  166. page: Math.max(this.listPage, 1),
  167. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  168. },
  169. complete: () => {
  170. this.loadIng--;
  171. },
  172. error: () => {
  173. this.noDataText = "数据加载失败!";
  174. },
  175. success: (res) => {
  176. if (res.ret === 1) {
  177. this.lists = res.data.lists;
  178. this.listTotal = res.data.total;
  179. this.noDataText = "没有相关的数据";
  180. } else {
  181. this.lists = [];
  182. this.listTotal = 0;
  183. this.noDataText = res.msg;
  184. }
  185. }
  186. });
  187. },
  188. addDrawerSuccess() {
  189. this.addDrawerShow = false;
  190. this.getLists(true);
  191. },
  192. contentReport(row) {
  193. this.contentShow = true;
  194. this.contentTitle = row.title;
  195. this.contentText = '详细内容加载中.....';
  196. $A.aAjax({
  197. url: 'report/content?id=' + row.id,
  198. error: () => {
  199. alert(this.$L('网络繁忙,请稍后再试!'));
  200. this.contentShow = false;
  201. },
  202. success: (res) => {
  203. if (res.ret === 1) {
  204. this.contentText = res.data.content;
  205. } else {
  206. this.contentShow = false;
  207. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  208. }
  209. }
  210. });
  211. },
  212. sendReport(row) {
  213. this.$Modal.confirm({
  214. title: '发送汇报',
  215. content: '你确定要发送汇报吗?',
  216. loading: true,
  217. onOk: () => {
  218. $A.aAjax({
  219. url: 'report/template?act=send&id=' + row.id + '&type=' + row.type,
  220. error: () => {
  221. this.$Modal.remove();
  222. alert(this.$L('网络繁忙,请稍后再试!'));
  223. },
  224. success: (res) => {
  225. this.$Modal.remove();
  226. this.$set(row, 'status', '已发送');
  227. setTimeout(() => {
  228. if (res.ret === 1) {
  229. this.$Message.success(res.msg);
  230. } else {
  231. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  232. }
  233. }, 350);
  234. }
  235. });
  236. }
  237. });
  238. },
  239. deleteReport(row) {
  240. this.$Modal.confirm({
  241. title: '删除汇报',
  242. content: '你确定要删除汇报吗?',
  243. loading: true,
  244. onOk: () => {
  245. $A.aAjax({
  246. url: 'report/template?act=delete&id=' + row.id + '&type=' + row.type,
  247. error: () => {
  248. this.$Modal.remove();
  249. alert(this.$L('网络繁忙,请稍后再试!'));
  250. },
  251. success: (res) => {
  252. this.$Modal.remove();
  253. this.lists.some((item, index) => {
  254. if (item.id == row.id) {
  255. this.lists.splice(index, 1);
  256. return true;
  257. }
  258. })
  259. setTimeout(() => {
  260. if (res.ret === 1) {
  261. this.$Message.success(res.msg);
  262. } else {
  263. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  264. }
  265. }, 350);
  266. }
  267. });
  268. }
  269. });
  270. }
  271. }
  272. }
  273. </script>