my.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. <Drawer v-model="addDrawerShow" width="70%">
  35. <report-add :canload="addDrawerShow" :id="addDrawerId" @on-success="addDrawerSuccess"></report-add>
  36. </Drawer>
  37. <Modal
  38. v-model="contentShow"
  39. :title="contentTitle"
  40. width="80%"
  41. :styles="{top: '35px', paddingBottom: '35px'}"
  42. footerHide>
  43. <report-content :content="contentText"></report-content>
  44. </Modal>
  45. </drawer-tabs-container>
  46. </template>
  47. <style lang="scss" scoped>
  48. .report-my {
  49. padding: 0 12px;
  50. .tableFill {
  51. margin: 12px 0 20px;
  52. }
  53. }
  54. </style>
  55. <script>
  56. import DrawerTabsContainer from "../DrawerTabsContainer";
  57. import ReportAdd from "./add";
  58. import ReportContent from "./content";
  59. /**
  60. * 我的汇报
  61. */
  62. export default {
  63. name: 'ReportMy',
  64. components: {ReportContent, ReportAdd, DrawerTabsContainer},
  65. props: {
  66. canload: {
  67. type: Boolean,
  68. default: true
  69. },
  70. },
  71. data () {
  72. return {
  73. keys: {},
  74. sorts: {key:'', order:''},
  75. loadYet: false,
  76. loadIng: 0,
  77. columns: [],
  78. lists: [],
  79. listPage: 1,
  80. listTotal: 0,
  81. noDataText: "",
  82. addDrawerId: 0,
  83. addDrawerShow: false,
  84. contentShow: false,
  85. contentTitle: '',
  86. contentText: '',
  87. }
  88. },
  89. created() {
  90. this.noDataText = this.$L("数据加载中.....");
  91. this.contentText = this.$L("内容加载中.....");
  92. this.columns = [{
  93. "title": this.$L("标题"),
  94. "key": 'title',
  95. "minWidth": 120,
  96. }, {
  97. "title": this.$L("类型"),
  98. "key": 'type',
  99. "minWidth": 80,
  100. "maxWidth": 120,
  101. "align": 'center',
  102. }, {
  103. "title": this.$L("状态"),
  104. "key": 'status',
  105. "minWidth": 80,
  106. "maxWidth": 120,
  107. "align": 'center',
  108. }, {
  109. "title": this.$L("创建日期"),
  110. "minWidth": 160,
  111. "maxWidth": 200,
  112. "align": 'center',
  113. "sortable": true,
  114. render: (h, params) => {
  115. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  116. }
  117. }, {
  118. "title": " ",
  119. "key": 'action',
  120. "align": 'right',
  121. "width": 120,
  122. render: (h, params) => {
  123. if (!params.row.id) {
  124. return null;
  125. }
  126. return h('div', [
  127. h('Tooltip', {
  128. props: { content: this.$L('查看'), transfer: true, delay: 600 },
  129. style: { position: 'relative' },
  130. }, [h('Icon', {
  131. props: { type: 'md-eye', size: 16 },
  132. style: { margin: '0 3px', cursor: 'pointer' },
  133. on: {
  134. click: () => {
  135. this.contentReport(params.row);
  136. }
  137. }
  138. })]),
  139. h('Tooltip', {
  140. props: { content: this.$L('编辑'), transfer: true, delay: 600 }
  141. }, [h('Icon', {
  142. props: { type: 'md-create', size: 16 },
  143. style: { margin: '0 3px', cursor: 'pointer' },
  144. on: {
  145. click: () => {
  146. this.addDrawerId = params.row.id;
  147. this.addDrawerShow = true
  148. }
  149. }
  150. })]),
  151. h('Tooltip', {
  152. props: { content: this.$L('发送'), transfer: true, delay: 600 }
  153. }, [h('Icon', {
  154. props: { type: 'md-send', size: 16 },
  155. style: { margin: '0 3px', cursor: 'pointer' },
  156. on: {
  157. click: () => {
  158. this.sendReport(params.row);
  159. }
  160. }
  161. })]),
  162. h('Tooltip', {
  163. props: { content: this.$L('删除'), transfer: true, delay: 600 }
  164. }, [h('Icon', {
  165. props: { type: 'md-trash', size: 16 },
  166. style: { margin: '0 3px', cursor: 'pointer' },
  167. on: {
  168. click: () => {
  169. this.deleteReport(params.row);
  170. }
  171. }
  172. })]),
  173. ]);
  174. },
  175. }];
  176. },
  177. mounted() {
  178. if (this.canload) {
  179. this.loadYet = true;
  180. this.getLists(true);
  181. }
  182. },
  183. watch: {
  184. canload(val) {
  185. if (val && !this.loadYet) {
  186. this.loadYet = true;
  187. this.getLists(true);
  188. }
  189. }
  190. },
  191. methods: {
  192. sreachTab(clear) {
  193. if (clear === true) {
  194. this.keys = {};
  195. }
  196. this.getLists(true);
  197. },
  198. sortChange(info) {
  199. this.sorts = {key:info.key, order:info.order};
  200. this.getLists(true);
  201. },
  202. setPage(page) {
  203. this.listPage = page;
  204. this.getLists();
  205. },
  206. setPageSize(size) {
  207. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  208. this.listPageSize = size;
  209. this.getLists();
  210. }
  211. },
  212. getLists(resetLoad) {
  213. if (resetLoad === true) {
  214. this.listPage = 1;
  215. }
  216. let whereData = $A.date2string($A.cloneData(this.keys));
  217. whereData.page = Math.max(this.listPage, 1);
  218. whereData.pagesize = Math.max($A.runNum(this.listPageSize), 10);
  219. whereData.sorts = $A.cloneData(this.sorts);
  220. this.loadIng++;
  221. this.noDataText = this.$L("数据加载中.....");
  222. $A.aAjax({
  223. url: 'report/my',
  224. data: whereData,
  225. complete: () => {
  226. this.loadIng--;
  227. },
  228. error: () => {
  229. this.noDataText = this.$L("数据加载失败!");
  230. },
  231. success: (res) => {
  232. if (res.ret === 1) {
  233. this.lists = res.data.lists;
  234. this.listTotal = res.data.total;
  235. this.noDataText = this.$L("没有相关的数据");
  236. } else {
  237. this.lists = [];
  238. this.listTotal = 0;
  239. this.noDataText = res.msg;
  240. }
  241. }
  242. });
  243. },
  244. addDrawerSuccess() {
  245. this.addDrawerShow = false;
  246. this.getLists(true);
  247. },
  248. contentReport(row) {
  249. this.contentShow = true;
  250. this.contentTitle = row.title;
  251. this.contentText = this.$L('详细内容加载中.....');
  252. $A.aAjax({
  253. url: 'report/content?id=' + row.id,
  254. error: () => {
  255. alert(this.$L('网络繁忙,请稍后再试!'));
  256. this.contentShow = false;
  257. },
  258. success: (res) => {
  259. if (res.ret === 1) {
  260. this.contentText = res.data.content;
  261. } else {
  262. this.contentShow = false;
  263. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  264. }
  265. }
  266. });
  267. },
  268. sendReport(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=send&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.$set(row, 'status', '已发送');
  283. setTimeout(() => {
  284. if (res.ret === 1) {
  285. this.$Message.success(res.msg);
  286. } else {
  287. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  288. }
  289. }, 350);
  290. }
  291. });
  292. }
  293. });
  294. },
  295. deleteReport(row) {
  296. this.$Modal.confirm({
  297. title: this.$L('删除汇报'),
  298. content: this.$L('你确定要删除汇报吗?'),
  299. loading: true,
  300. onOk: () => {
  301. $A.aAjax({
  302. url: 'report/template?act=delete&id=' + row.id + '&type=' + row.type,
  303. error: () => {
  304. this.$Modal.remove();
  305. alert(this.$L('网络繁忙,请稍后再试!'));
  306. },
  307. success: (res) => {
  308. this.$Modal.remove();
  309. this.lists.some((item, index) => {
  310. if (item.id == row.id) {
  311. this.lists.splice(index, 1);
  312. return true;
  313. }
  314. })
  315. setTimeout(() => {
  316. if (res.ret === 1) {
  317. this.$Message.success(res.msg);
  318. } else {
  319. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  320. }
  321. }, 350);
  322. }
  323. });
  324. }
  325. });
  326. }
  327. }
  328. }
  329. </script>