order.vue 15 KB

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