123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- <template>
- <a-card size="small" :bordered="false" class="expenseManagementList-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div ref="tableSearch" class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="4" :sm="24">
- <a-form-item label="费用单号">
- <a-input id="expenseManagementList-accountExpensesNo" v-model.trim="queryParam.accountExpensesNo" allowClear placeholder="请输入费用单号"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="创建时间">
- <rangeDate ref="rangeDate" @change="dateChange" />
- </a-form-item>
- </a-col>
- <a-col :md="4" :sm="24">
- <a-form-item label="费用类型">
- <a-cascader
- @change="changeCostType"
- change-on-select
- v-model="costType"
- expand-trigger="hover"
- :options="costTypeList"
- :fieldNames="{ label: 'name', value: 'costTypeSn', children: 'children' }"
- id="productInfoList-costType"
- placeholder="请选择费用类型"
- allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="4" :sm="24">
- <a-form-item label="单据状态">
- <v-select
- v-model="queryParam.state"
- ref="state"
- id="expenseManagementList-state"
- code="EXPENSE_AUDIT_TYPE"
- placeholder="请选择单据状态"
- allowClear></v-select>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <span class="table-page-search-submitButtons">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="expenseManagementList-refresh">查询</a-button>
- <a-button style="margin-left: 8px" @click="resetSearchForm()" :disabled="disabled" id="expenseManagementList-reset">重置</a-button>
- <!-- <a @click="advanced=!advanced" style="margin-left: 8px">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a> -->
- </span>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 操作按钮 -->
- <div class="table-operator">
- <a-button v-if="$hasPermissions('B_expenseNew')" id="expenseManagementList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
- </div>
- <!-- alert -->
- <a-alert type="info" style="margin-bottom:10px">
- <div slot="message">
- 共 <strong>{{ totalData&&(totalData.count || totalData.count==0) ? totalData.count : '--' }}</strong> 条记录,
- 金额共计 <strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? toThousands(totalData.totalAmount) : '--' }}</strong>
- </div>
- </a-alert>
- <!-- 列表 -->
- <s-table
- class="sTable fixPagination"
- ref="table"
- :style="{ height: tableHeight+84.5+'px' }"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ y: tableHeight }"
- :defaultLoadData="false"
- bordered>
- <!-- 费用类别 -->
- <template slot="expensesType" slot-scope="text, record">
- {{ record.expensesTypeName1 }} <span v-if="record.expensesTypeName2">>{{ record.expensesTypeName2 }}</span> <span v-if="record.expensesTypeName3">>{{ record.expensesTypeName3 }}</span>
- </template>
- <!-- 费用单号 -->
- <template slot="accountExpensesNo" slot-scope="text, record">
- <span :class="$hasPermissions('B_expenseDetail')?'table-td-link':'common'" @click="handleDetail(record)">{{ text }}</span>
- </template>
- <!-- 审核 -->
- <template slot="audit" slot-scope="text, record">
- <stateIcon :title="record.stateDictValue" :state="record.state == 'AUDIT_PASS'?'1':'2'"></stateIcon>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="link"
- v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseAudit')"
- class="button-primary"
- @click="handleAudit(record)"
- id="expenseManagement-audit-btn">审核</a-button>
- <a-button
- size="small"
- type="link"
- v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseEdit')"
- class="button-primary"
- @click="handleEdit(record)"
- id="expenseManagement-edit-btn">编辑</a-button>
- <a-button
- size="small"
- type="link"
- v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseDel')"
- class="button-error"
- @click="handleDel(record)"
- id="expenseManagement-del-btn">删除</a-button>
- <span v-if="record.state != 'WAIT_AUDIT'||( !$hasPermissions('B_expenseAudit')&& !$hasPermissions('B_expenseEdit') && !$hasPermissions('B_expenseDel'))">--</span>
- </template>
- </s-table>
- </a-spin>
- <!-- 详情 -->
- <expense-management-detail-modal :openModal="openModal" :itemId="itemId" @close="closeDetail" />
- </a-card>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import rangeDate from '@/views/common/rangeDate.vue'
- import { settleExpenseQuery, delExpense, settleExpenseQuerySum, auditExpense } from '@/api/settleExpense'
- import { costTypeAllQuery } from '@/api/costType'
- import expenseManagementDetailModal from './detailModal.vue'
- import stateIcon from '@/views/common/stateIcon'
- export default {
- name: 'ExpenseManagementList',
- components: { STable, VSelect, expenseManagementDetailModal, rangeDate, stateIcon },
- mixins: [commonMixin],
- data () {
- const _this = this
- return {
- spinning: false,
- tableHeight: 0,
- disabled: false, // 查询、重置按钮是否可操作
- advanced: true, // 高级搜索 展开/关闭
- costTypeList: [], // 费用类型
- costType: [],
- // 查询参数
- queryParam: {
- beginDate: '',
- endDate: '',
- accountExpensesNo: '',
- expensesTypeSn1: '',
- expensesTypeSn2: '',
- expensesTypeSn3: '',
- state: '',
- settleState: ''
- },
- // 汇总
- totalData: {
- count: 0,
- totalAmount: 0
- },
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
- { title: '费用单号', dataIndex: 'accountExpensesNo', width: '20%', align: 'center', scopedSlots: { customRender: 'accountExpensesNo' } },
- { title: '创建时间', dataIndex: 'createDate', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '费用类型', scopedSlots: { customRender: 'expensesType' }, width: '20%', align: 'center' },
- { title: '金额', dataIndex: 'settleAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- // { title: '单据状态', dataIndex: 'stateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '审核', scopedSlots: { customRender: 'audit' }, width: '3%', align: 'center' },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.spinning = true
- return settleExpenseQuery(Object.assign(parameter, this.queryParam)).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- }
- this.disabled = false
- // 费用类型
- if (this.costTypeList.length == 0) {
- this.getCostTypeList()
- }
- // 汇总
- this.totalData.count = data.count
- this.settleExpenseQuerySum(Object.assign(parameter, this.queryParam))
- }
- this.spinning = false
- return data
- })
- },
- openModal: false, // 查看详情 弹框
- itemId: '' // 当前id
- }
- },
- methods: {
- // 时间 change
- dateChange (date) {
- this.queryParam.beginDate = date[0]
- this.queryParam.endDate = date[1]
- },
- // 递归函数
- recursionFun (data) {
- if (data) {
- data.map((item, index) => {
- if (item.children && item.children.length == 0) {
- delete item.children
- } else {
- this.recursionFun(item.children)
- }
- })
- }
- },
- // 获取费用类型数据
- getCostTypeList () {
- costTypeAllQuery({}).then(res => {
- // 递归去除空children
- this.recursionFun(res.data)
- this.costTypeList = res.data
- })
- },
- closeDetail () {
- this.openModal = false
- this.itemId = null
- },
- // 费用类型 change
- changeCostType (val, opt) {
- this.queryParam.expensesTypeSn1 = val[0] ? val[0] : ''
- this.queryParam.expensesTypeSn2 = val[1] ? val[1] : ''
- this.queryParam.expensesTypeSn3 = val[2] ? val[2] : ''
- },
- // 新增/编辑
- handleEdit (row) {
- if (row) {
- this.$router.push({ name: 'expenseManagementEdit', params: { id: row.id } })
- } else {
- this.$router.push({ name: 'expenseManagementAdd' })
- }
- },
- // 详情
- handleDetail (row) {
- if (this.$hasPermissions('B_expenseDetail')) {
- this.itemId = row.id
- this.openModal = true
- }
- },
- // 审核
- handleAudit (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确定要审核吗?',
- centered: true,
- onOk () {
- _this.spinning = true
- auditExpense({
- id: row.id
- }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- })
- },
- // 删除
- handleDel (row) {
- const _this = this
- _this.itemId = row.id
- _this.$confirm({
- title: '提示',
- content: '删除后原数据不可恢复,是否删除?',
- centered: true,
- onOk () {
- _this.spinning = true
- delExpense({ id: _this.itemId }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- })
- },
- // 汇总
- settleExpenseQuerySum (params) {
- settleExpenseQuerySum(params).then(res => {
- this.totalData.totalAmount = res.data && res.data.settleAmount || 0
- })
- },
- // 重置
- resetSearchForm () {
- this.$refs.rangeDate.resetDate()
- this.queryParam.beginDate = ''
- this.queryParam.endDate = ''
- this.queryParam.accountExpensesNo = ''
- this.queryParam.expensesTypeSn1 = ''
- this.queryParam.expensesTypeSn2 = ''
- this.queryParam.expensesTypeSn3 = ''
- this.queryParam.state = ''
- this.queryParam.settleState = ''
- this.queryParam.beginDate = ''
- this.queryParam.endDate = ''
- this.costType = []
- this.$refs.table.refresh(true)
- },
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- },
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 270
- }
- },
- watch: {
- advanced (newValue, oldValue) {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- },
- '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
- this.setTableH()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- // 仅刷新列表,不重置页面
- if (this.$store.state.app.updateList) {
- this.pageInit()
- this.$refs.table.refresh()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .expenseManagementList-wrap{
- .sTable{
- margin-top: 10px;
- }
- .active{
- color: #ed1c24;
- cursor: pointer;
- }
- .common{
- color: rgba(0, 0, 0);
- }
- }
- </style>
|