list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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="4" :sm="24">
  9. <a-form-item label="费用单号">
  10. <a-input id="expenseManagementList-accountExpensesNo" v-model.trim="queryParam.accountExpensesNo" allowClear placeholder="请输入费用单号"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="创建时间">
  15. <rangeDate ref="rangeDate" @change="dateChange" />
  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">
  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 :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="expenseManagement-audit-btn">审核</a-button>
  100. <a-button
  101. size="small"
  102. type="link"
  103. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseEdit')"
  104. class="button-primary"
  105. @click="handleEdit(record)"
  106. id="expenseManagement-edit-btn">编辑</a-button>
  107. <a-button
  108. size="small"
  109. type="link"
  110. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseDel')"
  111. class="button-error"
  112. @click="handleDel(record)"
  113. id="expenseManagement-del-btn">删除</a-button>
  114. <span v-if="record.state != 'WAIT_AUDIT'||( !$hasPermissions('B_expenseAudit')&& !$hasPermissions('B_expenseEdit') && !$hasPermissions('B_expenseDel'))">--</span>
  115. </template>
  116. </s-table>
  117. </a-spin>
  118. <!-- 详情 -->
  119. <expense-management-detail-modal :openModal="openModal" :itemId="itemId" @close="closeDetail" />
  120. </a-card>
  121. </template>
  122. <script>
  123. import { commonMixin } from '@/utils/mixin'
  124. import { STable, VSelect } from '@/components'
  125. import rangeDate from '@/views/common/rangeDate.vue'
  126. import { settleExpenseQuery, delExpense, settleExpenseQuerySum, auditExpense } from '@/api/settleExpense'
  127. import { costTypeAllQuery } from '@/api/costType'
  128. import expenseManagementDetailModal from './detailModal.vue'
  129. import stateIcon from '@/views/common/stateIcon'
  130. export default {
  131. name: 'ExpenseManagementList',
  132. components: { STable, VSelect, expenseManagementDetailModal, rangeDate, stateIcon },
  133. mixins: [commonMixin],
  134. data () {
  135. const _this = this
  136. return {
  137. spinning: false,
  138. tableHeight: 0,
  139. disabled: false, // 查询、重置按钮是否可操作
  140. advanced: true, // 高级搜索 展开/关闭
  141. costTypeList: [], // 费用类型
  142. costType: [],
  143. // 查询参数
  144. queryParam: {
  145. beginDate: '',
  146. endDate: '',
  147. accountExpensesNo: '',
  148. expensesTypeSn1: '',
  149. expensesTypeSn2: '',
  150. expensesTypeSn3: '',
  151. state: '',
  152. settleState: ''
  153. },
  154. // 汇总
  155. totalData: {
  156. count: 0,
  157. totalAmount: 0
  158. },
  159. // 表头
  160. columns: [
  161. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  162. { title: '费用单号', dataIndex: 'accountExpensesNo', width: '20%', align: 'center', scopedSlots: { customRender: 'accountExpensesNo' } },
  163. { title: '创建时间', dataIndex: 'createDate', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  164. { title: '费用类型', scopedSlots: { customRender: 'expensesType' }, width: '20%', align: 'center' },
  165. { title: '金额', dataIndex: 'settleAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  166. // { title: '单据状态', dataIndex: 'stateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  167. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '3%', align: 'center' },
  168. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  169. ],
  170. // 加载数据方法 必须为 Promise 对象
  171. loadData: parameter => {
  172. this.disabled = true
  173. this.spinning = true
  174. return settleExpenseQuery(Object.assign(parameter, this.queryParam)).then(res => {
  175. let data
  176. if (res.status == 200) {
  177. data = res.data
  178. const no = (data.pageNo - 1) * data.pageSize
  179. for (var i = 0; i < data.list.length; i++) {
  180. data.list[i].no = no + i + 1
  181. }
  182. this.disabled = false
  183. // 费用类型
  184. if (this.costTypeList.length == 0) {
  185. this.getCostTypeList()
  186. }
  187. // 汇总
  188. this.totalData.count = data.count
  189. this.settleExpenseQuerySum(Object.assign(parameter, this.queryParam))
  190. }
  191. this.spinning = false
  192. return data
  193. })
  194. },
  195. openModal: false, // 查看详情 弹框
  196. itemId: '' // 当前id
  197. }
  198. },
  199. methods: {
  200. // 时间 change
  201. dateChange (date) {
  202. this.queryParam.beginDate = date[0]
  203. this.queryParam.endDate = date[1]
  204. },
  205. // 递归函数
  206. recursionFun (data) {
  207. if (data) {
  208. data.map((item, index) => {
  209. if (item.children && item.children.length == 0) {
  210. delete item.children
  211. } else {
  212. this.recursionFun(item.children)
  213. }
  214. })
  215. }
  216. },
  217. // 获取费用类型数据
  218. getCostTypeList () {
  219. costTypeAllQuery({}).then(res => {
  220. // 递归去除空children
  221. this.recursionFun(res.data)
  222. this.costTypeList = res.data
  223. })
  224. },
  225. closeDetail () {
  226. this.openModal = false
  227. this.itemId = null
  228. },
  229. // 费用类型 change
  230. changeCostType (val, opt) {
  231. this.queryParam.expensesTypeSn1 = val[0] ? val[0] : ''
  232. this.queryParam.expensesTypeSn2 = val[1] ? val[1] : ''
  233. this.queryParam.expensesTypeSn3 = val[2] ? val[2] : ''
  234. },
  235. // 新增/编辑
  236. handleEdit (row) {
  237. if (row) {
  238. this.$router.push({ name: 'expenseManagementEdit', params: { id: row.id } })
  239. } else {
  240. this.$router.push({ name: 'expenseManagementAdd' })
  241. }
  242. },
  243. // 详情
  244. handleDetail (row) {
  245. if (this.$hasPermissions('B_expenseDetail')) {
  246. this.itemId = row.id
  247. this.openModal = true
  248. }
  249. },
  250. // 审核
  251. handleAudit (row) {
  252. const _this = this
  253. this.$confirm({
  254. title: '提示',
  255. content: '确定要审核吗?',
  256. centered: true,
  257. onOk () {
  258. _this.spinning = true
  259. auditExpense({
  260. id: row.id
  261. }).then(res => {
  262. if (res.status == 200) {
  263. _this.$message.success(res.message)
  264. _this.$refs.table.refresh()
  265. _this.spinning = false
  266. } else {
  267. _this.spinning = false
  268. }
  269. })
  270. }
  271. })
  272. },
  273. // 删除
  274. handleDel (row) {
  275. const _this = this
  276. _this.itemId = row.id
  277. _this.$confirm({
  278. title: '提示',
  279. content: '删除后原数据不可恢复,是否删除?',
  280. centered: true,
  281. onOk () {
  282. _this.spinning = true
  283. delExpense({ id: _this.itemId }).then(res => {
  284. if (res.status == 200) {
  285. _this.$message.success(res.message)
  286. _this.$refs.table.refresh()
  287. _this.spinning = false
  288. } else {
  289. _this.spinning = false
  290. }
  291. })
  292. }
  293. })
  294. },
  295. // 汇总
  296. settleExpenseQuerySum (params) {
  297. settleExpenseQuerySum(params).then(res => {
  298. this.totalData.totalAmount = res.data && res.data.settleAmount || 0
  299. })
  300. },
  301. // 重置
  302. resetSearchForm () {
  303. this.$refs.rangeDate.resetDate()
  304. this.queryParam.beginDate = ''
  305. this.queryParam.endDate = ''
  306. this.queryParam.accountExpensesNo = ''
  307. this.queryParam.expensesTypeSn1 = ''
  308. this.queryParam.expensesTypeSn2 = ''
  309. this.queryParam.expensesTypeSn3 = ''
  310. this.queryParam.state = ''
  311. this.queryParam.settleState = ''
  312. this.queryParam.beginDate = ''
  313. this.queryParam.endDate = ''
  314. this.costType = []
  315. this.$refs.table.refresh(true)
  316. },
  317. pageInit () {
  318. const _this = this
  319. this.$nextTick(() => { // 页面渲染完成后的回调
  320. _this.setTableH()
  321. })
  322. },
  323. setTableH () {
  324. const tableSearchH = this.$refs.tableSearch.offsetHeight
  325. this.tableHeight = window.innerHeight - tableSearchH - 270
  326. }
  327. },
  328. watch: {
  329. advanced (newValue, oldValue) {
  330. const _this = this
  331. this.$nextTick(() => { // 页面渲染完成后的回调
  332. _this.setTableH()
  333. })
  334. },
  335. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  336. this.setTableH()
  337. }
  338. },
  339. mounted () {
  340. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  341. this.pageInit()
  342. this.resetSearchForm()
  343. }
  344. },
  345. activated () {
  346. // 如果是新页签打开,则重置当前页面
  347. if (this.$store.state.app.isNewTab) {
  348. this.pageInit()
  349. this.resetSearchForm()
  350. }
  351. // 仅刷新列表,不重置页面
  352. if (this.$store.state.app.updateList) {
  353. this.pageInit()
  354. this.$refs.table.refresh()
  355. }
  356. },
  357. beforeRouteEnter (to, from, next) {
  358. next(vm => {})
  359. }
  360. }
  361. </script>
  362. <style lang="less">
  363. .expenseManagementList-wrap{
  364. .sTable{
  365. margin-top: 10px;
  366. }
  367. .active{
  368. color: #ed1c24;
  369. cursor: pointer;
  370. }
  371. .common{
  372. color: rgba(0, 0, 0);
  373. }
  374. }
  375. </style>