list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline">
  7. <a-row :gutter="15">
  8. <a-col :md="4" :sm="24">
  9. <a-form-item label="费用发生月份">
  10. <a-month-picker
  11. placeholder="请选择月份"
  12. locale="zh-cn"
  13. v-model="queryParam.expenseDate"
  14. @change="onChange"
  15. :disabled-date="disabledDate"
  16. style="width: 100%;"/>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="6" :sm="24">
  20. <a-form-item label="费用单号" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  21. <a-input id="salesManagementList-expenseAccountNo" v-model.trim="queryParam.expenseAccountNo" allowClear placeholder="请输入费用单号"/>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :md="4" :sm="24">
  25. <a-form-item label="申请人" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  26. <employee style="width: 100%;" id="salesManagementList-Employee" v-model="queryParam.applyPersonSn"></employee>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="4" :sm="24">
  30. <a-form-item label="费用类型">
  31. <expenseType
  32. id="salesManagementList-expenseType"
  33. :changeOnSelect="true"
  34. v-model="expenseTypes"
  35. @change="expenseChange"
  36. placeholder="请选择费用类型"
  37. ></expenseType>
  38. </a-form-item>
  39. </a-col>
  40. <template v-if="advanced">
  41. <a-col :md="6" :sm="24">
  42. <a-form-item label="主题">
  43. <a-input id="salesManagementList-title" v-model.trim="queryParam.title" allowClear placeholder="请输入主题"/>
  44. </a-form-item>
  45. </a-col>
  46. <a-col :md="4" :sm="24">
  47. <a-form-item label="打印状态">
  48. <v-select
  49. v-model="queryParam.printStatus"
  50. ref="printStatus"
  51. id="pushOrder-printStatus"
  52. code="EXPENSE_ACCOUNT_PRINT_STATUS"
  53. placeholder="请选择打印状态"
  54. allowClear></v-select>
  55. </a-form-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-item label="销售单号">
  59. <a-input id="salesManagementList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  60. </a-form-item>
  61. </a-col>
  62. <a-col :md="4" :sm="24">
  63. <a-form-item label="状态">
  64. <v-select
  65. v-model="queryParam.state"
  66. ref="state"
  67. id="salesManagementList-state"
  68. code="EXPENSE_STATE"
  69. placeholder="请选择状态"
  70. allowClear></v-select>
  71. </a-form-item>
  72. </a-col>
  73. <!-- <a-col :md="4" :sm="24" v-show="isShowCustomerSearch">
  74. <a-form-item label="客服">
  75. <customerService ref="customerName" v-model="queryParam.bizUserSn"></customerService>
  76. </a-form-item>
  77. </a-col> -->
  78. </template>
  79. <a-col :md="6" :sm="24">
  80. <span class="table-page-search-submitButtons">
  81. <a-button type="primary" :disabled="disabled" @click="searchForm" id="salesManagementList-search">查询</a-button>
  82. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()" id="salesManagementList-reset">重置</a-button>
  83. <a @click="advanced=!advanced" style="margin-left: 8px" id="salesManagementList-advanced">
  84. {{ advanced ? '收起' : '展开' }}
  85. <a-icon :type="advanced ? 'up' : 'down'"/>
  86. </a>
  87. </span>
  88. </a-col>
  89. </a-row>
  90. </a-form>
  91. </div>
  92. </a-card>
  93. <a-card size="small" :bordered="false" class="salesManagementList-wrap">
  94. <a-spin :spinning="spinning" tip="Loading...">
  95. <!-- 操作按钮 -->
  96. <div class="table-operator">
  97. <a-button id="salesManagementList-add" type="primary" v-if="$hasPermissions('B_eRNew')" @click="handleEdit()">新增</a-button>
  98. <a-button
  99. id="salesManagementList-batchPrint"
  100. type="primary"
  101. v-if="$hasPermissions('B_eRPrint')"
  102. :loading="spinning"
  103. @click="handlePlPrint()"
  104. ghost>批量打印</a-button>
  105. <a-checkbox id="salesManagementList-print-remarks" v-model="printRemark" v-if="$hasPermissions('B_eRPrint')">打印备注</a-checkbox>
  106. <span style="margin-left: 8px" v-if="$hasPermissions('B_eRPrint')">
  107. <template v-if="rowSelectionInfo && rowSelectionInfo.selectedRowKeys.length>0">{{ `已选 ${rowSelectionInfo.selectedRowKeys.length} 项` }}</template>
  108. </span>
  109. </div>
  110. <!-- 列表 -->
  111. <s-table
  112. class="sTable fixPagination"
  113. ref="table"
  114. :row-selection="$hasPermissions('B_eRPrint')?{ columnWidth: '4%', getCheckboxProps: record => ({ props: { disabled: false } })}:null"
  115. @rowSelection="rowSelectionFun"
  116. :style="{ height: tableHeight+70+'px' }"
  117. size="small"
  118. :rowKey="(record) => record.id"
  119. :columns="columns"
  120. :pageSize="30"
  121. :data="loadData"
  122. :scroll="{ y: tableHeight }"
  123. :defaultLoadData="false"
  124. bordered>
  125. <!-- 单号 -->
  126. <template slot="expenseAccountNo" slot-scope="text, record">
  127. <span :id="'salesManagementList-detail-'+record.id" v-if="$hasPermissions('B_eRdetail')" class="link-bule" @click="handleDetail(record)">{{ record.expenseAccountNo }}</span>
  128. <div v-else>{{ record.expenseAccountNo||'--' }}</div>
  129. </template>
  130. <!-- 总数量 -->
  131. <template slot="totalQty" slot-scope="text, record">
  132. {{ record.totalQty }}
  133. </template>
  134. <!-- 费用类型 -->
  135. <template slot="expenseType" slot-scope="text, record">
  136. <div>{{ record.expenseTypeName || '--' }}<span v-if="record.expenseType2">/{{ record.expenseTypeName2 || '--' }}</span><span v-if="record.expenseType3">/{{ record.expenseTypeName3 || '--' }}</span></div>
  137. </template>
  138. <!-- 操作 -->
  139. <template slot="action" slot-scope="text, record">
  140. <div>
  141. <a-button
  142. :id="'salesManagementList-edit-'+record.id"
  143. v-if="record.state=='WAIT_SUBMIT'&&$hasPermissions('B_ERtEdit')"
  144. size="small"
  145. type="link"
  146. class="button-info"
  147. @click="handleEdit(record)"
  148. >
  149. 编辑
  150. </a-button>
  151. <a-button
  152. :id="'salesManagementList-audit-'+record.id"
  153. v-if="record.state!='WAIT_SUBMIT'&&$hasPermissions('B_ERAudit')"
  154. size="small"
  155. type="link"
  156. class="button-info"
  157. @click="handleSH(record)"
  158. >
  159. 审核进度
  160. </a-button>
  161. <a-button
  162. :id="'salesManagementList-editAge-'+record.id"
  163. v-if="record.state=='AUDIT_REJECT'"
  164. size="small"
  165. type="link"
  166. class="button-info"
  167. @click="againEdit(record)"
  168. >
  169. 再次编辑
  170. </a-button>
  171. <a-button
  172. :id="'salesManagementList-del-'+record.id"
  173. v-if="(record.state=='WAIT_SUBMIT'||record.state=='AUDIT_REJECT')&&$hasPermissions('B_ERDel')"
  174. size="small"
  175. type="link"
  176. class="button-error"
  177. @click="handleDel(record)"
  178. >
  179. 删除
  180. </a-button>
  181. </div>
  182. </template>
  183. </s-table>
  184. </a-spin>
  185. <!-- 审核进度 -->
  186. <verifyModal v-drag :openModal="openModal" :itemSn="itemSn" @close="openModal=false"></verifyModal>
  187. <!-- 新增 -->
  188. <baseDataModal :show="openBaseModal" @close="openBaseModal=false"></baseDataModal>
  189. <!-- 打印预览 -->
  190. <commonModal
  191. modalTit="费用报销单打印预览"
  192. width="700pt"
  193. okText="立即打印"
  194. :openModal="showTipModal"
  195. @cancel="showTipModal=false"
  196. @ok="$refs.printModal.prints()">
  197. <previewModal v-if="showTipModal" ref="printModal" @printOk="printOk"></previewModal>
  198. </commonModal>
  199. </a-card>
  200. </div>
  201. </template>
  202. <script>
  203. import { commonMixin } from '@/utils/mixin'
  204. import locale from 'ant-design-vue/es/date-picker/locale/zh_CN'
  205. import moment from 'moment'
  206. import subarea from '@/views/common/subarea.js'
  207. import employee from './employee.js'
  208. import { STable, VSelect } from '@/components'
  209. import verifyModal from './verifyModal.vue'
  210. import previewModal from './previewModal.vue'
  211. import commonModal from '@/views/common/commonModal.vue'
  212. import expenseType from '@/views/common/expenseType.js'
  213. import { getBatchLastProcessInstance } from '@/api/financeBook'
  214. import customerService from '@/views/common/customerService'
  215. import { expenseAccountList, expenseAccountDelete, expenseAccountAgainEdit, expenseAcctDetailFindList, expenseAccountUpdateBatch } from '@/api/expenseManagement'
  216. import baseDataModal from './baseDataModal.vue'
  217. export default {
  218. name: 'ExpenseReimbursementList',
  219. mixins: [commonMixin],
  220. components: { STable, VSelect, subarea, verifyModal, baseDataModal, employee, expenseType, previewModal, commonModal, customerService },
  221. data () {
  222. const _this = this
  223. return {
  224. locale,
  225. spinning: false,
  226. advanced: true, // 高级搜索 展开/关闭
  227. disabled: false, // 查询、重置按钮是否可操作
  228. openModal: false, // 审核进度弹框是否显示
  229. openBaseModal: false, // 基础信息新建
  230. showTipModal: false, // 打印预览组件
  231. itemSn: '', // 费用单sn
  232. tableHeight: 0, // 表格高度
  233. expenseTypes: [], // 费用类型
  234. // 查询参数
  235. queryParam: {
  236. expenseDate: moment().format('YYYY-MM'), // 月份
  237. expenseAccountNo: '', // 费用单号
  238. title: '', // 主题
  239. expenseType: undefined, // 费用类型
  240. expenseType2: undefined, // 费用类型2
  241. expenseType3: undefined, // 费用类型3
  242. printStatus: undefined, // 打印状态
  243. state: undefined, // 状态
  244. salesBillNo: '', // 销售单号
  245. bizUserSn: undefined // 客服
  246. },
  247. columns: [
  248. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  249. { title: '费用单号', width: '8%', align: 'center', scopedSlots: { customRender: 'expenseAccountNo' } },
  250. { title: '申请人', dataIndex: 'applyPersonName', width: '6%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  251. { title: '申请部门', dataIndex: 'applyDepartmentName', width: '8%', align: 'left', customRender: function (text) { return text || '--' } },
  252. { title: '费用类型', scopedSlots: { customRender: 'expenseType' }, width: '8%', align: 'left' },
  253. { title: '费用发生月份', dataIndex: 'expenseDate', width: '6%', align: 'center', customRender: function (text) { return moment(text).format('YYYY年MM月') || '--' } },
  254. { title: '主题', dataIndex: 'title', width: '10%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  255. { title: '合计金额', dataIndex: 'applyExpenseTotal', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  256. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  257. { title: '审核时间', dataIndex: 'finishDate', width: '8%', align: 'center', customRender: function (text, record) { return record.state == 'AUDIT_REJECT' || record.state == 'AUDIT_PASS' ? text : '--' } },
  258. { title: '打印状态', dataIndex: 'printStatusDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  259. { title: '状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  260. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  261. ],
  262. // 加载数据方法 必须为 Promise 对象
  263. loadData: parameter => {
  264. this.disabled = true
  265. this.spinning = true
  266. delete parameter.tableId
  267. delete parameter.index
  268. const params = Object.assign(parameter, this.queryParam)
  269. if (params.expenseDate) {
  270. params.expenseDate = params.expenseDate + '-01'
  271. }
  272. return expenseAccountList(params).then(res => {
  273. let data
  274. if (res.status == 200) {
  275. data = res.data
  276. const no = (data.pageNo - 1) * data.pageSize
  277. for (var i = 0; i < data.list.length; i++) {
  278. data.list[i].no = no + i + 1
  279. data.list[i].content = data.list[i].content ? data.list[i].content.replace(/\n+/, '\n').split('\n') : ''
  280. }
  281. this.disabled = false
  282. }
  283. this.spinning = false
  284. return data
  285. })
  286. },
  287. rowSelectionInfo: null, // 批量选择的数据
  288. printRemark: false // 是否打印备注
  289. }
  290. },
  291. methods: {
  292. // 表格选中项
  293. rowSelectionFun (obj) {
  294. this.rowSelectionInfo = obj || null
  295. },
  296. // 打印结束,记录打印状态
  297. printOk (data) {
  298. if (data && data.status == 200) {
  299. const rows = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  300. const ret = []
  301. rows.map(item => {
  302. ret.push({
  303. id: item.id,
  304. printStatus: 'PRINT'
  305. })
  306. })
  307. expenseAccountUpdateBatch(ret).then(res => {
  308. if (res.status == 200) {
  309. this.$refs.table.refresh()
  310. this.$refs.table.clearSelected()
  311. }
  312. this.spinning = false
  313. this.showTipModal = false
  314. })
  315. } else {
  316. this.spinning = false
  317. }
  318. },
  319. // 批量打印
  320. async handlePlPrint () {
  321. const _this = this
  322. const rows = _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows || []
  323. const slen = rows.length
  324. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
  325. _this.$message.warning('请在列表勾选后再进行批量操作!')
  326. return false
  327. }
  328. // 开始打印
  329. this.spinning = true
  330. const pageData = []
  331. const businessSnList = []
  332. // 循环获取
  333. for (let i = 0; i < rows.length; i++) {
  334. // 费用明细
  335. const fyListData = await expenseAcctDetailFindList({ expenseAccountSn: rows[i].expenseAccountSn }).then(res => res.data)
  336. // 审核明细,待提交状态不获取
  337. if (rows[i].state != 'WAIT_SUBMIT') {
  338. businessSnList.push(rows[i].expenseAccountSn)
  339. }
  340. // 组装数据
  341. pageData.push({
  342. printRemark: this.printRemark,
  343. expenseInfo: rows[i],
  344. fyListData: fyListData,
  345. spListData: []
  346. })
  347. }
  348. // 获取审核进度信息
  349. const spListData = await getBatchLastProcessInstance({ 'businessType': 'EXPENSES', 'businessSnList': businessSnList }).then(res => res.data)
  350. pageData.map(item => {
  351. if (spListData) {
  352. const sp = spListData[item.expenseInfo.expenseAccountSn]
  353. item.spListData = sp ? sp.taskVOList : []
  354. }
  355. })
  356. // 打开预览弹框
  357. this.showTipModal = true
  358. this.$nextTick(() => {
  359. this.$refs.printModal.setData(pageData)
  360. this.spinning = false
  361. })
  362. },
  363. // 费用发生月份
  364. onChange (date, dateString) {
  365. this.queryParam.expenseDate = dateString
  366. },
  367. // 费用发生月份禁用范围
  368. disabledDate (current) {
  369. return current && current > moment().endOf('day')
  370. },
  371. // 费用类型选择
  372. expenseChange (val, opts) {
  373. this.expenseTypes = val || []
  374. this.queryParam.expenseType = val && val[0] ? val[0] : ''
  375. this.queryParam.expenseType2 = val && val[1] ? val[1] : ''
  376. this.queryParam.expenseType3 = val && val[2] ? val[2] : ''
  377. },
  378. // 详情页面
  379. handleDetail (row) {
  380. this.$router.push({ name: 'expenseReimbursementListDetail', params: { sn: row.expenseAccountSn } })
  381. },
  382. // 新增、编辑
  383. handleEdit (row) {
  384. // 编辑
  385. if (row && row.expenseAccountSn) {
  386. this.$router.push({ name: 'expenseReimbursementEdit', params: { sn: row.expenseAccountSn } })
  387. } else {
  388. this.openBaseModal = true
  389. }
  390. },
  391. // 删除
  392. handleDel (row) {
  393. const _this = this
  394. this.$confirm({
  395. title: '提示',
  396. content: '确认要删除吗?',
  397. centered: true,
  398. closable: true,
  399. onOk () {
  400. _this.spinning = true
  401. expenseAccountDelete({ expenseAccountSn: row.expenseAccountSn }).then(res => {
  402. if (res.status == 200) {
  403. _this.$message.success(res.message)
  404. _this.$refs.table.refresh()
  405. }
  406. _this.spinning = false
  407. })
  408. }
  409. })
  410. },
  411. // 审核进度弹框
  412. handleSH (row) {
  413. this.openModal = true
  414. this.itemSn = row.expenseAccountSn
  415. },
  416. // 再次编辑
  417. againEdit (row) {
  418. const _this = this
  419. this.$confirm({
  420. title: '操作提示',
  421. content: '系统将自动生成一个新的费用报销单,与原审核不通过的单据内容相同。您可以对新单据进行编辑、提交等操作,原单据保持不变,确认操作吗?',
  422. centered: true,
  423. closable: true,
  424. onOk () {
  425. _this.spinning = true
  426. expenseAccountAgainEdit({ expenseAccountSn: row.expenseAccountSn }).then(res => {
  427. if (res.status == 200) {
  428. _this.$message.success(res.message)
  429. _this.resetSearchForm()
  430. }
  431. _this.spinning = false
  432. })
  433. }
  434. })
  435. },
  436. // 查询列表
  437. searchForm () {
  438. this.$refs.table.refresh(true)
  439. this.$refs.table.clearSelected()
  440. },
  441. // 重置列表
  442. resetSearchForm () {
  443. this.queryParam = {
  444. expenseDate: '', // 月份
  445. expenseAccountNo: '', // 费用单号
  446. title: '', // 主题
  447. expenseType: undefined, // 费用类型
  448. expenseType2: undefined, // 费用类型2
  449. expenseType3: undefined, // 费用类型3
  450. state: undefined, // 状态
  451. printStatus: undefined,
  452. applyPersonSn: undefined,
  453. salesBillNo: '', // 销售单号
  454. bizUserSn: undefined
  455. }
  456. this.expenseTypes = []
  457. this.searchForm()
  458. },
  459. // 页面初始化
  460. pageInit () {
  461. const _this = this
  462. this.$nextTick(() => { // 页面渲染完成后的回调
  463. _this.setTableH()
  464. })
  465. },
  466. // 计算表格高度
  467. setTableH () {
  468. const tableSearchH = this.$refs.tableSearch.offsetHeight
  469. this.tableHeight = window.innerHeight - tableSearchH - 240
  470. }
  471. },
  472. watch: {
  473. advanced (newValue, oldValue) {
  474. const _this = this
  475. this.$nextTick(() => { // 页面渲染完成后的回调
  476. _this.setTableH()
  477. })
  478. },
  479. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  480. this.setTableH()
  481. }
  482. },
  483. mounted () {
  484. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  485. this.pageInit()
  486. this.resetSearchForm()
  487. }
  488. },
  489. activated () {
  490. // 如果是新页签打开,则重置当前页面
  491. if (this.$store.state.app.isNewTab) {
  492. this.pageInit()
  493. this.resetSearchForm()
  494. }
  495. // 仅刷新列表,不重置页面
  496. if (this.$store.state.app.updateList) {
  497. this.pageInit()
  498. this.$refs.table.refresh()
  499. }
  500. },
  501. beforeRouteEnter (to, from, next) {
  502. next(vm => {})
  503. }
  504. }
  505. </script>
  506. <style lang="less">
  507. .salesManagementList-wrap{
  508. .sTable{
  509. .badge-con-t{
  510. .ant-badge-count{
  511. transform: scale(0.8);
  512. font-size: 13px;
  513. }
  514. }
  515. }
  516. }
  517. </style>