order.vue 9.0 KB

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