receive.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <drawer-tabs-container>
  3. <div class="report-receive">
  4. <!-- 搜索 -->
  5. <Row class="sreachBox">
  6. <div class="item">
  7. <div class="item-3">
  8. <sreachTitle :val="keys.username">发送人</sreachTitle>
  9. <Input v-model="keys.username" placeholder="用户名"/>
  10. </div>
  11. <div class="item-3">
  12. <sreachTitle :val="keys.type">类型</sreachTitle>
  13. <Select v-model="keys.type" placeholder="全部">
  14. <Option value="">全部</Option>
  15. <Option value="日报">日报</Option>
  16. <Option value="周报">周报</Option>
  17. </Select>
  18. </div>
  19. <div class="item-3">
  20. <sreachTitle :val="keys.indate">日期</sreachTitle>
  21. <Date-picker v-model="keys.indate" type="daterange" placement="bottom" placeholder="日期范围"></Date-picker>
  22. </div>
  23. </div>
  24. <div class="item item-button">
  25. <Button type="text" v-if="$A.objImplode(keys)!=''" @click="sreachTab(true)">取消筛选</Button>
  26. <Button type="primary" icon="md-search" :loading="loadIng > 0" @click="sreachTab">搜索</Button>
  27. </div>
  28. </Row>
  29. <!-- 列表 -->
  30. <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" @on-sort-change="sortChange" stripe></Table>
  31. <!-- 分页 -->
  32. <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>
  33. </div>
  34. </drawer-tabs-container>
  35. </template>
  36. <style lang="scss" scoped>
  37. .report-receive {
  38. margin: 0 12px;
  39. .tableFill {
  40. margin: 12px 0 20px;
  41. }
  42. }
  43. </style>
  44. <script>
  45. import DrawerTabsContainer from "../DrawerTabsContainer";
  46. /**
  47. * 收到的汇报
  48. */
  49. export default {
  50. name: 'ReportReceive',
  51. components: {DrawerTabsContainer},
  52. props: {
  53. canload: {
  54. type: Boolean,
  55. default: true
  56. },
  57. labelLists: {
  58. type: Array,
  59. },
  60. },
  61. data() {
  62. return {
  63. keys: {},
  64. sorts: {key:'', order:''},
  65. loadYet: false,
  66. loadIng: 0,
  67. columns: [],
  68. lists: [],
  69. listPage: 1,
  70. listTotal: 0,
  71. noDataText: "数据加载中.....",
  72. }
  73. },
  74. created() {
  75. this.columns = [{
  76. "title": "标题",
  77. "key": 'title',
  78. "minWidth": 120,
  79. }, {
  80. "title": "发送人",
  81. "key": 'username',
  82. "sortable": true,
  83. "minWidth": 80,
  84. "maxWidth": 150,
  85. }, {
  86. "title": "创建日期",
  87. "width": 160,
  88. "align": 'center',
  89. render: (h, params) => {
  90. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  91. }
  92. }, {
  93. "title": "类型",
  94. "key": 'type',
  95. "width": 80,
  96. "align": 'center',
  97. }, {
  98. "title": "操作",
  99. "key": 'action',
  100. "width": 80,
  101. "align": 'center',
  102. render: (h, params) => {
  103. return h('a', '查看');
  104. }
  105. }];
  106. },
  107. mounted() {
  108. if (this.canload) {
  109. this.loadYet = true;
  110. this.getLists(true);
  111. }
  112. },
  113. watch: {
  114. canload(val) {
  115. if (val && !this.loadYet) {
  116. this.loadYet = true;
  117. this.getLists(true);
  118. }
  119. }
  120. },
  121. methods: {
  122. sreachTab(clear) {
  123. if (clear === true) {
  124. this.keys = {};
  125. }
  126. this.getLists(true);
  127. },
  128. sortChange(info) {
  129. this.sorts = {key:info.key, order:info.order};
  130. this.getLists(true);
  131. },
  132. setPage(page) {
  133. this.listPage = page;
  134. this.getLists();
  135. },
  136. setPageSize(size) {
  137. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  138. this.listPageSize = size;
  139. this.getLists();
  140. }
  141. },
  142. getLists(resetLoad) {
  143. if (resetLoad === true) {
  144. this.listPage = 1;
  145. }
  146. this.loadIng++;
  147. let whereData = $A.cloneData(this.keys);
  148. whereData.page = Math.max(this.listPage, 1);
  149. whereData.pagesize = Math.max($A.runNum(this.listPageSize), 10);
  150. whereData.sorts = $A.cloneData(this.sorts);
  151. this.noDataText = "数据加载中.....";
  152. $A.aAjax({
  153. url: 'report/receive',
  154. data: whereData,
  155. complete: () => {
  156. this.loadIng--;
  157. },
  158. error: () => {
  159. this.noDataText = "数据加载失败!";
  160. },
  161. success: (res) => {
  162. if (res.ret === 1) {
  163. this.lists = res.data.lists;
  164. this.listTotal = res.data.total;
  165. this.noDataText = "没有相关的数据";
  166. } else {
  167. this.lists = [];
  168. this.listTotal = 0;
  169. this.noDataText = res.msg;
  170. }
  171. }
  172. });
  173. },
  174. }
  175. }
  176. </script>