list.vue 11 KB

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