order.vue 11 KB

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