list.vue 12 KB

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