index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. :moreParameters="moreParameters2"
  42. expCode="exp2"
  43. >
  44. </template-page>
  45. </div>
  46. </template>
  47. </zj-tab-page>
  48. </template>
  49. <script>
  50. import TemplatePage from '@/components/template/template-page-1.vue'
  51. import import_mixin from '@/components/template/import_mixin.js'
  52. import operation_mixin from '@/components/template/operation_mixin.js'
  53. import {
  54. dailySummaryReduceCountList,
  55. dailySummaryIncrDecrCostList,
  56. dailySummaryIncrDecrCostImport,
  57. dailySummaryIncrDecrCostListExport,
  58. dailySummaryReduceBatchDo,
  59. dailySummaryReduceBatchDel,
  60. dailySummaryReduceCountDelete,
  61. dailySummaryReduceCountDo
  62. } from '@/api/increaseAndDecreaseExpense'
  63. export default {
  64. components: { TemplatePage },
  65. mixins: [import_mixin, operation_mixin],
  66. data() {
  67. return {
  68. // 表格属性
  69. tableAttributes: {
  70. // 启用勾选列
  71. selectColumn: true
  72. },
  73. // 表格事件
  74. tableEvents: {
  75. 'selection-change': this.selectionChange
  76. },
  77. // 勾选选中行
  78. recordSelected: [],
  79. // 表格属性
  80. tableAttributes2: {
  81. // 启用勾选列
  82. selectColumn: true
  83. },
  84. // 表格事件
  85. tableEvents2: {
  86. 'selection-change': this.selectionChange2
  87. },
  88. // 勾选选中行
  89. recordSelected2: [],
  90. // 表单
  91. formData: {}
  92. }
  93. },
  94. computed: {
  95. // 更多参数
  96. moreParameters() {
  97. return [
  98. {
  99. name: '工单类型',
  100. key: 'doStatus',
  101. value: '',
  102. conditions: [
  103. {
  104. label: '全部',
  105. value: ''
  106. },
  107. {
  108. label: '未执行',
  109. value: '2'
  110. },
  111. {
  112. label: '已执行',
  113. value: '1'
  114. }
  115. ]
  116. }
  117. ]
  118. },
  119. moreParameters2() {
  120. return [
  121. {
  122. name: '工单类型',
  123. key: 'doStatus',
  124. value: '',
  125. conditions: [
  126. {
  127. label: '全部',
  128. value: ''
  129. },
  130. {
  131. label: '未执行',
  132. value: '2'
  133. },
  134. {
  135. label: '已执行',
  136. value: '1'
  137. }
  138. ]
  139. }
  140. ]
  141. },
  142. optionsEvensGroup() {
  143. return [
  144. [
  145. [
  146. this.optionsEvensAuth('import', ({ moduleName }) => {
  147. return {
  148. name: moduleName,
  149. render: () => {
  150. return this.importButton(dailySummaryIncrDecrCostImport, moduleName)
  151. }
  152. }
  153. })
  154. ]
  155. ]
  156. ]
  157. },
  158. //
  159. optionsEvensGroup2() {
  160. return [
  161. [
  162. [
  163. this.optionsEvensAuth('batchExecute2', {
  164. click: () => {
  165. if (this.recordSelected2.length === 0) {
  166. this.$message.warning('请勾选')
  167. return
  168. }
  169. dailySummaryReduceBatchDo({
  170. ids: this.recordSelected2.map(item => item.id).join(',')
  171. }).then(res => {
  172. this.$message({ type: 'success', message: '设置成功!' })
  173. this.$refs.pageRef2.refreshList()
  174. })
  175. }
  176. })
  177. ],
  178. [
  179. this.optionsEvensAuth('batchDel2', {
  180. click: () => {
  181. if (this.recordSelected2.length === 0) {
  182. this.$message.warning('请勾选')
  183. return
  184. }
  185. dailySummaryReduceBatchDel({
  186. ids: this.recordSelected2.map(item => item.id).join(',')
  187. }).then(res => {
  188. this.$message({ type: 'success', message: '删除成功!' })
  189. this.$refs.pageRef2.refreshList()
  190. })
  191. }
  192. })
  193. ]
  194. ]
  195. ]
  196. },
  197. formItems() {
  198. return []
  199. }
  200. },
  201. methods: {
  202. // 列表请求函数
  203. getList(p, cb) {
  204. var pam = JSON.parse(JSON.stringify(p))
  205. try {
  206. if (pam.doStatus) {
  207. pam.params.push({ param: 'a.do_status', compare: '=', value: pam.doStatus })
  208. }
  209. cb && cb(pam)
  210. return dailySummaryReduceCountList(pam)
  211. } catch (err) {}
  212. },
  213. getList2(p, cb) {
  214. var pam = JSON.parse(JSON.stringify(p))
  215. try {
  216. if (pam.doStatus) {
  217. pam.params.push({ param: 'a.do_status', compare: '=', value: pam.doStatus })
  218. }
  219. cb && cb(pam)
  220. return dailySummaryIncrDecrCostList(pam)
  221. } catch (err) {}
  222. },
  223. // 列表导出函数
  224. exportList2: dailySummaryIncrDecrCostListExport,
  225. // 表格列解析渲染数据更改
  226. columnParsing(item, defaultData) {
  227. return defaultData
  228. },
  229. // 监听勾选变化
  230. selectionChange(data) {
  231. this.recordSelected = data
  232. },
  233. selectionChange2(data) {
  234. this.recordSelected2 = data
  235. },
  236. operation() {
  237. return this.operationBtn({
  238. view: {
  239. click: ({ row, index, column }) => {
  240. this.$refs.tabPage.addTab({
  241. // 对应显示的模块
  242. activeKey: 'view',
  243. // 唯一标识
  244. key: 'view',
  245. // 页签名称
  246. label: '明细',
  247. // 打开时事件
  248. triggerEvent: () => {},
  249. // 关闭时事件
  250. closeEvent: () => {}
  251. })
  252. }
  253. },
  254. execute: {
  255. conditions: ({ row, index, column }) => {
  256. return row.doStatus == '2'
  257. },
  258. prompt: '确定执行吗?',
  259. click: ({ row, index, column }) => {
  260. dailySummaryReduceCountDo({ importBatchNos: row.importBatchNo }).then(res => {
  261. this.$message({ type: 'success', message: '执行成功!' })
  262. this.$refs.pageRef.refreshList()
  263. })
  264. }
  265. },
  266. coverImport: {
  267. import: true,
  268. click: ({ row, index, column, file }) => {
  269. var formdata = new FormData()
  270. formdata.append('file', file)
  271. formdata.append('importBatchNo', row.importBatchNo)
  272. dailySummaryIncrDecrCostImport({ formdata })
  273. .then(res => {
  274. this.$refs.pageRef.refreshList()
  275. this.$message({
  276. type: 'success',
  277. message: '导入成功!'
  278. })
  279. })
  280. .catch(err => {
  281. this.$message({
  282. type: 'error',
  283. message: err.message || '导入失败'
  284. })
  285. })
  286. }
  287. },
  288. del: {
  289. prompt: '确定删除吗?',
  290. click: ({ row, index, column }) => {
  291. dailySummaryReduceCountDelete({ importBatchNo: row.importBatchNo }).then(res => {
  292. this.$message({ type: 'success', message: '删除成功!' })
  293. this.$refs.pageRef.refreshList()
  294. })
  295. }
  296. }
  297. })
  298. },
  299. operation2() {
  300. return this.operationBtn({
  301. execute2: {
  302. conditions: ({ row, index, column }) => {
  303. return row.doStatus == '2'
  304. },
  305. prompt: '确定执行吗?',
  306. click: ({ row, index, column }) => {
  307. dailySummaryReduceBatchDo({ ids: row.id }).then(res => {
  308. this.$message({ type: 'success', message: '设置成功!' })
  309. this.$refs.pageRef2.refreshList()
  310. })
  311. }
  312. },
  313. del2: {
  314. prompt: '确定删除吗?',
  315. click: ({ row, index, column }) => {
  316. dailySummaryReduceBatchDel({ ids: row.id }).then(res => {
  317. this.$message({ type: 'success', message: '删除成功!' })
  318. this.$refs.pageRef2.refreshList()
  319. })
  320. }
  321. }
  322. })
  323. }
  324. }
  325. }
  326. </script>
  327. <style lang="scss" scoped></style>