list.vue 12 KB

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