list.vue 11 KB

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