dash.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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() : '-' }}</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. </div>
  28. </div>
  29. <avue-crud ref="crud"
  30. v-model="form"
  31. v-model:page="page"
  32. :before-open="beforeOpen"
  33. :data="data"
  34. :option="option"
  35. :permission="permissionList"
  36. :table-loading="loading"
  37. class="curd"
  38. @row-del="rowDel"
  39. @tree-load="treeLoad"
  40. @current-change="currentChange"
  41. @size-change="sizeChange"
  42. @refresh-change="refreshChange"
  43. @on-load="onLoad">
  44. <template #menu="{row}">
  45. <el-button icon="Upload" type='primary' text @click="track(row)"> {{
  46. row.isReport === 1 ? "已经上报" : "项目上报"
  47. }}
  48. </el-button>
  49. </template>
  50. </avue-crud>
  51. <!-- 新增-->
  52. <el-dialog v-model="showAdd"
  53. append-to-body
  54. center
  55. title="新增项目"
  56. width="35%">
  57. <div v-loading='addLoading'>
  58. <el-form ref='form' :model="projectForm" class="lab mt-20" label-width="100px" :rules="rules">
  59. <div class="flex flex-center flex-col mr-20">
  60. <el-form-item class="full-width" label="项目名称" prop='name'>
  61. <el-input
  62. v-model="projectForm.name"
  63. clearable
  64. placeholder="输入项目名称"
  65. />
  66. </el-form-item>
  67. <el-form-item class="full-width" label="项目总投" prop='totalAmount'>
  68. <el-input
  69. v-model="projectForm.totalAmount"
  70. clearable
  71. placeholder="输入项目总投(万元)"
  72. >
  73. <template #append>(万元)</template>
  74. </el-input>
  75. </el-form-item>
  76. <el-form-item class="full-width" label="项目类型" prop='projectType'>
  77. <el-select
  78. v-model="projectForm.projectType"
  79. clearable
  80. placeholder="选择项目类型"
  81. style="width: 100%"
  82. >
  83. <el-option
  84. v-for="item in typeList"
  85. :key="item.id"
  86. :label="item.name"
  87. :value="item.id"
  88. />
  89. </el-select>
  90. </el-form-item>
  91. <el-form-item class="full-width" label="项目标签" prop='tags'>
  92. <el-select
  93. v-model="projectForm.tags"
  94. clearable
  95. placeholder="选择项目标签"
  96. style="width: 100%"
  97. >
  98. <el-option
  99. v-for="item in tagsList"
  100. :key="item.dictKey"
  101. :label="item.dictValue"
  102. :value="item.dictKey"
  103. />
  104. </el-select>
  105. </el-form-item>
  106. <el-form-item class="full-width" label="建设内容">
  107. <el-input
  108. v-model="projectForm.introduction"
  109. :rows="6"
  110. clearable
  111. placeholder="输入项目建设内容"
  112. type="textarea"
  113. />
  114. </el-form-item>
  115. <div class="flex flex-center mt-10">
  116. <base-button class="mr-20" icon="Close" title="取消" type="0" @click="showAdd = false"/>
  117. <base-button icon="Check" title="保存" @click="projectSave"/>
  118. </div>
  119. </div>
  120. </el-form>
  121. </div>
  122. </el-dialog>
  123. <form-dialog :dialogType="diaType" @close="diaType = -1" @export='exportExcel'/>
  124. </div>
  125. </template>
  126. <script>
  127. import BaseButton from '../../../components/base-button.vue'
  128. import permissionStore from '@/store/permission.js'
  129. import { vaildData } from '@/utils/tools.js'
  130. import formDialog from '@/views/home/component/form_dialog.vue'
  131. import { getLazyList } from '@/api/project/index.js'
  132. export default {
  133. name: 'dash',
  134. components: { BaseButton, formDialog },
  135. setup () {
  136. const permissions = permissionStore()
  137. return { permissions }
  138. },
  139. data () {
  140. return {
  141. disable: false,
  142. showAdd: false,
  143. active: 0,
  144. loading: false,
  145. addLoading: false,
  146. data: [],
  147. form: {},
  148. option: {
  149. refreshBtn: false,
  150. tip: false,
  151. lazy: true,
  152. columnBtn: false,
  153. searchShow: true,
  154. selection: true,
  155. editBtn: true,
  156. editBtnText: '资料管理',
  157. editBtnIcon: 'Document',
  158. addBtn: false,
  159. delBtn: true,
  160. border: true,
  161. index: true,
  162. align: 'center',
  163. viewBtn: true,
  164. viewBtnText: '详情',
  165. menuWidth: 380,
  166. dialogClickModal: false,
  167. column: [
  168. {
  169. label: '项目名称',
  170. prop: 'name',
  171. addDisplay: false,
  172. editDisplay: false
  173. },
  174. {
  175. label: '项目情况',
  176. prop: 'projectStage',
  177. type: 'select',
  178. width: 180,
  179. dicUrl: '/api/blade-system/dict-biz/dictionary?code=project-situation',
  180. props: {
  181. label: 'dictValue',
  182. value: 'dictKey'
  183. }
  184. },
  185. {
  186. label: '项目总投资(万元)',
  187. prop: 'totalAmount',
  188. width: 180,
  189. type: 'number',
  190. precision: 2,
  191. formatter: (val, value, label) => {
  192. return val.totalAmount.toLocaleString()
  193. }
  194. },
  195. {
  196. label: '股(科)室',
  197. prop: 'createDeptName',
  198. width: 180
  199. },
  200. {
  201. label: '子项目数量',
  202. prop: 'lot',
  203. width: 180
  204. },
  205. {
  206. label: '是否开工',
  207. prop: 'isStart',
  208. width: 180,
  209. dicData: [
  210. {
  211. label: '否',
  212. value: 0
  213. },
  214. {
  215. label: '是',
  216. value: 1
  217. }
  218. ]
  219. },
  220. {
  221. label: '项目类型',
  222. prop: 'projectTypeName',
  223. width: 180
  224. },
  225. {
  226. label: '创建时间',
  227. prop: 'createTime',
  228. width: 180
  229. }]
  230. },
  231. page: {
  232. size: 10,
  233. current: 1,
  234. total: 0
  235. },
  236. stage: [],
  237. numList: [],
  238. typeList: [],
  239. tagsList: [],
  240. num: '',
  241. projectForm: {
  242. name: '',
  243. totalAmount: '',
  244. projectType: '',
  245. tags: '',
  246. introduction: ''
  247. },
  248. rules: {
  249. name: [
  250. { required: true, message: '请输入项目名称', trigger: 'blur' }
  251. ],
  252. projectType: [
  253. {
  254. required: true,
  255. message: '请选择项目类型',
  256. trigger: 'change'
  257. }
  258. ],
  259. tags: [
  260. {
  261. required: true,
  262. message: '请选择项目标签',
  263. trigger: 'change'
  264. }
  265. ]
  266. },
  267. diaType: -1,
  268. parentId: 0,
  269. queryData: null
  270. }
  271. },
  272. created () {
  273. this.getTypeList()
  274. this.getNumList()
  275. this.$bus.on('serach', (res) => {
  276. if (res.dictKey === '') {
  277. this.active = 0
  278. this.onLoad(res)
  279. }
  280. })
  281. },
  282. computed: {
  283. permissionList () {
  284. return {
  285. delBtn: vaildData(this.permissions.permissions.home_del, false)
  286. }
  287. }
  288. },
  289. methods: {
  290. switchTab(item, index) {
  291. this.active = index
  292. this.onLoad({projectStage: item.dictKey})
  293. },
  294. onLoad (query = {}) {
  295. this.loading = true
  296. const data = { ...query, parentId: this.parentId }
  297. this.queryData = data
  298. this.$api.project.projectList(this.page.currentPage, this.page.pageSize, data).then(res => {
  299. this.loading = false
  300. if (res.code === 200) {
  301. this.data = res.data.records.map(e => {
  302. e.projectStage = e.projectStage + ''
  303. return e
  304. })
  305. this.page.total = res.data.total
  306. }
  307. }).finally(() => {
  308. this.loading = false
  309. })
  310. },
  311. beforeOpen (done, type) {
  312. if (['edit'].includes(type)) {
  313. this.$router.push({
  314. path: '/home/details',
  315. query: { id: this.form.id, type: '0', ownerId: this.form.createUser }
  316. })
  317. } else if (type === 'view') {
  318. // this.$alert('功能建设中,尽情期待...', '消息提醒', {
  319. // confirmButtonText: 'OK'
  320. // })
  321. this.$router.push({
  322. path: '/home/pro_detail',
  323. query: { id: this.form.id }
  324. })
  325. }
  326. },
  327. currentChange (currentPage) {
  328. this.page.current = currentPage
  329. },
  330. sizeChange (pageSize) {
  331. this.page.size = pageSize
  332. },
  333. refreshChange () {
  334. this.onLoad()
  335. },
  336. treeLoad (tree, treeNode, resolve) {
  337. this.loading = true
  338. getLazyList(tree.id).then(res => {
  339. this.loading = false
  340. resolve(res.data.data.childrenList.map(e => {
  341. e.projectStage = e.projectStage.toString()
  342. return e
  343. }))
  344. })
  345. },
  346. rowDel (row) {
  347. this.$confirm('确定删除选择的项目?', {
  348. confirmButtonText: '确定',
  349. cancelButtonText: '取消',
  350. type: 'warning'
  351. })
  352. .then(() => {
  353. this.$api.project.projectRemove({ ids: row.id }).then(res => {
  354. if (res.code === 200) {
  355. this.$message.success(res.msg)
  356. this.onLoad()
  357. } else {
  358. this.$message.error(res.msg)
  359. }
  360. })
  361. })
  362. },
  363. getNumList () {
  364. this.$api.project.userNunList().then(res => {
  365. if (res.code === 200) {
  366. this.numList = res.data.projectStage
  367. this.num = res.data.totalAmount
  368. }
  369. })
  370. },
  371. getTotalAmount (data) {
  372. this.$api.project.totalAmount(Object.assign(data, this.query)).then(res => {
  373. if (res.code === 200) {
  374. this.num = res.data
  375. } else {
  376. this.$message.error(res.msg)
  377. }
  378. })
  379. },
  380. getTypeList () {
  381. this.$api.project.typeList({ type: 1, size: 999, current: 1 }).then(res => {
  382. this.typeList = res.data.records
  383. })
  384. this.$api.common.dicList({ code: 'project-tags' }).then(res => {
  385. if (res.code === 200) {
  386. this.tagsList = res.data
  387. }
  388. })
  389. },
  390. track (res) {
  391. if (res.isReport === 1) {
  392. this.$message.error('该项目已经上报')
  393. return
  394. }
  395. this.$confirm('是否确定进行项目上报', {
  396. confirmButtonText: '确定',
  397. cancelButtonText: '取消',
  398. type: 'warning'
  399. }).then(() => {
  400. const data = { id: res.id, isReport: 1 }
  401. this.$api.project.proUpdate(data).then(res => {
  402. if (res.code === 200) {
  403. console.log(res)
  404. this.$message.success(res.msg)
  405. } else {
  406. this.$message.error(res.msg)
  407. }
  408. })
  409. })
  410. },
  411. projectSave() {
  412. if (this.disable) {
  413. this.$message.error('正在处理,请稍后...')
  414. return
  415. }
  416. this.$refs.form.validate((valid) => {
  417. if (valid) {
  418. this.disable = true
  419. this.addLoading = true
  420. this.$api.project.projectAdd(this.projectForm).then(res => {
  421. this.disable = false
  422. this.addLoading = false
  423. if (res.code === 200) {
  424. this.showAdd = false
  425. this.$message.success(res.msg)
  426. this.onLoad()
  427. } else {
  428. this.showAdd = false
  429. this.$message.error(res.msg)
  430. }
  431. })
  432. }
  433. })
  434. }
  435. }
  436. }
  437. </script>
  438. <style lang="scss" scoped>
  439. .tip {
  440. width: 260px;
  441. height: 38px;
  442. background-color: #FBF6ED;
  443. font-weight: 500;
  444. flex-wrap: nowrap;
  445. margin-left: 20px;
  446. }
  447. .total-s {
  448. width: 200px;
  449. height: 50px;
  450. border: 1px solid #825618;
  451. border-radius: 10px;
  452. margin-right: 20px;
  453. box-shadow: 2px 2px 10px 2px rgba(113, 73, 39, 0.3);
  454. .sp {
  455. color: #ECAB56;
  456. white-space: nowrap;
  457. margin-left: 20px;
  458. }
  459. .sp1 {
  460. color: #ECAB56;
  461. margin-right: 20px;
  462. }
  463. }
  464. .total {
  465. width: 200px;
  466. height: 50px;
  467. border-radius: 10px;
  468. margin-right: 20px;
  469. background-color: #F0F2F7;
  470. .sp {
  471. color: #707070;
  472. white-space: nowrap;
  473. margin-left: 20px;
  474. }
  475. .sp1 {
  476. color: #825618;
  477. margin-right: 20px;
  478. }
  479. }
  480. .curd {
  481. :deep(.avue-crud__menu) {
  482. min-height: 10px;
  483. }
  484. }
  485. </style>