receive.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. "sortable": true,
  91. "minWidth": 120,
  92. }, {
  93. "title": "发送人",
  94. "key": 'username',
  95. "sortable": true,
  96. "minWidth": 80,
  97. "maxWidth": 130,
  98. }, {
  99. "title": "类型",
  100. "key": 'type',
  101. "minWidth": 80,
  102. "maxWidth": 120,
  103. "align": 'center',
  104. }, {
  105. "title": "创建日期",
  106. "minWidth": 160,
  107. "maxWidth": 200,
  108. "align": 'center',
  109. "sortable": true,
  110. render: (h, params) => {
  111. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  112. }
  113. }, {
  114. "title": " ",
  115. "key": 'action',
  116. "width": 70,
  117. "align": 'center',
  118. render: (h, params) => {
  119. return h('div', [
  120. h('Tooltip', {
  121. props: { content: '查看', transfer: true, delay: 600 },
  122. style: { position: 'relative' },
  123. }, [h('Icon', {
  124. props: { type: 'md-eye', size: 16 },
  125. style: { margin: '0 3px', cursor: 'pointer' },
  126. on: {
  127. click: () => {
  128. this.contentReport(params.row);
  129. }
  130. }
  131. })]),
  132. ]);
  133. }
  134. }];
  135. },
  136. mounted() {
  137. if (this.canload) {
  138. this.loadYet = true;
  139. this.getLists(true);
  140. }
  141. },
  142. watch: {
  143. canload(val) {
  144. if (val && !this.loadYet) {
  145. this.loadYet = true;
  146. this.getLists(true);
  147. }
  148. }
  149. },
  150. methods: {
  151. sreachTab(clear) {
  152. if (clear === true) {
  153. this.keys = {};
  154. }
  155. this.getLists(true);
  156. },
  157. sortChange(info) {
  158. this.sorts = {key:info.key, order:info.order};
  159. this.getLists(true);
  160. },
  161. setPage(page) {
  162. this.listPage = page;
  163. this.getLists();
  164. },
  165. setPageSize(size) {
  166. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  167. this.listPageSize = size;
  168. this.getLists();
  169. }
  170. },
  171. getLists(resetLoad) {
  172. if (resetLoad === true) {
  173. this.listPage = 1;
  174. }
  175. let whereData = $A.date2string($A.cloneData(this.keys));
  176. whereData.page = Math.max(this.listPage, 1);
  177. whereData.pagesize = Math.max($A.runNum(this.listPageSize), 10);
  178. whereData.sorts = $A.cloneData(this.sorts);
  179. this.loadIng++;
  180. this.noDataText = "数据加载中.....";
  181. $A.aAjax({
  182. url: 'report/receive',
  183. data: whereData,
  184. complete: () => {
  185. this.loadIng--;
  186. },
  187. error: () => {
  188. this.noDataText = "数据加载失败!";
  189. },
  190. success: (res) => {
  191. if (res.ret === 1) {
  192. this.lists = res.data.lists;
  193. this.listTotal = res.data.total;
  194. this.noDataText = "没有相关的数据";
  195. } else {
  196. this.lists = [];
  197. this.listTotal = 0;
  198. this.noDataText = res.msg;
  199. }
  200. }
  201. });
  202. },
  203. contentReport(row) {
  204. this.contentShow = true;
  205. this.contentTitle = row.title;
  206. this.contentText = '详细内容加载中.....';
  207. $A.aAjax({
  208. url: 'report/content?id=' + row.id,
  209. error: () => {
  210. alert(this.$L('网络繁忙,请稍后再试!'));
  211. this.contentShow = false;
  212. },
  213. success: (res) => {
  214. if (res.ret === 1) {
  215. this.contentText = res.data.content;
  216. } else {
  217. this.contentShow = false;
  218. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  219. }
  220. }
  221. });
  222. },
  223. }
  224. }
  225. </script>