order.vue 12 KB

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