order.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <hc-new-card>
  3. <template #header>
  4. <hc-new-switch :datas="tabTab" :keys="tabKey" :round="false" size="default" @change="tabChange" />
  5. <div v-if="tabKey === 'key2'" class="ml-3 w-40">
  6. <el-select v-model="searchForm.key1" filterable block placeholder="选择工区">
  7. <el-option label="工区1" value="1" />
  8. <el-option label="工区2" value="2" />
  9. <el-option label="工区3" value="3" />
  10. </el-select>
  11. </div>
  12. </template>
  13. <template #extra>
  14. <el-button hc-btn type="primary" @click="addModalClick">
  15. <hc-icon name="add" />
  16. <span>新增</span>
  17. </el-button>
  18. <el-button hc-btn type="warning" :disabled="tableCheckKeys.length <= 0" @click="reportClick">
  19. <hc-icon name="send-plane-2" />
  20. <span>上报</span>
  21. </el-button>
  22. <el-button hc-btn color="#FF7D43" :loading="undoLoading" class="text-white" :disabled="tableCheckKeys.length <= 0" @click="undoReportClick">
  23. <span>撤销上报11</span>
  24. </el-button>
  25. </template>
  26. <div class="relative h-full flex">
  27. <div :id="`hc_table_card_${uuid}`" class="flex-1">
  28. <hc-card-item>
  29. <hc-table
  30. ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading"
  31. is-current-row is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
  32. @row-click="tableRowClick" @selection-change="tableCheckChange"
  33. >
  34. <template #action="{ row }">
  35. <template v-if="row.approveStatus === 2">
  36. <el-link v-if="row.commandStatus === 0" type="success" @click="rowExecuteChange(row.id)">下达</el-link>
  37. <el-link v-if="row.commandStatus === 0" type="danger" @click="delRowClick(row)">删除</el-link>
  38. <el-link v-if="row.commandStatus === 1 && row.citeStatus === 0" type="success" @click="rowAnnulChange(row.id)">撤销下达</el-link>
  39. </template>
  40. <template v-if="row.approveStatus === 0 || row.approveStatus === 3">
  41. <el-link type="success" @click="rowEditClick(row)">修改</el-link>
  42. <el-link type="danger" @click="delRowClick(row)">删除</el-link>
  43. </template>
  44. </template>
  45. </hc-table>
  46. <template #action>
  47. <hc-pages :pages="searchForm" @change="pageChange" />
  48. </template>
  49. </hc-card-item>
  50. </div>
  51. <div :id="`hc_info_card_${uuid}`">
  52. <el-scrollbar>
  53. <hc-card-item title="详情信息">
  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">{{ tableInfo.changeNumber ?? '-' }}</hc-info-table-td>
  58. <hc-info-table-td center is-title>变更方案名称:</hc-info-table-td>
  59. <hc-info-table-td width="120px">{{ tableInfo.changeName ?? '-' }}</hc-info-table-td>
  60. <hc-info-table-td center is-title>变更发起单位:</hc-info-table-td>
  61. <hc-info-table-td width="120px">{{ tableInfo.changeUnit ?? '-' }}</hc-info-table-td>
  62. </tr>
  63. <tr>
  64. <hc-info-table-td center is-title>业务日期:</hc-info-table-td>
  65. <hc-info-table-td width="160px">{{ tableInfo.businessDate ?? '-' }}</hc-info-table-td>
  66. <hc-info-table-td center is-title>变更类型:</hc-info-table-td>
  67. <hc-info-table-td width="120px">{{ tableInfo.changeTypeName ?? '-' }}</hc-info-table-td>
  68. <hc-info-table-td center is-title>延长工期:</hc-info-table-td>
  69. <hc-info-table-td width="120px">{{ tableInfo.lengthenDays ?? '-' }}</hc-info-table-td>
  70. </tr>
  71. <tr>
  72. <hc-info-table-td center is-title>变更申请金额:</hc-info-table-td>
  73. <hc-info-table-td width="120px">{{ tableInfo.changeMoney ?? '-' }}</hc-info-table-td>
  74. <hc-info-table-td center is-title>设计图完成时间:</hc-info-table-td>
  75. <hc-info-table-td width="120px">{{ tableInfo.designDate ?? '-' }}</hc-info-table-td>
  76. <hc-info-table-td center is-title>实际变更桩号:</hc-info-table-td>
  77. <hc-info-table-td width="120px">{{ tableInfo.realityChangeNumber ?? '-' }}</hc-info-table-td>
  78. </tr>
  79. <tr>
  80. <hc-info-table-td center is-title>变更归类:</hc-info-table-td>
  81. <hc-info-table-td width="120px">{{ tableInfo.changeClassifyName ?? '-' }}</hc-info-table-td>
  82. <hc-info-table-td center is-title>变更批复文号:</hc-info-table-td>
  83. <hc-info-table-td width="120px">{{ tableInfo.changeApprovalNumber ?? '-' }}</hc-info-table-td>
  84. <hc-info-table-td center is-title>变更批复时间:</hc-info-table-td>
  85. <hc-info-table-td width="120px">{{ tableInfo.changeApprovalDate ?? '-' }}</hc-info-table-td>
  86. </tr>
  87. <tr>
  88. <hc-info-table-td center is-title>引用预变更:</hc-info-table-td>
  89. <hc-info-table-td width="auto" colspan="5">-</hc-info-table-td>
  90. </tr>
  91. <tr>
  92. <hc-info-table-td center is-title>变更原因:</hc-info-table-td>
  93. <hc-info-table-td width="auto" colspan="5">{{ tableInfo.changeCause ?? '-' }}</hc-info-table-td>
  94. </tr>
  95. </hc-info-table>
  96. </hc-card-item>
  97. <hc-card-item class="mt-3" title="变更申请部位">
  98. <hc-table ref="tableRef1" :column="tableColumn1" :datas="tableInfo.nodeList" is-new :index-style="{ width: 60 }" is-current-row @row-click="tableNodeRowClick" />
  99. </hc-card-item>
  100. <hc-card-item v-if="tableChangeData.length > 0" class="mt-3" title="变更申请清单">
  101. <div class="no-border hc-table-ref-box">
  102. <el-table class="w-full" :data="tableChangeData" row-key="id" height="100%" highlight-current-row border>
  103. <el-table-column type="index" label="序号" />
  104. <el-table-column prop="formNumber" label="清单编号" />
  105. <el-table-column prop="formName" label="清单名称" />
  106. <el-table-column prop="currentPrice" label="单价" />
  107. <el-table-column label="数量" align="center">
  108. <el-table-column prop="contractTotal" label="变更前" />
  109. <el-table-column prop="currentChangeTotal" label="变更增减" />
  110. <el-table-column prop="changeTotal" label="变更后" />
  111. </el-table-column>
  112. <el-table-column label="金额" align="center">
  113. <el-table-column prop="contractMoney" label="变更前" />
  114. <el-table-column prop="currentChangeMoney" label="变更增减" />
  115. <el-table-column prop="changeMoney" label="变更后" />
  116. </el-table-column>
  117. </el-table>
  118. </div>
  119. </hc-card-item>
  120. <!-- 附件列表 -->
  121. <hc-card-item class="mt-3" title="附件列表">
  122. <hc-form-upload
  123. v-model="tableInfo.fileList" class="table-info-file"
  124. :options="{ type: 'list', props: uploadFormProps, isArr: true }"
  125. :upload="{ options: { multiple: false } }"
  126. />
  127. </hc-card-item>
  128. </el-scrollbar>
  129. </div>
  130. </div>
  131. <!-- 上报弹窗 -->
  132. <hc-report-dialog v-model="isReport" :info="reportInfo" :is-build-audit="false" :is-batch="true" @finish="reportFinish" />
  133. <!-- 新增修改的弹窗 -->
  134. <addModal v-model="isAddShow" :ids="addEditIds" @finish="addEditFinish" />
  135. </hc-new-card>
  136. </template>
  137. <script setup>
  138. import { nextTick, onActivated, onMounted, ref } from 'vue'
  139. import { backMeterTask } from '~api/other'
  140. import { useAppStore } from '~src/store'
  141. import { actionConfirm, delMessage } from '~uti/tools'
  142. import addModal from './components/order/addModal.vue'
  143. import { arrToId, getArrValue, getObjValue, getRandom, isNullES } from 'js-fast-way'
  144. import mainApi from '~api/alter/admin/order'
  145. defineOptions({
  146. name: 'AlterAdminOrder',
  147. })
  148. const uuid = getRandom(4)
  149. const useAppState = useAppStore()
  150. const projectId = ref(useAppState.getProjectId || '')
  151. const contractId = ref(useAppState.getContractId || '')
  152. //渲染完成
  153. onMounted(() => {
  154. setSplitRef()
  155. })
  156. //激活
  157. onActivated(() => {
  158. getTableData()
  159. })
  160. //初始化设置拖动分割线
  161. const setSplitRef = () => {
  162. //配置参考: https://split.js.org/#/?direction=vertical&snapOffset=0
  163. nextTick(() => {
  164. window.$split(['#hc_table_card_' + uuid, '#hc_info_card_' + uuid], {
  165. sizes: [60, 40],
  166. snapOffset: 0,
  167. minSize: [100, 400],
  168. })
  169. })
  170. }
  171. //类型tab数据和相关处理
  172. const tabKey = ref('key1')
  173. const tabTab = ref([
  174. { key: 'key1', name: '普通变更' },
  175. { key: 'key2', name: '工区变更' },
  176. ])
  177. const tabChange = (item) => {
  178. tabKey.value = item?.key
  179. }
  180. //搜索表单
  181. const searchForm = ref({
  182. key1: null, current: 1, size: 10, total: 0,
  183. })
  184. //分页
  185. const pageChange = ({ current, size }) => {
  186. searchForm.value.current = current
  187. searchForm.value.size = size
  188. getTableData()
  189. }
  190. //表格数据
  191. const tableRef = ref(null)
  192. const tableColumn = ref([
  193. { key: 'changeNumber', name: '变更编号' },
  194. { key: 'changeName', name: '变更名称' },
  195. { key: 'changeMoney', name: '变更金额' },
  196. { key: 'changeTypeName', name: '变更类型' },
  197. { key: 'changeApprovalDate', name: '变更批复日期' },
  198. { key: 'approveStatusName', name: '审批状态' },
  199. { key: 'action', name: '操作', width: 94 },
  200. ])
  201. const tableData = ref([])
  202. //获取表格数据
  203. const tableLoading = ref(false)
  204. const getTableData = async () => {
  205. tableData.value = []
  206. tableLoading.value = true
  207. const { data } = await mainApi.getPage({
  208. ...searchForm.value,
  209. projectId: projectId.value,
  210. contractId: contractId.value,
  211. })
  212. tableData.value = getArrValue(data['records'])
  213. searchForm.value.total = data.total || 0
  214. tableLoading.value = false
  215. //默认选中第一行
  216. let info = {}
  217. if (tableData.value.length > 0) {
  218. info = tableData.value[0]
  219. }
  220. tableRef.value?.tableRef?.setCurrentRow(info)
  221. getTableDetail(info).then()
  222. }
  223. //表格行被点击
  224. const tableRowClick = ({ row }) => {
  225. getTableDetail(row)
  226. }
  227. //获取详情
  228. const tableInfo = ref({})
  229. const getTableDetail = async (row) => {
  230. if (!row.id) return
  231. const { data } = await mainApi.getDetail({ id: row.id })
  232. const dataInfo = getObjValue(data)
  233. dataInfo.nodeList = getArrValue(dataInfo.nodeList)
  234. tableInfo.value = dataInfo
  235. //默认选中部位的第一行
  236. let info = {}
  237. if (dataInfo.nodeList.length > 0) {
  238. info = dataInfo.nodeList[0]
  239. }
  240. tableRef1.value?.tableRef?.setCurrentRow(info)
  241. tableChangeData.value = getArrValue(info.formList)
  242. }
  243. //修改
  244. const addEditIds = ref('')
  245. const rowEditClick = (row) => {
  246. addEditIds.value = row.id
  247. nextTick(() => {
  248. isAddShow.value = true
  249. })
  250. }
  251. //新增修改的弹窗
  252. const isAddShow = ref(false)
  253. const addModalClick = () => {
  254. addEditIds.value = ''
  255. nextTick(() => {
  256. isAddShow.value = true
  257. })
  258. }
  259. const tableRef1 = ref(null)
  260. //申请部位
  261. const tableColumn1 = ref([
  262. { key: 'nodeName', name: '工程名称' },
  263. { key: 'nodeUrl', name: '节点路径' },
  264. { key: 'contractPicture', name: '合同图号' },
  265. { key: 'changeMoney', name: '变更后金额(元)' },
  266. { key: 'isSupplementName', name: '是否增补' },
  267. ])
  268. //申请部位被点击
  269. const tableChangeData = ref([])
  270. const tableNodeRowClick = ({ row }) => {
  271. tableChangeData.value = getArrValue(row.formList)
  272. }
  273. //附件列表
  274. const uploadFormProps = {
  275. url: 'fileUrl',
  276. name: 'fileName',
  277. }
  278. //新增修改完成
  279. const addEditFinish = () => {
  280. getTableData()
  281. }
  282. //删除
  283. const delRowClick = (row) => {
  284. delMessage(async () => {
  285. const { error, code, msg } = await mainApi.remove({ ids: row.id })
  286. if (!error && code === 200) {
  287. window.$message.success('删除成功')
  288. getTableData().then()
  289. } else {
  290. window.$message.error(msg ?? '删除失败')
  291. }
  292. })
  293. }
  294. //下达变更
  295. const rowExecuteChange = async (id) => {
  296. if (isNullES(id)) {
  297. window.$message.error('id异常')
  298. return
  299. }
  300. // 确认发起请求
  301. actionConfirm(async () => {
  302. tableLoading.value = true
  303. const { error, code, msg } = await mainApi.executeChange({ id })
  304. tableLoading.value = false
  305. if (!error && code === 200) {
  306. window.$message.success('下达成功')
  307. getTableData().then()
  308. } else {
  309. window.$message.error(msg ?? '下达失败')
  310. }
  311. })
  312. }
  313. //撤销下达
  314. const rowAnnulChange = async (id) => {
  315. if (isNullES(id)) {
  316. window.$message.error('id异常')
  317. return
  318. }
  319. // 确认发起请求
  320. actionConfirm(async () => {
  321. tableLoading.value = true
  322. const { error, code, msg } = await mainApi.annulChange({ id })
  323. tableLoading.value = false
  324. if (!error && code === 200) {
  325. window.$message.success('撤销下达成功')
  326. getTableData().then()
  327. } else {
  328. window.$message.error(msg ?? '撤销下达失败')
  329. }
  330. })
  331. }
  332. //表格选择
  333. const tableCheckKeys = ref([])
  334. const tableCheckChange = (keys) => {
  335. tableCheckKeys.value = keys
  336. }
  337. //是否上报
  338. const isReport = ref(false)
  339. const reportInfo = ref({})
  340. const reportClick = () => {
  341. const rows = tableCheckKeys.value
  342. //判断是否满足条件
  343. const result = rows.every(({ approveStatus }) => {
  344. return approveStatus === 0
  345. })
  346. if (!result) {
  347. window.$message?.warning('请选择未上报的数据')
  348. return
  349. }
  350. //处理数据
  351. const rowIds = arrToId(rows)
  352. reportInfo.value = { type: 4, periodId: rowIds }
  353. nextTick(() => {
  354. isReport.value = true
  355. })
  356. }
  357. //上报完成
  358. const reportFinish = () => {
  359. window.location.reload()
  360. }
  361. //撤销上报
  362. const undoLoading = ref(false)
  363. const undoReportClick = async () => {
  364. const rows = tableCheckKeys.value
  365. if (rows.length <= 0) {
  366. window.$message?.warning('请先勾选要撤销的数据')
  367. return
  368. }
  369. if (rows.length > 1) {
  370. window.$message?.warning('每次只能撤销一条数据')
  371. return
  372. }
  373. const { id, approveStatus } = rows[0]
  374. if (approveStatus !== 1) {
  375. window.$message?.warning('只能撤销待审批的数据')
  376. return
  377. }
  378. undoLoading.value = true
  379. const { isRes } = await backMeterTask({
  380. periodId: id,
  381. type: 3,
  382. })
  383. undoLoading.value = false
  384. if (!isRes) return
  385. window.$message.success('撤回成功')
  386. reportFinish()
  387. }
  388. </script>
  389. <style lang="scss">
  390. .table-info-file .item-upload-btn {
  391. display: none;
  392. }
  393. .hc-ui-form-upload-box.table-info-file .hc-ui-form-item-dashed.list .file-list-box {
  394. margin-top: 0;
  395. }
  396. .hc-ui-form-upload-box.table-info-file .hc-ui-form-item-dashed.list .file-list-box .item .close-icon {
  397. display: none;
  398. }
  399. </style>