综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. <template>
  2. <view class="container">
  3. <!-- 搜索栏 -->
  4. <view class="search-box">
  5. <view class="search-header" @tap="toggleSearch">
  6. <text class="search-title">搜索条件</text>
  7. <text class="search-icon">{{ isSearchExpanded ? '收起' : '展开' }}</text>
  8. </view>
  9. <view class="search-content" v-if="isSearchExpanded">
  10. <view class="search-item">
  11. <text>项目编号</text>
  12. <input v-model="queryParams.projectNumber" placeholder="请输入项目编号" @confirm="handleQuery" />
  13. </view>
  14. <view class="search-item">
  15. <text>项目名称</text>
  16. <input v-model="queryParams.projectName" placeholder="请输入项目名称" @confirm="handleQuery" />
  17. </view>
  18. <view class="search-item">
  19. <text>项目负责人</text>
  20. <picker mode="selector" :range="userList" range-key="text" @change="handleLeaderChange">
  21. <view class="picker">
  22. <text>{{ selectedLeader || '请选择项目负责人' }}</text>
  23. </view>
  24. </picker>
  25. </view>
  26. <view class="search-item">
  27. <text>承担部门</text>
  28. <picker mode="selector" :range="deptList" range-key="text" @change="handleDeptChange">
  29. <view class="picker">
  30. <text>{{ selectedDept || '请选择承担部门' }}</text>
  31. </view>
  32. </picker>
  33. </view>
  34. <view class="search-item">
  35. <text>其他关键字</text>
  36. <input v-model="queryParams.queryString" placeholder="请输入关键字" @confirm="handleQuery" />
  37. </view>
  38. <view class="search-buttons">
  39. <button type="primary" size="mini" @tap="handleQuery">搜索</button>
  40. <button type="default" size="mini" @tap="resetQuery">重置</button>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 项目列表 -->
  45. <view class="list-box">
  46. <view class="list-header">
  47. <text class="title">测绘项目列表</text>
  48. <view class="header-btns">
  49. <button type="primary" size="mini" @tap="handleRegister">登记项目</button>
  50. <button type="default" size="mini" @tap="handleExport">导出项目</button>
  51. </view>
  52. </view>
  53. <scroll-view
  54. scroll-y
  55. class="list-scroll"
  56. @scrolltolower="loadMore"
  57. :refresher-enabled="true"
  58. :refresher-triggered="isRefreshing"
  59. @refresherrefresh="onRefresh"
  60. >
  61. <view class="list-content">
  62. <view class="project-card" v-for="(item, index) in projectList" :key="index">
  63. <!-- 卡片头部 -->
  64. <view class="card-header">
  65. <view class="header-left">
  66. <text class="project-name">{{ item.projectName }}</text>
  67. <text class="status-tag" :class="item.isFinished === '0' ? 'success' : 'warning'">
  68. {{ item.isFinished === '0' ? '进行中' : '已结束' }}
  69. </text>
  70. </view>
  71. <text class="level-tag" :class="item.projectLevel === '0' ? 'info' : 'error'">
  72. {{ item.projectLevel === '0' ? '一般项目' : '重大项目' }}
  73. </text>
  74. </view>
  75. <!-- 卡片内容 -->
  76. <view class="card-content">
  77. <view class="info-row">
  78. <text class="label">项目编号:</text>
  79. <text class="value">{{ item.projectNumber }}</text>
  80. </view>
  81. <view class="info-row">
  82. <text class="label">合同编码:</text>
  83. <text class="value">{{ item.contract ? item.contract.contractCode : '未关联' }}</text>
  84. </view>
  85. <view class="info-row">
  86. <text class="label">承担部门:</text>
  87. <text class="value">{{ item.undertakingDeptName }}</text>
  88. </view>
  89. <view class="info-row">
  90. <text class="label">项目负责人:</text>
  91. <text class="value">{{ item.projectLeaderUser ? item.projectLeaderUser.nickName : '' }}</text>
  92. </view>
  93. <view class="info-row">
  94. <text class="label">项目类型:</text>
  95. <text class="value">{{ item.projectType }}</text>
  96. </view>
  97. <view class="info-row">
  98. <text class="label">项目进度:</text>
  99. <view class="progress-box">
  100. <progress :percent="item.percentage" :activeColor="getProgressColor(item.percentage)" />
  101. <text class="progress-text">{{ item.percentage }}%</text>
  102. </view>
  103. </view>
  104. </view>
  105. <!-- 卡片底部 -->
  106. <view class="card-footer">
  107. <button type="primary" size="mini" @tap="handleView(item)">查看</button>
  108. <button type="warn" size="mini" @tap="handleDelete(item)">删除</button>
  109. <button type="default" size="mini" @tap="handleRelate(item)">关联合同</button>
  110. </view>
  111. </view>
  112. </view>
  113. </scroll-view>
  114. <!-- 加载更多 -->
  115. <view class="load-more" v-if="projectList.length > 0">
  116. <text v-if="hasMore">上拉加载更多</text>
  117. <text v-else>没有更多数据了</text>
  118. </view>
  119. </view>
  120. </view>
  121. </template>
  122. <script>
  123. import { listProject, listProjectFuzzy, delProject } from "@/api/oa/project/project";
  124. import { getProjectProgress } from "@/api/oa/project/projectProgress";
  125. import { listDept } from '@/api/system/dept';
  126. import { listUser } from '@/api/system/user';
  127. export default {
  128. data() {
  129. return {
  130. isSearchExpanded: false,
  131. queryParams: {
  132. pageNum: 1,
  133. pageSize: 10,
  134. projectNumber: '',
  135. projectLeader: '',
  136. projectName: '',
  137. queryString: '',
  138. undertakingDept: ''
  139. },
  140. projectList: [],
  141. total: 0,
  142. loading: false,
  143. userList: [],
  144. deptList: [],
  145. selectedLeader: '',
  146. selectedDept: '',
  147. hasMore: true,
  148. isRefreshing: false
  149. }
  150. },
  151. onLoad() {
  152. this.getList();
  153. this.getDeptList();
  154. this.getUserList();
  155. },
  156. methods: {
  157. toggleSearch() {
  158. this.isSearchExpanded = !this.isSearchExpanded;
  159. },
  160. resetQuery() {
  161. this.queryParams = {
  162. pageNum: 1,
  163. pageSize: 10,
  164. projectNumber: '',
  165. projectLeader: '',
  166. projectName: '',
  167. queryString: '',
  168. undertakingDept: ''
  169. };
  170. this.selectedLeader = '';
  171. this.selectedDept = '';
  172. this.handleQuery();
  173. },
  174. async getList() {
  175. this.loading = true;
  176. try {
  177. const response = this.queryParams.queryString ?
  178. await listProjectFuzzy(this.queryParams) :
  179. await listProject(this.queryParams);
  180. if (this.queryParams.pageNum === 1) {
  181. this.projectList = response.rows;
  182. } else {
  183. this.projectList = [...this.projectList, ...response.rows];
  184. }
  185. this.total = response.total;
  186. this.hasMore = this.projectList.length < this.total;
  187. for (let project of this.projectList) {
  188. const res = await getProjectProgress(project.projectId);
  189. if (res.data && res.data.length > 0) {
  190. project.percentage = Number(res.data[res.data.length - 1].percentage);
  191. } else {
  192. project.percentage = 0;
  193. }
  194. if (project.isFinished === '1') {
  195. project.percentage = 100;
  196. }
  197. }
  198. } catch (error) {
  199. uni.showToast({
  200. title: '获取数据失败',
  201. icon: 'none'
  202. });
  203. } finally {
  204. this.loading = false;
  205. this.isRefreshing = false;
  206. }
  207. },
  208. async getDeptList() {
  209. try {
  210. const res = await listDept({});
  211. this.deptList = res.data.map(item => ({
  212. value: item.deptId,
  213. text: item.deptName
  214. }));
  215. } catch (error) {
  216. uni.showToast({
  217. title: '获取部门列表失败',
  218. icon: 'none'
  219. });
  220. }
  221. },
  222. async getUserList() {
  223. try {
  224. const res = await listUser({ pageNum: 1, pageSize: 9999 });
  225. this.userList = res.rows.map(item => ({
  226. value: item.userId,
  227. text: item.nickName
  228. }));
  229. } catch (error) {
  230. uni.showToast({
  231. title: '获取用户列表失败',
  232. icon: 'none'
  233. });
  234. }
  235. },
  236. handleQuery() {
  237. this.queryParams.pageNum = 1;
  238. this.getList();
  239. },
  240. handleLeaderChange(e) {
  241. const index = e.detail.value;
  242. this.queryParams.projectLeader = this.userList[index].value;
  243. this.selectedLeader = this.userList[index].text;
  244. this.handleQuery();
  245. },
  246. handleDeptChange(e) {
  247. const index = e.detail.value;
  248. this.queryParams.undertakingDept = this.deptList[index].value;
  249. this.selectedDept = this.deptList[index].text;
  250. this.handleQuery();
  251. },
  252. handleView(row) {
  253. uni.navigateTo({
  254. url: `/pages/project/info?id=${row.projectId}&projectName=${encodeURIComponent(row.projectName)}`
  255. });
  256. },
  257. handleDelete(row) {
  258. uni.showModal({
  259. title: '提示',
  260. content: `是否确认删除项目编号为"${row.projectNumber}"的数据项?`,
  261. success: async (res) => {
  262. if (res.confirm) {
  263. try {
  264. await delProject(row.projectId);
  265. this.getList();
  266. uni.showToast({
  267. title: '删除成功',
  268. icon: 'success'
  269. });
  270. } catch (error) {
  271. uni.showToast({
  272. title: '删除失败',
  273. icon: 'none'
  274. });
  275. }
  276. }
  277. }
  278. });
  279. },
  280. handleRegister() {
  281. uni.navigateTo({
  282. url: '/pages/project/register'
  283. });
  284. },
  285. handleExport() {
  286. uni.showToast({
  287. title: '导出功能开发中',
  288. icon: 'none'
  289. });
  290. },
  291. handleRelate(row) {
  292. uni.showToast({
  293. title: '关联合同功能开发中',
  294. icon: 'none'
  295. });
  296. },
  297. loadMore() {
  298. if (this.hasMore) {
  299. this.queryParams.pageNum++;
  300. this.getList();
  301. }
  302. },
  303. onRefresh() {
  304. this.isRefreshing = true;
  305. this.queryParams.pageNum = 1;
  306. this.getList();
  307. },
  308. getProgressColor(percentage) {
  309. if (!percentage) return '#ff4d4f';
  310. if (percentage <= 20) return '#ff4d4f';
  311. if (percentage <= 50) return '#faad14';
  312. if (percentage <= 80) return '#1890ff';
  313. return '#52c41a';
  314. }
  315. }
  316. }
  317. </script>
  318. <style>
  319. .container {
  320. padding: 20rpx;
  321. background-color: #f5f5f5;
  322. height: 100vh;
  323. display: flex;
  324. flex-direction: column;
  325. }
  326. .search-box {
  327. background-color: #fff;
  328. border-radius: 8rpx;
  329. margin-bottom: 20rpx;
  330. overflow: hidden;
  331. }
  332. .search-header {
  333. padding: 20rpx;
  334. display: flex;
  335. justify-content: space-between;
  336. align-items: center;
  337. border-bottom: 1px solid #ebeef5;
  338. }
  339. .search-title {
  340. font-size: 32rpx;
  341. font-weight: bold;
  342. color: #333;
  343. }
  344. .search-icon {
  345. font-size: 28rpx;
  346. color: #909399;
  347. }
  348. .search-content {
  349. padding: 20rpx;
  350. }
  351. .search-item {
  352. margin-bottom: 20rpx;
  353. }
  354. .search-item text {
  355. display: block;
  356. margin-bottom: 10rpx;
  357. font-size: 28rpx;
  358. color: #333;
  359. }
  360. .search-item input,
  361. .search-item .picker {
  362. width: 100%;
  363. height: 80rpx;
  364. padding: 0 20rpx;
  365. border: 1px solid #dcdfe6;
  366. border-radius: 4rpx;
  367. box-sizing: border-box;
  368. }
  369. .search-item .picker {
  370. line-height: 80rpx;
  371. color: #606266;
  372. }
  373. .search-buttons {
  374. display: flex;
  375. gap: 20rpx;
  376. margin-top: 20rpx;
  377. }
  378. .search-buttons button {
  379. flex: 1;
  380. }
  381. .list-box {
  382. flex: 1;
  383. background-color: #fff;
  384. border-radius: 8rpx;
  385. display: flex;
  386. flex-direction: column;
  387. overflow: hidden;
  388. }
  389. .list-header {
  390. padding: 20rpx;
  391. display: flex;
  392. justify-content: space-between;
  393. align-items: center;
  394. border-bottom: 1px solid #ebeef5;
  395. }
  396. .title {
  397. font-size: 32rpx;
  398. font-weight: bold;
  399. }
  400. .header-btns {
  401. display: flex;
  402. gap: 20rpx;
  403. }
  404. .list-scroll {
  405. flex: 1;
  406. height: 0;
  407. }
  408. .list-content {
  409. padding: 20rpx;
  410. }
  411. .project-card {
  412. background-color: #fff;
  413. border-radius: 8rpx;
  414. margin-bottom: 20rpx;
  415. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
  416. overflow: hidden;
  417. }
  418. .card-header {
  419. padding: 20rpx;
  420. display: flex;
  421. justify-content: space-between;
  422. align-items: center;
  423. border-bottom: 1px solid #ebeef5;
  424. background-color: #fafafa;
  425. }
  426. .header-left {
  427. display: flex;
  428. align-items: center;
  429. gap: 20rpx;
  430. }
  431. .project-name {
  432. font-size: 32rpx;
  433. font-weight: bold;
  434. color: #333;
  435. }
  436. .status-tag,
  437. .level-tag {
  438. padding: 4rpx 12rpx;
  439. border-radius: 4rpx;
  440. font-size: 24rpx;
  441. }
  442. .success {
  443. background-color: #f0f9eb;
  444. color: #67c23a;
  445. }
  446. .warning {
  447. background-color: #fdf6ec;
  448. color: #e6a23c;
  449. }
  450. .info {
  451. background-color: #f4f4f5;
  452. color: #909399;
  453. }
  454. .error {
  455. background-color: #fef0f0;
  456. color: #f56c6c;
  457. }
  458. .card-content {
  459. padding: 20rpx;
  460. }
  461. .info-row {
  462. display: flex;
  463. align-items: center;
  464. margin-bottom: 16rpx;
  465. }
  466. .info-row:last-child {
  467. margin-bottom: 0;
  468. }
  469. .info-row .label {
  470. width: 160rpx;
  471. color: #909399;
  472. font-size: 28rpx;
  473. }
  474. .info-row .value {
  475. flex: 1;
  476. color: #333;
  477. font-size: 28rpx;
  478. }
  479. .progress-box {
  480. flex: 1;
  481. display: flex;
  482. align-items: center;
  483. gap: 20rpx;
  484. }
  485. .progress-box progress {
  486. flex: 1;
  487. }
  488. .progress-text {
  489. width: 80rpx;
  490. text-align: right;
  491. color: #333;
  492. font-size: 28rpx;
  493. }
  494. .card-footer {
  495. display: flex;
  496. justify-content: flex-end;
  497. gap: 20rpx;
  498. padding: 20rpx;
  499. border-top: 1px solid #ebeef5;
  500. background-color: #fafafa;
  501. }
  502. .card-footer button {
  503. margin: 0;
  504. padding: 0 30rpx;
  505. }
  506. .load-more {
  507. text-align: center;
  508. padding: 20rpx;
  509. color: #909399;
  510. font-size: 28rpx;
  511. }
  512. </style>