unit.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. <template>
  2. <div class="relative h-full flex">
  3. <div :id="`hc_tree_card_${uuid}`">
  4. <hc-new-card scrollbar>
  5. <template #header>
  6. <div class="w-full flex justify-between">
  7. <el-button hc-btn type="primary" :loading="setLoading" @click="setTree">重新设置treeCode</el-button>
  8. <el-button hc-btn type="primary" :loading="linkLoading" @click="linkDataClick(1)">关联资料</el-button>
  9. </div>
  10. </template>
  11. <hc-lazy-tree
  12. v-if="ishowTree"
  13. :auto-expand-keys="TreeAutoExpandKeys"
  14. tree-key="id"
  15. :h-props="treeProps"
  16. is-load-menu
  17. @load="treeLoadNode"
  18. @load-menu="treeLoadMenu"
  19. @menu-tap="treeMenuTap"
  20. @node-tap="treeNodeTap"
  21. />
  22. </hc-new-card>
  23. </div>
  24. <div :id="`hc_table_card_${uuid}`" class="flex-1">
  25. <hc-new-card scrollbar title="合同计量单元">
  26. <template #extra>
  27. <el-button hc-btn type="primary" @click="editModalShow = true">修改</el-button>
  28. <el-button hc-btn type="danger">删除</el-button>
  29. <el-button hc-btn type="warning" @click="treeModalShow = true">增补单元</el-button>
  30. <el-button hc-btn type="success" @click="leadModal">导入</el-button>
  31. </template>
  32. <div class="relative">
  33. <infoTable :info-data="curTreeData" />
  34. <HcTitle title="清单分解汇总列表">
  35. <template #extra>
  36. <div class="text-sm text-orange">温馨提示:累计分解量 > 合同变更后量,整行文字红色</div>
  37. </template>
  38. </HcTitle>
  39. <div style="height: calc(50vh - 210px);">
  40. <hc-table
  41. :is-stripe="false" :column="tableColumn" :datas="tableData" :loading="tableLoading"
  42. is-new :index-style="{ width: 60 }" :row-style="tableRowStyle"
  43. >
  44. <template #key1="{ row }">
  45. <i class="i-iconoir-open-select-hand-gesture inline-block" />
  46. </template>
  47. </hc-table>
  48. </div>
  49. <HcTitle title="质检关联清单">
  50. <template #extra>
  51. <el-button hc-btn type="primary" @click="linkDataClick(2)">关联</el-button>
  52. <el-button hc-btn type="primary" :loading="batchCancleload" :disabled="cancelKeys.length == 0" @click="batchCancle">批量取消</el-button>
  53. </template>
  54. </HcTitle>
  55. <div style="height: calc(50vh - 250px);">
  56. <hc-table
  57. :is-stripe="false" :column="qualtableColumn" :datas="qualtableData" :loading="tableLoading"
  58. is-new :index-style="{ width: 60 }"
  59. is-check @selection-change="tableSelectionChange"
  60. >
  61. <template #appStatusName="{ row }">
  62. <el-tag
  63. v-if="row.appStatusName"
  64. :type="`${row.appStatusName === '已审批' ? 'success' : row.appStatusName === '已填报-待审批' ? 'warning' : row.appStatusName === '已填报-未上报' ? 'primary' : 'info'}`"
  65. class="mx-1" effect="dark"
  66. >
  67. {{ row.appStatusName }}
  68. </el-tag>
  69. </template>
  70. <template #action="{ row }">
  71. <el-button hc-btn type="primary" size="small" :loading="row?.load" @click="cancleLink(row)">取消关联</el-button>
  72. </template>
  73. </hc-table>
  74. </div>
  75. </div>
  76. </hc-new-card>
  77. </div>
  78. <!-- 节点新增和编辑 -->
  79. <treeForm
  80. v-model="treeModalShow" :ids="curTreeData.id" :menu-type="menuType"
  81. :template-id="curTreeData.templateId" @finish="finishForm"
  82. />
  83. <!-- 修改合同计量单元 -->
  84. <rowData
  85. v-model="editModalShow" :is-table="isInfoView" :ids="curTreeData.id" :cur-tree-data="curTreeData"
  86. @finish="finishEdit" @close="closeEdit" @get-detail="getTreeNodeDetail"
  87. />
  88. <!-- 调整排序 -->
  89. <hc-new-dialog
  90. v-model="sortModalShow" is-table widths="1100px" title="调整排序" :loading="sortNodeLoading"
  91. @save="sortModalSave"
  92. >
  93. <hc-table
  94. ui="hc-table-row-drop"
  95. :column="sortTableColumn" :datas="sortTableData" :loading="sortTableLoading"
  96. is-row-drop quick-sort is-new :index-style="{ width: 80 }"
  97. @row-drop="sortTableRowDrop" @row-sort="sortTableRowDrop"
  98. >
  99. <template #key2="{ row }">
  100. <span class="text-link">{{ row?.key2 }}</span>
  101. </template>
  102. <template #action="{ index }">
  103. <span class="text-link text-xl" @click="upSortClick(index)">
  104. <HcIcon name="arrow-up" fill />
  105. </span>
  106. <span class="text-link ml-2 text-xl" @click="downSortClick(index)">
  107. <HcIcon name="arrow-down" fill />
  108. </span>
  109. </template>
  110. </hc-table>
  111. </hc-new-dialog>
  112. <!-- 导入合同计量单元 -->
  113. <hc-new-dialog v-model="leadModalShow" scrollbar widths="1100px" title="合同计量单元导入" @save="leadModalSave">
  114. <div class="hc-el-upload-drag">
  115. <el-upload
  116. ref="leadUploadRef" hc drag :show-file-list="true" :auto-upload="false" :headers="getHeader()"
  117. action="/api/blade-meter/tree/contract/import" :data="{ id: checkTreeId, type: typevalue }" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  118. :on-error="handFileError"
  119. :on-success="handleFileDUcess"
  120. :disabled="!typevalue"
  121. @click="beforeUpload"
  122. >
  123. <div class="hc-ui-upload-btn">
  124. <div class="hc-uploader-drop">
  125. <div class="upload-icon">
  126. <HcIcon name="upload-cloud" />
  127. </div>
  128. <div class="text">将文件拖动到此处,或点击上传</div>
  129. </div>
  130. <div class="hc-uploader-accept">支持的文件格式: Excel(xls、xlsx)</div>
  131. </div>
  132. </el-upload>
  133. </div>
  134. <hc-title>
  135. <span>范例模板</span>
  136. <template #extra>
  137. <span style="color: red;">*</span> 切换范例模板:
  138. <el-select
  139. v-model="typevalue"
  140. placeholder="请选择"
  141. style="width: 240px"
  142. clearable
  143. >
  144. <el-option
  145. v-for="item in typeoptions"
  146. :key="item.value"
  147. :label="item.label"
  148. :value="item.value"
  149. />
  150. </el-select>
  151. <el-link type="primary" @click="downLoadExel">下载范例模板.xls</el-link>
  152. </template>
  153. </hc-title>
  154. <el-table v-if="typevalue === '2'" :data="tableLeadData" style="width: 100%;" row-key="id" border>
  155. <el-table-column prop="k1" label="工程编号" width="90" />
  156. <el-table-column prop="k2" label="节点编号" width="90" />
  157. <el-table-column prop="k3" label="清单编号" width="90" />
  158. <el-table-column prop="k4" label="工程名称" />
  159. <el-table-column prop="k5" label="施工图数量" width="100" />
  160. <el-table-column prop="k6" label="合同图号" width="90" />
  161. <el-table-column prop="k7" label="备注" />
  162. </el-table>
  163. <el-table v-if="typevalue === '1'" :data="tableLeadData1" style="width: 100%;" row-key="id" border>
  164. <el-table-column prop="k1" label="桩号支付编号" />
  165. <el-table-column prop="k2" label="图号" />
  166. <el-table-column prop="k3" label="403-1-1" />
  167. <el-table-column prop="k4" label="403-1-2" />
  168. <el-table-column prop="k5" label="403-1-3" />
  169. <el-table-column prop="k6" label="404-1-4" />
  170. <el-table-column prop="k7" label="清单编号..." />
  171. <el-table-column prop="k8" label="备注" />
  172. </el-table>
  173. <el-table v-if="typevalue === '3'" :data="tableLeadData3" style="width: 100%;" row-key="id" border>
  174. <el-table-column prop="k1" label="单位工程" />
  175. <el-table-column prop="k2" label="子单位工程" />
  176. <el-table-column prop="k3" label="分部工程" />
  177. <el-table-column prop="k4" label="子分部工程" />
  178. <el-table-column prop="k5" label="图册" />
  179. <el-table-column prop="k6" label="图号" />
  180. <el-table-column prop="k7" label="开始桩号" />
  181. <el-table-column prop="k8" label="结束桩号" />
  182. <el-table-column prop="k9" label="清单编号" />
  183. <el-table-column prop="k10" label="清单名称" />
  184. <el-table-column prop="k11" label="分解核实量" />
  185. </el-table>
  186. <div v-if="typevalue === '1'" class="mt-3 text-orange font-400">温馨提示:清单编号需手动填写,清单编号列填写施工图数量,若有关联则填写数字,反之保留空白</div>
  187. </hc-new-dialog>
  188. <!--
  189. 关联资料 -->
  190. <linkData :link-modal="linkModal" :is-check-id="isCheckId" :check-ids="checkTreeId" :right-tree-check="rightTreeCheck" @close="closeLink" @save="saveLink" />
  191. </div>
  192. </template>
  193. <script setup>
  194. import { nextTick, onMounted, ref } from 'vue'
  195. import { arrToId, arrToKey, getArrValue, getObjValue, getRandom } from 'js-fast-way'
  196. import infoTable from './components/unit/info-table.vue'
  197. import treeForm from './components/unit/tree-form.vue'
  198. import rowData from './components/unit/row-data.vue'
  199. import unitApi from '~api/project/debit/contract/unit.js'
  200. import linkData from './components/unit/link-data.vue'
  201. import { useAppStore } from '~src/store'
  202. import { getStoreValue, setStoreValue } from '~src/utils/storage'
  203. import { HcDelMsg } from 'hc-vue3-ui'
  204. import { getDictionary } from '~api/other'
  205. import BigNumber from 'bignumber.js'
  206. import { getHeader } from 'hc-vue3-ui'
  207. const useAppState = useAppStore()
  208. const projectId = ref(useAppState.getProjectId || '')
  209. const contractId = ref(useAppState.getContractId || '')
  210. defineOptions({
  211. name: 'ProjectDebitContractUnit',
  212. })
  213. const uuid = getRandom(4)
  214. //渲染完成
  215. onMounted(() => {
  216. setSplitRef()
  217. // getNodeType()
  218. })
  219. //初始化设置拖动分割线
  220. const setSplitRef = () => {
  221. //配置参考: https://split.js.org/#/?direction=vertical&snapOffset=0
  222. nextTick(() => {
  223. window.$split(['#hc_tree_card_' + uuid, '#hc_table_card_' + uuid], {
  224. sizes: [20, 80],
  225. snapOffset: 0,
  226. minSize: [50, 500],
  227. })
  228. })
  229. }
  230. //获节点类型
  231. const nodeOptions = ref([])
  232. const getNodeType = async (id) => {
  233. const { data } = await unitApi.getNodeTypeList({
  234. id,
  235. })
  236. nodeOptions.value = getArrValue(data)
  237. nodeOptions.value.forEach((ele) => {
  238. ele.dictKey = Number(ele.dictKey)
  239. })
  240. }
  241. //搜索表单
  242. const searchForm = ref({})
  243. //数据格式
  244. const treeProps = {
  245. label: 'nodeName',
  246. children: 'children',
  247. isLeaf: 'notExsitChild',
  248. }
  249. const ishowTree = ref(true)
  250. //重新设置树
  251. const setLoading = ref(false)
  252. const setTree = async () => {
  253. setLoading.value = true
  254. const { error, code, msg } = await unitApi.refresh({
  255. projectId: projectId.value,
  256. contractId: contractId.value,
  257. })
  258. setLoading.value = false
  259. if (!error && code === 200) {
  260. window.$message.success(msg)
  261. ishowTree.value = false
  262. setTimeout(() => {
  263. ishowTree.value = true
  264. }, 100)
  265. } else {
  266. window.$message.error(msg)
  267. }
  268. }
  269. //懒加载的数据
  270. const TreeAutoExpandKeys = ref(getStoreValue('wbsTreeExpandKeys') || [])
  271. const treeLoadNode = async ({ node, item, level }, resolve) => {
  272. let id = 0
  273. if (level !== 0) {
  274. const nodeData = getObjValue(item)
  275. id = nodeData?.id || ''
  276. }
  277. //获取数据
  278. const { error, code, data } = await unitApi.lazyTree({
  279. contractId: contractId.value,
  280. id: id,
  281. })
  282. resolve(getArrValue(data))
  283. }
  284. //节点点击
  285. const isInfoView = ref(false)
  286. const checkTreeId = ref('')
  287. const checkTreeLevel = ref('')
  288. const treeNodeTap = ({ node, data, keys }) => {
  289. treeClickdata.value = data
  290. const { level } = node
  291. checkTreeLevel.value = level
  292. checkTreeId.value = data.id
  293. getNodeType(data.id)
  294. isInfoView.value = node.isLeaf
  295. TreeAutoExpandKeys.value = keys || []
  296. setStoreValue('wbsTreeExpandKeys', keys)
  297. getTreeNodeDetail(data)
  298. }
  299. //获取节点详情
  300. //选中的节点数组
  301. const rightTreeCheck = ref([])
  302. const curTreeData = ref({})
  303. const getTreeNodeDetail = async ({ id }) => {
  304. const { error, code, data } = await unitApi.getNodeDetail({ id })
  305. if (!error && code === 200) {
  306. curTreeData.value = getObjValue(data)
  307. tableData.value = curTreeData.value['decompositionList']
  308. qualtableData.value = curTreeData.value['linkNodeList']
  309. rightTreeCheck.value = arrToKey(qualtableData.value, 'wbsTreeId', ',').split(',')
  310. nodeOptions.value.forEach((ele) => {
  311. if (curTreeData.value.nodeType === ele.dictKey) {
  312. curTreeData.value.nodeTypeName = ele.dictValue
  313. }
  314. })
  315. } else {
  316. curTreeData.value = {}
  317. tableData.value = []
  318. qualtableData.value = []
  319. }
  320. }
  321. //菜单
  322. const treeLoadMenu = ({ item, level }, resolve) => {
  323. const { isLock } = item
  324. if (level === 1) {
  325. if (isLock === 1) {
  326. return resolve([
  327. { icon: 'lock', label: '解锁', key: 'lock' },
  328. { icon: 'upload-cloud', label: '导入', key: 'lead' },
  329. { icon: 'add', label: '新增', key: 'add' },
  330. { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
  331. ])
  332. } else {
  333. return resolve([
  334. { icon: 'lock', label: '锁定', key: 'lock' },
  335. { icon: 'upload-cloud', label: '导入', key: 'lead' },
  336. { icon: 'add', label: '新增', key: 'add' },
  337. { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
  338. ])
  339. }
  340. } else {
  341. if (isLock === 1) {
  342. return resolve([
  343. { icon: 'lock', label: '解锁', key: 'lock' },
  344. { icon: 'upload-cloud', label: '导入', key: 'lead' },
  345. { icon: 'add', label: '新增', key: 'add' },
  346. { icon: 'pencil', label: '修改', key: 'edit' },
  347. { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
  348. { icon: 'close', label: '删除', key: 'del' },
  349. ])
  350. } else {
  351. return resolve([
  352. { icon: 'lock', label: '锁定', key: 'lock' },
  353. { icon: 'upload-cloud', label: '导入', key: 'lead' },
  354. { icon: 'add', label: '新增', key: 'add' },
  355. { icon: 'pencil', label: '修改', key: 'edit' },
  356. { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
  357. { icon: 'close', label: '删除', key: 'del' },
  358. ])
  359. }
  360. }
  361. }
  362. const menuType = ref('')
  363. const treeClickdata = ref()
  364. const treeMenuTap = ({ key, node, data, keys }) => {
  365. const { isDecompositionData } = data
  366. isInfoView.value = node.isLeaf
  367. menuType.value = key
  368. getTreeNodeDetail(data)
  369. setStoreValue('wbsTreeExpandKeys', keys)
  370. TreeAutoExpandKeys.value = keys || []
  371. if (data?.isLock !== 1) {
  372. if (key === 'add') {
  373. if (isDecompositionData === 1) {
  374. window.$message.warning('该节点下面不允许新增节点')
  375. } else {
  376. treeModalShow.value = true
  377. }
  378. }
  379. if (key === 'edit') {
  380. editModalShow.value = true
  381. }
  382. if (key === 'sort') {
  383. let nodes = [], childNodes = []
  384. childNodes = node?.parent?.childNodes || node?.parent?.children || []
  385. for (let i = 0; i < childNodes.length; i++) {
  386. const res = childNodes[i]?.data
  387. nodes.push({
  388. nodeName: res?.nodeName,
  389. id: res?.id,
  390. })
  391. }
  392. sortTableData.value = nodes
  393. sortModalShow.value = true
  394. }
  395. if (key === 'del') {
  396. delModalClick()
  397. }
  398. }
  399. if (data?.isLock === 1 && key !== 'lock') {
  400. window.$message.warning('当前节点为锁定状态,不允许操作')
  401. }
  402. if (key === 'lock') {
  403. handleLockNode()
  404. }
  405. }
  406. //锁定节点
  407. const handleLockNode = async () => {
  408. const { error, code, msg } = await unitApi.getLock({
  409. id: curTreeData.value.id || '',
  410. lockStatus: curTreeData.value?.isLock === 1 ? 0 : 1,
  411. })
  412. if (!error && code === 200) {
  413. window?.$message?.success(msg)
  414. window?.location?.reload() //刷新页面
  415. }
  416. }
  417. //删除节点
  418. const delModalClick = async () => {
  419. await HcDelMsg({
  420. type: 'delete',
  421. title: '确认删除提醒',
  422. text: '请谨慎考虑后,确认是否需要删除?',
  423. confirmText: '确认删除',
  424. cancelText: '取消操作',
  425. }, async (instance, resolve) => {
  426. instance.confirmButtonLoading = true
  427. instance.confirmButtonText = 'Loading...'
  428. await removeContractTreeNode()
  429. instance.confirmButtonLoading = false
  430. resolve()
  431. })
  432. }
  433. const removeContractTreeNode = async () => {
  434. const loadingInstance = window.$loading.service({
  435. fullscreen: true,
  436. text: '删除节点中,请耐心等待...',
  437. background: 'rgba(0, 0, 0, 0.7)',
  438. })
  439. const { error, code, msg } = await unitApi.deleteNode({
  440. id: curTreeData.value.id || '',
  441. })
  442. loadingInstance.close()
  443. if (!error && code === 200) {
  444. window?.$message?.success('删除成功')
  445. window?.location?.reload() //刷新页面
  446. } else {
  447. window.$message.error(msg)
  448. }
  449. }
  450. //表格数据
  451. const tableLoading = ref(false)
  452. const tableColumn = ref([
  453. { key: 'key1', name: '分解明细', width: 80, align: 'center' },
  454. { key: 'formNumber', name: '清单编号', width: 120, align: 'center' },
  455. { key: 'formName', name: '清单名称', align: 'center' },
  456. { key: 'currentPrice', name: '单价', width: 90, align: 'center' },
  457. { key: 'contractTotal', name: '合同数量', width: 100, align: 'center' },
  458. { key: 'changeTotal', name: '变更后数量', width: 110, align: 'center' },
  459. { key: 'buildPictureTotal', name: '施工图数量', align: 'center' },
  460. { key: 'changeBuildPictureTotal', name: '施工图变更后数量', align: 'center' },
  461. ])
  462. const tableData = ref([])
  463. //质检关联清单
  464. const qualtableColumn = ref([
  465. { key: 'part', name: '分/子分项部位', align: 'center' },
  466. { key: 'appStatusName', name: '审核状态', align: 'center' },
  467. { key: 'action', name: '操作', align: 'center' },
  468. ])
  469. const qualtableData = ref([])
  470. const cancelKeys = ref('')
  471. //多选事件
  472. const tableSelectionChange = (rows) => {
  473. console.log(rows)
  474. cancelKeys.value = arrToKey(rows, 'id', ',')
  475. }
  476. //设置某一行的样式
  477. const tableRowStyle = ({ row }) => {
  478. let residueNum = new BigNumber(row.residueNum) //a
  479. let contract = new BigNumber('0') //b
  480. //a 大于 b = 1,a 等于 b = 0,a 小于 b = -1, a 或 b 的值异常时 = null
  481. const isCompared = residueNum.comparedTo(contract)
  482. if (isCompared === -1 || isCompared === null) {
  483. return '--el-table-tr-bg-color: #fe0000; --el-table-row-hover-bg-color: #fe0000; color: white;'
  484. }
  485. }
  486. //弹窗
  487. const treeModalShow = ref(false)
  488. const editModalShow = ref(false)
  489. const finishForm = () => {
  490. treeModalShow.value = false
  491. ishowTree.value = false
  492. setTimeout(() => {
  493. ishowTree.value = true
  494. }, 100)
  495. }
  496. const finishEdit = () => {
  497. editModalShow.value = false
  498. ishowTree.value = false
  499. setTimeout(() => {
  500. ishowTree.value = true
  501. }, 100)
  502. }
  503. const closeEdit = () => {
  504. editModalShow.value = false
  505. ishowTree.value = false
  506. setTimeout(() => {
  507. ishowTree.value = true
  508. }, 100)
  509. }
  510. //调整排序
  511. const sortModalShow = ref(false)
  512. //表格数据
  513. const sortTableColumn = ref([
  514. { key: 'nodeName', name: '节点名称' },
  515. { key: 'action', name: '排序', width: 90 },
  516. ])
  517. const sortTableLoading = ref(false)
  518. const sortTableData = ref([])
  519. //拖动完成
  520. const sortTableRowDrop = (rows) => {
  521. sortTableData.value = [] // 先清空,否则排序会异常
  522. nextTick(() => {
  523. sortTableData.value = rows
  524. })
  525. }
  526. //向下
  527. const downSortClick = (index) => {
  528. const indexs = index + 1
  529. const data = sortTableData.value
  530. if (indexs !== data.length) {
  531. const tmp = data.splice(indexs, 1)
  532. sortTableData.value.splice(index, 0, tmp[0])
  533. } else {
  534. window?.$message?.warning('已经处于置底,无法下移')
  535. }
  536. }
  537. //向上
  538. const upSortClick = (index) => {
  539. const data = sortTableData.value || []
  540. if (index !== 0) {
  541. const tmp = data.splice(index - 1, 1)
  542. sortTableData.value.splice(index, 0, tmp[0])
  543. } else {
  544. window?.$message?.warning('已经处于置顶,无法上移')
  545. }
  546. }
  547. const sortNodeLoading = ref(false)
  548. const sortModalSave = async () => {
  549. const ids = arrToId(sortTableData.value)
  550. //发起请求
  551. sortNodeLoading.value = true
  552. const { error, code, msg } = await unitApi.sortForm({ ids })
  553. sortNodeLoading.value = false
  554. //判断状态
  555. if (!error && code === 200) {
  556. window?.$message?.success('保存成功')
  557. sortModalShow.value = false
  558. window?.location?.reload() //刷新页面
  559. } else {
  560. window.$message.error(msg)
  561. }
  562. }
  563. //合同计量单元导入
  564. const leadModalShow = ref(false)
  565. const leadUploadRef = ref(null)
  566. const leadModal = ()=>{
  567. if (!checkTreeId.value) {
  568. window.$message.warning('请先选择左侧节点')
  569. return
  570. }
  571. // if (checkTreeLevel.value > 3) {
  572. // window.$message.warning('只能从前三层节点开始导入,操作失败')
  573. // return
  574. // }
  575. leadModalShow.value = true
  576. }
  577. const handleFileDUcess = (res)=>{
  578. const { msg, code } = res
  579. if ( code === 200) {
  580. window?.$message?.success(msg)
  581. } else {
  582. window.$message.warning(msg)
  583. }
  584. }
  585. const beforeUpload = ()=>{
  586. if (!typevalue.value) {
  587. window.$message.warning('请先选择模板')
  588. return
  589. }
  590. }
  591. const handFileError = (err)=>{
  592. const msg = JSON.parse(err.message).msg
  593. window.$message.warning(msg)
  594. }
  595. const tableLeadData = ref([
  596. { id: 1, k1: '100', k2: '100-1', k3: '', k4: 'K01+000~K015+000(举例本标段里程号)', k5: '', k6: '', k7: '' },
  597. { id: 2, k1: '100', k2: '100-1', k3: '101-1a', k4: '按合同条款规定,提供建筑工程一切险', k5: '5', k6: '', k7: '' },
  598. { id: 3, k1: '100', k2: '100-1', k3: '101-1b', k4: '线外供电干线设施', k5: '3', k6: '', k7: '' },
  599. { id: 4, k1: '200', k2: '100-2', k3: '', k4: 'K01+000~K015+000(举例本标段里程桩号)', k5: '', k6: '', k7: '' },
  600. { id: 5, k1: '200', k2: '100-2', k3: '200-2-a', k4: '按合同条款规定,提供建筑工程一切险', k5: '5', k6: '', k7: '' },
  601. { id: 6, k1: '200', k2: '100-2', k3: '200-2-b', k4: '线外供电干线设施', k5: '3', k6: '', k7: '' },
  602. ])
  603. const tableLeadData1 = ref([
  604. { id: 1, k1: '0-A#桩基', k2: '', k3: '1', k4: '', k5: '1', k6: '1', k7: '1', k8:'' },
  605. { id: 2, k1: '0-A#桩基', k2: '', k3: '1', k4: '1', k5: '0', k6: '1', k7: '1', k8:'' },
  606. { id: 3, k1: '0-A#桩基', k2: '', k3: '', k4: '1', k5: '1', k6: '1', k7: '1', k8:'' },
  607. ])
  608. const tableLeadData3 = ref([
  609. { id: 1, k1: '总则', k2: '', k3: '工程保险费', k4:'', k5: '保险费', k6: '按合同条款规定,提供建筑工程一切险', k7: '', k8: '', k9:'K58+096', k10:'K64+249', k11:'101-1-1', k12:'按合同条款规定,提供建筑工程一切险', k13:1 },
  610. { id: 2, k1: '总则', k2: '', k3: '工程保险费', k4:'', k5: '保险费', k6: '安全生产责任险', k7: '', k8: '', k9:'K58+096', k10:'K64+249', k11:'101-1-4', k12:'安全生产责任险', k13:1 },
  611. { id: 3, k1: '路基工程', k2: '南城互通', k3: '场地清理', k4: '挖除旧路面', k5: '沥青混凝土面层', k6: '挖除及铣刨(含沥青砼桥面铺装)', k7: '第一册', k8:'S3-59', k9:'黄岩2号高架桥(左右幅新建)桥下道路挖除', k10:'', k11:'202-2-2', k12:'挖除及铣刨(含沥青砼桥面铺装)', k13:42221 },
  612. ])
  613. const leadModalSave = async () => {
  614. await leadUploadRef.value.submit()
  615. leadModalShow.value = false
  616. ishowTree.value = false
  617. setTimeout(() => {
  618. ishowTree.value = true
  619. }, 1000)
  620. }
  621. //下载范例模板
  622. const downLoadExel = ()=>{
  623. if (typevalue.value) {
  624. if (typevalue.value === '1') {
  625. window.open('https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240307/1430b65643615f80156ec328a9a09ff8.xlsx', '_blank')
  626. } else {
  627. window.open('https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20240109/98addbf48d620030504b2cb03b1c24f5.xls', '_blank')
  628. }
  629. } else {
  630. window.$message.warning('请先选择模板')
  631. }
  632. }
  633. const typeoptions = ref([
  634. {
  635. value: '1',
  636. label: '模板1',
  637. },
  638. {
  639. value: '2',
  640. label: '模板2',
  641. },
  642. {
  643. value: '3',
  644. label: '模板3',
  645. },
  646. ])
  647. const typevalue = ref('')
  648. //关联资料
  649. const isCheckId = ref(1)
  650. const linkLoading = ref(false)
  651. const linkModal = ref(false)
  652. const linkDataClick = (type)=>{
  653. linkModal.value = true
  654. isCheckId.value = type
  655. }
  656. const closeLink = ()=>{
  657. linkModal.value = false
  658. getTreeNodeDetail(treeClickdata.value)
  659. }
  660. const saveLink = ()=>{
  661. linkModal.value = false
  662. getTreeNodeDetail(treeClickdata.value)
  663. }
  664. const cancleLink = async (row)=>{
  665. row.load = true
  666. const { error, code, msg } = await unitApi.deleteLinkWbsTree({ ids:row.id })
  667. row.load = false
  668. //判断状态
  669. if (!error && code === 200) {
  670. window?.$message?.success(msg)
  671. getTreeNodeDetail(treeClickdata.value)
  672. } else {
  673. window.$message.error(msg)
  674. }
  675. }
  676. const batchCancleload = ref(false)
  677. const batchCancle = async ()=>{
  678. batchCancleload.value = true
  679. const { error, code, msg } = await unitApi.deleteLinkWbsTree({ ids:cancelKeys.value })
  680. batchCancleload.value = false
  681. //判断状态
  682. if (!error && code === 200) {
  683. window?.$message?.success(msg)
  684. getTreeNodeDetail(treeClickdata.value)
  685. } else {
  686. window.$message.error(msg)
  687. }
  688. }
  689. </script>