list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <a-card size="small" :bordered="false" class="expenseManagementList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="创建时间">
  10. <rangeDate id="expenseManagementList-rangeDate" ref="rangeDate" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="4" :sm="24">
  14. <a-form-item label="费用单号">
  15. <a-input id="expenseManagementList-accountExpensesNo" v-model.trim="queryParam.accountExpensesNo" allowClear placeholder="请输入费用单号"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="4" :sm="24">
  19. <a-form-item label="费用类型">
  20. <a-cascader
  21. @change="changeCostType"
  22. change-on-select
  23. v-model="costType"
  24. expand-trigger="hover"
  25. :options="costTypeList"
  26. :fieldNames="{ label: 'name', value: 'costTypeSn', children: 'children' }"
  27. id="productInfoList-costType"
  28. placeholder="请选择费用类型"
  29. allowClear />
  30. </a-form-item>
  31. </a-col>
  32. <a-col :md="4" :sm="24">
  33. <a-form-item label="单据状态">
  34. <v-select
  35. v-model="queryParam.state"
  36. ref="state"
  37. id="expenseManagementList-state"
  38. code="EXPENSE_AUDIT_TYPE"
  39. placeholder="请选择单据状态"
  40. allowClear></v-select>
  41. </a-form-item>
  42. </a-col>
  43. <a-col :md="6" :sm="24">
  44. <span class="table-page-search-submitButtons">
  45. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="expenseManagementList-refresh">查询</a-button>
  46. <a-button style="margin-left: 8px" @click="resetSearchForm()" :disabled="disabled" id="expenseManagementList-reset">重置</a-button>
  47. <!-- <a @click="advanced=!advanced" style="margin-left: 8px" id="expenseManagementList-advanced">
  48. {{ advanced ? '收起' : '展开' }}
  49. <a-icon :type="advanced ? 'up' : 'down'"/>
  50. </a> -->
  51. </span>
  52. </a-col>
  53. </a-row>
  54. </a-form>
  55. </div>
  56. <!-- 操作按钮 -->
  57. <div class="table-operator">
  58. <a-button v-if="$hasPermissions('B_expenseNew')" id="expenseManagementList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
  59. </div>
  60. <!-- alert -->
  61. <a-alert type="info" style="margin-bottom:10px">
  62. <div slot="message">
  63. 共 <strong>{{ totalData&&(totalData.count || totalData.count==0) ? totalData.count : '--' }}</strong> 条记录,
  64. 金额共计 <strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? toThousands(totalData.totalAmount) : '--' }}</strong>
  65. </div>
  66. </a-alert>
  67. <!-- 列表 -->
  68. <s-table
  69. class="sTable fixPagination"
  70. ref="table"
  71. :style="{ height: tableHeight+84.5+'px' }"
  72. size="small"
  73. :rowKey="(record) => record.id"
  74. :columns="columns"
  75. :data="loadData"
  76. :scroll="{ y: tableHeight }"
  77. :defaultLoadData="false"
  78. bordered>
  79. <!-- 费用类别 -->
  80. <template slot="expensesType" slot-scope="text, record">
  81. {{ record.expensesTypeName1 }} <span v-if="record.expensesTypeName2">>{{ record.expensesTypeName2 }}</span> <span v-if="record.expensesTypeName3">>{{ record.expensesTypeName3 }}</span>
  82. </template>
  83. <!-- 费用单号 -->
  84. <template slot="accountExpensesNo" slot-scope="text, record">
  85. <span :id="'expenseManagementList-detail-'+record.id" :class="$hasPermissions('B_expenseDetail')?'table-td-link':'common'" @click="handleDetail(record)">{{ text }}</span>
  86. </template>
  87. <!-- 审核 -->
  88. <template slot="audit" slot-scope="text, record">
  89. <stateIcon :title="record.stateDictValue" :state="record.state == 'AUDIT_PASS'?'1':'2'"></stateIcon>
  90. </template>
  91. <!-- 操作 -->
  92. <template slot="action" slot-scope="text, record">
  93. <a-button
  94. size="small"
  95. type="link"
  96. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseAudit')"
  97. class="button-primary"
  98. @click="handleAudit(record)"
  99. :id="'expenseManagementList-audit-'+record.id"
  100. >审核</a-button>
  101. <a-button
  102. size="small"
  103. type="link"
  104. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseEdit')"
  105. class="button-primary"
  106. @click="handleEdit(record)"
  107. :id="'expenseManagementList-edit-'+record.id">编辑</a-button>
  108. <a-button
  109. size="small"
  110. type="link"
  111. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseDel')"
  112. class="button-error"
  113. @click="handleDel(record)"
  114. :id="'expenseManagementList-del-'+record.id">删除</a-button>
  115. <span v-if="record.state != 'WAIT_AUDIT'||( !$hasPermissions('B_expenseAudit')&& !$hasPermissions('B_expenseEdit') && !$hasPermissions('B_expenseDel'))">--</span>
  116. </template>
  117. </s-table>
  118. </a-spin>
  119. <!-- 详情 -->
  120. <expense-management-detail-modal :openModal="openModal" :itemId="itemId" @close="closeDetail" />
  121. </a-card>
  122. </template>
  123. <script>
  124. import { commonMixin } from '@/utils/mixin'
  125. import { STable, VSelect } from '@/components'
  126. import rangeDate from '@/views/common/rangeDate.vue'
  127. import { costTypeAllQuery } from '@/api/costType'
  128. import expenseManagementDetailModal from './detailModal.vue'
  129. import stateIcon from '@/views/common/stateIcon'
  130. import { settleExpenseQuery, delExpense, settleExpenseQuerySum, auditExpense } from '@/api/settleExpense'
  131. export default {
  132. name: 'ExpenseManagementList',
  133. components: { STable, VSelect, expenseManagementDetailModal, rangeDate, stateIcon },
  134. mixins: [commonMixin],
  135. data () {
  136. const _this = this
  137. return {
  138. spinning: false,
  139. tableHeight: 0, // 表格高度
  140. disabled: false, // 查询、重置按钮是否可操作
  141. advanced: true, // 高级搜索 展开/关闭
  142. costTypeList: [], // 费用类型列表
  143. costType: [], // 已选费用类型
  144. // 查询参数
  145. queryParam: {
  146. beginDate: '', // 开始时间
  147. endDate: '', // 结束时间
  148. accountExpensesNo: '', // 费用单号
  149. expensesTypeSn1: '', // 费用类型1
  150. expensesTypeSn2: '', // 费用类型2
  151. expensesTypeSn3: '', // 费用类型3
  152. state: '', // 单据状态
  153. settleState: ''// 结算状态
  154. },
  155. // 汇总
  156. totalData: {
  157. count: 0, // 总数量
  158. totalAmount: 0 // 总金额
  159. },
  160. // 表头
  161. columns: [
  162. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  163. { title: '费用单号', dataIndex: 'accountExpensesNo', width: '20%', align: 'center', scopedSlots: { customRender: 'accountExpensesNo' } },
  164. { title: '创建时间', dataIndex: 'createDate', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  165. { title: '费用类型', scopedSlots: { customRender: 'expensesType' }, width: '20%', align: 'center' },
  166. { title: '金额', dataIndex: 'settleAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  167. // { title: '单据状态', dataIndex: 'stateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  168. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '3%', align: 'center' },
  169. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  170. ],
  171. // 加载数据方法 必须为 Promise 对象
  172. loadData: parameter => {
  173. this.disabled = true
  174. this.spinning = true
  175. return settleExpenseQuery(Object.assign(parameter, this.queryParam)).then(res => {
  176. let data
  177. if (res.status == 200) {
  178. data = res.data
  179. const no = (data.pageNo - 1) * data.pageSize
  180. for (var i = 0; i < data.list.length; i++) {
  181. data.list[i].no = no + i + 1
  182. }
  183. this.disabled = false
  184. // 费用类型
  185. if (this.costTypeList.length == 0) {
  186. this.getCostTypeList()
  187. }
  188. // 汇总
  189. this.totalData.count = data.count
  190. this.settleExpenseQuerySum(Object.assign(parameter, this.queryParam))
  191. }
  192. this.spinning = false
  193. return data
  194. })
  195. },
  196. openModal: false, // 查看详情 弹框
  197. itemId: '' // 当前id
  198. }
  199. },
  200. methods: {
  201. // 时间 change
  202. dateChange (date) {
  203. this.queryParam.beginDate = date[0]
  204. this.queryParam.endDate = date[1]
  205. },
  206. // 递归函数
  207. recursionFun (data) {
  208. if (data) {
  209. data.map((item, index) => {
  210. if (item.children && item.children.length == 0) {
  211. delete item.children
  212. } else {
  213. this.recursionFun(item.children)
  214. }
  215. })
  216. }
  217. },
  218. // 获取费用类型数据
  219. getCostTypeList () {
  220. costTypeAllQuery({}).then(res => {
  221. // 递归去除空children
  222. this.recursionFun(res.data)
  223. this.costTypeList = res.data
  224. })
  225. },
  226. // 费用类型 change
  227. changeCostType (val, opt) {
  228. this.queryParam.expensesTypeSn1 = val[0] ? val[0] : ''
  229. this.queryParam.expensesTypeSn2 = val[1] ? val[1] : ''
  230. this.queryParam.expensesTypeSn3 = val[2] ? val[2] : ''
  231. },
  232. // 新增/编辑
  233. handleEdit (row) {
  234. if (row) {
  235. this.$router.push({ name: 'expenseManagementEdit', params: { id: row.id } })
  236. } else {
  237. this.$router.push({ name: 'expenseManagementAdd' })
  238. }
  239. },
  240. // 打开详情弹框
  241. handleDetail (row) {
  242. if (this.$hasPermissions('B_expenseDetail')) {
  243. this.itemId = row.id
  244. this.openModal = true
  245. }
  246. },
  247. // 关闭详情弹框
  248. closeDetail () {
  249. this.openModal = false
  250. this.itemId = null
  251. },
  252. // 审核确认
  253. handleAudit (row) {
  254. const _this = this
  255. this.$confirm({
  256. title: '提示',
  257. content: '确定要审核吗?',
  258. centered: true,
  259. onOk () {
  260. _this.spinning = true
  261. auditExpense({
  262. id: row.id
  263. }).then(res => {
  264. if (res.status == 200) {
  265. _this.$message.success(res.message)
  266. _this.$refs.table.refresh()
  267. _this.spinning = false
  268. } else {
  269. _this.spinning = false
  270. }
  271. })
  272. }
  273. })
  274. },
  275. // 删除
  276. handleDel (row) {
  277. const _this = this
  278. _this.itemId = row.id
  279. _this.$confirm({
  280. title: '提示',
  281. content: '删除后原数据不可恢复,是否删除?',
  282. centered: true,
  283. onOk () {
  284. _this.spinning = true
  285. delExpense({ id: _this.itemId }).then(res => {
  286. if (res.status == 200) {
  287. _this.$message.success(res.message)
  288. _this.$refs.table.refresh()
  289. _this.spinning = false
  290. } else {
  291. _this.spinning = false
  292. }
  293. })
  294. }
  295. })
  296. },
  297. // 汇总
  298. settleExpenseQuerySum (params) {
  299. settleExpenseQuerySum(params).then(res => {
  300. this.totalData.totalAmount = res.data && res.data.settleAmount || 0
  301. })
  302. },
  303. // 重置
  304. resetSearchForm () {
  305. this.$refs.rangeDate.resetDate()
  306. this.queryParam.beginDate = ''
  307. this.queryParam.endDate = ''
  308. this.queryParam.accountExpensesNo = ''
  309. this.queryParam.expensesTypeSn1 = ''
  310. this.queryParam.expensesTypeSn2 = ''
  311. this.queryParam.expensesTypeSn3 = ''
  312. this.queryParam.state = ''
  313. this.queryParam.settleState = ''
  314. this.queryParam.beginDate = ''
  315. this.queryParam.endDate = ''
  316. this.costType = []
  317. this.$refs.table.refresh(true)
  318. },
  319. // 页面初始化
  320. pageInit () {
  321. const _this = this
  322. this.$nextTick(() => { // 页面渲染完成后的回调
  323. _this.setTableH()
  324. })
  325. },
  326. // 表格高度计算
  327. setTableH () {
  328. const tableSearchH = this.$refs.tableSearch.offsetHeight
  329. this.tableHeight = window.innerHeight - tableSearchH - 270
  330. }
  331. },
  332. watch: {
  333. advanced (newValue, oldValue) {
  334. const _this = this
  335. this.$nextTick(() => { // 页面渲染完成后的回调
  336. _this.setTableH()
  337. })
  338. },
  339. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  340. this.setTableH()
  341. }
  342. },
  343. mounted () {
  344. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  345. this.pageInit()
  346. this.resetSearchForm()
  347. }
  348. },
  349. activated () {
  350. // 如果是新页签打开,则重置当前页面
  351. if (this.$store.state.app.isNewTab) {
  352. this.pageInit()
  353. this.resetSearchForm()
  354. }
  355. // 仅刷新列表,不重置页面
  356. if (this.$store.state.app.updateList) {
  357. this.pageInit()
  358. this.$refs.table.refresh()
  359. }
  360. },
  361. beforeRouteEnter (to, from, next) {
  362. next(vm => {})
  363. }
  364. }
  365. </script>
  366. <style lang="less">
  367. .expenseManagementList-wrap{
  368. .sTable{
  369. margin-top: 10px;
  370. }
  371. .active{
  372. color: #ed1c24;
  373. cursor: pointer;
  374. }
  375. .common{
  376. color: rgba(0, 0, 0);
  377. }
  378. }
  379. </style>