order.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <hc-new-card>
  3. <template #header>
  4. <div class="w-40">
  5. <el-select v-model="searchForm.meterPeriodId" placeholder="选择计量期" filterable clearable block @change="searchKey1Click">
  6. <el-option v-for="item in key1Data" :key="item.id" :label="item.periodName" :value="item.id" />
  7. </el-select>
  8. </div>
  9. </template>
  10. <template #extra>
  11. <el-button hc-btn type="primary" @click="addModalClick">
  12. <HcIcon name="add" />
  13. <span>新增</span>
  14. </el-button>
  15. <el-button hc-btn type="primary" @click="reportClick">
  16. <HcIcon name="send-plane-2" />
  17. <span>上报</span>
  18. </el-button>
  19. </template>
  20. <div class="relative h-full flex">
  21. <div class="flex-1">
  22. <hc-card-item>
  23. <hc-table
  24. :column="tableColumn" :datas="tableData" :loading="tableLoading"
  25. is-new is-check :check-style="{ width: 29 }" :index-style="{ width: 60 }"
  26. is-current-row @selection-change="tableCheckChange" @row-click="hanleRow"
  27. >
  28. <template #action="{ row }">
  29. <el-link type="success" @click="rowEditClick(row)">修改</el-link>
  30. <el-link type="danger" @click="delRowClick(row)">删除</el-link>
  31. </template>
  32. </hc-table>
  33. <template #action>
  34. <hc-pages :pages="searchForm" @change="pageChange" />
  35. </template>
  36. </hc-card-item>
  37. </div>
  38. <div class="ml-3 w-[600px]">
  39. <hc-card-item title="详情信息" scrollbar>
  40. <hc-info-table>
  41. <tr>
  42. <hc-info-table-td center is-title>计量期:</hc-info-table-td>
  43. <hc-info-table-td width="120px">{{ infoData?.periodNumber }}</hc-info-table-td>
  44. <hc-info-table-td center is-title>业务日期:</hc-info-table-td>
  45. <hc-info-table-td width="120px">{{ infoData?.businessDate }}</hc-info-table-td>
  46. </tr>
  47. <tr>
  48. <hc-info-table-td center is-title>计量金额:</hc-info-table-td>
  49. <hc-info-table-td width="120px">{{ infoData?.meterMoney }}</hc-info-table-td>
  50. <hc-info-table-td center is-title>开工预付款总额:</hc-info-table-td>
  51. <hc-info-table-td width="120px">{{ infoData?.startPayAmount }}</hc-info-table-td>
  52. </tr>
  53. <tr>
  54. <hc-info-table-td center is-title>申请依据:</hc-info-table-td>
  55. <hc-info-table-td width="auto" colspan="3">{{ infoData?.applyCause }}</hc-info-table-td>
  56. </tr>
  57. </hc-info-table>
  58. <div class="mt-5">附件列表</div>
  59. <div class="mt-3">
  60. <template v-if="infoData?.fileList?.length > 0">
  61. <el-check-tag v-for="item in infoData?.fileList" :key="item.id" checked class="mr-2" @click="viewFile(item)">{{ item.fileName }}</el-check-tag>
  62. </template>
  63. <HcNoData v-else />
  64. </div>
  65. </hc-card-item>
  66. </div>
  67. </div>
  68. <!-- 新增/修改 -->
  69. <HcDataModal v-model="isDataModal" :info-data="infoData" :ids="editId" @close="finishData" />
  70. <!-- 上报弹窗 -->
  71. <hc-report-dialog v-model="isReport" />
  72. </hc-new-card>
  73. </template>
  74. <script setup>
  75. import { onActivated, onMounted, ref } from 'vue'
  76. import HcDataModal from './components/order/dataModal.vue'
  77. import { getArrValue, getObjValue } from 'js-fast-way'
  78. import mainApi from '~api/debit-pay/start-work/order.js'
  79. import periodApi from '~api/debit-pay/material/periods.js'
  80. import { useAppStore } from '~src/store'
  81. import { delMessageV2 } from '~com/message/index.js'
  82. const useAppState = useAppStore()
  83. const contractId = ref(useAppState.getContractId)
  84. defineOptions({
  85. name: 'DebitPayStartWorkOrder',
  86. })
  87. //渲染完成
  88. onMounted(() => {
  89. getTableData()
  90. })
  91. onActivated(() => {
  92. getKey1Data()
  93. })
  94. //计量期
  95. const key1Data = ref([])
  96. const getKey1Data = async ()=>{
  97. const { error, code, data } = await periodApi.allPeriod({
  98. contractId:contractId.value,
  99. type:2,
  100. })
  101. tableLoading.value = false
  102. if (!error && code === 200) {
  103. key1Data.value = getArrValue(data)
  104. } else {
  105. key1Data.value = []
  106. }
  107. }
  108. //搜索表单
  109. const searchForm = ref({
  110. key1: null, current: 1, size: 10, total: 0,
  111. })
  112. //计量期
  113. const searchKey1Click = () => {
  114. getTableData()
  115. }
  116. //分页
  117. const pageChange = ({ current, size }) => {
  118. searchForm.value.current = current
  119. searchForm.value.size = size
  120. }
  121. //表格数据
  122. const tableLoading = ref(false)
  123. const tableColumn = ref([
  124. { key: 'periodName', name: '计量期' },
  125. { key: 'businessDate', name: '业务日期' },
  126. { key: 'meterMoney', name: '计量金额' },
  127. { key: 'approveStatusName', name: '审批状态' },
  128. { key: 'action', name: '操作', width: 94 },
  129. ])
  130. const tableData = ref([
  131. ])
  132. const getTableData = async () => {
  133. tableLoading.value = true
  134. console.log(searchForm.value, 'searchForm.value')
  135. const { error, code, data } = await mainApi.getPage({
  136. ...searchForm.value,
  137. contractId:contractId.value,
  138. })
  139. tableLoading.value = false
  140. if (!error && code === 200) {
  141. tableData.value = getArrValue(data['records'])
  142. if (tableData.value.length > 0) {
  143. getDetail(tableData.value[0].id)
  144. } else {
  145. infoData.value = {}
  146. }
  147. } else {
  148. tableData.value = []
  149. }
  150. }
  151. //获取详情
  152. const infoData = ref({})
  153. const getDetail = async (id)=>{
  154. const { error, code, data } = await mainApi.detail({
  155. id,
  156. })
  157. if (!error && code === 200) {
  158. infoData.value = getObjValue(data)
  159. } else {
  160. infoData.value = {}
  161. }
  162. }
  163. //查看附件
  164. const viewFile = (item)=>{
  165. const { filePdfUrl } = item
  166. if (filePdfUrl) {
  167. window.open(filePdfUrl, '_blank')
  168. }
  169. }
  170. //表格选择
  171. const tableCheckChange = () => {
  172. }
  173. const hanleRow = ({ row })=>{
  174. getDetail(row.id)
  175. }
  176. //新增
  177. const isDataModal = ref(false)
  178. const addModalClick = () => {
  179. isDataModal.value = true
  180. editId.value = ''
  181. }
  182. const editId = ref('')
  183. //修改
  184. const rowEditClick = (row) => {
  185. isDataModal.value = true
  186. editId.value = row.id
  187. }
  188. const delRowClick = async (row)=>{
  189. delMessageV2(async (action, instance, done) => {
  190. if (action === 'confirm') {
  191. instance.confirmButtonLoading = true
  192. removeProPay(row.id)
  193. instance.confirmButtonLoading = false
  194. done()
  195. } else {
  196. done()
  197. }
  198. })
  199. }
  200. const removeProPay = async (id) => {
  201. const { error, code } = await mainApi.remove({
  202. ids: id,
  203. })
  204. if (!error && code === 200) {
  205. window?.$message?.success('删除成功')
  206. getTableData()
  207. }
  208. }
  209. const finishData = ()=>{
  210. isDataModal.value = false
  211. getTableData()
  212. }
  213. //是否上报
  214. const isReport = ref(false)
  215. const reportClick = () => {
  216. isReport.value = true
  217. }
  218. </script>
  219. <style scoped lang="scss">
  220. </style>