list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div class="funAccountList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" v-if="$hasPermissions('B_fundAccountEnable')" 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" v-if="$hasPermissions('B_FA_New')" 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="action" slot-scope="text, record">
  40. <a-button
  41. size="small"
  42. type="link"
  43. v-if="(record.state == 'ENABLE'||record.state == 'DISABLE')&&$hasPermissions('B_FA_QYJY')"
  44. class="button-primary"
  45. @click="handleEnable(record)"
  46. id="foundAcount-enable-btn">
  47. {{ record.state == 'ENABLE'?'禁用':'' }}
  48. {{ record.state == 'DISABLE'?'启用':'' }}
  49. </a-button>
  50. <a-button
  51. size="small"
  52. type="link"
  53. v-if="(record.state == 'ENABLE'||record.state == 'DISABLE')&&$hasPermissions('M_fundAccount_detail')"
  54. class="button-primary"
  55. @click="handleDetail(record)"
  56. id="foundAcount-detail-btn">资金明细</a-button>
  57. <a-button
  58. size="small"
  59. type="link"
  60. v-if="record.state == 'WAIT'&&$hasPermissions('B_FA_Audit')"
  61. class="button-primary"
  62. @click="handleAudit(record)"
  63. id="foundAcount-audit-btn">审核</a-button>
  64. <a-button
  65. size="small"
  66. type="link"
  67. v-if="record.state == 'WAIT'&&$hasPermissions('B_FA_Edit')"
  68. class="button-primary"
  69. @click="handleEdit(record)"
  70. id="foundAcount-edit-btn">编辑</a-button>
  71. <a-button
  72. size="small"
  73. type="link"
  74. v-if="record.state == 'WAIT'&&$hasPermissions('B_FA_delete')"
  75. class="button-error"
  76. @click="handleDel(record)"
  77. id="foundAcount-del-btn">删除</a-button>
  78. </template>
  79. </s-table>
  80. </a-card>
  81. </a-spin>
  82. <!-- 新增编辑 -->
  83. <addModal ref="addModal" :openModal="openModal" @ok="addSuccess" @close="closeAddModal" />
  84. </div>
  85. </template>
  86. <script>
  87. import { commonMixin } from '@/utils/mixin'
  88. import { mapActions } from 'vuex'
  89. import { STable, VSelect } from '@/components'
  90. import rangeDate from '@/views/common/rangeDate.vue'
  91. import addModal from './addModal.vue'
  92. import { settleAccountList, settleAccountEnable, settleAccountDelete, settleAccountAudit } from '@/api/settleAcount'
  93. export default {
  94. name: 'ExpenseManagementList',
  95. components: { STable, VSelect, addModal, rangeDate },
  96. mixins: [commonMixin],
  97. data () {
  98. return {
  99. spinning: false,
  100. tableHeight: 0,
  101. disabled: false, // 查询、重置按钮是否可操作
  102. advanced: true, // 高级搜索 展开/关闭
  103. enableFundAccount: '', // 结算管理开启状态
  104. // 查询参数
  105. queryParam: {},
  106. // 表头
  107. columns: [
  108. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  109. { title: '账户类型', dataIndex: 'settleStyleName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  110. { title: '账户名称', dataIndex: 'accountName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '账户号码', dataIndex: 'accountNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '收入金额', dataIndex: 'totalIncomeAmount', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  113. { title: '支出金额', dataIndex: 'totalExpendAmount', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  114. { title: '状态', dataIndex: 'stateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  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 settleAccountList(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. ...mapActions(['UpdateSettleAccount', 'GetSettleAccountState']),
  141. enableFundAccountChange (v) {
  142. this.UpdateSettleAccount({ enableFlag: v.target.value }).then(res => {
  143. if (res.status == 200) {
  144. this.GetSettleAccountState()
  145. }
  146. this.$message.info(res.message)
  147. })
  148. },
  149. // 关闭弹框
  150. closeAddModal () {
  151. this.openModal = false
  152. this.itemId = null
  153. },
  154. // 新增/编辑
  155. handleEdit (row) {
  156. this.openModal = true
  157. this.$nextTick(() => {
  158. this.$refs.addModal.setData(row)
  159. })
  160. },
  161. addSuccess () {
  162. this.$refs.table.refresh()
  163. },
  164. // 资金明细
  165. handleDetail (row) {
  166. this.$router.push({ name: 'fundAccountDetail', params: { sn: row.settleAccountSn } })
  167. },
  168. // 审核
  169. handleAudit (row) {
  170. const _this = this
  171. this.$confirm({
  172. title: '提示',
  173. content: '审核通过后,账户信息不能再修改,确认审核通过吗?',
  174. centered: true,
  175. onOk () {
  176. _this.spinning = true
  177. settleAccountAudit({
  178. settleAccountSn: row.settleAccountSn,
  179. auditState: 'PASS'
  180. }).then(res => {
  181. if (res.status == 200) {
  182. _this.$message.success(res.message)
  183. _this.$refs.table.refresh()
  184. }
  185. _this.spinning = false
  186. })
  187. }
  188. })
  189. },
  190. // 启用,禁用
  191. handleEnable (row) {
  192. const _this = this
  193. this.$confirm({
  194. title: '提示',
  195. content: row.state == 'ENABLE' ? '确认禁用该账户吗?' : '确认启用该账户吗?',
  196. centered: true,
  197. onOk () {
  198. _this.spinning = true
  199. settleAccountEnable({
  200. settleAccountSn: row.settleAccountSn,
  201. enableFlag: row.state == 'ENABLE' ? 'DISABLE' : 'ENABLE'
  202. }).then(res => {
  203. if (res.status == 200) {
  204. _this.$message.success(res.message)
  205. _this.$refs.table.refresh()
  206. }
  207. _this.spinning = false
  208. })
  209. }
  210. })
  211. },
  212. // 删除
  213. handleDel (row) {
  214. const _this = this
  215. _this.$confirm({
  216. title: '提示',
  217. content: '删除后原数据不可恢复,是否删除?',
  218. centered: true,
  219. onOk () {
  220. _this.spinning = true
  221. settleAccountDelete({ settleAccountSn: row.settleAccountSn }).then(res => {
  222. if (res.status == 200) {
  223. _this.$message.success(res.message)
  224. _this.$refs.table.refresh()
  225. }
  226. _this.spinning = false
  227. })
  228. }
  229. })
  230. },
  231. // 重置
  232. resetSearchForm () {
  233. this.$refs.table.refresh(true)
  234. },
  235. pageInit () {
  236. const _this = this
  237. this.$nextTick(() => { // 页面渲染完成后的回调
  238. _this.setTableH()
  239. })
  240. // 结算账户状态查询
  241. if (this.$hasPermissions('M_fundAccountList') && this.$hasPermissions('B_fundAccountEnable')) {
  242. this.GetSettleAccountState().then(res => {
  243. if (res.status == 200) {
  244. this.enableFundAccount = res.data.functionEnableFlag
  245. }
  246. })
  247. }
  248. },
  249. setTableH () {
  250. const tableSearchH = this.$refs.tableSearch.offsetHeight
  251. this.tableHeight = window.innerHeight - tableSearchH - 270
  252. }
  253. },
  254. watch: {
  255. advanced (newValue, oldValue) {
  256. const _this = this
  257. this.$nextTick(() => { // 页面渲染完成后的回调
  258. _this.setTableH()
  259. })
  260. },
  261. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  262. this.setTableH()
  263. }
  264. },
  265. mounted () {
  266. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  267. this.pageInit()
  268. this.resetSearchForm()
  269. }
  270. },
  271. activated () {
  272. // 如果是新页签打开,则重置当前页面
  273. if (this.$store.state.app.isNewTab) {
  274. this.pageInit()
  275. this.resetSearchForm()
  276. }
  277. // 仅刷新列表,不重置页面
  278. if (this.$store.state.app.updateList) {
  279. this.pageInit()
  280. this.$refs.table.refresh()
  281. }
  282. },
  283. beforeRouteEnter (to, from, next) {
  284. next(vm => {})
  285. }
  286. }
  287. </script>
  288. <style lang="less">
  289. .funAccountList-wrap{
  290. .funAccountList-page-search-wrapper{
  291. font-size: 16px;
  292. padding:10px 15px;
  293. margin-bottom: 8px;
  294. background-color: #fff;
  295. > div{
  296. padding: 5px 0;
  297. &:last-child{
  298. color: #999;
  299. font-size: 14px;
  300. }
  301. }
  302. }
  303. .sTable{
  304. margin-top: 10px;
  305. }
  306. .active{
  307. color: #ed1c24;
  308. cursor: pointer;
  309. }
  310. .common{
  311. color: rgba(0, 0, 0);
  312. }
  313. }
  314. </style>