receive.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. <Modal
  35. v-model="contentShow"
  36. :title="contentTitle"
  37. width="80%"
  38. :styles="{top: '35px', paddingBottom: '35px'}"
  39. footerHide>
  40. <report-content :content="contentText"></report-content>
  41. </Modal>
  42. </drawer-tabs-container>
  43. </template>
  44. <style lang="scss" scoped>
  45. .report-receive {
  46. margin: 0 12px;
  47. .tableFill {
  48. margin: 12px 0 20px;
  49. }
  50. }
  51. </style>
  52. <script>
  53. import DrawerTabsContainer from "../DrawerTabsContainer";
  54. import ReportContent from "./content";
  55. /**
  56. * 收到的汇报
  57. */
  58. export default {
  59. name: 'ReportReceive',
  60. components: {ReportContent, DrawerTabsContainer},
  61. props: {
  62. canload: {
  63. type: Boolean,
  64. default: true
  65. },
  66. labelLists: {
  67. type: Array,
  68. },
  69. },
  70. data() {
  71. return {
  72. keys: {},
  73. sorts: {key:'', order:''},
  74. loadYet: false,
  75. loadIng: 0,
  76. columns: [],
  77. lists: [],
  78. listPage: 1,
  79. listTotal: 0,
  80. noDataText: "数据加载中.....",
  81. contentShow: false,
  82. contentTitle: '',
  83. contentText: '内容加载中.....',
  84. }
  85. },
  86. created() {
  87. this.columns = [{
  88. "title": "标题",
  89. "key": 'title',
  90. "minWidth": 120,
  91. }, {
  92. "title": "发送人",
  93. "key": 'username',
  94. "sortable": true,
  95. "minWidth": 80,
  96. "maxWidth": 150,
  97. }, {
  98. "title": "创建日期",
  99. "width": 160,
  100. "align": 'center',
  101. "sortable": true,
  102. render: (h, params) => {
  103. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  104. }
  105. }, {
  106. "title": "类型",
  107. "key": 'type',
  108. "width": 80,
  109. "align": 'center',
  110. }, {
  111. "title": "操作",
  112. "key": 'action',
  113. "width": 80,
  114. "align": 'center',
  115. render: (h, params) => {
  116. return h('a', {
  117. style: {padding: '0 2px', fontSize: '12px'},
  118. on: {
  119. click: () => {
  120. this.contentReport(params.row);
  121. }
  122. }
  123. }, '查看');
  124. }
  125. }];
  126. },
  127. mounted() {
  128. if (this.canload) {
  129. this.loadYet = true;
  130. this.getLists(true);
  131. }
  132. },
  133. watch: {
  134. canload(val) {
  135. if (val && !this.loadYet) {
  136. this.loadYet = true;
  137. this.getLists(true);
  138. }
  139. }
  140. },
  141. methods: {
  142. sreachTab(clear) {
  143. if (clear === true) {
  144. this.keys = {};
  145. }
  146. this.getLists(true);
  147. },
  148. sortChange(info) {
  149. this.sorts = {key:info.key, order:info.order};
  150. this.getLists(true);
  151. },
  152. setPage(page) {
  153. this.listPage = page;
  154. this.getLists();
  155. },
  156. setPageSize(size) {
  157. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  158. this.listPageSize = size;
  159. this.getLists();
  160. }
  161. },
  162. getLists(resetLoad) {
  163. if (resetLoad === true) {
  164. this.listPage = 1;
  165. }
  166. let whereData = $A.date2string($A.cloneData(this.keys));
  167. whereData.page = Math.max(this.listPage, 1);
  168. whereData.pagesize = Math.max($A.runNum(this.listPageSize), 10);
  169. whereData.sorts = $A.cloneData(this.sorts);
  170. this.loadIng++;
  171. this.noDataText = "数据加载中.....";
  172. $A.aAjax({
  173. url: 'report/receive',
  174. data: whereData,
  175. complete: () => {
  176. this.loadIng--;
  177. },
  178. error: () => {
  179. this.noDataText = "数据加载失败!";
  180. },
  181. success: (res) => {
  182. if (res.ret === 1) {
  183. this.lists = res.data.lists;
  184. this.listTotal = res.data.total;
  185. this.noDataText = "没有相关的数据";
  186. } else {
  187. this.lists = [];
  188. this.listTotal = 0;
  189. this.noDataText = res.msg;
  190. }
  191. }
  192. });
  193. },
  194. contentReport(row) {
  195. this.contentShow = true;
  196. this.contentTitle = row.title;
  197. this.contentText = '详细内容加载中.....';
  198. $A.aAjax({
  199. url: 'report/content?id=' + row.id,
  200. error: () => {
  201. alert(this.$L('网络繁忙,请稍后再试!'));
  202. this.contentShow = false;
  203. },
  204. success: (res) => {
  205. if (res.ret === 1) {
  206. this.contentText = res.data.content;
  207. } else {
  208. this.contentShow = false;
  209. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  210. }
  211. }
  212. });
  213. },
  214. }
  215. }
  216. </script>