list.vue 13 KB

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