list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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="6" :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="6" :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. <template v-if="advanced">
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="费用发生月份">
  32. <a-month-picker
  33. placeholder="请选择月份"
  34. locale="zh-cn"
  35. v-model="queryParam.expenseDate"
  36. @change="onChange"
  37. :disabled-date="disabledDate"
  38. style="width: 100%;"/>
  39. </a-form-item>
  40. </a-col>
  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="6" :sm="24">
  47. <a-form-item label="状态">
  48. <v-select
  49. v-model="queryParam.state"
  50. ref="state"
  51. id="salesManagementList-state"
  52. code="EXPENSE_STATE"
  53. placeholder="请选择状态"
  54. allowClear></v-select>
  55. </a-form-item>
  56. </a-col>
  57. </template>
  58. <a-col :md="6" :sm="24">
  59. <span class="table-page-search-submitButtons">
  60. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  61. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  62. <a @click="advanced=!advanced" style="margin-left: 8px">
  63. {{ advanced ? '收起' : '展开' }}
  64. <a-icon :type="advanced ? 'up' : 'down'"/>
  65. </a>
  66. </span>
  67. </a-col>
  68. </a-row>
  69. </a-form>
  70. </div>
  71. <!-- 操作按钮 -->
  72. <div class="table-operator">
  73. <a-button type="primary" class="button-error" v-if="$hasPermissions('B_eRNew')" @click="handleEdit()">新增</a-button>
  74. </div>
  75. <!-- 列表 -->
  76. <s-table
  77. class="sTable fixPagination"
  78. ref="table"
  79. :style="{ height: tableHeight+70.5+'px' }"
  80. size="small"
  81. :rowKey="(record) => record.id"
  82. :columns="columns"
  83. :data="loadData"
  84. :scroll="{ y: tableHeight }"
  85. :defaultLoadData="false"
  86. bordered>
  87. <!-- 单号 -->
  88. <template slot="expenseAccountNo" slot-scope="text, record">
  89. <span v-if="$hasPermissions('B_eRdetail')" class="link-bule" @click="handleDetail(record)">{{ record.expenseAccountNo }}</span>
  90. <div v-else>{{ record.expenseAccountNo||'--' }}</div>
  91. </template>
  92. <!-- 总数量 -->
  93. <template slot="totalQty" slot-scope="text, record">
  94. {{ record.totalQty }}
  95. </template>
  96. <!-- 费用类型 -->
  97. <template slot="expenseType" slot-scope="text, record">
  98. <div>{{ record.expenseTypeName || '--' }}<span v-if="record.expenseType2">/{{ record.expenseTypeName2 || '--' }}</span></div>
  99. </template>
  100. <!-- 操作 -->
  101. <template slot="action" slot-scope="text, record">
  102. <a-button
  103. v-if="record.state=='WAIT_SUBMIT'&&$hasPermissions('B_ERtEdit')"
  104. size="small"
  105. type="link"
  106. class="button-info"
  107. @click="handleEdit(record)"
  108. >
  109. 编辑
  110. </a-button>
  111. <a-button
  112. v-if="record.state=='WAIT_SUBMIT'&&$hasPermissions('B_ERDel')"
  113. size="small"
  114. type="link"
  115. class="button-error"
  116. @click="handleDel(record)"
  117. >
  118. 删除
  119. </a-button>
  120. <a-button
  121. v-if="record.state!='WAIT_SUBMIT'&&$hasPermissions('B_ERAudit')"
  122. size="small"
  123. type="link"
  124. class="button-info"
  125. @click="handleSH(record)"
  126. >
  127. 审核进度
  128. </a-button>
  129. <a-button
  130. v-if="record.state=='AUDIT_REJECT'"
  131. size="small"
  132. type="link"
  133. class="button-info"
  134. @click="againEdit(record)"
  135. >
  136. 再次编辑
  137. </a-button>
  138. <!-- <span v-if="record.state=='AUDIT_REJECT' || record.state=='AUDIT_PASS'">--</span> -->
  139. </template>
  140. </s-table>
  141. </a-spin>
  142. <!-- 审核进度 -->
  143. <verifyModal :openModal="openModal" :itemSn="itemSn" @close="openModal=false"></verifyModal>
  144. <!-- 新增 -->
  145. <baseDataModal :show="openBaseModal" @close="openBaseModal=false"></baseDataModal>
  146. </a-card>
  147. </template>
  148. <script>
  149. import { commonMixin } from '@/utils/mixin'
  150. import locale from 'ant-design-vue/es/date-picker/locale/zh_CN'
  151. import moment from 'moment'
  152. import subarea from '@/views/common/subarea.js'
  153. import employee from './employee.js'
  154. import { STable, VSelect } from '@/components'
  155. import verifyModal from './verifyModal.vue'
  156. import expenseType from '@/views/common/expenseType.js'
  157. import { expenseAccountList, expenseAccountDelete, expenseAccountAgainEdit } from '@/api/expenseManagement'
  158. import baseDataModal from './baseDataModal.vue'
  159. export default {
  160. name: 'ExpenseReimbursementList',
  161. mixins: [commonMixin],
  162. components: { STable, VSelect, subarea, verifyModal, baseDataModal, employee, expenseType },
  163. data () {
  164. return {
  165. locale,
  166. spinning: false,
  167. advanced: false, // 高级搜索 展开/关闭
  168. disabled: false, // 查询、重置按钮是否可操作
  169. openModal: false, // 审核进度弹框是否显示
  170. openBaseModal: false, // 基础信息新建
  171. itemSn: '', // 费用单sn
  172. tableHeight: 0,
  173. expenseTypes: [],
  174. // 查询参数
  175. queryParam: {
  176. expenseDate: moment().format('YYYY-MM'), // 月份
  177. expenseAccountNo: '', // 费用单号
  178. title: '', // 主题
  179. expenseType: undefined, // 费用类型
  180. expenseType2: undefined, // 费用类型2
  181. state: undefined // 状态
  182. },
  183. // 加载数据方法 必须为 Promise 对象
  184. loadData: parameter => {
  185. this.disabled = true
  186. this.spinning = true
  187. delete parameter.tableId
  188. delete parameter.index
  189. const params = Object.assign(parameter, this.queryParam)
  190. if (params.expenseDate) {
  191. params.expenseDate = params.expenseDate + '-01'
  192. }
  193. return expenseAccountList(params).then(res => {
  194. let data
  195. if (res.status == 200) {
  196. data = res.data
  197. const no = (data.pageNo - 1) * data.pageSize
  198. for (var i = 0; i < data.list.length; i++) {
  199. data.list[i].no = no + i + 1
  200. }
  201. this.disabled = false
  202. }
  203. this.spinning = false
  204. return data
  205. })
  206. },
  207. columns: [{ title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  208. { title: '费用单号', width: '12%', align: 'center', scopedSlots: { customRender: 'expenseAccountNo' } },
  209. { title: '申请人', dataIndex: 'applyPersonName', width: '8%', align: 'left', 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: '6%', align: 'center' },
  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: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? 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: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  218. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }]
  219. }
  220. },
  221. methods: {
  222. onChange (date, dateString) {
  223. this.queryParam.expenseDate = dateString
  224. },
  225. disabledDate (current) {
  226. return current && current > moment().endOf('day')
  227. },
  228. expenseChange (val, opts) {
  229. console.log(val, opts)
  230. this.expenseTypes = val || []
  231. this.queryParam.expenseType = val && val[0] ? val[0] : ''
  232. this.queryParam.expenseType2 = val && val[1] ? val[1] : ''
  233. },
  234. // 详情
  235. handleDetail (row) {
  236. this.$router.push({ name: 'expenseReimbursementListDetail', params: { sn: row.expenseAccountSn } })
  237. },
  238. // 新增、编辑
  239. handleEdit (row) {
  240. if (row && row.expenseAccountSn) {
  241. this.$router.push({ name: 'expenseReimbursementEdit', params: { sn: row.expenseAccountSn } })
  242. } else {
  243. this.openBaseModal = true
  244. }
  245. },
  246. // 删除
  247. handleDel (row) {
  248. const _this = this
  249. this.$confirm({
  250. title: '提示',
  251. content: '确认要删除吗?',
  252. centered: true,
  253. closable: true,
  254. onOk () {
  255. _this.spinning = true
  256. expenseAccountDelete({ expenseAccountSn: row.expenseAccountSn }).then(res => {
  257. if (res.status == 200) {
  258. _this.$message.success(res.message)
  259. _this.$refs.table.refresh()
  260. _this.spinning = false
  261. } else {
  262. _this.spinning = false
  263. }
  264. })
  265. }
  266. })
  267. },
  268. // 审核进度
  269. handleSH (row) {
  270. this.openModal = true
  271. this.itemSn = row.expenseAccountSn
  272. },
  273. // 再次编辑
  274. againEdit (row) {
  275. const _this = this
  276. this.$confirm({
  277. title: '操作提示',
  278. content: '系统将自动生成一个新的费用报销单,与原审核不通过的单据内容相同。您可以对新单据进行编辑、提交等操作,原单据保持不变,确认操作吗?',
  279. centered: true,
  280. closable: true,
  281. onOk () {
  282. _this.spinning = true
  283. expenseAccountAgainEdit({ expenseAccountSn: row.expenseAccountSn }).then(res => {
  284. if (res.status == 200) {
  285. _this.$message.success(res.message)
  286. _this.resetSearchForm()
  287. }
  288. _this.spinning = false
  289. })
  290. }
  291. })
  292. },
  293. // 重置
  294. resetSearchForm () {
  295. this.queryParam = {
  296. expenseDate: '', // 月份
  297. expenseAccountNo: '', // 费用单号
  298. title: '', // 主题
  299. expenseType: undefined, // 费用类型
  300. expenseType2: undefined, // 费用类型2
  301. state: undefined, // 状态
  302. applyPersonSn: undefined
  303. }
  304. this.expenseTypes = []
  305. this.$refs.table.refresh(true)
  306. },
  307. pageInit () {
  308. const _this = this
  309. this.$nextTick(() => { // 页面渲染完成后的回调
  310. _this.setTableH()
  311. })
  312. },
  313. setTableH () {
  314. const tableSearchH = this.$refs.tableSearch.offsetHeight
  315. this.tableHeight = window.innerHeight - tableSearchH - 235
  316. }
  317. },
  318. watch: {
  319. advanced (newValue, oldValue) {
  320. const _this = this
  321. this.$nextTick(() => { // 页面渲染完成后的回调
  322. _this.setTableH()
  323. })
  324. },
  325. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  326. this.setTableH()
  327. }
  328. },
  329. mounted () {
  330. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  331. this.pageInit()
  332. this.resetSearchForm()
  333. }
  334. },
  335. activated () {
  336. // 如果是新页签打开,则重置当前页面
  337. if (this.$store.state.app.isNewTab) {
  338. this.pageInit()
  339. this.resetSearchForm()
  340. }
  341. // 仅刷新列表,不重置页面
  342. if (this.$store.state.app.updateList) {
  343. this.pageInit()
  344. this.$refs.table.refresh()
  345. }
  346. },
  347. beforeRouteEnter (to, from, next) {
  348. next(vm => {})
  349. }
  350. }
  351. </script>
  352. <style lang="less">
  353. .salesManagementList-wrap{
  354. .sTable{
  355. margin-top: 10px;
  356. .badge-con-t{
  357. .ant-badge-count{
  358. transform: scale(0.8);
  359. font-size: 13px;
  360. }
  361. }
  362. }
  363. }
  364. </style>