list.vue 18 KB

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