my.vue 14 KB

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