receive.vue 8.8 KB

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