dash.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <div class="full-height full-width flex flex-col">
  3. <div class="white-bg flex flex-col padding">
  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">{{ Number.parseFloat(num).toLocaleString() }}</span>万元</span>
  10. </div>
  11. <div class="flex ml-20 hide-scrollbar" style="overflow-x: scroll;width: 86vw" v-show='stage && stage.length > 0'>
  12. <div v-for="(item,index) in stage" :key='item.id' :class="active === index ? 'total-s' : 'total'"
  13. class="flex flex-col flex-center mt-20 bold font-16 pointer" @click='switchTab(item,index)'
  14. >
  15. <span class=" sp">{{ item.name }}</span>
  16. <span class=" sp1 mt-5">{{ item.projectNumber }}<span class="grey font-14 ml-5">个</span></span>
  17. </div>
  18. </div>
  19. <div v-if='permissions.permissions?.projectAdd' class='flex flex-center flex-justify-start'>
  20. <base-button class="ml-20 mt-20" icon="Plus" title="新增"
  21. @click="showAdd = true"/>
  22. <base-button class="ml-20 mt-20" icon="Edit" title="项目导入"
  23. @click="showImport = true"/>
  24. </div>
  25. </div>
  26. <avue-crud ref="crud"
  27. v-model="form"
  28. v-model:page="page"
  29. :before-open="beforeOpen"
  30. :data="data"
  31. :option="option"
  32. :permission="permissionList"
  33. :table-loading="loading"
  34. class="curd"
  35. @row-del="rowDel"
  36. @current-change="currentChange"
  37. @size-change="sizeChange"
  38. @refresh-change="refreshChange"
  39. @on-load="onLoad">
  40. <!-- <template #menu="{row}">-->
  41. <!-- <el-button icon="Operation" text @click="track(row.id)">跟踪审计</el-button>-->
  42. <!-- </template>-->
  43. </avue-crud>
  44. <!-- 新增-->
  45. <el-dialog v-model="showAdd"
  46. append-to-body
  47. center
  48. title="新增项目"
  49. width="35%">
  50. <div>
  51. <el-form ref='form' :model="projectForm" class="lab mt-20" label-width="100px" :rules="rules">
  52. <div class="flex flex-center flex-col mr-20">
  53. <el-form-item class="full-width" label="项目名称" prop='name'>
  54. <el-input
  55. v-model="projectForm.name"
  56. clearable
  57. placeholder="输入项目名称"
  58. />
  59. </el-form-item>
  60. <el-form-item class="full-width" label="项目总投" prop='totalAmount'>
  61. <el-input
  62. v-model="projectForm.totalAmount"
  63. clearable
  64. placeholder="输入项目总投(万元)"
  65. >
  66. <template #append>(万元)</template>
  67. </el-input>
  68. </el-form-item>
  69. <el-form-item class="full-width" label="项目类型" prop='projectType'>
  70. <el-select
  71. v-model="projectForm.projectType"
  72. clearable
  73. placeholder="选择项目类型"
  74. style="width: 100%"
  75. >
  76. <el-option
  77. v-for="item in typeList"
  78. :key="item.id"
  79. :label="item.name"
  80. :value="item.id"
  81. />
  82. </el-select>
  83. </el-form-item>
  84. <el-form-item class="full-width" label="项目标签" prop='tags'>
  85. <el-select
  86. v-model="projectForm.tags"
  87. clearable
  88. placeholder="选择项目标签"
  89. style="width: 100%"
  90. >
  91. <el-option
  92. v-for="item in tagsList"
  93. :key="item.dictKey"
  94. :label="item.dictValue"
  95. :value="item.dictKey"
  96. />
  97. </el-select>
  98. </el-form-item>
  99. <el-form-item class="full-width" label="建设内容">
  100. <el-input
  101. v-model="projectForm.introduction"
  102. :rows="6"
  103. clearable
  104. placeholder="输入项目建设内容"
  105. type="textarea"
  106. />
  107. </el-form-item>
  108. <div class="flex flex-center mt-10">
  109. <base-button class="mr-20" icon="Close" title="取消" type="0" @click="showAdd = false"/>
  110. <base-button icon="Check" title="保存" @click="projectSave"/>
  111. </div>
  112. </div>
  113. </el-form>
  114. </div>
  115. </el-dialog>
  116. <!-- 导入-->
  117. <el-dialog v-model='showImport'
  118. append-to-body
  119. center
  120. title="项目导入"
  121. width="50%">
  122. <div class='flex flex-justify-start flex-align-center'>
  123. <span>模版下载:</span>
  124. <el-button type='primary' plain class='ml-20'>模 版</el-button>
  125. </div>
  126. <div class='flex flex-justify-start flex-align-center mt-20'>
  127. <upload-file type='primary' max='1'
  128. @close='showImport = false'
  129. accept='.xls,.xlsx'
  130. :data='{isCovered:0}'
  131. action='/api/blade-project-manage/project/import-project'
  132. @success='success'>确 定</upload-file>
  133. </div>
  134. <el-divider/>
  135. </el-dialog>
  136. </div>
  137. </template>
  138. <script>
  139. import BaseButton from '../../../components/base-button.vue'
  140. import permissionStore from '@/store/permission.js'
  141. import { vaildData } from '@/utils/tools.js'
  142. import uploadFile from '@/components/upload-file.vue'
  143. export default {
  144. name: 'dash',
  145. components: { BaseButton, uploadFile },
  146. setup () {
  147. const permissions = permissionStore()
  148. return { permissions }
  149. },
  150. data () {
  151. return {
  152. showAdd: false,
  153. showImport: false,
  154. active: 0,
  155. loading: false,
  156. data: [],
  157. form: {},
  158. option: {
  159. calcHeight: 230,
  160. refreshBtn: false,
  161. tip: false,
  162. columnBtn: false,
  163. searchShow: true,
  164. editBtn: true,
  165. editBtnText: '跟踪审计',
  166. editBtnIcon: 'Operation',
  167. addBtn: false,
  168. delBtn: true,
  169. border: true,
  170. index: true,
  171. align: 'center',
  172. viewBtn: true,
  173. menuWidth: 320,
  174. dialogClickModal: false,
  175. column: [
  176. {
  177. label: '项目名称',
  178. prop: 'name',
  179. addDisplay: false,
  180. editDisplay: false,
  181. width: 400
  182. },
  183. {
  184. label: '项目总投资(万元)',
  185. prop: 'totalAmount',
  186. width: 180,
  187. type: 'number',
  188. precision: 2,
  189. formatter: (val, value, label) => {
  190. return val.totalAmount.toLocaleString()
  191. }
  192. },
  193. {
  194. label: '项目类型',
  195. prop: 'projectTypeName',
  196. type: 'select',
  197. width: 240,
  198. dicUrl: '/api/blade-system/dict-biz/dictionary?code=project-tags',
  199. props: {
  200. label: 'dictValue',
  201. value: 'dictKey'
  202. }
  203. },
  204. {
  205. label: '项目领域',
  206. prop: 'dictName',
  207. width: 240
  208. },
  209. {
  210. label: '发债时间',
  211. prop: 'issueDate',
  212. type: 'month',
  213. width: 240,
  214. format: 'YYYY-MM',
  215. valueFormat: 'YYYY-MM'
  216. },
  217. {
  218. label: '更新时间',
  219. prop: 'updateTime',
  220. type: 'month',
  221. width: 240,
  222. format: 'YYYY-MM-DD',
  223. valueFormat: 'YYYY-MM-DD'
  224. }]
  225. },
  226. page: {
  227. size: 10,
  228. current: 1,
  229. total: 0
  230. },
  231. stage: [],
  232. typeList: [],
  233. tagsList: [],
  234. num: '',
  235. projectForm: {
  236. name: '',
  237. totalAmount: '',
  238. projectType: '',
  239. tags: '',
  240. introduction: ''
  241. },
  242. rules: {
  243. name: [
  244. { required: true, message: '请输入项目名称', trigger: 'blur' }
  245. ],
  246. projectType: [
  247. {
  248. required: true,
  249. message: '请选择项目类型',
  250. trigger: 'change'
  251. }
  252. ],
  253. tags: [
  254. {
  255. required: true,
  256. message: '请选择项目标签',
  257. trigger: 'change'
  258. }
  259. ]
  260. }
  261. }
  262. },
  263. created () {
  264. this.getTypeList()
  265. this.$bus.on('serach', (res) => {
  266. this.onLoad(res)
  267. })
  268. },
  269. computed: {
  270. permissionList () {
  271. return {
  272. delBtn: vaildData(this.permissions.permissions.home_del, false)
  273. }
  274. }
  275. },
  276. methods: {
  277. switchTab (item, index) {
  278. this.active = index
  279. this.onLoad({ stageId: item.id === -1 ? '' : item.id })
  280. },
  281. onLoad (query = {}) {
  282. this.loading = true
  283. const data = { ...query, ...this.page }
  284. this.$api.project.projectList(this.page.current, this.page.size, data).then(res => {
  285. this.loading = false
  286. if (res.code === 200) {
  287. this.data = res.data.content
  288. this.num = res.msg
  289. this.page.total = res.data.totalElements
  290. this.loading = false
  291. }
  292. this.getStageList()
  293. })
  294. },
  295. beforeOpen (done, type) {
  296. if (['view'].includes(type)) {
  297. this.$router.push({
  298. path: '/home/details',
  299. query: { id: this.form.id, type: '0', ownerId: this.form.createUser }
  300. })
  301. } else if (type === 'edit') {
  302. this.$alert('功能建设中,尽情期待...', '消息提醒', {
  303. confirmButtonText: 'OK'
  304. })
  305. // this.$router.push({
  306. // path: '/home/details',
  307. // query: { id: this.form.id, type: '1' }
  308. // })
  309. }
  310. },
  311. currentChange (currentPage) {
  312. this.page.current = currentPage
  313. console.log(this.page)
  314. },
  315. sizeChange (pageSize) {
  316. this.page.size = pageSize
  317. },
  318. refreshChange () {
  319. this.onLoad()
  320. },
  321. rowDel (row) {
  322. this.$confirm('确定删除选择的项目?', {
  323. confirmButtonText: '确定',
  324. cancelButtonText: '取消',
  325. type: 'warning'
  326. })
  327. .then(() => {
  328. this.$api.project.projectRemove({ ids: row.id }).then(res => {
  329. if (res.code === 200) {
  330. this.$message.success(res.msg)
  331. this.onLoad()
  332. } else {
  333. this.$message.error(res.msg)
  334. }
  335. })
  336. })
  337. },
  338. getStageList () {
  339. this.$api.project.userStageList().then(res => {
  340. if (res.code === 200) {
  341. this.stage = res.data
  342. }
  343. })
  344. },
  345. getTypeList () {
  346. this.$api.project.typeList().then(res => {
  347. this.typeList = res.data.records
  348. })
  349. this.$api.common.dicList({ code: 'project-tags' }).then(res => {
  350. if (res.code === 200) {
  351. this.tagsList = res.data
  352. }
  353. })
  354. },
  355. projectSave () {
  356. this.$refs.form.validate((valid) => {
  357. if (valid) {
  358. this.$api.project.projectAdd(this.projectForm).then(res => {
  359. if (res.code === 200) {
  360. this.showAdd = false
  361. this.$message.success(res.msg)
  362. this.onLoad()
  363. } else {
  364. this.showAdd = false
  365. this.$message.error(res.msg)
  366. }
  367. })
  368. }
  369. })
  370. },
  371. success (res) {
  372. this.showImport = false
  373. this.$message.success('上传成功')
  374. this.onLoad()
  375. }
  376. }
  377. }
  378. </script>
  379. <style lang="scss" scoped>
  380. .tip {
  381. width: 260px;
  382. height: 38px;
  383. background-color: #FBF6ED;
  384. font-weight: 500;
  385. flex-wrap: nowrap;
  386. margin-left: 20px;
  387. }
  388. .total-s {
  389. width: 220px;
  390. height: 70px;
  391. border: 1px solid #825618;
  392. border-radius: 10px;
  393. margin-right: 20px;
  394. box-shadow: 2px 2px 10px 2px rgba(113, 73, 39, 0.3);
  395. .sp {
  396. color: #ECAB56;
  397. white-space: nowrap;
  398. }
  399. .sp1 {
  400. color: #ECAB56;
  401. }
  402. }
  403. .total {
  404. width: 220px;
  405. height: 70px;
  406. border-radius: 10px;
  407. margin-right: 20px;
  408. background-color: #F0F2F7;
  409. .sp {
  410. color: #707070;
  411. white-space: nowrap;
  412. margin-right: 20px;
  413. }
  414. .sp1 {
  415. color: #825618;
  416. }
  417. }
  418. .curd {
  419. :deep(.avue-crud__menu) {
  420. min-height: 10px;
  421. }
  422. }
  423. </style>