list.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="funAccountList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="funAccountList-page-search-wrapper">
  6. <div>
  7. 资金账户功能:
  8. <a-radio-group
  9. size="large"
  10. v-model="enableFundAccount"
  11. :options="[
  12. { label: '启用', value: '1' },
  13. { label: '禁用', value: '0' },
  14. ]"
  15. @change="enableFundAccountChange" />
  16. </div>
  17. <div>
  18. 开启资金账户功能后,在进行财务收款和付款时,需要从下面列表选择一个账户。
  19. </div>
  20. </div>
  21. <a-card size="small" :bordered="false">
  22. <!-- 操作按钮 -->
  23. <div class="table-operator">
  24. <a-button id="funAccountList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
  25. </div>
  26. <!-- 列表 -->
  27. <s-table
  28. class="sTable fixPagination"
  29. ref="table"
  30. :style="{ height: tableHeight+84.5+'px' }"
  31. size="small"
  32. :rowKey="(record) => record.id"
  33. :columns="columns"
  34. :data="loadData"
  35. :scroll="{ y: tableHeight }"
  36. :defaultLoadData="false"
  37. bordered>
  38. <!-- 费用类别 -->
  39. <template slot="expensesType" slot-scope="text, record">
  40. {{ record.expensesTypeName1 }} <span v-if="record.expensesTypeName2">>{{ record.expensesTypeName2 }}</span> <span v-if="record.expensesTypeName3">>{{ record.expensesTypeName3 }}</span>
  41. </template>
  42. <!-- 审核 -->
  43. <template slot="audit" slot-scope="text, record">
  44. <stateIcon :title="record.stateDictValue" :state="record.state == 'AUDIT_PASS'?'1':'2'"></stateIcon>
  45. </template>
  46. <!-- 操作 -->
  47. <template slot="action" slot-scope="text, record">
  48. <a-button
  49. size="small"
  50. type="link"
  51. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseAudit')"
  52. class="button-primary"
  53. @click="handleDetail(record)"
  54. id="foundAcount-detail-btn">资金明细</a-button>
  55. <a-button
  56. size="small"
  57. type="link"
  58. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseAudit')"
  59. class="button-primary"
  60. @click="handleAudit(record)"
  61. id="foundAcount-audit-btn">审核</a-button>
  62. <a-button
  63. size="small"
  64. type="link"
  65. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseEdit')"
  66. class="button-primary"
  67. @click="handleEdit(record)"
  68. id="foundAcount-edit-btn">编辑</a-button>
  69. <a-button
  70. size="small"
  71. type="link"
  72. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseDel')"
  73. class="button-error"
  74. @click="handleDel(record)"
  75. id="foundAcount-del-btn">删除</a-button>
  76. <span v-if="record.state != 'WAIT_AUDIT'||( !$hasPermissions('B_expenseAudit')&& !$hasPermissions('B_expenseEdit') && !$hasPermissions('B_expenseDel'))">--</span>
  77. </template>
  78. </s-table>
  79. </a-card>
  80. </a-spin>
  81. <!-- 详情 -->
  82. <addModal :openModal="openModal" :itemId="itemId" @close="closeAddModal" />
  83. </div>
  84. </template>
  85. <script>
  86. import { commonMixin } from '@/utils/mixin'
  87. import { STable, VSelect } from '@/components'
  88. import rangeDate from '@/views/common/rangeDate.vue'
  89. import { settleExpenseQuery, delExpense, auditExpense } from '@/api/settleExpense'
  90. import addModal from './addModal.vue'
  91. import stateIcon from '@/views/common/stateIcon'
  92. export default {
  93. name: 'ExpenseManagementList',
  94. components: { STable, VSelect, addModal, rangeDate, stateIcon },
  95. mixins: [commonMixin],
  96. data () {
  97. return {
  98. spinning: false,
  99. tableHeight: 0,
  100. disabled: false, // 查询、重置按钮是否可操作
  101. advanced: true, // 高级搜索 展开/关闭
  102. enableFundAccount: '1',
  103. // 查询参数
  104. queryParam: {},
  105. // 表头
  106. columns: [
  107. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  108. { title: '账户类型', dataIndex: 'accountExpensesNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '账户名称', dataIndex: 'createDate', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  110. { title: '账户号码', scopedSlots: { customRender: 'expensesType' }, width: '20%', align: 'center' },
  111. { title: '收入金额', dataIndex: 'settleAmount', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  112. { title: '支出金额', dataIndex: 'settleAmount1', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  113. { title: '启用', scopedSlots: { customRender: 'enable' }, width: '3%', align: 'center' },
  114. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '3%', align: 'center' },
  115. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  116. ],
  117. // 加载数据方法 必须为 Promise 对象
  118. loadData: parameter => {
  119. this.disabled = true
  120. this.spinning = true
  121. return settleExpenseQuery(Object.assign(parameter, this.queryParam)).then(res => {
  122. let data
  123. if (res.status == 200) {
  124. data = res.data
  125. const no = (data.pageNo - 1) * data.pageSize
  126. for (var i = 0; i < data.list.length; i++) {
  127. data.list[i].no = no + i + 1
  128. }
  129. this.disabled = false
  130. }
  131. this.spinning = false
  132. return data
  133. })
  134. },
  135. openModal: false, // 查看详情 弹框
  136. itemId: '' // 当前id
  137. }
  138. },
  139. methods: {
  140. enableFundAccountChange (v) {
  141. },
  142. // 关闭弹框
  143. closeAddModal () {
  144. this.openModal = false
  145. this.itemId = null
  146. },
  147. // 新增/编辑
  148. handleEdit (row) {
  149. this.itemId = row ? row.id : null
  150. this.openModal = true
  151. },
  152. // 资金明细
  153. handleDetail (row) {
  154. this.$router.push({ name: 'fundAccountDetail', params: { id: row.id } })
  155. },
  156. // 审核
  157. handleAudit (row) {
  158. const _this = this
  159. this.$confirm({
  160. title: '提示',
  161. content: '确定要审核吗?',
  162. centered: true,
  163. onOk () {
  164. _this.spinning = true
  165. auditExpense({
  166. id: row.id
  167. }).then(res => {
  168. if (res.status == 200) {
  169. _this.$message.success(res.message)
  170. _this.$refs.table.refresh()
  171. _this.spinning = false
  172. } else {
  173. _this.spinning = false
  174. }
  175. })
  176. }
  177. })
  178. },
  179. // 删除
  180. handleDel (row) {
  181. const _this = this
  182. _this.itemId = row.id
  183. _this.$confirm({
  184. title: '提示',
  185. content: '删除后原数据不可恢复,是否删除?',
  186. centered: true,
  187. onOk () {
  188. _this.spinning = true
  189. delExpense({ id: _this.itemId }).then(res => {
  190. if (res.status == 200) {
  191. _this.$message.success(res.message)
  192. _this.$refs.table.refresh()
  193. _this.spinning = false
  194. } else {
  195. _this.spinning = false
  196. }
  197. })
  198. }
  199. })
  200. },
  201. // 重置
  202. resetSearchForm () {
  203. this.$refs.table.refresh(true)
  204. },
  205. pageInit () {
  206. const _this = this
  207. this.$nextTick(() => { // 页面渲染完成后的回调
  208. _this.setTableH()
  209. })
  210. },
  211. setTableH () {
  212. const tableSearchH = this.$refs.tableSearch.offsetHeight
  213. this.tableHeight = window.innerHeight - tableSearchH - 270
  214. }
  215. },
  216. watch: {
  217. advanced (newValue, oldValue) {
  218. const _this = this
  219. this.$nextTick(() => { // 页面渲染完成后的回调
  220. _this.setTableH()
  221. })
  222. },
  223. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  224. this.setTableH()
  225. }
  226. },
  227. mounted () {
  228. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  229. this.pageInit()
  230. this.resetSearchForm()
  231. }
  232. },
  233. activated () {
  234. // 如果是新页签打开,则重置当前页面
  235. if (this.$store.state.app.isNewTab) {
  236. this.pageInit()
  237. this.resetSearchForm()
  238. }
  239. // 仅刷新列表,不重置页面
  240. if (this.$store.state.app.updateList) {
  241. this.pageInit()
  242. this.$refs.table.refresh()
  243. }
  244. },
  245. beforeRouteEnter (to, from, next) {
  246. next(vm => {})
  247. }
  248. }
  249. </script>
  250. <style lang="less">
  251. .funAccountList-wrap{
  252. .funAccountList-page-search-wrapper{
  253. font-size: 16px;
  254. padding:10px 15px;
  255. margin-bottom: 8px;
  256. background-color: #fff;
  257. > div{
  258. padding: 5px 0;
  259. &:last-child{
  260. color: #999;
  261. font-size: 14px;
  262. }
  263. }
  264. }
  265. .sTable{
  266. margin-top: 10px;
  267. }
  268. .active{
  269. color: #ed1c24;
  270. cursor: pointer;
  271. }
  272. .common{
  273. color: rgba(0, 0, 0);
  274. }
  275. }
  276. </style>