list.vue 12 KB

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