list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <a-card size="small" :bordered="false" class="expenseManagementList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div 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. <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="6" :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="6" :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" showIcon 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) ? '¥'+totalData.totalAmount : '--' }}</strong>
  67. </div>
  68. </a-alert>
  69. <!-- 列表 -->
  70. <s-table
  71. class="sTable"
  72. ref="table"
  73. size="default"
  74. :rowKey="(record) => record.id"
  75. :columns="columns"
  76. :data="loadData"
  77. :scroll="{ x: 1120, y: tableHeight }"
  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')?'active':'common'" @click="handleDetail(record)">{{ text }}</span>
  86. </template>
  87. <!-- 操作 -->
  88. <template slot="action" slot-scope="text, record">
  89. <a-button
  90. size="small"
  91. type="link"
  92. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseAudit')"
  93. class="button-warning"
  94. @click="handleAudit(record)"
  95. id="expenseManagement-audit-btn">审核</a-button>
  96. <a-button
  97. size="small"
  98. type="link"
  99. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseEdit')"
  100. class="button-info"
  101. @click="handleEdit(record)"
  102. id="expenseManagement-edit-btn">编辑</a-button>
  103. <a-button
  104. size="small"
  105. type="link"
  106. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_expenseDel')"
  107. class="button-error"
  108. @click="handleDel(record)"
  109. id="expenseManagement-del-btn">删除</a-button>
  110. <span v-if="record.state != 'WAIT_AUDIT'||( !$hasPermissions('B_expenseAudit')&& !$hasPermissions('B_expenseEdit') && !$hasPermissions('B_expenseDel'))">--</span>
  111. </template>
  112. </s-table>
  113. </a-spin>
  114. <!-- 详情 -->
  115. <expense-management-detail-modal :openModal="openModal" :itemId="itemId" @close="closeDetail" />
  116. </a-card>
  117. </template>
  118. <script>
  119. import { STable, VSelect } from '@/components'
  120. import rangeDate from '@/views/common/rangeDate.vue'
  121. import { settleExpenseQuery, delExpense, settleExpenseQuerySum, auditExpense } from '@/api/settleExpense'
  122. import { costTypeAllQuery } from '@/api/costType'
  123. import expenseManagementDetailModal from './detailModal.vue'
  124. export default {
  125. components: { STable, VSelect, expenseManagementDetailModal, rangeDate },
  126. data () {
  127. return {
  128. spinning: false,
  129. tableHeight: 0,
  130. disabled: false, // 查询、重置按钮是否可操作
  131. advanced: false, // 高级搜索 展开/关闭
  132. costTypeList: [], // 费用类型
  133. costType: [],
  134. // 查询参数
  135. queryParam: {
  136. beginDate: '',
  137. endDate: '',
  138. accountExpensesNo: '',
  139. expensesTypeSn1: '',
  140. expensesTypeSn2: '',
  141. expensesTypeSn3: '',
  142. state: '',
  143. settleState: ''
  144. },
  145. // 汇总
  146. totalData: {
  147. count: 0,
  148. totalAmount: 0
  149. },
  150. // 表头
  151. columns: [
  152. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  153. { title: '费用单号', dataIndex: 'accountExpensesNo', width: 250, align: 'center', scopedSlots: { customRender: 'accountExpensesNo' } },
  154. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  155. { title: '费用类型', align: 'center', scopedSlots: { customRender: 'expensesType' } },
  156. { title: '金额', dataIndex: 'settleAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  157. { title: '单据状态', dataIndex: 'stateDictValue', width: 110, align: 'center', customRender: function (text) { return text || '--' } },
  158. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  159. ],
  160. // 加载数据方法 必须为 Promise 对象
  161. loadData: parameter => {
  162. this.disabled = true
  163. if (this.tableHeight == 0) {
  164. this.tableHeight = window.innerHeight - 300
  165. }
  166. return settleExpenseQuery(Object.assign(parameter, this.queryParam)).then(res => {
  167. const data = res.data
  168. const no = (data.pageNo - 1) * data.pageSize
  169. for (var i = 0; i < data.list.length; i++) {
  170. data.list[i].no = no + i + 1
  171. }
  172. this.disabled = false
  173. // 费用类型
  174. if (this.costTypeList.length == 0) {
  175. this.getCostTypeList()
  176. }
  177. // 汇总
  178. this.totalData.count = data.count
  179. this.settleExpenseQuerySum(Object.assign(parameter, this.queryParam))
  180. return data
  181. })
  182. },
  183. openModal: false, // 查看详情 弹框
  184. itemId: '' // 当前id
  185. }
  186. },
  187. methods: {
  188. // 时间 change
  189. dateChange (date) {
  190. this.queryParam.beginDate = date[0]
  191. this.queryParam.endDate = date[1]
  192. },
  193. // 递归函数
  194. recursionFun (data) {
  195. if (data) {
  196. data.map((item, index) => {
  197. if (item.children && item.children.length == 0) {
  198. delete item.children
  199. } else {
  200. this.recursionFun(item.children)
  201. }
  202. })
  203. }
  204. },
  205. // 获取费用类型数据
  206. getCostTypeList () {
  207. costTypeAllQuery({}).then(res => {
  208. // 递归去除空children
  209. this.recursionFun(res.data)
  210. this.costTypeList = res.data
  211. })
  212. },
  213. closeDetail () {
  214. this.openModal = false
  215. this.itemId = null
  216. },
  217. // 费用类型 change
  218. changeCostType (val, opt) {
  219. this.queryParam.expensesTypeSn1 = val[0] ? val[0] : ''
  220. this.queryParam.expensesTypeSn2 = val[1] ? val[1] : ''
  221. this.queryParam.expensesTypeSn3 = val[2] ? val[2] : ''
  222. },
  223. // 新增/编辑
  224. handleEdit (row) {
  225. if (row) {
  226. this.$router.push({ name: 'expenseManagementEdit', params: { id: row.id } })
  227. } else {
  228. this.$router.push({ name: 'expenseManagementAdd' })
  229. }
  230. },
  231. // 详情
  232. handleDetail (row) {
  233. if (this.$hasPermissions('B_expenseDetail')) {
  234. this.itemId = row.id
  235. this.openModal = true
  236. }
  237. },
  238. // 审核
  239. handleAudit (row) {
  240. const _this = this
  241. this.$confirm({
  242. title: '提示',
  243. content: '确定要审核吗?',
  244. centered: true,
  245. onOk () {
  246. _this.spinning = true
  247. auditExpense({
  248. id: row.id
  249. }).then(res => {
  250. if (res.status == 200) {
  251. _this.$message.success(res.message)
  252. _this.$refs.table.refresh()
  253. _this.spinning = false
  254. } else {
  255. _this.spinning = false
  256. }
  257. })
  258. }
  259. })
  260. },
  261. // 删除
  262. handleDel (row) {
  263. const _this = this
  264. _this.itemId = row.id
  265. _this.$confirm({
  266. title: '提示',
  267. content: '删除后原数据不可恢复,是否删除?',
  268. centered: true,
  269. onOk () {
  270. _this.spinning = true
  271. delExpense({ id: _this.itemId }).then(res => {
  272. if (res.status == 200) {
  273. _this.$message.success(res.message)
  274. _this.$refs.table.refresh()
  275. _this.spinning = false
  276. } else {
  277. _this.spinning = false
  278. }
  279. })
  280. }
  281. })
  282. },
  283. // 汇总
  284. settleExpenseQuerySum (params) {
  285. settleExpenseQuerySum(params).then(res => {
  286. this.totalData.totalAmount = res.data && res.data.settleAmount || 0
  287. })
  288. },
  289. // 重置
  290. resetSearchForm () {
  291. this.$refs.rangeDate.resetDate()
  292. this.queryParam.beginDate = ''
  293. this.queryParam.endDate = ''
  294. this.queryParam.accountExpensesNo = ''
  295. this.queryParam.expensesTypeSn1 = ''
  296. this.queryParam.expensesTypeSn2 = ''
  297. this.queryParam.expensesTypeSn3 = ''
  298. this.queryParam.state = ''
  299. this.queryParam.settleState = ''
  300. this.queryParam.beginDate = ''
  301. this.queryParam.endDate = ''
  302. this.costType = []
  303. this.$refs.table.refresh(true)
  304. }
  305. }
  306. }
  307. </script>
  308. <style lang="less">
  309. .expenseManagementList-wrap{
  310. .sTable{
  311. margin-top: 15px;
  312. }
  313. .active{
  314. color: #ed1c24;
  315. cursor: pointer;
  316. }
  317. .common{
  318. color: rgba(0, 0, 0, 0.65);
  319. }
  320. }
  321. </style>