order.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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" :disabled="approveStatus !== 0" @click="addModalClick">
  12. <HcIcon name="add" />
  13. <span>新增</span>
  14. </el-button>
  15. <el-button hc-btn type="primary" :disabled="approveStatus !== 0" @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" :disabled="approveStatus !== 0" @click="rowEditClick(row)">修改</el-link>
  30. <el-link type="danger" :disabled="approveStatus !== 0" @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" :info="reportInfo" @finish="reportFinish" />
  72. </hc-new-card>
  73. </template>
  74. <script setup>
  75. import { nextTick, onActivated, ref } from 'vue'
  76. import { useAppStore } from '~src/store'
  77. import HcDataModal from './components/order/dataModal.vue'
  78. import { getArrValue, getObjValue } from 'js-fast-way'
  79. import mainApi from '~api/debit-pay/start-work/order.js'
  80. import periodApi from '~api/debit-pay/material/periods.js'
  81. import { HcDelMsg } from 'hc-vue3-ui'
  82. import { toPdfPage } from '~uti/btn-auth'
  83. const useAppState = useAppStore()
  84. const contractId = ref(useAppState.getContractId)
  85. defineOptions({
  86. name: 'DebitPayStartWorkOrder',
  87. })
  88. //渲染完成
  89. onActivated(async () => {
  90. await getKey1Data()
  91. getTableData().then()
  92. })
  93. onActivated(() => {
  94. getKey1Data()
  95. })
  96. //计量期
  97. const key1Data = ref([])
  98. const approveStatus = ref(0)
  99. const getKey1Data = async ()=>{
  100. const { error, code, data } = await periodApi.allPeriod({
  101. contractId:contractId.value,
  102. type:2,
  103. })
  104. tableLoading.value = false
  105. if (!error && code === 200) {
  106. let newArr = getArrValue(data), info = getObjValue(newArr[newArr.length - 1])
  107. searchForm.value.meterPeriodId = info.id
  108. approveStatus.value = info.approveStatus
  109. key1Data.value = newArr
  110. } else {
  111. key1Data.value = []
  112. }
  113. }
  114. //搜索表单
  115. const searchForm = ref({
  116. meterPeriodId: null, current: 1, size: 20, total: 0,
  117. })
  118. //计量期
  119. const searchKey1Click = () => {
  120. let info = getObjValue(key1Data.value.find((item) => item.id === searchForm.value.meterPeriodId))
  121. approveStatus.value = info.approveStatus
  122. searchForm.value.current = 1
  123. getTableData()
  124. }
  125. //分页
  126. const pageChange = ({ current, size }) => {
  127. searchForm.value.current = current
  128. searchForm.value.size = size
  129. getTableData()
  130. }
  131. //表格数据
  132. const tableLoading = ref(false)
  133. const tableColumn = ref([
  134. { key: 'periodName', name: '计量期' },
  135. { key: 'businessDate', name: '业务日期' },
  136. { key: 'meterMoney', name: '计量金额' },
  137. { key: 'approveStatusName', name: '审批状态' },
  138. { key: 'action', name: '操作', width: 94 },
  139. ])
  140. const tableData = ref([
  141. ])
  142. const getTableData = async () => {
  143. tableLoading.value = true
  144. console.log(searchForm.value, 'searchForm.value')
  145. const { error, code, data } = await mainApi.getPage({
  146. ...searchForm.value,
  147. contractId:contractId.value,
  148. })
  149. tableLoading.value = false
  150. if (!error && code === 200) {
  151. tableData.value = getArrValue(data['records'])
  152. searchForm.value.total = data['total']
  153. if (tableData.value.length > 0) {
  154. getDetail(tableData.value[0].id)
  155. } else {
  156. infoData.value = {}
  157. }
  158. } else {
  159. tableData.value = []
  160. searchForm.value.total = 0
  161. }
  162. }
  163. //获取详情
  164. const infoData = ref({})
  165. const getDetail = async (id)=>{
  166. const { error, code, data } = await mainApi.detail({
  167. id,
  168. })
  169. if (!error && code === 200) {
  170. infoData.value = getObjValue(data)
  171. } else {
  172. infoData.value = {}
  173. }
  174. }
  175. //查看附件
  176. const viewFile = (item)=>{
  177. toPdfPage(item.filePdfUrl)
  178. }
  179. //表格选择
  180. const tableCheckChange = () => {
  181. }
  182. const hanleRow = ({ row })=>{
  183. getDetail(row.id)
  184. }
  185. //新增
  186. const isDataModal = ref(false)
  187. const addModalClick = () => {
  188. isDataModal.value = true
  189. editId.value = ''
  190. }
  191. const editId = ref('')
  192. //修改
  193. const rowEditClick = (row) => {
  194. isDataModal.value = true
  195. editId.value = row.id
  196. }
  197. const delRowClick = (row)=>{
  198. HcDelMsg( async ( resolve) => {
  199. await removeProPay(row.id)
  200. resolve() //关闭弹窗的回调
  201. })
  202. }
  203. const removeProPay = async (id) => {
  204. const { error, code, msg } = await mainApi.remove({
  205. ids: id,
  206. })
  207. if (!error && code === 200) {
  208. window?.$message?.success('删除成功')
  209. getTableData()
  210. } else {
  211. window.$message.error(msg ?? '操作失败')
  212. }
  213. }
  214. const finishData = ()=>{
  215. isDataModal.value = false
  216. getTableData()
  217. }
  218. //是否上报
  219. const isReport = ref(false)
  220. const reportInfo = ref({})
  221. const reportClick = () => {
  222. reportInfo.value = {
  223. type: 3,
  224. periodId: searchForm.value.meterPeriodId,
  225. }
  226. nextTick(() => {
  227. isReport.value = true
  228. })
  229. }
  230. //上报完成
  231. const reportFinish = () => {
  232. window.location.reload()
  233. }
  234. </script>
  235. <style scoped lang="scss">
  236. </style>