list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <a-card size="small" :bordered="false" class="expenseManagementList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="费用单号">
  9. <a-input id="expenseManagementList-accountExpensesNo" v-model.trim="queryParam.accountExpensesNo" allowClear placeholder="请输入费用单号"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="创建时间">
  14. <rangeDate ref="rangeDate" @change="dateChange" />
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="费用类型">
  19. <a-cascader
  20. @change="changeCostType"
  21. change-on-select
  22. v-model="costType"
  23. expand-trigger="hover"
  24. :options="costTypeList"
  25. :fieldNames="{ label: 'name', value: 'costTypeSn', children: 'children' }"
  26. id="productInfoList-costType"
  27. placeholder="请选择费用类型"
  28. allowClear />
  29. </a-form-item>
  30. </a-col>
  31. <template v-if="advanced">
  32. <a-col :md="6" :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. </template>
  44. <a-col :md="6" :sm="24">
  45. <span class="table-page-search-submitButtons">
  46. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="expenseManagementList-refresh">查询</a-button>
  47. <a-button style="margin-left: 8px" @click="resetSearchForm()" :disabled="disabled" id="expenseManagementList-reset">重置</a-button>
  48. <a @click="advanced=!advanced" style="margin-left: 8px">
  49. {{ advanced ? '收起' : '展开' }}
  50. <a-icon :type="advanced ? 'up' : 'down'"/>
  51. </a>
  52. </span>
  53. </a-col>
  54. </a-row>
  55. </a-form>
  56. </div>
  57. <!-- 操作按钮 -->
  58. <div class="table-operator">
  59. <a-button id="expenseManagementList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
  60. </div>
  61. <!-- alert -->
  62. <a-alert type="info" showIcon style="margin-bottom:15px">
  63. <div slot="message">共 <strong>{{ totalData.count }}</strong> 条记录,金额共计 <strong>¥{{ totalData.totalAmount }}</strong></div>
  64. </a-alert>
  65. <!-- 列表 -->
  66. <s-table
  67. class="sTable"
  68. ref="table"
  69. size="default"
  70. :rowKey="(record) => record.id"
  71. :columns="columns"
  72. :data="loadData"
  73. :scroll="{ x: 1120, y: tableHeight }"
  74. bordered>
  75. <!-- 费用类别 -->
  76. <template slot="expensesType" slot-scope="text, record">
  77. {{ record.expensesTypeName1 }} <span v-if="record.expensesTypeName2">>{{ record.expensesTypeName2 }}</span> <span v-if="record.expensesTypeName3">>{{ record.expensesTypeName3 }}</span>
  78. </template>
  79. <!-- 状态 -->
  80. <template slot="accountExpensesNo" slot-scope="text, record">
  81. <span style="color: #ed1c24;cursor: pointer;" @click="handleDetail(record)">{{ text }}</span>
  82. </template>
  83. <!-- 操作 -->
  84. <template slot="action" slot-scope="text, record">
  85. <a-button
  86. size="small"
  87. type="link"
  88. v-if="record.state == 'WAIT_AUDIT'"
  89. class="button-warring"
  90. @click="handleAudit(record)"
  91. id="expenseManagement-edit-btn">审核</a-button>
  92. <a-button
  93. size="small"
  94. type="link"
  95. v-if="record.state == 'WAIT_AUDIT'"
  96. class="button-info"
  97. @click="handleEdit(record)"
  98. id="expenseManagement-edit-btn">编辑</a-button>
  99. <a-button
  100. size="small"
  101. type="link"
  102. v-if="record.state == 'WAIT_AUDIT'"
  103. class="button-error"
  104. @click="handleDel(record)"
  105. id="expenseManagement-del-btn">删除</a-button>
  106. <span v-if="record.state != 'WAIT_AUDIT'">--</span>
  107. </template>
  108. </s-table>
  109. <!-- 详情 -->
  110. <expense-management-detail-modal :openModal="openModal" :itemId="itemId" @close="closeDetail" />
  111. </a-card>
  112. </template>
  113. <script>
  114. import { STable, VSelect } from '@/components'
  115. import rangeDate from '@/views/common/rangeDate.vue'
  116. import { settleExpenseQuery, delExpense, settleExpenseQuerySum, auditExpense } from '@/api/settleExpense'
  117. import { costTypeAllQuery } from '@/api/costType'
  118. import expenseManagementDetailModal from './detailModal.vue'
  119. export default {
  120. components: { STable, VSelect, expenseManagementDetailModal, rangeDate },
  121. data () {
  122. return {
  123. tableHeight: 0,
  124. disabled: false, // 查询、重置按钮是否可操作
  125. advanced: false, // 高级搜索 展开/关闭
  126. costTypeList: [], // 费用类型
  127. costType: [],
  128. // 查询参数
  129. queryParam: {
  130. beginDate: '',
  131. endDate: '',
  132. accountExpensesNo: '',
  133. expensesTypeSn1: '',
  134. expensesTypeSn2: '',
  135. expensesTypeSn3: '',
  136. state: '',
  137. settleState: ''
  138. },
  139. // 汇总
  140. totalData: {
  141. count: 0,
  142. totalAmount: 0
  143. },
  144. // 表头
  145. columns: [
  146. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  147. { title: '费用单号', dataIndex: 'accountExpensesNo', width: 250, align: 'center', scopedSlots: { customRender: 'accountExpensesNo' } },
  148. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '费用类型', align: 'center', scopedSlots: { customRender: 'expensesType' } },
  150. { title: '金额', dataIndex: 'settleAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  151. { title: '单据状态', dataIndex: 'stateDictValue', width: 110, align: 'center' },
  152. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  153. ],
  154. // 加载数据方法 必须为 Promise 对象
  155. loadData: parameter => {
  156. this.disabled = true
  157. if (this.tableHeight == 0) {
  158. this.tableHeight = window.innerHeight - 300
  159. }
  160. return settleExpenseQuery(Object.assign(parameter, this.queryParam)).then(res => {
  161. const data = res.data
  162. const no = (data.pageNo - 1) * data.pageSize
  163. for (var i = 0; i < data.list.length; i++) {
  164. data.list[i].no = no + i + 1
  165. }
  166. this.disabled = false
  167. // 费用类型
  168. if (this.costTypeList.length == 0) {
  169. this.getCostTypeList()
  170. }
  171. // 汇总
  172. this.totalData.count = data.count
  173. this.settleExpenseQuerySum(Object.assign(parameter, this.queryParam))
  174. return data
  175. })
  176. },
  177. openModal: false, // 查看详情 弹框
  178. itemId: '' // 当前id
  179. }
  180. },
  181. methods: {
  182. // 时间 change
  183. dateChange (date) {
  184. this.queryParam.beginDate = date[0]
  185. this.queryParam.endDate = date[1]
  186. },
  187. // 递归函数
  188. recursionFun (data) {
  189. if (data) {
  190. data.map((item, index) => {
  191. if (item.children && item.children.length == 0) {
  192. delete item.children
  193. } else {
  194. this.recursionFun(item.children)
  195. }
  196. })
  197. }
  198. },
  199. // 获取费用类型数据
  200. getCostTypeList () {
  201. costTypeAllQuery({}).then(res => {
  202. // 递归去除空children
  203. this.recursionFun(res.data)
  204. this.costTypeList = res.data
  205. })
  206. },
  207. closeDetail () {
  208. this.openModal = false
  209. this.itemId = null
  210. },
  211. // 费用类型 change
  212. changeCostType (val, opt) {
  213. this.queryParam.expensesTypeSn1 = val[0] ? val[0] : ''
  214. this.queryParam.expensesTypeSn2 = val[1] ? val[1] : ''
  215. this.queryParam.expensesTypeSn3 = val[2] ? val[2] : ''
  216. },
  217. // 新增/编辑
  218. handleEdit (row) {
  219. if (row) {
  220. this.$router.push({ name: 'expenseManagementEdit', params: { id: row.id } })
  221. } else {
  222. this.$router.push({ name: 'expenseManagementAdd' })
  223. }
  224. },
  225. // 详情
  226. handleDetail (row) {
  227. this.itemId = row.id
  228. this.openModal = true
  229. },
  230. // 审核
  231. handleAudit (row) {
  232. const _this = this
  233. this.$confirm({
  234. title: '提示',
  235. content: '确定要审核吗?',
  236. centered: true,
  237. onOk () {
  238. auditExpense({
  239. id: row.id
  240. }).then(res => {
  241. if (res.status == 200) {
  242. _this.$message.success(res.message)
  243. _this.$refs.table.refresh()
  244. }
  245. })
  246. }
  247. })
  248. },
  249. // 删除
  250. handleDel (row) {
  251. const _this = this
  252. _this.itemId = row.id
  253. _this.$confirm({
  254. title: '提示',
  255. content: '删除后原数据不可恢复,是否删除?',
  256. centered: true,
  257. onOk () {
  258. delExpense({ id: _this.itemId }).then(res => {
  259. if (res.status == 200) {
  260. _this.$message.success(res.message)
  261. _this.$refs.table.refresh()
  262. }
  263. })
  264. }
  265. })
  266. },
  267. // 汇总
  268. settleExpenseQuerySum (params) {
  269. settleExpenseQuerySum(params).then(res => {
  270. this.totalData.totalAmount = res.data.settleAmount || 0
  271. })
  272. },
  273. // 重置
  274. resetSearchForm () {
  275. this.$refs.rangeDate.resetDate()
  276. this.queryParam.beginDate = ''
  277. this.queryParam.endDate = ''
  278. this.queryParam.accountExpensesNo = ''
  279. this.queryParam.expensesTypeSn1 = ''
  280. this.queryParam.expensesTypeSn2 = ''
  281. this.queryParam.expensesTypeSn3 = ''
  282. this.queryParam.state = ''
  283. this.queryParam.settleState = ''
  284. this.queryParam.beginDate = ''
  285. this.queryParam.endDate = ''
  286. this.costType = []
  287. this.$refs.table.refresh(true)
  288. }
  289. }
  290. }
  291. </script>
  292. <style lang="less">
  293. .expenseManagementList-wrap{
  294. .sTable{
  295. margin-top: 15px;
  296. }
  297. }
  298. </style>