list.vue 18 KB

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