list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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: 'FundAccountManagementList',
  95. components: { STable, VSelect, addModal, rangeDate },
  96. mixins: [commonMixin],
  97. data () {
  98. const _this = this
  99. return {
  100. spinning: false,
  101. tableHeight: 0,
  102. disabled: false, // 查询、重置按钮是否可操作
  103. advanced: true, // 高级搜索 展开/关闭
  104. enableFundAccount: '', // 结算管理开启状态
  105. // 查询参数
  106. queryParam: {},
  107. // 表头
  108. columns: [
  109. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  110. { title: '账户类型', dataIndex: 'settleStyleName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '账户名称', dataIndex: 'accountName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '账户号码', dataIndex: 'accountNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  113. { title: '收入金额', dataIndex: 'totalIncomeAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  114. { title: '支出金额', dataIndex: 'totalExpendAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  115. { title: '状态', dataIndex: 'stateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  116. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  117. ],
  118. // 加载数据方法 必须为 Promise 对象
  119. loadData: parameter => {
  120. this.disabled = true
  121. this.spinning = true
  122. return settleAccountList(Object.assign(parameter, this.queryParam)).then(res => {
  123. let data
  124. if (res.status == 200) {
  125. data = res.data
  126. const no = (data.pageNo - 1) * data.pageSize
  127. for (var i = 0; i < data.list.length; i++) {
  128. data.list[i].no = no + i + 1
  129. }
  130. this.disabled = false
  131. }
  132. this.spinning = false
  133. return data
  134. })
  135. },
  136. openModal: false, // 查看详情 弹框
  137. itemId: '' // 当前id
  138. }
  139. },
  140. methods: {
  141. ...mapActions(['UpdateSettleAccount', 'GetSettleAccountState']),
  142. enableFundAccountChange (v) {
  143. this.UpdateSettleAccount({ enableFlag: v.target.value }).then(res => {
  144. if (res.status == 200) {
  145. this.GetSettleAccountState()
  146. }
  147. this.$message.info(res.message)
  148. })
  149. },
  150. // 关闭弹框
  151. closeAddModal () {
  152. this.openModal = false
  153. this.itemId = null
  154. },
  155. // 新增/编辑
  156. handleEdit (row) {
  157. this.openModal = true
  158. this.$nextTick(() => {
  159. this.$refs.addModal.setData(row)
  160. })
  161. },
  162. addSuccess () {
  163. this.$refs.table.refresh()
  164. },
  165. // 资金明细
  166. handleDetail (row) {
  167. this.$router.push({ name: 'fundAccountDetail', params: { sn: row.settleAccountSn } })
  168. },
  169. // 审核
  170. handleAudit (row) {
  171. const _this = this
  172. this.$confirm({
  173. title: '提示',
  174. content: '审核通过后,账户信息不能再修改,确认审核通过吗?',
  175. centered: true,
  176. onOk () {
  177. _this.spinning = true
  178. settleAccountAudit({
  179. settleAccountSn: row.settleAccountSn,
  180. auditState: 'PASS'
  181. }).then(res => {
  182. if (res.status == 200) {
  183. _this.$message.success(res.message)
  184. _this.$refs.table.refresh()
  185. }
  186. _this.spinning = false
  187. })
  188. }
  189. })
  190. },
  191. // 启用,禁用
  192. handleEnable (row) {
  193. const _this = this
  194. this.$confirm({
  195. title: '提示',
  196. content: row.state == 'ENABLE' ? '确认禁用该账户吗?' : '确认启用该账户吗?',
  197. centered: true,
  198. onOk () {
  199. _this.spinning = true
  200. settleAccountEnable({
  201. settleAccountSn: row.settleAccountSn,
  202. enableFlag: row.state == 'ENABLE' ? 'DISABLE' : 'ENABLE'
  203. }).then(res => {
  204. if (res.status == 200) {
  205. _this.$message.success(res.message)
  206. _this.$refs.table.refresh()
  207. }
  208. _this.spinning = false
  209. })
  210. }
  211. })
  212. },
  213. // 删除
  214. handleDel (row) {
  215. const _this = this
  216. _this.$confirm({
  217. title: '提示',
  218. content: '删除后原数据不可恢复,是否删除?',
  219. centered: true,
  220. onOk () {
  221. _this.spinning = true
  222. settleAccountDelete({ settleAccountSn: row.settleAccountSn }).then(res => {
  223. if (res.status == 200) {
  224. _this.$message.success(res.message)
  225. _this.$refs.table.refresh()
  226. }
  227. _this.spinning = false
  228. })
  229. }
  230. })
  231. },
  232. // 重置
  233. resetSearchForm () {
  234. this.$refs.table.refresh(true)
  235. },
  236. pageInit () {
  237. const _this = this
  238. this.$nextTick(() => { // 页面渲染完成后的回调
  239. _this.setTableH()
  240. })
  241. // 结算账户状态查询
  242. if (this.$hasPermissions('M_fundAccountList') && this.$hasPermissions('B_fundAccountEnable')) {
  243. this.GetSettleAccountState().then(res => {
  244. if (res.status == 200) {
  245. this.enableFundAccount = res.data.functionEnableFlag
  246. }
  247. })
  248. }
  249. },
  250. setTableH () {
  251. const tableSearchH = this.$refs.tableSearch.offsetHeight
  252. this.tableHeight = window.innerHeight - tableSearchH - 270
  253. }
  254. },
  255. watch: {
  256. advanced (newValue, oldValue) {
  257. const _this = this
  258. this.$nextTick(() => { // 页面渲染完成后的回调
  259. _this.setTableH()
  260. })
  261. },
  262. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  263. this.setTableH()
  264. }
  265. },
  266. mounted () {
  267. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  268. this.pageInit()
  269. this.resetSearchForm()
  270. }
  271. },
  272. activated () {
  273. // 如果是新页签打开,则重置当前页面
  274. if (this.$store.state.app.isNewTab) {
  275. this.pageInit()
  276. this.resetSearchForm()
  277. }
  278. // 仅刷新列表,不重置页面
  279. if (this.$store.state.app.updateList) {
  280. this.pageInit()
  281. this.$refs.table.refresh()
  282. }
  283. },
  284. beforeRouteEnter (to, from, next) {
  285. next(vm => {})
  286. }
  287. }
  288. </script>
  289. <style lang="less">
  290. .funAccountList-wrap{
  291. .funAccountList-page-search-wrapper{
  292. font-size: 16px;
  293. padding:10px 15px;
  294. margin-bottom: 8px;
  295. background-color: #fff;
  296. > div{
  297. padding: 5px 0;
  298. &:last-child{
  299. color: #999;
  300. font-size: 14px;
  301. }
  302. }
  303. }
  304. .sTable{
  305. margin-top: 10px;
  306. }
  307. .active{
  308. color: #ed1c24;
  309. cursor: pointer;
  310. }
  311. .common{
  312. color: rgba(0, 0, 0);
  313. }
  314. }
  315. </style>