list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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="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. <previewModal ref="printModal" @printOk="printOk"></previewModal>
  165. </a-card>
  166. </template>
  167. <script>
  168. import { commonMixin } from '@/utils/mixin'
  169. import locale from 'ant-design-vue/es/date-picker/locale/zh_CN'
  170. import moment from 'moment'
  171. import subarea from '@/views/common/subarea.js'
  172. import employee from './employee.js'
  173. import { STable, VSelect } from '@/components'
  174. import verifyModal from './verifyModal.vue'
  175. import previewModal from './previewModal.vue'
  176. import expenseType from '@/views/common/expenseType.js'
  177. import { getBatchLastProcessInstance } from '@/api/financeBook'
  178. import { expenseAccountList, expenseAccountDelete, expenseAccountAgainEdit, expenseAcctDetailFindList } from '@/api/expenseManagement'
  179. import baseDataModal from './baseDataModal.vue'
  180. export default {
  181. name: 'ExpenseReimbursementList',
  182. mixins: [commonMixin],
  183. components: { STable, VSelect, subarea, verifyModal, baseDataModal, employee, expenseType, previewModal },
  184. data () {
  185. let _this=this
  186. return {
  187. locale,
  188. spinning: false,
  189. advanced: false, // 高级搜索 展开/关闭
  190. disabled: false, // 查询、重置按钮是否可操作
  191. openModal: false, // 审核进度弹框是否显示
  192. openBaseModal: false, // 基础信息新建
  193. itemSn: '', // 费用单sn
  194. tableHeight: 0,
  195. expenseTypes: [],
  196. // 查询参数
  197. queryParam: {
  198. expenseDate: moment().format('YYYY-MM'), // 月份
  199. expenseAccountNo: '', // 费用单号
  200. title: '', // 主题
  201. expenseType: undefined, // 费用类型
  202. expenseType2: undefined, // 费用类型2
  203. printStatus: undefined, // 打印状态
  204. state: undefined // 状态
  205. },
  206. columns: [
  207. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  208. { title: '费用单号', width: '8%', align: 'center', scopedSlots: { customRender: 'expenseAccountNo' } },
  209. { title: '申请人', dataIndex: 'applyPersonName', width: '6%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  210. { title: '申请部门', dataIndex: 'applyDepartmentName', width: '8%', align: 'left', customRender: function (text) { return text || '--' } },
  211. { title: '费用类型', scopedSlots: { customRender: 'expenseType' }, width: '8%', align: 'left' },
  212. { title: '费用发生月份', dataIndex: 'expenseDate', width: '6%', align: 'center', customRender: function (text) { return moment(text).format('YYYY年MM月') || '--' } },
  213. { title: '主题', dataIndex: 'title', width: '10%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  214. { title: '合计金额', dataIndex: 'applyExpenseTotal', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  215. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  216. { title: '审核时间', dataIndex: 'finishDate', width: '8%', align: 'center', customRender: function (text, record) { return record.state == 'AUDIT_REJECT' || record.state == 'AUDIT_PASS' ? text : '--' } },
  217. { title: '打印状态', dataIndex: 'printStatusDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  218. { title: '状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  220. ],
  221. // 加载数据方法 必须为 Promise 对象
  222. loadData: parameter => {
  223. this.disabled = true
  224. this.spinning = true
  225. delete parameter.tableId
  226. delete parameter.index
  227. const params = Object.assign(parameter, this.queryParam)
  228. if (params.expenseDate) {
  229. params.expenseDate = params.expenseDate + '-01'
  230. }
  231. return expenseAccountList(params).then(res => {
  232. let data
  233. if (res.status == 200) {
  234. data = res.data
  235. const no = (data.pageNo - 1) * data.pageSize
  236. for (var i = 0; i < data.list.length; i++) {
  237. data.list[i].no = no + i + 1
  238. data.list[i].content = data.list[i].content ? data.list[i].content.replace(/\n+/, '\n').split('\n') : ''
  239. }
  240. this.disabled = false
  241. }
  242. this.spinning = false
  243. return data
  244. })
  245. },
  246. rowSelectionInfo: null // 批量选择的数据
  247. }
  248. },
  249. methods: {
  250. // 表格选中项
  251. rowSelectionFun (obj) {
  252. this.rowSelectionInfo = obj || null
  253. },
  254. printOk(res){
  255. this.spinning = false
  256. if(res&&res.status == 200){
  257. this.$refs.table.refresh()
  258. }
  259. },
  260. // 批量打印
  261. async handlePlPrint () {
  262. const _this = this
  263. const rows = _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows || []
  264. const slen = rows.length
  265. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
  266. _this.$message.warning('请在列表勾选后再进行批量操作!')
  267. return false
  268. }
  269. this.spinning = true
  270. const pageData = []
  271. const businessSnList = []
  272. for(let i=0;i<rows.length;i++){
  273. // 费用明细
  274. const fyListData = await expenseAcctDetailFindList({ expenseAccountSn: rows[i].expenseAccountSn }).then(res => res.data)
  275. // 审核明细,待提交状态不获取
  276. if(rows[i].state != 'WAIT_SUBMIT'){
  277. businessSnList.push(rows[i].expenseAccountSn)
  278. }
  279. pageData.push({
  280. expenseInfo: rows[i],
  281. fyListData: fyListData,
  282. spListData: []
  283. })
  284. }
  285. // 获取审核进度信息
  286. const spListData = await getBatchLastProcessInstance({ 'businessType': 'EXPENSES', 'businessSnList': businessSnList }).then(res => res.data)
  287. pageData.map(item => {
  288. const sp = spListData[item.expenseInfo.expenseAccountSn]
  289. item.spListData = sp ? sp.taskVOList : []
  290. })
  291. console.log(pageData)
  292. this.$refs.printModal.setData(pageData)
  293. },
  294. onChange (date, dateString) {
  295. this.queryParam.expenseDate = dateString
  296. },
  297. disabledDate (current) {
  298. return current && current > moment().endOf('day')
  299. },
  300. expenseChange (val, opts) {
  301. console.log(val, opts)
  302. this.expenseTypes = val || []
  303. this.queryParam.expenseType = val && val[0] ? val[0] : ''
  304. this.queryParam.expenseType2 = val && val[1] ? val[1] : ''
  305. },
  306. // 详情
  307. handleDetail (row) {
  308. this.$router.push({ name: 'expenseReimbursementListDetail', params: { sn: row.expenseAccountSn } })
  309. },
  310. // 新增、编辑
  311. handleEdit (row) {
  312. if (row && row.expenseAccountSn) {
  313. this.$router.push({ name: 'expenseReimbursementEdit', params: { sn: row.expenseAccountSn } })
  314. } else {
  315. this.openBaseModal = true
  316. }
  317. },
  318. // 删除
  319. handleDel (row) {
  320. const _this = this
  321. this.$confirm({
  322. title: '提示',
  323. content: '确认要删除吗?',
  324. centered: true,
  325. closable: true,
  326. onOk () {
  327. _this.spinning = true
  328. expenseAccountDelete({ expenseAccountSn: row.expenseAccountSn }).then(res => {
  329. if (res.status == 200) {
  330. _this.$message.success(res.message)
  331. _this.$refs.table.refresh()
  332. _this.spinning = false
  333. } else {
  334. _this.spinning = false
  335. }
  336. })
  337. }
  338. })
  339. },
  340. // 审核进度
  341. handleSH (row) {
  342. this.openModal = true
  343. this.itemSn = row.expenseAccountSn
  344. },
  345. // 再次编辑
  346. againEdit (row) {
  347. const _this = this
  348. this.$confirm({
  349. title: '操作提示',
  350. content: '系统将自动生成一个新的费用报销单,与原审核不通过的单据内容相同。您可以对新单据进行编辑、提交等操作,原单据保持不变,确认操作吗?',
  351. centered: true,
  352. closable: true,
  353. onOk () {
  354. _this.spinning = true
  355. expenseAccountAgainEdit({ expenseAccountSn: row.expenseAccountSn }).then(res => {
  356. if (res.status == 200) {
  357. _this.$message.success(res.message)
  358. _this.resetSearchForm()
  359. }
  360. _this.spinning = false
  361. })
  362. }
  363. })
  364. },
  365. searchForm(){
  366. this.$refs.table.refresh(true)
  367. this.$refs.table.clearSelected()
  368. },
  369. // 重置
  370. resetSearchForm () {
  371. this.queryParam = {
  372. expenseDate: '', // 月份
  373. expenseAccountNo: '', // 费用单号
  374. title: '', // 主题
  375. expenseType: undefined, // 费用类型
  376. expenseType2: undefined, // 费用类型2
  377. state: undefined, // 状态
  378. applyPersonSn: undefined
  379. }
  380. this.expenseTypes = []
  381. this.searchForm()
  382. },
  383. pageInit () {
  384. const _this = this
  385. this.$nextTick(() => { // 页面渲染完成后的回调
  386. _this.setTableH()
  387. })
  388. },
  389. setTableH () {
  390. const tableSearchH = this.$refs.tableSearch.offsetHeight
  391. this.tableHeight = window.innerHeight - tableSearchH - 220
  392. }
  393. },
  394. watch: {
  395. advanced (newValue, oldValue) {
  396. const _this = this
  397. this.$nextTick(() => { // 页面渲染完成后的回调
  398. _this.setTableH()
  399. })
  400. },
  401. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  402. this.setTableH()
  403. }
  404. },
  405. mounted () {
  406. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  407. this.pageInit()
  408. this.resetSearchForm()
  409. }
  410. },
  411. activated () {
  412. // 如果是新页签打开,则重置当前页面
  413. if (this.$store.state.app.isNewTab) {
  414. this.pageInit()
  415. this.resetSearchForm()
  416. }
  417. // 仅刷新列表,不重置页面
  418. if (this.$store.state.app.updateList) {
  419. this.pageInit()
  420. this.$refs.table.refresh()
  421. }
  422. },
  423. beforeRouteEnter (to, from, next) {
  424. next(vm => {})
  425. }
  426. }
  427. </script>
  428. <style lang="less">
  429. .salesManagementList-wrap{
  430. .sTable{
  431. .badge-con-t{
  432. .ant-badge-count{
  433. transform: scale(0.8);
  434. font-size: 13px;
  435. }
  436. }
  437. }
  438. }
  439. </style>