my.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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">类型</sreachTitle>
  9. <Select v-model="keys.type" placeholder="全部">
  10. <Option value="">全部</Option>
  11. <Option value="日报">日报</Option>
  12. <Option value="周报">周报</Option>
  13. </Select>
  14. </div>
  15. <div class="item-2">
  16. <sreachTitle :val="keys.indate">日期</sreachTitle>
  17. <Date-picker v-model="keys.indate" type="daterange" placement="bottom" placeholder="日期范围"></Date-picker>
  18. </div>
  19. </div>
  20. <div class="item item-button">
  21. <Button type="text" v-if="$A.objImplode(keys)!=''" @click="sreachTab(true)">取消筛选</Button>
  22. <Button type="primary" icon="md-search" :loading="loadIng > 0" @click="sreachTab">搜索</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]">新建汇报</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.columns = [{
  91. "title": "标题",
  92. "key": 'title',
  93. "minWidth": 120,
  94. }, {
  95. "title": "类型",
  96. "key": 'type',
  97. "minWidth": 80,
  98. "maxWidth": 120,
  99. "align": 'center',
  100. }, {
  101. "title": "状态",
  102. "key": 'status',
  103. "minWidth": 80,
  104. "maxWidth": 120,
  105. "align": 'center',
  106. }, {
  107. "title": "创建日期",
  108. "minWidth": 160,
  109. "maxWidth": 200,
  110. "align": 'center',
  111. "sortable": true,
  112. render: (h, params) => {
  113. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  114. }
  115. }, {
  116. "title": " ",
  117. "key": 'action',
  118. "align": 'right',
  119. "width": 120,
  120. render: (h, params) => {
  121. if (!params.row.id) {
  122. return null;
  123. }
  124. return h('div', [
  125. h('Tooltip', {
  126. props: { content: '查看', transfer: true, delay: 600 },
  127. style: { position: 'relative' },
  128. }, [h('Icon', {
  129. props: { type: 'md-eye', size: 16 },
  130. style: { margin: '0 3px', cursor: 'pointer' },
  131. on: {
  132. click: () => {
  133. this.contentReport(params.row);
  134. }
  135. }
  136. })]),
  137. h('Tooltip', {
  138. props: { content: '编辑', transfer: true, delay: 600 }
  139. }, [h('Icon', {
  140. props: { type: 'md-create', size: 16 },
  141. style: { margin: '0 3px', cursor: 'pointer' },
  142. on: {
  143. click: () => {
  144. this.addDrawerId = params.row.id;
  145. this.addDrawerShow = true
  146. }
  147. }
  148. })]),
  149. h('Tooltip', {
  150. props: { content: '发送', transfer: true, delay: 600 }
  151. }, [h('Icon', {
  152. props: { type: 'md-send', size: 16 },
  153. style: { margin: '0 3px', cursor: 'pointer' },
  154. on: {
  155. click: () => {
  156. this.sendReport(params.row);
  157. }
  158. }
  159. })]),
  160. h('Tooltip', {
  161. props: { content: '删除', transfer: true, delay: 600 }
  162. }, [h('Icon', {
  163. props: { type: 'md-trash', size: 16 },
  164. style: { margin: '0 3px', cursor: 'pointer' },
  165. on: {
  166. click: () => {
  167. this.deleteReport(params.row);
  168. }
  169. }
  170. })]),
  171. ]);
  172. },
  173. }];
  174. },
  175. mounted() {
  176. if (this.canload) {
  177. this.loadYet = true;
  178. this.getLists(true);
  179. }
  180. },
  181. watch: {
  182. canload(val) {
  183. if (val && !this.loadYet) {
  184. this.loadYet = true;
  185. this.getLists(true);
  186. }
  187. }
  188. },
  189. methods: {
  190. sreachTab(clear) {
  191. if (clear === true) {
  192. this.keys = {};
  193. }
  194. this.getLists(true);
  195. },
  196. sortChange(info) {
  197. this.sorts = {key:info.key, order:info.order};
  198. this.getLists(true);
  199. },
  200. setPage(page) {
  201. this.listPage = page;
  202. this.getLists();
  203. },
  204. setPageSize(size) {
  205. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  206. this.listPageSize = size;
  207. this.getLists();
  208. }
  209. },
  210. getLists(resetLoad) {
  211. if (resetLoad === true) {
  212. this.listPage = 1;
  213. }
  214. let whereData = $A.date2string($A.cloneData(this.keys));
  215. whereData.page = Math.max(this.listPage, 1);
  216. whereData.pagesize = Math.max($A.runNum(this.listPageSize), 10);
  217. whereData.sorts = $A.cloneData(this.sorts);
  218. this.loadIng++;
  219. this.noDataText = "数据加载中.....";
  220. $A.aAjax({
  221. url: 'report/my',
  222. data: whereData,
  223. complete: () => {
  224. this.loadIng--;
  225. },
  226. error: () => {
  227. this.noDataText = "数据加载失败!";
  228. },
  229. success: (res) => {
  230. if (res.ret === 1) {
  231. this.lists = res.data.lists;
  232. this.listTotal = res.data.total;
  233. this.noDataText = "没有相关的数据";
  234. } else {
  235. this.lists = [];
  236. this.listTotal = 0;
  237. this.noDataText = res.msg;
  238. }
  239. }
  240. });
  241. },
  242. addDrawerSuccess() {
  243. this.addDrawerShow = false;
  244. this.getLists(true);
  245. },
  246. contentReport(row) {
  247. this.contentShow = true;
  248. this.contentTitle = row.title;
  249. this.contentText = '详细内容加载中.....';
  250. $A.aAjax({
  251. url: 'report/content?id=' + row.id,
  252. error: () => {
  253. alert(this.$L('网络繁忙,请稍后再试!'));
  254. this.contentShow = false;
  255. },
  256. success: (res) => {
  257. if (res.ret === 1) {
  258. this.contentText = res.data.content;
  259. } else {
  260. this.contentShow = false;
  261. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  262. }
  263. }
  264. });
  265. },
  266. sendReport(row) {
  267. this.$Modal.confirm({
  268. title: '发送汇报',
  269. content: '你确定要发送汇报吗?',
  270. loading: true,
  271. onOk: () => {
  272. $A.aAjax({
  273. url: 'report/template?act=send&id=' + row.id + '&type=' + row.type,
  274. error: () => {
  275. this.$Modal.remove();
  276. alert(this.$L('网络繁忙,请稍后再试!'));
  277. },
  278. success: (res) => {
  279. this.$Modal.remove();
  280. this.$set(row, 'status', '已发送');
  281. setTimeout(() => {
  282. if (res.ret === 1) {
  283. this.$Message.success(res.msg);
  284. } else {
  285. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  286. }
  287. }, 350);
  288. }
  289. });
  290. }
  291. });
  292. },
  293. deleteReport(row) {
  294. this.$Modal.confirm({
  295. title: '删除汇报',
  296. content: '你确定要删除汇报吗?',
  297. loading: true,
  298. onOk: () => {
  299. $A.aAjax({
  300. url: 'report/template?act=delete&id=' + row.id + '&type=' + row.type,
  301. error: () => {
  302. this.$Modal.remove();
  303. alert(this.$L('网络繁忙,请稍后再试!'));
  304. },
  305. success: (res) => {
  306. this.$Modal.remove();
  307. this.lists.some((item, index) => {
  308. if (item.id == row.id) {
  309. this.lists.splice(index, 1);
  310. return true;
  311. }
  312. })
  313. setTimeout(() => {
  314. if (res.ret === 1) {
  315. this.$Message.success(res.msg);
  316. } else {
  317. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  318. }
  319. }, 350);
  320. }
  321. });
  322. }
  323. });
  324. }
  325. }
  326. }
  327. </script>