list.vue 19 KB

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