Base.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. </template>
  3. <script>
  4. import { destroy } from "@/utils/ComponentUtils"
  5. import baseMixin from '@/mixin/baseMixin'
  6. let _ = require('lodash')
  7. import bus from '@/assets/js/event.js'
  8. import ApprovalModal from '@/components/ApprovalModal'
  9. export default {
  10. mixins: [baseMixin],
  11. data () {
  12. return {
  13. menuId: this.$route.name,
  14. checkType: 2,
  15. checkedKeys: [],
  16. refresh: true,
  17. globalReadonly: true,
  18. approver: '',
  19. initAfterFlag: false,
  20. submitStatus: 1,
  21. taskComment: ''
  22. }
  23. },
  24. computed: {
  25. curRemoveMenuName: function() {
  26. return this.$store.state.home.curRemoveMenuName;
  27. },
  28. refreshTabId: function() {
  29. this.refreshTable(this.$store.state.home.refreshTabId);
  30. return this.$store.state.home.refreshTabId;
  31. },
  32. curUser() {
  33. return this.$store.state.user.user;
  34. },
  35. theme() {
  36. return this.$store.state.home.theme;
  37. }
  38. },
  39. watch: {
  40. curRemoveMenuName: function() {
  41. //console.log(1 + this.$route.name);
  42. //destroy(this);
  43. },
  44. refreshTabId: function() {
  45. console.log(this.$route.name + " - " + this.refreshTabId)
  46. this.refreshTable();
  47. },
  48. 'page.pageNo': function() {
  49. this.checkedKeys = [];
  50. },
  51. checkedKeys: function() {
  52. if (!this.page.list || this.checkedKeys.length != this.page.list.length) {
  53. this.checkType = 2;
  54. } else {
  55. this.checkType = (this.page.list && this.page.list.length >= 1) ? 1 : 2;
  56. }
  57. }
  58. },
  59. mounted () {
  60. },
  61. methods: {
  62. autoSearch: _.debounce(function() {
  63. this.$refs.pagination.search(1, true);
  64. }, 500),
  65. refreshTable: function (refreshTabId) {
  66. if (this.$route.name != refreshTabId) {
  67. return;
  68. }
  69. if (this.$refs.pagination == null) {
  70. return;
  71. }
  72. this.$nextTick(() => {
  73. if (this.$refs.pagination.$parent.$vnode.tag.endWith("-" + refreshTabId)) {
  74. this.$store.commit('home/SET_CUR_REFRESH_TABLE_TAB_ID', null);
  75. this.$refs.pagination.refresh();
  76. }
  77. });
  78. },
  79. checkAll: function(data) {
  80. this.checkedKeys = [];
  81. if (data.checked && this.page.list) {
  82. this.page.list.forEach(item => {
  83. this.checkedKeys.push(item.id);
  84. });
  85. }
  86. },
  87. check: function(data) {
  88. if (data.checked) {
  89. this.checkedKeys.push(data.val);
  90. } else {
  91. this.checkedKeys.remove(data.val);
  92. }
  93. },
  94. download: function (data, fileName) {
  95. if (!data || !data.data) {
  96. msg("文件下载失败(文件或已被删除)");
  97. return
  98. }
  99. let url = window.URL.createObjectURL(new Blob([data.data]))
  100. let link = document.createElement('a')
  101. link.style.display = 'none'
  102. link.href = url
  103. link.setAttribute('download', fileName || decodeURIComponent(data.fileName))
  104. document.body.appendChild(link)
  105. link.click()
  106. },
  107. refreshed: function() {
  108. this.refresh = false;
  109. this.$nextTick(() => {
  110. this.refresh = true;
  111. });
  112. },
  113. close: function () {
  114. var formViewName = this.$route.name;
  115. var _listViewName = formViewName;
  116. if (formViewName.endWith('Form')) {
  117. _listViewName = _listViewName.substring(0, formViewName.length - 4) + "List";
  118. } else if (formViewName.endWith('Add')) {
  119. _listViewName = _listViewName.substring(0, formViewName.length - 3) + "List";
  120. }
  121. if (_listViewName == "TransactionSubjectList" || _listViewName == "ProjectSubjectList") {
  122. _listViewName = "MeetingSubjectList";
  123. }
  124. this.closeView(this.$parent, formViewName, _listViewName);
  125. },
  126. closeView: function(parent, formViewName, _listViewName, viewName) {
  127. if (!parent) {
  128. return;
  129. }
  130. if (parent.backView) {
  131. parent.backView(formViewName, viewName || _listViewName);
  132. } else {
  133. this.closeView(parent.$parent, formViewName, _listViewName, parent.listView);
  134. }
  135. },
  136. toView: function(viewName, params, parent) {
  137. if (arguments.length == 2) {
  138. parent = this.$parent;
  139. }
  140. if (!parent) {
  141. return;
  142. }
  143. if (parent.clickMenu) {
  144. parent.clickMenu({
  145. "name": viewName,
  146. }, 3, params);
  147. return;
  148. }
  149. this.toView(viewName, params, parent.$parent);
  150. },
  151. approvalSubmit(status, cenableFlow) {
  152. // 默认正常(审批通过)状态
  153. this.submitStatus = status || 4;
  154. if (cenableFlow != false && this.enableFlow) {
  155. this.$layer.iframe({
  156. content: {
  157. content: ApprovalModal, //传递的组件对象
  158. parent: this,//当前的vue对象
  159. data: {
  160. submitFlow: true,
  161. taskName: this.$route.params.taskName || this.taskName,
  162. }
  163. },
  164. area: ['500px', '300px'],
  165. title: "选择审批人"
  166. });
  167. } else {
  168. this.save();
  169. }
  170. },
  171. trueSelectApproverAfter(approver, layerid) {
  172. this.approver = approver;
  173. this.save(layerid);
  174. },
  175. }
  176. }
  177. </script>
  178. <style scoped>
  179. </style>