my.vue 12 KB

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