index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title + '-列表', essential: true }]">
  3. <template slot-scope="{ activeKey, data }">
  4. <div
  5. :style="{
  6. width: '100%',
  7. height: activeKey == 'list' ? '100%' : '0px',
  8. overflow: 'hidden'
  9. }"
  10. >
  11. <template-page
  12. ref="pageRef"
  13. :get-list="getList"
  14. :table-attributes="tableAttributes"
  15. :table-events="tableEvents"
  16. :options-evens-group="optionsEvensGroup"
  17. :moreParameters="moreParameters"
  18. :column-parsing="columnParsing"
  19. :operationColumnWidth="180"
  20. :operation="operation()"
  21. >
  22. </template-page>
  23. </div>
  24. <div
  25. v-if="activeKey == 'view'"
  26. :style="{
  27. width: '100%',
  28. height: '100%',
  29. overflow: 'hidden'
  30. }"
  31. >
  32. <template-page
  33. ref="pageRef2"
  34. :operationColumnWidth="180"
  35. :table-attributes="tableAttributes2"
  36. :table-events="tableEvents2"
  37. :get-list="getList2"
  38. :exportList="exportList2"
  39. :options-evens-group="optionsEvensGroup2"
  40. :operation="operation2()"
  41. expCode="exp2"
  42. >
  43. </template-page>
  44. </div>
  45. </template>
  46. </zj-tab-page>
  47. </template>
  48. <script>
  49. import TemplatePage from '@/components/template/template-page-1.vue'
  50. import import_mixin from '@/components/template/import_mixin.js'
  51. import operation_mixin from '@/components/template/operation_mixin.js'
  52. import {
  53. dailySummaryReduceCountList,
  54. dailySummaryIncrDecrCostList,
  55. dailySummaryIncrDecrCostImport,
  56. dailySummaryIncrDecrCostListExport,
  57. dailySummaryReduceBatchDo,
  58. dailySummaryReduceBatchDel,
  59. dailySummaryReduceCountDelete,
  60. dailySummaryReduceCountDo
  61. } from '@/api/increaseAndDecreaseExpense'
  62. export default {
  63. components: { TemplatePage },
  64. mixins: [import_mixin, operation_mixin],
  65. data() {
  66. return {
  67. // 表格属性
  68. tableAttributes: {
  69. // 启用勾选列
  70. selectColumn: true
  71. },
  72. // 表格事件
  73. tableEvents: {
  74. 'selection-change': this.selectionChange
  75. },
  76. // 勾选选中行
  77. recordSelected: [],
  78. // 表格属性
  79. tableAttributes2: {
  80. // 启用勾选列
  81. selectColumn: true
  82. },
  83. // 表格事件
  84. tableEvents2: {
  85. 'selection-change': this.selectionChange2
  86. },
  87. // 勾选选中行
  88. recordSelected2: [],
  89. // 表单
  90. formData: {}
  91. }
  92. },
  93. computed: {
  94. // 更多参数
  95. moreParameters() {
  96. return []
  97. },
  98. optionsEvensGroup() {
  99. return [
  100. [
  101. [
  102. this.optionsEvensAuth('import', ({ moduleName }) => {
  103. return {
  104. name: moduleName,
  105. render: () => {
  106. return this.importButton(dailySummaryIncrDecrCostImport, moduleName)
  107. }
  108. }
  109. })
  110. ]
  111. ]
  112. ]
  113. },
  114. //
  115. optionsEvensGroup2() {
  116. return [
  117. [
  118. [
  119. this.optionsEvensAuth('batchExecute2', {
  120. click: () => {
  121. if (this.recordSelected2.length === 0) {
  122. this.$message.warning('请勾选')
  123. return
  124. }
  125. dailySummaryReduceBatchDo({
  126. ids: this.recordSelected2.map(item => item.id).join(',')
  127. }).then(res => {
  128. this.$message({ type: 'success', message: '设置成功!' })
  129. this.$refs.pageRef2.refreshList()
  130. })
  131. }
  132. })
  133. ],
  134. [
  135. this.optionsEvensAuth('batchDel2', {
  136. click: () => {
  137. if (this.recordSelected.length === 0) {
  138. this.$message.warning('请勾选')
  139. return
  140. }
  141. dailySummaryReduceBatchDel({
  142. ids: this.recordSelected.map(item => item.id).join(',')
  143. }).then(res => {
  144. this.$message({ type: 'success', message: '删除成功!' })
  145. this.$refs.pageRef2.refreshList()
  146. })
  147. }
  148. })
  149. ]
  150. ]
  151. ]
  152. },
  153. formItems() {
  154. return []
  155. }
  156. },
  157. methods: {
  158. // 列表请求函数
  159. getList(p, cb) {
  160. try {
  161. cb && cb(p)
  162. return dailySummaryReduceCountList(p)
  163. } catch (error) {
  164. console.log(error)
  165. }
  166. },
  167. getList2(p, cb) {
  168. try {
  169. cb && cb(p)
  170. return dailySummaryIncrDecrCostList(p)
  171. } catch (error) {
  172. console.log(error)
  173. }
  174. },
  175. // 列表导出函数
  176. exportList2: dailySummaryIncrDecrCostListExport,
  177. // 表格列解析渲染数据更改
  178. columnParsing(item, defaultData) {
  179. return defaultData
  180. },
  181. // 监听勾选变化
  182. selectionChange(data) {
  183. this.recordSelected = data
  184. },
  185. selectionChange2(data) {
  186. this.recordSelected2 = data
  187. },
  188. operation() {
  189. return this.operationBtn({
  190. view: {
  191. click: ({ row, index, column }) => {
  192. this.$refs.tabPage.addTab({
  193. // 对应显示的模块
  194. activeKey: 'view',
  195. // 唯一标识
  196. key: 'view',
  197. // 页签名称
  198. label: '明细',
  199. // 打开时事件
  200. triggerEvent: () => {},
  201. // 关闭时事件
  202. closeEvent: () => {}
  203. })
  204. }
  205. },
  206. execute: {
  207. prompt: '确定执行吗?',
  208. click: ({ row, index, column }) => {
  209. dailySummaryReduceCountDo({ importBatchNos: row.importBatchNo }).then(res => {
  210. this.$message({ type: 'success', message: '执行成功!' })
  211. this.$refs.pageRef.refreshList()
  212. })
  213. }
  214. },
  215. coverImport: {
  216. import: true,
  217. click: ({ row, index, column, file }) => {
  218. var formdata = new FormData()
  219. formdata.append('file', file)
  220. formdata.append('importBatchNo', row.importBatchNo)
  221. dailySummaryIncrDecrCostImport({ formdata })
  222. .then(res => {
  223. this.$refs.pageRef.refreshList()
  224. this.$message({
  225. type: 'success',
  226. message: '导入成功!'
  227. })
  228. })
  229. .catch(err => {
  230. this.$message({
  231. type: 'error',
  232. message: err.message || '导入失败'
  233. })
  234. })
  235. }
  236. },
  237. del: {
  238. prompt: '确定删除吗?',
  239. click: ({ row, index, column }) => {
  240. dailySummaryReduceCountDelete({ importBatchNo: row.importBatchNo }).then(res => {
  241. this.$message({ type: 'success', message: '删除成功!' })
  242. this.$refs.pageRef.refreshList()
  243. })
  244. }
  245. }
  246. })
  247. },
  248. operation2() {
  249. return this.operationBtn({
  250. execute2: {
  251. click: ({ row, index, column }) => {
  252. dailySummaryReduceBatchDo({ ids: row.id }).then(res => {
  253. this.$message({ type: 'success', message: '设置成功!' })
  254. this.$refs.pageRef2.refreshList()
  255. })
  256. }
  257. },
  258. del2: {
  259. prompt: '确定删除吗?',
  260. click: ({ row, index, column }) => {
  261. dailySummaryReduceBatchDel({ ids: row.id }).then(res => {
  262. this.$message({ type: 'success', message: '删除成功!' })
  263. this.$refs.pageRef2.refreshList()
  264. })
  265. }
  266. }
  267. })
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="scss" scoped></style>