dash.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. <template>
  2. <div class="full-height full-width flex flex-col">
  3. <div class="flex flex-col padding white-bg">
  4. <div class="flex flex-align-center tip">
  5. <el-icon class="ml-20" color="#BC002D">
  6. <WarningFilled/>
  7. </el-icon>
  8. <span class="ml-5">项目总投资额<span
  9. class="main-color bold">{{ num ? Number.parseFloat(num).toLocaleString() : '0' }}</span>万元</span>
  10. </div>
  11. <div class="flex ml-20 hide-scrollbar" style="overflow-x: scroll;width: 86vw;"
  12. v-show='numList && numList.length > 0'>
  13. <div v-for="(item,index) in numList" :key='item.id' :class="active === index ? 'total-s' : 'total'"
  14. class="flex flex-center flex-justify-between mt-20 bold font-16 pointer" @click='switchTab(item,index)'
  15. >
  16. <span class=" sp">{{ item.name }}</span>
  17. <span class=" sp1 ">{{ item.number }}<span class="grey font-13">个</span></span>
  18. </div>
  19. </div>
  20. <div class='flex flex-center flex-justify-start'>
  21. <base-button class="ml-20 mt-20" icon="Plus" title="新增"
  22. @click="showAdd = true"/>
  23. <base-button class="ml-20 mt-20" icon="el-icon-upload" title="数据导入"
  24. @click="diaType = 0"/>
  25. <base-button class="ml-20 mt-20" icon="el-icon-download" title="数据导出"
  26. @click="diaType = 1"/>
  27. <base-button class="ml-20 mt-20" type="0" icon="el-icon-download" title="汇总数据导出"
  28. @click="diaType = 2"/>
  29. </div>
  30. </div>
  31. <avue-crud ref="crud"
  32. v-model="form"
  33. v-model:page="page"
  34. :before-open="beforeOpen"
  35. :data="data"
  36. :option="option"
  37. :permission="permissionList"
  38. :table-loading="loading"
  39. class="curd"
  40. @row-del="rowDel"
  41. @tree-load="treeLoad"
  42. @current-change="currentChange"
  43. @size-change="sizeChange"
  44. @refresh-change="refreshChange"
  45. @selection-change="selectionChange"
  46. @on-load="onLoad">
  47. <template #menu="{row}">
  48. <el-button v-if='user.info.viewStage !== 1' icon="Upload" type='primary' text @click="track(row)"> {{
  49. row.isReport === 1 ? "已经上报" : "项目上报"
  50. }}
  51. </el-button>
  52. </template>
  53. <template #plan_storage_time-header="{column}">
  54. <div class='flex flex-center'>
  55. <div class='mr-5'>{{ (column || {}).label }}</div>
  56. <el-tooltip content='红色为计划开工时间,蓝色为实际开工时间'>
  57. <el-icon>
  58. <InfoFilled/>
  59. </el-icon>
  60. </el-tooltip>
  61. </div>
  62. </template>
  63. <template #plan_storage_time="{row}">
  64. <div class='flex flex-center'>
  65. <div class='mr-5 red' v-if='row.plan_storage_time !== undefined && row.is_storage === 0 '>
  66. {{ row.plan_storage_time.substring(0, 10) }}
  67. </div>
  68. <div class='mr-5 blue' v-else>{{ row.storage_time ? row.storage_time.substring(0, 10) : '' }}</div>
  69. </div>
  70. </template>
  71. <template #plan_commencement_time-header="{column}">
  72. <div class='flex flex-center'>
  73. <div class='mr-5'>{{ (column || {}).label }}</div>
  74. <el-tooltip content='红色为计划开工时间,蓝色为实际开工时间'>
  75. <el-icon>
  76. <InfoFilled/>
  77. </el-icon>
  78. </el-tooltip>
  79. </div>
  80. </template>
  81. <template #plan_commencement_time="{row}">
  82. <div class='flex flex-center'>
  83. <div class='mr-5 red'
  84. v-if='plan_commencement_time !== undefined && (row.is_start === undefined ||row.is_start === 0 )'>{{
  85. row.plan_commencement_time.substring(0, 10)
  86. }}
  87. </div>
  88. <div class='mr-5 blue' v-else>{{ row.start_time ? row.start_time.substring(0, 10) : '' }}</div>
  89. </div>
  90. </template>
  91. </avue-crud>
  92. <!-- 新增-->
  93. <el-dialog v-model="showAdd"
  94. append-to-body
  95. center
  96. title="新增项目"
  97. width="35%">
  98. <div v-loading='addLoading'>
  99. <el-form ref='form' :model="projectForm" class="lab mt-20" label-width="100px" :rules="rules">
  100. <div class="flex flex-center flex-col mr-20">
  101. <el-form-item class="full-width" label="项目名称" prop='name'>
  102. <el-input
  103. v-model="projectForm.name"
  104. clearable
  105. placeholder="输入项目名称"
  106. />
  107. </el-form-item>
  108. <el-form-item class="full-width" label="项目总投" prop='totalAmount'>
  109. <el-input
  110. v-model="projectForm.totalAmount"
  111. clearable
  112. placeholder="输入项目总投(万元)"
  113. >
  114. <template #append>(万元)</template>
  115. </el-input>
  116. </el-form-item>
  117. <!-- <el-form-item class="full-width" label="项目类型" prop='projectType'>-->
  118. <!-- <el-select-->
  119. <!-- v-model="projectForm.projectType"-->
  120. <!-- clearable-->
  121. <!-- placeholder="选择项目类型"-->
  122. <!-- style="width: 100%"-->
  123. <!-- >-->
  124. <!-- <el-option-->
  125. <!-- v-for="item in typeList"-->
  126. <!-- :key="item.id"-->
  127. <!-- :label="item.name"-->
  128. <!-- :value="item.id"-->
  129. <!-- />-->
  130. <!-- </el-select>-->
  131. <!-- </el-form-item>-->
  132. <el-form-item class="full-width" label="项目标签" prop='tags'>
  133. <el-select
  134. v-model="projectForm.tags"
  135. clearable
  136. placeholder="选择项目标签"
  137. style="width: 100%"
  138. >
  139. <el-option
  140. v-for="item in tagsList"
  141. :key="item.dictKey"
  142. :label="item.dictValue"
  143. :value="item.dictKey"
  144. />
  145. </el-select>
  146. </el-form-item>
  147. <el-form-item class="full-width" label="建设内容">
  148. <el-input
  149. v-model="projectForm.introduction"
  150. :rows="6"
  151. clearable
  152. placeholder="输入项目建设内容"
  153. type="textarea"
  154. />
  155. </el-form-item>
  156. <div class="flex flex-center mt-10">
  157. <base-button class="mr-20" icon="Close" title="取消" type="0" @click="showAdd = false"/>
  158. <base-button icon="Check" title="保存" @click="projectSave"/>
  159. </div>
  160. </div>
  161. </el-form>
  162. </div>
  163. </el-dialog>
  164. <form-dialog :dialogType="diaType" @close="formDialogClose" @export='exportExcel' :ids='selectList'/>
  165. <summary-dialog :dialogType="diaType" @close="diaType = -1"
  166. :select-num='selectList.length === 0 ? page.total : selectList.length'
  167. @export='exportExcelTotal'/>
  168. </div>
  169. </template>
  170. <script>
  171. import BaseButton from '../../../components/base-button.vue'
  172. import permissionStore from '@/store/permission.js'
  173. import formDialog from '@/views/home/component/form_dialog.vue'
  174. import { getLazyList } from '@/api/project/index.js'
  175. import summaryDialog from '@/views/home/component/summary_dialog.vue'
  176. import { useStore } from '@/store/user.js'
  177. export default {
  178. name: 'dash',
  179. components: { BaseButton, formDialog, summaryDialog },
  180. setup () {
  181. const permissions = permissionStore()
  182. const user = useStore()
  183. return { permissions, user }
  184. },
  185. data () {
  186. return {
  187. dialogLoading: false,
  188. disable: false,
  189. showAdd: false,
  190. active: 0,
  191. loading: false,
  192. addLoading: false,
  193. data: [],
  194. form: {},
  195. option: {
  196. menuType: 'menu',
  197. menuBtnTitle: '操作',
  198. refreshBtn: false,
  199. tip: false,
  200. lazy: true,
  201. columnBtn: false,
  202. searchShow: true,
  203. selection: true,
  204. editBtn: true,
  205. editBtnText: '资料管理',
  206. editBtnIcon: 'Document',
  207. addBtn: false,
  208. delBtn: true,
  209. border: true,
  210. reserveSelection: true,
  211. align: 'center',
  212. viewBtn: true,
  213. viewBtnText: '详情',
  214. dialogClickModal: false,
  215. column: [
  216. {
  217. label: '项目名称',
  218. prop: 'name',
  219. addDisplay: false,
  220. editDisplay: false,
  221. fixed: true,
  222. minWidth: 200
  223. },
  224. {
  225. label: '项目情况',
  226. prop: 'project_stage',
  227. type: 'select',
  228. width: 120,
  229. dicUrl: '/api/blade-system/dict-biz/dictionary?code=project-situation',
  230. props: {
  231. label: 'dictValue',
  232. value: 'dictKey'
  233. }
  234. },
  235. {
  236. label: '项目总投资(万元)',
  237. prop: 'total_amount',
  238. width: 120,
  239. type: 'number',
  240. precision: 2,
  241. formatter: (val, value, label) => {
  242. return val.total_amount.toLocaleString()
  243. }
  244. },
  245. {
  246. label: '责任单位',
  247. prop: 'responsible_unit'
  248. },
  249. {
  250. label: '子项目数量',
  251. prop: 'lot',
  252. width: 120,
  253. hide: true
  254. },
  255. {
  256. label: '是否入库',
  257. prop: 'is_storage',
  258. width: 120,
  259. dicData: [
  260. {
  261. label: '否',
  262. value: 0
  263. },
  264. {
  265. label: '是',
  266. value: 1
  267. }
  268. ]
  269. },
  270. {
  271. label: '计划(实际)入库时间',
  272. prop: 'plan_storage_time',
  273. width: 120,
  274. formatter: (val, value, label) => {
  275. return value.substring(0, 10)
  276. }
  277. },
  278. {
  279. label: '是否开工',
  280. prop: 'is_start',
  281. width: 120,
  282. dicData: [
  283. {
  284. label: '否',
  285. value: 0
  286. },
  287. {
  288. label: '是',
  289. value: 1
  290. }
  291. ]
  292. },
  293. {
  294. label: '计划(实际)开工时间',
  295. prop: 'plan_commencement_time',
  296. width: 120,
  297. formatter: (val, value, label) => {
  298. return value.substring(0, 10)
  299. }
  300. },
  301. {
  302. label: '创建时间',
  303. prop: 'create_time',
  304. width: 120,
  305. formatter: (val, value, label) => {
  306. return value.substring(0, 10)
  307. }
  308. }]
  309. },
  310. page: {
  311. size: 10,
  312. current: 1,
  313. total: 0
  314. },
  315. stage: [],
  316. numList: [],
  317. typeList: [],
  318. tagsList: [],
  319. num: '',
  320. projectForm: {
  321. name: '',
  322. totalAmount: '',
  323. projectType: '1602565634250186753',
  324. tags: '',
  325. introduction: ''
  326. },
  327. rules: {
  328. name: [
  329. { required: true, message: '请输入项目名称', trigger: 'blur' }
  330. ],
  331. projectType: [
  332. {
  333. required: true,
  334. message: '请选择项目类型',
  335. trigger: 'change'
  336. }
  337. ],
  338. tags: [
  339. {
  340. required: true,
  341. message: '请选择项目标签',
  342. trigger: 'change'
  343. }
  344. ]
  345. },
  346. diaType: -1,
  347. parentId: 0,
  348. queryData: null,
  349. owerQuery: {},
  350. projectStageQuery: {},
  351. selectList: []
  352. }
  353. },
  354. created () {
  355. const index = this.option.column.findIndex(sub => sub.prop === 'lot')
  356. console.log(index)
  357. if (this.user.info.viewStage === 1) {
  358. this.option.column[index].hide = true
  359. } else {
  360. this.option.column[index].hide = false
  361. }
  362. this.$bus.on('serach', (res, type) => {
  363. this.owerQuery = res
  364. if (res.type === false) {
  365. this.projectStageQuery.projectStage = ''
  366. this.active = 0
  367. }
  368. this.onLoad(Object.assign(this.owerQuery, this.projectStageQuery))
  369. this.getNumList(Object.assign(this.owerQuery, this.projectStageQuery))
  370. })
  371. this.getTypeList()
  372. this.getNumList()
  373. },
  374. unmounted () {
  375. sessionStorage.removeItem('selectList')
  376. },
  377. methods: {
  378. switchTab (item, index) {
  379. this.active = index
  380. this.projectStageQuery = { projectStage: item.dictKey }
  381. this.onLoad(Object.assign(this.owerQuery, this.projectStageQuery))
  382. },
  383. onLoad (query = {}) {
  384. this.loading = true
  385. const data = { ...this.owerQuery, parentId: this.parentId }
  386. this.queryData = data
  387. console.log(query.projectStage)
  388. this.$api.project.projectList(this.page.currentPage, this.page.pageSize, this.queryData).then(res => {
  389. this.loading = false
  390. if (res.code === 200) {
  391. this.data = res.data.records.map(e => {
  392. e.projectStage = e.projectStage + ''
  393. e.selected = true
  394. return e
  395. })
  396. this.page.total = res.data.total
  397. }
  398. }).finally(() => {
  399. this.loading = false
  400. })
  401. },
  402. selectionChange (list) {
  403. this.selectList = list.map(sub => sub.id)
  404. },
  405. beforeOpen (done, type) {
  406. if (['edit'].includes(type)) {
  407. this.$router.push({
  408. path: '/home/details',
  409. query: { id: this.form.id, type: '0', ownerId: this.form.createUser }
  410. })
  411. } else if (type === 'view') {
  412. this.$router.push({
  413. path: '/home/pro_detail',
  414. query: { id: this.form.id, projectStage: this.form.project_stage }
  415. })
  416. }
  417. },
  418. currentChange (currentPage) {
  419. this.page.current = currentPage
  420. },
  421. sizeChange (pageSize) {
  422. this.page.size = pageSize
  423. },
  424. refreshChange () {
  425. this.onLoad()
  426. },
  427. treeLoad (tree, treeNode, resolve) {
  428. this.loading = true
  429. getLazyList(tree.id).then(res => {
  430. this.loading = false
  431. resolve(res.data.data.childrenList.map(e => {
  432. e.project_stage = e.project_stage.toString()
  433. return e
  434. }))
  435. })
  436. },
  437. rowDel (row) {
  438. this.$confirm('确定删除选择的项目?', {
  439. confirmButtonText: '确定',
  440. cancelButtonText: '取消',
  441. type: 'warning'
  442. })
  443. .then(() => {
  444. this.$api.project.projectRemove({ ids: row.id }).then(res => {
  445. if (res.code === 200) {
  446. this.$message.success(res.msg)
  447. this.onLoad()
  448. } else {
  449. this.$message.error(res.msg)
  450. }
  451. })
  452. })
  453. },
  454. getNumList (data) {
  455. this.$api.project.userNunList(data).then(res => {
  456. if (res.code === 200) {
  457. this.numList = res.data.projectStage
  458. this.num = res.data.projectStage[0].totalAmount
  459. }
  460. })
  461. },
  462. getTypeList () {
  463. this.$api.project.typeList({ type: 1, size: 999, current: 1 }).then(res => {
  464. this.typeList = res.data.records
  465. })
  466. this.$api.common.dicList({ code: 'project-tags' }).then(res => {
  467. if (res.code === 200) {
  468. this.tagsList = res.data
  469. }
  470. })
  471. },
  472. track (res) {
  473. if (res.isReport === 1) {
  474. this.$message.error('该项目已经上报')
  475. return
  476. }
  477. this.$confirm(res.project_stage === 1 ? '上报后该项目情况将更新为正式项目,请确认项目相关信息已经审核完成' : '是否确定进行项目上报', {
  478. confirmButtonText: '确定',
  479. cancelButtonText: '取消',
  480. type: 'warning'
  481. }).then(() => {
  482. const data = { id: res.id, is_report: 1, project_stage: res.project_stage === 1 ? 2 : res.project_stage }
  483. this.$api.project.proUpdate(data).then(res => {
  484. if (res.code === 200) {
  485. this.onLoad()
  486. this.$message.success(res.msg)
  487. } else {
  488. this.$message.error(res.msg)
  489. }
  490. })
  491. })
  492. },
  493. projectSave () {
  494. if (this.disable) {
  495. this.$message.error('正在处理,请稍后...')
  496. return
  497. }
  498. this.$refs.form.validate((valid) => {
  499. if (valid) {
  500. this.disable = true
  501. this.addLoading = true
  502. this.$api.project.projectAdd(this.projectForm).then(res => {
  503. this.disable = false
  504. this.addLoading = false
  505. if (res.code === 200) {
  506. this.showAdd = false
  507. this.$message.success(res.msg)
  508. this.onLoad()
  509. } else {
  510. this.showAdd = false
  511. this.$message.error(res.msg)
  512. }
  513. })
  514. }
  515. })
  516. },
  517. formDialogClose () {
  518. this.diaType = -1
  519. },
  520. exportExcel (res) {
  521. const data = Object.assign(this.queryData, { columnName: res, projectIds: this.selectList.join(',') })
  522. this.$api.params.exportResult(data).then(res => {
  523. if (res.hasOwnProperty('code')) {
  524. this.$message.error(res.msg)
  525. return
  526. }
  527. this.download(res)
  528. })
  529. },
  530. exportExcelTotal (item) {
  531. const data = { ...this.queryData, projectIds: this.selectList.join(',') }
  532. this.$api.params.summaryExport(Object.assign(item, data)).then(res => {
  533. if (res.hasOwnProperty('code')) {
  534. this.$message.error(res.msg)
  535. return
  536. }
  537. this.download(res)
  538. })
  539. },
  540. download (res) {
  541. const url = window.URL.createObjectURL(new Blob([res], { type: 'application/vnd.ms-excel' }))
  542. const link = document.createElement('a')
  543. link.style.display = 'none'
  544. link.href = url
  545. const excelName = new Date().getTime() + '.xlsx'
  546. link.setAttribute('download', excelName)
  547. document.body.appendChild(link)
  548. link.click()
  549. link.remove()
  550. this.diaType = -1
  551. this.$message.success('导出成功')
  552. }
  553. }
  554. }
  555. </script>
  556. <style lang="scss" scoped>
  557. .tip {
  558. width: 260px;
  559. height: 38px;
  560. background-color: #FBF6ED;
  561. font-weight: 500;
  562. flex-wrap: nowrap;
  563. margin-left: 20px;
  564. }
  565. .total-s {
  566. width: 200px;
  567. height: 50px;
  568. border: 1px solid #825618;
  569. border-radius: 10px;
  570. margin-right: 20px;
  571. box-shadow: 2px 2px 10px 2px rgba(113, 73, 39, 0.3);
  572. .sp {
  573. color: #ECAB56;
  574. white-space: nowrap;
  575. margin-left: 20px;
  576. }
  577. .sp1 {
  578. color: #ECAB56;
  579. margin-right: 20px;
  580. }
  581. }
  582. .total {
  583. width: 200px;
  584. height: 50px;
  585. border-radius: 10px;
  586. margin-right: 20px;
  587. background-color: #F0F2F7;
  588. .sp {
  589. color: #707070;
  590. white-space: nowrap;
  591. margin-left: 20px;
  592. }
  593. .sp1 {
  594. color: #825618;
  595. margin-right: 20px;
  596. }
  597. }
  598. .curd {
  599. :deep(.avue-crud__menu) {
  600. min-height: 10px;
  601. }
  602. }
  603. </style>