material.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <hc-card title="材料调差" class="hc-debit-pay-material-material">
  3. <template #header>
  4. <div class="w-32">
  5. <el-select v-model="searchForm.contractPeriodId" placeholder="选择调差期" filterable clearable block>
  6. <template v-for="item in adjustment" :key="item.id">
  7. <el-option v-if="item.approveStatus === 2" :label="item.periodNumber" :value="item.id" />
  8. </template>
  9. </el-select>
  10. </div>
  11. <div class="ml-3 w-40">
  12. <el-date-picker v-model="searchForm.adjustMonth" class="block" type="month" format="YYYY-MM" value-format="YYYY-MM" placeholder="调差月份" />
  13. </div>
  14. <el-button class="ml-3" type="primary" @click="searchClick">
  15. <hc-icon name="search" />
  16. <span>搜索</span>
  17. </el-button>
  18. </template>
  19. <template #extra>
  20. <el-button hc-btn type="primary" @click="addFormModal">
  21. <hc-icon name="add" />
  22. <span>新增</span>
  23. </el-button>
  24. </template>
  25. <hc-table :column="tableColumn" :datas="tableData" :index-style="{ width: 60 }" :loading="tableLoading">
  26. <template #materialName="{ row }">
  27. <el-link type="primary" @click="rowTop(row)">{{ row.materialName }}</el-link>
  28. </template>
  29. <template #approveStatus="{ row }">
  30. <span v-if="row.approveStatus === 1" class="text-green">已完结</span>
  31. <span v-else class="text-gray">未完结</span>
  32. </template>
  33. <template #action="{ row }">
  34. <el-link type="primary" :disabled="row.approveStatus === 1" @click="rowEditClick(row)">编辑</el-link>
  35. <el-link type="danger" :disabled="row.approveStatus === 1" @click="rowDelClick(row)">删除</el-link>
  36. </template>
  37. </hc-table>
  38. <template #action>
  39. <hc-pages :pages="searchForm" @change="pageChange" />
  40. </template>
  41. <!-- 新增/编辑 -->
  42. <HcdataModal v-model="isFormModal" :meter-period-id="searchForm.contractPeriodId" :ids="rowId" @finish="dataModalFinish" />
  43. </hc-card>
  44. </template>
  45. <script setup>
  46. import { nextTick, onActivated, ref } from 'vue'
  47. import { useAppStore } from '~src/store'
  48. import { HcDelMsg } from 'hc-vue3-ui'
  49. import { getArrValue } from 'js-fast-way'
  50. import mainApi from '~api/debit-pay/material/material'
  51. import HcdataModal from './components/material/dataModal.vue'
  52. //初始化
  53. const store = useAppStore()
  54. const projectId = ref(store.getProjectId)
  55. const contractId = ref(store.getContractId)
  56. //渲染完成
  57. onActivated(() => {
  58. getPeriodAdjustment()
  59. getTableData()
  60. })
  61. //获取调差期
  62. const adjustment = ref([])
  63. const getPeriodAdjustment = async () => {
  64. const { data } = await mainApi.periodAdjustment(contractId.value)
  65. adjustment.value = getArrValue(data)
  66. }
  67. //搜索表单
  68. const searchForm = ref({
  69. contractPeriodId: null, adjustMonth: null,
  70. current: 1, size: 20, total: 0,
  71. })
  72. const searchClick = () => {
  73. searchForm.value.current = 1
  74. getTableData()
  75. }
  76. //分页
  77. const pageChange = ({ current, size }) => {
  78. searchForm.value.current = current
  79. searchForm.value.size = size
  80. getTableData()
  81. }
  82. //表格
  83. const tableColumn = [
  84. { key: 'contractPeriodNumber', name: '调差期', width: 100, align: 'center' },
  85. { key: 'adjustMonth', name: '调差月份', width: 120, align: 'center' },
  86. { key: 'materialName', name: '材料名称' },
  87. { key: 'materialPrice', name: '基准价格(元)', width: 140, align: 'center' },
  88. { key: 'currentPrice', name: '施工期价格(元)', width: 140, align: 'center' },
  89. { key: 'adjustTotal', name: '调差数量', width: 140, align: 'center' },
  90. { key: 'adjustMoney', name: '调差金额', width: 140, align: 'center' },
  91. { key: 'approveStatus', name: '状态', width: 120, align: 'center' },
  92. { key: 'action', name: '操作', width: 100, align: 'center' },
  93. ]
  94. const tableData = ref([])
  95. //获取表格数据
  96. const tableLoading = ref(false)
  97. const getTableData = async () => {
  98. tableLoading.value = true
  99. const { error, code, data } = await mainApi.page({
  100. ...searchForm.value,
  101. projectId: projectId.value,
  102. contractId: contractId.value,
  103. })
  104. tableLoading.value = false
  105. if (!error && code === 200) {
  106. tableData.value = getArrValue(data['records'])
  107. searchForm.value.total = data['total']
  108. } else {
  109. tableData.value = []
  110. searchForm.value.total = 0
  111. }
  112. }
  113. //新增
  114. const isFormModal = ref(false)
  115. const rowId = ref('')
  116. const addFormModal = () => {
  117. rowId.value = ''
  118. isFormModal.value = true
  119. }
  120. //材料名称被点击
  121. const rowTop = (row) => {
  122. rowId.value = row.id
  123. nextTick(() => {
  124. isFormModal.value = true
  125. })
  126. }
  127. //编辑
  128. const rowEditClick = (row) => {
  129. rowId.value = row.id
  130. nextTick(() => {
  131. isFormModal.value = true
  132. })
  133. }
  134. //数据弹窗完成
  135. const dataModalFinish = () => {
  136. isFormModal.value = false
  137. getTableData()
  138. }
  139. //删除
  140. const rowDelClick = (row) => {
  141. HcDelMsg(async (resolve) => {
  142. const { code, msg } = await mainApi.delete(row.id)
  143. resolve()
  144. if (code === 200) {
  145. window.$message.success('删除成功')
  146. getTableData().then()
  147. } else {
  148. window.$message.error(msg ?? '操作失败')
  149. }
  150. })
  151. }
  152. </script>
  153. <style scoped lang="scss">
  154. </style>