my.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. "width": 160,
  97. "align": 'center',
  98. "sortable": true,
  99. render: (h, params) => {
  100. return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
  101. }
  102. }, {
  103. "title": "类型",
  104. "key": 'type',
  105. "width": 80,
  106. "align": 'center',
  107. }, {
  108. "title": "状态",
  109. "key": 'status',
  110. "width": 80,
  111. "align": 'center',
  112. }, {
  113. "title": "操作",
  114. "key": 'action',
  115. "width": 140,
  116. "align": 'center',
  117. render: (h, params) => {
  118. let arr = [];
  119. arr.push(h('a', {
  120. style: {padding: '0 2px', fontSize: '12px'},
  121. on: {
  122. click: () => {
  123. this.contentReport(params.row);
  124. }
  125. }
  126. }, '查看'));
  127. arr.push(h('a', {
  128. style: {padding: '0 2px', fontSize: '12px'},
  129. on: {
  130. click: () => {
  131. this.addDrawerId = params.row.id;
  132. this.addDrawerShow = true
  133. }
  134. }
  135. }, '编辑'));
  136. if (params.row.status == '未发送') {
  137. arr.push(h('a', {
  138. style: {padding: '0 2px', fontSize: '12px'},
  139. on: {
  140. click: () => {
  141. this.deleteReport(params.row);
  142. }
  143. }
  144. }, '删除'));
  145. arr.push(h('a', {
  146. style: {padding: '0 2px', fontSize: '12px'},
  147. on: {
  148. click: () => {
  149. this.sendReport(params.row);
  150. }
  151. }
  152. }, '发送'));
  153. }
  154. return h('div', arr);
  155. }
  156. }];
  157. },
  158. mounted() {
  159. if (this.canload) {
  160. this.loadYet = true;
  161. this.getLists(true);
  162. }
  163. },
  164. watch: {
  165. canload(val) {
  166. if (val && !this.loadYet) {
  167. this.loadYet = true;
  168. this.getLists(true);
  169. }
  170. }
  171. },
  172. methods: {
  173. sreachTab(clear) {
  174. if (clear === true) {
  175. this.keys = {};
  176. }
  177. this.getLists(true);
  178. },
  179. sortChange(info) {
  180. this.sorts = {key:info.key, order:info.order};
  181. this.getLists(true);
  182. },
  183. setPage(page) {
  184. this.listPage = page;
  185. this.getLists();
  186. },
  187. setPageSize(size) {
  188. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  189. this.listPageSize = size;
  190. this.getLists();
  191. }
  192. },
  193. getLists(resetLoad) {
  194. if (resetLoad === true) {
  195. this.listPage = 1;
  196. }
  197. let whereData = $A.date2string($A.cloneData(this.keys));
  198. whereData.page = Math.max(this.listPage, 1);
  199. whereData.pagesize = Math.max($A.runNum(this.listPageSize), 10);
  200. whereData.sorts = $A.cloneData(this.sorts);
  201. this.loadIng++;
  202. this.noDataText = "数据加载中.....";
  203. $A.aAjax({
  204. url: 'report/my',
  205. data: whereData,
  206. complete: () => {
  207. this.loadIng--;
  208. },
  209. error: () => {
  210. this.noDataText = "数据加载失败!";
  211. },
  212. success: (res) => {
  213. if (res.ret === 1) {
  214. this.lists = res.data.lists;
  215. this.listTotal = res.data.total;
  216. this.noDataText = "没有相关的数据";
  217. } else {
  218. this.lists = [];
  219. this.listTotal = 0;
  220. this.noDataText = res.msg;
  221. }
  222. }
  223. });
  224. },
  225. addDrawerSuccess() {
  226. this.addDrawerShow = false;
  227. this.getLists(true);
  228. },
  229. contentReport(row) {
  230. this.contentShow = true;
  231. this.contentTitle = row.title;
  232. this.contentText = '详细内容加载中.....';
  233. $A.aAjax({
  234. url: 'report/content?id=' + row.id,
  235. error: () => {
  236. alert(this.$L('网络繁忙,请稍后再试!'));
  237. this.contentShow = false;
  238. },
  239. success: (res) => {
  240. if (res.ret === 1) {
  241. this.contentText = res.data.content;
  242. } else {
  243. this.contentShow = false;
  244. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  245. }
  246. }
  247. });
  248. },
  249. sendReport(row) {
  250. this.$Modal.confirm({
  251. title: '发送汇报',
  252. content: '你确定要发送汇报吗?',
  253. loading: true,
  254. onOk: () => {
  255. $A.aAjax({
  256. url: 'report/template?act=send&id=' + row.id + '&type=' + row.type,
  257. error: () => {
  258. this.$Modal.remove();
  259. alert(this.$L('网络繁忙,请稍后再试!'));
  260. },
  261. success: (res) => {
  262. this.$Modal.remove();
  263. this.$set(row, 'status', '已发送');
  264. setTimeout(() => {
  265. if (res.ret === 1) {
  266. this.$Message.success(res.msg);
  267. } else {
  268. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  269. }
  270. }, 350);
  271. }
  272. });
  273. }
  274. });
  275. },
  276. deleteReport(row) {
  277. this.$Modal.confirm({
  278. title: '删除汇报',
  279. content: '你确定要删除汇报吗?',
  280. loading: true,
  281. onOk: () => {
  282. $A.aAjax({
  283. url: 'report/template?act=delete&id=' + row.id + '&type=' + row.type,
  284. error: () => {
  285. this.$Modal.remove();
  286. alert(this.$L('网络繁忙,请稍后再试!'));
  287. },
  288. success: (res) => {
  289. this.$Modal.remove();
  290. this.lists.some((item, index) => {
  291. if (item.id == row.id) {
  292. this.lists.splice(index, 1);
  293. return true;
  294. }
  295. })
  296. setTimeout(() => {
  297. if (res.ret === 1) {
  298. this.$Message.success(res.msg);
  299. } else {
  300. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  301. }
  302. }, 350);
  303. }
  304. });
  305. }
  306. });
  307. }
  308. }
  309. }
  310. </script>