You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

530 lines
15 KiB

  1. <template>
  2. <div class="customer-css">
  3. <!-- 查询条件 -->
  4. <el-form :inline="true" label-position="top" class="search-form-inline">
  5. <div class="search-row">
  6. <el-form-item label="费用单号" class="search-item">
  7. <el-input v-model="searchData.feeNo" style="width: 120px" @keyup.enter.native="getMainData"/>
  8. </el-form-item>
  9. <el-form-item label="申请人" class="search-item" >
  10. <el-input v-model="searchData.applyUser" style="width: 120px" @keyup.enter.native="getMainData"/>
  11. </el-form-item>
  12. <el-form-item label="费用日期" class="search-item">
  13. <el-date-picker
  14. v-model="searchData.feeDate"
  15. type="date"
  16. value-format="yyyy-MM-dd"
  17. placeholder="选择日期"
  18. style="width: 100%;">
  19. </el-date-picker>
  20. </el-form-item>
  21. <el-form-item label=" " class="search-item search-btn-item">
  22. <el-button type="primary" @click="getMainData" style="">查询</el-button>
  23. <el-button @click="handleAdd" type="primary" style="margin-left: 2px">新增</el-button>
  24. </el-form-item>
  25. </div>
  26. </el-form>
  27. <el-table
  28. :height="height"
  29. :data="mainDataList"
  30. border
  31. ref="mainTable"
  32. highlight-current-row
  33. @row-click="changeData"
  34. v-loading="dataListLoading"
  35. style="width: 100%;">
  36. <el-table-column
  37. v-for="(item,index) in columnArray1" :key="index"
  38. :sortable="item.columnSortable"
  39. :prop="item.columnProp"
  40. :header-align="item.headerAlign"
  41. :show-overflow-tooltip="item.showOverflowTooltip"
  42. :align="item.align"
  43. :fixed="item.fixed==''?false:item.fixed"
  44. :min-width="item.columnWidth"
  45. :label="item.columnLabel">
  46. <template slot-scope="scope">
  47. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
  51. <template slot-scope="scope">
  52. <el-link type="primary" style="cursor: pointer; margin-right: 10px;" @click="handleEdit(scope.row)">编辑</el-link>
  53. <el-link type="danger" style="cursor: pointer;" @click="handleDelete(scope.row)">删除</el-link>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <!-- 分页插件 -->
  58. <el-pagination style="margin-top: 0px"
  59. @size-change="sizeChangeHandle"
  60. @current-change="currentChangeHandle"
  61. :current-page="pageIndex"
  62. :page-sizes="[20, 50, 100, 200, 500]"
  63. :page-size="pageSize"
  64. :total="totalPage"
  65. layout="total, sizes, prev, pager, next, jumper">
  66. </el-pagination>
  67. <!-- 详情页签 -->
  68. <el-tabs v-model="activeTab" style="margin-top: 0px; width: 99%;" @tab-click="handleTabClick" class="customer-tab" type="border-card">
  69. <!-- 费用明细 -->
  70. <el-tab-pane label="费用明细" name="detail">
  71. <fee-detail-tab ref="feeDetailTab" :fee-data="currentRow" :table-height="detailHeight" />
  72. </el-tab-pane>
  73. <!-- 申请单清单 -->
  74. <el-tab-pane label="申请单清单" name="request">
  75. <request-fee-tab ref="requestFeeTab" :fee-data="currentRow" :table-height="detailHeight" />
  76. </el-tab-pane>
  77. </el-tabs>
  78. <!-- 新增弹窗 -->
  79. <el-dialog
  80. title="新增费用记录"
  81. :visible.sync="addDialogVisible"
  82. width="30%"
  83. top="10vh"
  84. :close-on-click-modal="false">
  85. <el-form :model="addFormData" :rules="addRules" ref="addFormData" label-width="100px" size="small" label-position="top">
  86. <el-form-item label="费用日期" prop="feeDate" >
  87. <el-date-picker
  88. v-model="addFormData.feeDate"
  89. type="date"
  90. value-format="yyyy-MM-dd"
  91. placeholder="选择日期"
  92. style="width: 50%">
  93. </el-date-picker>
  94. </el-form-item>
  95. <el-form-item label="申请人" prop="applyUser">
  96. <el-input v-model="addFormData.applyUser" placeholder="请输入申请人" style="width: 50%"></el-input>
  97. </el-form-item>
  98. <el-form-item label="备注">
  99. <el-input
  100. type="textarea"
  101. v-model="addFormData.remark"
  102. :autosize="{ minRows: 3, maxRows: 6 }"
  103. placeholder="请输入备注">
  104. </el-input>
  105. </el-form-item>
  106. </el-form>
  107. <div slot="footer" class="dialog-footer">
  108. <el-button type="primary" @click="handleSaveAdd">保存</el-button>
  109. <el-button @click="addDialogVisible = false">取消</el-button>
  110. </div>
  111. </el-dialog>
  112. </div>
  113. </template>
  114. <script>
  115. import { searchFeeHeaderList, createFeeHeader, updateFeeHeader, deleteFeeRecord } from '@/api/inspection/srmFee.js'
  116. import FeeDetailTab from './com_feeDetailTab.vue'
  117. import RequestFeeTab from './com_requestFeeTab.vue'
  118. export default {
  119. name: 'SrmFeeList',
  120. components: {
  121. FeeDetailTab,
  122. RequestFeeTab
  123. },
  124. data() {
  125. return {
  126. functionId: this.$route.meta.menuId,
  127. height: 400,
  128. detailHeight: 400,
  129. currentRow: {},
  130. activeTab: 'detail',
  131. addDialogVisible: false,
  132. addFormData: {
  133. feeDate: '',
  134. applyUser: '',
  135. remark: ''
  136. },
  137. addRules: {
  138. feeDate: [
  139. { required: true, message: '请选择费用日期', trigger: 'change' }
  140. ],
  141. applyUser: [
  142. { required: true, message: '请输入申请人', trigger: 'blur' }
  143. ]
  144. },
  145. searchData: {
  146. feeNo: '',
  147. applyUser: '',
  148. feeDate: '',
  149. site: this.$store.state.user.site,
  150. page: 1,
  151. limit: 50
  152. },
  153. pageIndex: 1,
  154. pageSize: 50,
  155. totalPage: 0,
  156. mainDataList: [],
  157. dataListLoading: false,
  158. columnArray1: [
  159. {
  160. userId: this.$store.state.user.name,
  161. functionId: this.functionId,
  162. serialNumber: 'FeeTable1FeeNo',
  163. tableId: 'FeeTable1',
  164. tableName: '费用管理',
  165. columnProp: 'feeNo',
  166. headerAlign: 'center',
  167. align: 'left',
  168. columnLabel: '费用单号',
  169. columnWidth: '150',
  170. columnHidden: false,
  171. columnImage: false,
  172. columnSortable: false,
  173. sortLv: 0,
  174. status: true,
  175. fixed: false
  176. },
  177. {
  178. userId: this.$store.state.user.name,
  179. functionId: this.functionId,
  180. serialNumber: 'FeeTable1FeeDate',
  181. tableId: 'FeeTable1',
  182. tableName: '费用管理',
  183. columnProp: 'feeDate',
  184. headerAlign: 'center',
  185. align: 'center',
  186. columnLabel: '费用日期',
  187. columnWidth: '120',
  188. columnHidden: false,
  189. columnImage: false,
  190. columnSortable: false,
  191. sortLv: 0,
  192. status: true,
  193. fixed: false
  194. },
  195. {
  196. userId: this.$store.state.user.name,
  197. functionId: this.functionId,
  198. serialNumber: 'FeeTable1TotalAmount',
  199. tableId: 'FeeTable1',
  200. tableName: '费用管理',
  201. columnProp: 'totalAmount',
  202. headerAlign: 'center',
  203. align: 'right',
  204. columnLabel: '总金额',
  205. columnWidth: '120',
  206. columnHidden: false,
  207. columnImage: false,
  208. columnSortable: false,
  209. sortLv: 0,
  210. status: true,
  211. fixed: false
  212. },
  213. {
  214. userId: this.$store.state.user.name,
  215. functionId: this.functionId,
  216. serialNumber: 'FeeTable1ApplyUser',
  217. tableId: 'FeeTable1',
  218. tableName: '费用管理',
  219. columnProp: 'applyUser',
  220. headerAlign: 'center',
  221. align: 'left',
  222. columnLabel: '申请人',
  223. columnWidth: '100',
  224. columnHidden: false,
  225. columnImage: false,
  226. columnSortable: false,
  227. sortLv: 0,
  228. status: true,
  229. fixed: false
  230. },
  231. {
  232. userId: this.$store.state.user.name,
  233. functionId: this.functionId,
  234. serialNumber: 'FeeTable1CreatedBy',
  235. tableId: 'FeeTable1',
  236. tableName: '费用管理',
  237. columnProp: 'createdBy',
  238. headerAlign: 'center',
  239. align: 'left',
  240. columnLabel: '创建人',
  241. columnWidth: '100',
  242. columnHidden: false,
  243. columnImage: false,
  244. columnSortable: false,
  245. sortLv: 0,
  246. status: true,
  247. fixed: false
  248. },
  249. {
  250. userId: this.$store.state.user.name,
  251. functionId: this.functionId,
  252. serialNumber: 'FeeTable1CreatedDate',
  253. tableId: 'FeeTable1',
  254. tableName: '费用管理',
  255. columnProp: 'createdDate',
  256. headerAlign: 'center',
  257. align: 'center',
  258. columnLabel: '创建时间',
  259. columnWidth: '160',
  260. columnHidden: false,
  261. columnImage: false,
  262. columnSortable: false,
  263. sortLv: 0,
  264. status: true,
  265. fixed: false
  266. },
  267. {
  268. userId: this.$store.state.user.name,
  269. functionId: this.functionId,
  270. serialNumber: 'FeeTable1Remark',
  271. tableId: 'FeeTable1',
  272. tableName: '费用管理',
  273. columnProp: 'remark',
  274. headerAlign: 'center',
  275. align: 'left',
  276. columnLabel: '备注',
  277. columnWidth: '200',
  278. columnHidden: false,
  279. columnImage: false,
  280. columnSortable: false,
  281. sortLv: 0,
  282. status: true,
  283. fixed: false
  284. }
  285. ]
  286. }
  287. },
  288. mounted() {
  289. this.$nextTick(() => {
  290. this.height = (window.innerHeight - 220) / 2
  291. this.detailHeight = (window.innerHeight - 220) / 2
  292. this.getMainData()
  293. })
  294. },
  295. methods: {
  296. // 查询数据
  297. getMainData() {
  298. console.log('开始查询费用列表...')
  299. this.searchData.limit = this.pageSize
  300. this.searchData.page = this.pageIndex
  301. this.dataListLoading = true
  302. console.log('设置 loading 为 true')
  303. searchFeeHeaderList(this.searchData).then(({ data }) => {
  304. console.log('接口返回数据:', data)
  305. if (data && data.code === 0) {
  306. this.mainDataList = data.page.list || []
  307. this.pageIndex = data.page.currPage
  308. this.pageSize = data.page.pageSize
  309. this.totalPage = data.page.totalCount
  310. this.$nextTick(() => {
  311. if (this.$refs.mainTable) {
  312. this.$refs.mainTable.clearSelection()
  313. }
  314. })
  315. // 判断是否有数据
  316. if (this.mainDataList.length > 0) {
  317. this.$refs.mainTable.setCurrentRow(this.mainDataList[0])
  318. this.changeData(this.mainDataList[0])
  319. } else {
  320. this.changeData(null)
  321. }
  322. } else {
  323. console.error('查询失败:', data)
  324. this.$message.error((data && data.msg) || '查询失败')
  325. }
  326. this.dataListLoading = false
  327. console.log('设置 loading 为 false')
  328. }).catch((error) => {
  329. console.error('查询费用列表异常:', error)
  330. this.$message.error('查询失败,请稍后重试')
  331. this.dataListLoading = false
  332. console.log('异常处理,设置 loading 为 false')
  333. })
  334. },
  335. // 每页数
  336. sizeChangeHandle(val) {
  337. this.pageSize = val
  338. this.pageIndex = 1
  339. this.getMainData()
  340. },
  341. // 当前页
  342. currentChangeHandle(val) {
  343. this.pageIndex = val
  344. this.getMainData()
  345. },
  346. // 行点击事件
  347. changeData(row) {
  348. this.currentRow = row ? JSON.parse(JSON.stringify(row)) : {}
  349. },
  350. // 页签点击事件
  351. handleTabClick(tab) {
  352. if (tab.name === 'detail') {
  353. this.$nextTick(() => {
  354. if (this.$refs.feeDetailTab) {
  355. this.$refs.feeDetailTab.loadDetailList()
  356. }
  357. })
  358. } else if (tab.name === 'request') {
  359. this.$nextTick(() => {
  360. if (this.$refs.requestFeeTab) {
  361. this.$refs.requestFeeTab.loadRequestFeeList()
  362. }
  363. })
  364. }
  365. },
  366. // 新增
  367. handleAdd() {
  368. this.addDialogVisible = true
  369. this.addFormData = {
  370. feeDate: '',
  371. applyUser: '',
  372. remark: ''
  373. }
  374. if (this.$refs.addFormData) {
  375. this.$refs.addFormData.clearValidate()
  376. }
  377. },
  378. // 保存新增
  379. handleSaveAdd() {
  380. this.$refs.addFormData.validate((valid) => {
  381. if (valid) {
  382. const params = {
  383. site: this.$store.state.user.site,
  384. feeDate: this.addFormData.feeDate,
  385. applyUser: this.addFormData.applyUser,
  386. remark: this.addFormData.remark,
  387. createdBy: this.$store.state.user.name,
  388. updateBy: this.$store.state.user.name
  389. }
  390. createFeeHeader(params).then(({ data }) => {
  391. if (data.code === 0) {
  392. this.$message.success('创建成功')
  393. this.addDialogVisible = false
  394. this.getMainData()
  395. } else {
  396. this.$message.error(data.msg || '创建失败')
  397. }
  398. }).catch(() => {
  399. this.$message.error('创建失败')
  400. })
  401. }
  402. })
  403. },
  404. // 编辑(切换到费用明细页签)
  405. handleEdit(row) {
  406. this.changeData(row)
  407. this.activeTab = 'detail'
  408. this.$nextTick(() => {
  409. if (this.$refs.feeDetailTab) {
  410. this.$refs.feeDetailTab.loadDetailList()
  411. }
  412. })
  413. },
  414. // 删除
  415. handleDelete(row) {
  416. this.$confirm('确定要删除该费用记录吗?删除后将同时删除明细和关联申请单。', '提示', {
  417. confirmButtonText: '确定',
  418. cancelButtonText: '取消',
  419. type: 'warning'
  420. }).then(() => {
  421. const params = {
  422. site: row.site,
  423. feeNo: row.feeNo
  424. }
  425. deleteFeeRecord(params).then(({ data }) => {
  426. if (data.code === 0) {
  427. this.$message.success('删除成功')
  428. this.getMainData()
  429. } else {
  430. this.$message.error(data.msg || '删除失败')
  431. }
  432. }).catch(() => {
  433. this.$message.error('删除失败')
  434. })
  435. }).catch(() => {})
  436. }
  437. },
  438. created() {
  439. this.getMainData()
  440. }
  441. }
  442. </script>
  443. <style scoped lang="scss">
  444. .search-form-inline {
  445. background: #fff;
  446. padding: 0;
  447. margin-bottom: 0;
  448. }
  449. .search-row {
  450. display: flex;
  451. align-items: flex-end;
  452. flex-wrap: wrap;
  453. gap: 0;
  454. margin-bottom: 0;
  455. }
  456. .search-item {
  457. flex: none;
  458. margin-bottom: 0;
  459. margin-right: 12px;
  460. }
  461. .search-item /deep/ .el-form-item__label {
  462. font-size: 14px;
  463. padding-bottom: 0;
  464. line-height: 1.2;
  465. }
  466. .search-btn-item {
  467. flex: none;
  468. margin-bottom: 0;
  469. margin-right: 0;
  470. }
  471. .search-btn-item /deep/ .el-form-item__content {
  472. line-height: normal;
  473. }
  474. .search-item /deep/ .el-form-item__label {
  475. font-size: 13px;
  476. color: #606266;
  477. padding-bottom: 5px;
  478. line-height: 1;
  479. height: auto;
  480. }
  481. .search-item /deep/ .el-form-item__content {
  482. line-height: normal;
  483. }
  484. /deep/ .customer-tab .el-tabs__content {
  485. padding: 5px !important;
  486. }
  487. // 按钮样式(与 inspectionRequestList 保持一致)
  488. .customer-bun-min {
  489. padding: 7px 12px;
  490. font-size: 12px;
  491. border-radius: 3px;
  492. }
  493. </style>