createTask.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. <template>
  2. <view class="container">
  3. <Step :step="currentStep" :stepsData="currentText" />
  4. <scroll-view class="content" scroll-y>
  5. <!-- 驳回意见提示 -->
  6. <view class="rejection-banner" v-if="rejectionInfo">
  7. <view class="rejection-icon">✕</view>
  8. <view class="rejection-text">驳回意见: {{ rejectionInfo }}</view>
  9. </view>
  10. <!-- 基本信息 -->
  11. <view class="form-section">
  12. <view class="form-item">
  13. <view class="form-label">
  14. <text class="required">*</text>
  15. <text>任务归属</text>
  16. </view>
  17. <view class="form-input picker-input" :class="{ placeholder: !formData.institution }"
  18. @click="showTaskPopup=true">
  19. {{ formData.institution || '请选择任务归属' }}
  20. <image class="icon" src="/static/image/icon_more.png"></image>
  21. </view>
  22. </view>
  23. <view class="form-item">
  24. <view class="form-label">
  25. <text class="required">*</text>
  26. <text>归属项目</text>
  27. </view>
  28. <view class="form-input picker-input" :class="{ placeholder: !formData.belongingProject }"
  29. @click="showBelongingPopup = true">
  30. {{ formData.belongingProject || '请选择归属项目' }}
  31. <image class="icon" src="/static/image/icon_more.png"></image>
  32. </view>
  33. </view>
  34. <view class="form-item">
  35. <view class="form-label">
  36. <text class="required">*</text>
  37. <text>费用分摊</text>
  38. </view>
  39. <view class="form-input picker-input" :class="{ placeholder: !formData.costAllocation }"
  40. @click="showPicker('费用分摊',costColumns)">
  41. {{ formData.costAllocation || '请选择费用分摊主体' }}
  42. <image class="icon" src="/static/image/icon_more.png"></image>
  43. </view>
  44. </view>
  45. <view class="form-item">
  46. <view class="form-label">
  47. <text class="required">*</text>
  48. <text>添加任务备注</text>
  49. </view>
  50. <EvanSwitch v-model="formData.addRemark"></EvanSwitch>
  51. </view>
  52. <view class="form-item">
  53. <view class="form-label">
  54. <text class="required">*</text>
  55. <text>归属类型</text>
  56. </view>
  57. <text class="txt">院内</text>
  58. </view>
  59. <view class="form-item">
  60. <view class="form-label">
  61. <text class="required">*</text>
  62. <text>任务类型</text>
  63. </view>
  64. <view class="form-input picker-input" :class="{ placeholder: !formData.taskType }"
  65. @click="showPicker('任务类型',taskTypeColumns)">
  66. {{ formData.taskType || '请选择任务类型' }}
  67. <image class="icon" src="/static/image/icon_more.png"></image>
  68. </view>
  69. </view>
  70. <view class="form-item">
  71. <view class="form-label">
  72. <text class="required">*</text>
  73. <text>计划开始时间</text>
  74. </view>
  75. <picker mode="date" :value="formData.planStartTime" fields="day" @change="onPlanStartTimeChange">
  76. <view class="form-input picker-input" :class="{ placeholder: !formData.planStartTime }">
  77. {{ formData.planStartTime || '请选择计划开始时间' }}
  78. <image class="icon" src="/static/image/icon_more.png"></image>
  79. </view>
  80. </picker>
  81. </view>
  82. <view class="form-item">
  83. <view class="form-label">
  84. <text class="required">*</text>
  85. <text>计划结束时间</text>
  86. </view>
  87. <picker mode="date" :value="formData.planEndTime" fields="day" @change="onPlanEndTimeChange">
  88. <view class="form-input picker-input" :class="{ placeholder: !formData.planEndTime }">
  89. {{ formData.planEndTime || '请选择计划结束时间' }}
  90. <image class="icon" src="/static/image/icon_more.png"></image>
  91. </view>
  92. </picker>
  93. </view>
  94. </view>
  95. </scroll-view>
  96. <view class="next-button" @click="toNext">下一步</view>
  97. <u-picker :title='pickerTitle' :show="showPickerVisible" confirmColor='#576B95' ref="uPicker"
  98. :columns="pickerData" @confirm="confirm" @cancel="cancel">
  99. </u-picker>
  100. <u-popup :show="showBelongingPopup" mode="bottom" round="20" @close="closePopup" closeable>
  101. <view class="popup-content p32">
  102. <view class="popup-header">
  103. <text class="title">归属项目</text>
  104. </view>
  105. <view class="search-box">
  106. <image class="icon" src="/static/image/search.png"></image>
  107. <u-input v-model="searchKeyword" placeholder="请输入归属项目" border="none" clearable />
  108. </view>
  109. <scroll-view scroll-y class="project-list">
  110. <view v-for="(project, index) in filteredProjects" :key="index" class="project-item"
  111. :class="{ active: selectedIndex === index }" @tap="selectProject(project, index)">
  112. <text class="project-name">{{ project.name }}</text>
  113. <image class="icon" src="/static/image/icon_right.png"></image>
  114. </view>
  115. </scroll-view>
  116. </view>
  117. </u-popup>
  118. <u-popup :show="showTaskPopup" mode="bottom" round="16" @close="showTaskPopup = false" safeAreaInsetBottom>
  119. <view class="popup-content">
  120. <view class="popup-header">
  121. <text class="popup-title">任务归属</text>
  122. <image class="close-icon" src="/static/image/icon_cross.png" @click="showTaskPopup=false"></image>
  123. </view>
  124. <view class="two-level-container">
  125. <scroll-view class="primary-list" scroll-y>
  126. <view v-for="(item, index) in primaryOptions" :key="index" class="primary-item"
  127. :class="{ 'primary-active': activePrimaryIndex === index }"
  128. @click="handlePrimarySelect(index)">
  129. <text class="primary-text">{{ item.name }}</text>
  130. </view>
  131. </scroll-view>
  132. <scroll-view class="secondary-list" scroll-y>
  133. <view v-for="(subItem, subIndex) in currentSecondaryOptions" :key="subIndex"
  134. class="secondary-item" :class="{ 'secondary-active': selectedSecondaryItem === subItem }"
  135. @click="handleSecondarySelect(subItem)">
  136. <text class="secondary-text">{{ subItem }}</text>
  137. <u-icon v-if="selectedSecondaryItem === subItem" name="checkbox-mark" color="#2979ff"
  138. size="20" />
  139. </view>
  140. </scroll-view>
  141. </view>
  142. <view class="popup-footer">
  143. <button class="confirm-btn" @click="handleConfirm">确定</button>
  144. </view>
  145. </view>
  146. </u-popup>
  147. </view>
  148. </template>
  149. <script>
  150. import Step from '@/pages_task/components/step.vue'
  151. import EvanSwitch from '@/components/evan-switch.vue'
  152. export default {
  153. components: {
  154. Step,
  155. EvanSwitch
  156. },
  157. data() {
  158. return {
  159. showTaskPopup: false,
  160. primaryOptions: [{
  161. id: 1,
  162. name: '中药事业部',
  163. children: ['中药一部', '中药二部', '中药三部', '中药四部']
  164. },
  165. {
  166. id: 2,
  167. name: '事业1组',
  168. children: ['事业1组-项目部', '事业1组-市场部', '事业1组-技术部']
  169. },
  170. {
  171. id: 3,
  172. name: '学术研究部',
  173. children: ['学术研究一部', '学术研究二部', '学术研究三部']
  174. },
  175. {
  176. id: 4,
  177. name: '湖南省药学服务公司',
  178. children: ['药学服务一部', '药学服务二部', '药学服务三部']
  179. },
  180. {
  181. id: 5,
  182. name: '医药事业部',
  183. children: ['医药一部', '医药二部', '医药三部']
  184. },
  185. {
  186. id: 6,
  187. name: '医疗事业部',
  188. children: ['医疗一部', '医疗二部', '医疗三部']
  189. },
  190. {
  191. id: 7,
  192. name: '健康管理部',
  193. children: ['健康管理一部', '健康管理二部']
  194. },
  195. {
  196. id: 8,
  197. name: '医疗事业部',
  198. children: ['医疗一部', '医疗二部', '医疗三部']
  199. },
  200. {
  201. id: 9,
  202. name: '健康管理部',
  203. children: ['健康管理一部', '健康管理二部']
  204. }
  205. ],
  206. activePrimaryIndex: 0,
  207. currentSecondaryOptions: [],
  208. selectedSecondaryItem: '',
  209. selectedPrimaryItem: null,
  210. selectedIndex: -1,
  211. selectedProject: null,
  212. belongingprojects: [{
  213. name: '学术交流项目'
  214. },
  215. {
  216. name: '科学调研项目'
  217. },
  218. {
  219. name: '2026年1月医学研究项目'
  220. },
  221. {
  222. name: '2026年2月医学研究项目'
  223. },
  224. {
  225. name: '2026年3月医学研究项目'
  226. }
  227. ],
  228. searchKeyword: '',
  229. showBelongingPopup: false,
  230. showPickerVisible: false,
  231. costColumns: [
  232. ['主体1', '主体2', '主体3'],
  233. ],
  234. taskTypeColumns: [
  235. ['类型1', '类型2', '类型3'],
  236. ],
  237. currentStep: 1,
  238. currentText: [{
  239. id: 1,
  240. stepNumber: 1,
  241. title: '填写任务'
  242. },
  243. {
  244. id: 2,
  245. stepNumber: 2,
  246. title: '选择客户'
  247. },
  248. {
  249. id: 3,
  250. stepNumber: 3,
  251. title: '积分设置'
  252. }
  253. ],
  254. rejectionInfo: '',
  255. formData: {
  256. costAllocation: '',
  257. planStartTime: '',
  258. planEndTime: '',
  259. institution: '',
  260. belongingProject: '',
  261. taskType: '',
  262. addRemark: false
  263. },
  264. pickerTitle: '默认标题',
  265. pickerData: []
  266. }
  267. },
  268. onLoad(options) {
  269. if (options.rejectionInfo) {
  270. this.rejectionInfo = decodeURIComponent(options.rejectionInfo)
  271. }
  272. // 初始化二级选项
  273. this.currentSecondaryOptions = this.primaryOptions[0]?.children || []
  274. },
  275. computed: {
  276. filteredProjects() {
  277. if (!this.searchKeyword.trim()) {
  278. return this.belongingprojects;
  279. }
  280. return this.belongingprojects.filter(project =>
  281. project.name.includes(this.searchKeyword)
  282. );
  283. }
  284. },
  285. methods: {
  286. handlePrimarySelect(index) {
  287. this.activePrimaryIndex = index;
  288. this.currentSecondaryOptions = this.primaryOptions[index].children || [];
  289. this.selectedSecondaryItem = '';
  290. },
  291. handleSecondarySelect(item) {
  292. this.selectedSecondaryItem = item;
  293. this.selectedPrimaryItem = this.primaryOptions[this.activePrimaryIndex];
  294. },
  295. handleConfirm() {
  296. if (this.selectedSecondaryItem) {
  297. const displayText = `${this.selectedPrimaryItem.name} > ${this.selectedSecondaryItem}`;
  298. this.formData.institution = displayText;
  299. this.showTaskPopup = false;
  300. } else {
  301. uni.showToast({
  302. title: '请选择二级部门',
  303. icon: 'none'
  304. });
  305. }
  306. },
  307. closePopup() {
  308. this.showBelongingPopup = false;
  309. this.searchKeyword = '';
  310. this.selectedIndex = -1;
  311. },
  312. selectProject(project, index) {
  313. this.selectedIndex = index;
  314. this.selectedProject = project;
  315. this.formData.belongingProject = project.name;
  316. setTimeout(() => {
  317. this.showBelongingPopup = false;
  318. this.searchKeyword = '';
  319. this.selectedIndex = -1;
  320. }, 300);
  321. },
  322. showPicker(title, data) {
  323. this.pickerData = data
  324. this.pickerTitle = title
  325. this.showPickerVisible = true
  326. },
  327. confirm(e) {
  328. if (e.value && e.value.length > 0) {
  329. if (this.pickerTitle === '费用分摊') {
  330. this.formData.costAllocation = e.value[0]
  331. } else if (this.pickerTitle === '任务类型') {
  332. this.formData.taskType = e.value[0]
  333. }
  334. }
  335. this.showPickerVisible = false
  336. },
  337. cancel() {
  338. this.showPickerVisible = false
  339. },
  340. toNext() {
  341. uni.navigateTo({
  342. url: '/pages_task/selectCustomer'
  343. })
  344. },
  345. onPlanStartTimeChange(e) {
  346. this.formData.planStartTime = e.detail.value
  347. },
  348. onPlanEndTimeChange(e) {
  349. this.formData.planEndTime = e.detail.value
  350. }
  351. }
  352. }
  353. </script>
  354. <style lang="scss" scoped>
  355. .container {
  356. min-height: 100vh;
  357. background: #F7F8FA;
  358. display: flex;
  359. flex-direction: column;
  360. position: relative;
  361. &::before {
  362. content: '';
  363. position: absolute;
  364. top: 0;
  365. left: 0;
  366. right: 0;
  367. width: 100%;
  368. height: 544rpx;
  369. background: linear-gradient(180deg, #E4EFFE 0%, rgba(228, 239, 254, 0) 100%);
  370. }
  371. .content {
  372. flex: 1;
  373. box-sizing: border-box;
  374. .rejection-banner {
  375. display: flex;
  376. align-items: center;
  377. padding: 24rpx;
  378. background: #FF5030;
  379. color: #fff;
  380. margin: 24rpx;
  381. border-radius: 8rpx;
  382. .rejection-icon {
  383. width: 40rpx;
  384. height: 40rpx;
  385. border-radius: 50%;
  386. background: rgba(255, 255, 255, 0.3);
  387. display: flex;
  388. align-items: center;
  389. justify-content: center;
  390. font-size: 24rpx;
  391. margin-right: 16rpx;
  392. }
  393. .rejection-text {
  394. flex: 1;
  395. font-size: 28rpx;
  396. line-height: 1.5;
  397. }
  398. }
  399. .form-section {
  400. background: #fff;
  401. margin: 20rpx;
  402. border-radius: 16rpx;
  403. padding: 32rpx;
  404. .form-item {
  405. display: flex;
  406. justify-content: space-between;
  407. align-items: center;
  408. border-bottom: 1px solid #EBEDF0;
  409. padding: 30rpx 0;
  410. &:last-child {
  411. border-bottom: 0;
  412. }
  413. .form-label {
  414. display: flex;
  415. align-items: center;
  416. font-size: 28rpx;
  417. color: #333;
  418. margin-bottom: 16rpx;
  419. .required {
  420. color: #CF3546;
  421. margin-right: 4rpx;
  422. }
  423. }
  424. .txt {
  425. font-size: 28rpx;
  426. color: #333333;
  427. }
  428. .form-input {
  429. flex: 1;
  430. font-size: 28rpx;
  431. color: #C8C9CC;
  432. &.placeholder {
  433. color: #C8C9CC;
  434. }
  435. &.picker-input {
  436. display: flex;
  437. align-items: center;
  438. justify-content: flex-end;
  439. }
  440. .icon {
  441. width: 36rpx;
  442. height: 36rpx;
  443. }
  444. }
  445. }
  446. }
  447. }
  448. .next-button {
  449. text-align: center;
  450. font-size: 32rpx;
  451. color: #FFFFFF;
  452. height: 88rpx;
  453. line-height: 88rpx;
  454. background: #388BFF;
  455. border-radius: 200rpx;
  456. margin: 32rpx;
  457. }
  458. }
  459. ::v-deep .u-popup__content {
  460. border-radius: 40rpx 40rpx 0 0 !important;
  461. }
  462. .popup-content {
  463. border-radius: 40rpx 40rpx 0rpx 0rpx;
  464. height: 70vh;
  465. background-color: #fff;
  466. .popup-header {
  467. padding: 40rpx 30rpx 20rpx;
  468. text-align: center;
  469. .close-icon {
  470. width: 44rpx;
  471. height: 44rpx;
  472. position: absolute;
  473. right: 32rpx;
  474. }
  475. flex-shrink: 0;
  476. .title {
  477. font-size: 32rpx;
  478. font-weight: 600;
  479. color: #333;
  480. }
  481. .popup-title {
  482. font-size: 32rpx;
  483. font-weight: 600;
  484. color: #333;
  485. }
  486. }
  487. .search-box {
  488. display: flex;
  489. align-items: center;
  490. background: #F7F8FA;
  491. border-radius: 38rpx;
  492. padding: 16rpx 28rpx;
  493. margin-bottom: 24rpx;
  494. .icon {
  495. width: 26rpx;
  496. height: 26rpx;
  497. margin-right: 10rpx;
  498. }
  499. }
  500. .project-list {
  501. height: calc(100% - 200rpx);
  502. .project-item {
  503. display: flex;
  504. justify-content: space-between;
  505. align-items: center;
  506. padding: 28rpx 0;
  507. font-size: 28rpx;
  508. border-bottom: 1rpx solid #eee;
  509. &:active {
  510. background-color: #f9f9f9;
  511. }
  512. &.active {
  513. .project-name {
  514. font-weight: 500;
  515. color: #388BFF;
  516. }
  517. .icon {
  518. opacity: 1;
  519. }
  520. }
  521. .project-name {
  522. color: #333;
  523. transition: all 0.2s ease;
  524. }
  525. .icon {
  526. width: 36rpx;
  527. height: 36rpx;
  528. opacity: 0;
  529. transition: opacity 0.2s ease;
  530. }
  531. }
  532. }
  533. .two-level-container {
  534. display: flex;
  535. flex: 1;
  536. border-top: 1rpx solid #f5f5f5;
  537. .primary-list {
  538. width: 40%;
  539. background-color: #f8f9fa;
  540. .primary-item {
  541. padding: 28rpx 20rpx;
  542. background: #F2F3F5;
  543. &:active {
  544. background: #FFFFFF;
  545. }
  546. &.primary-active {
  547. position: relative;
  548. background-color: #fff;
  549. &::before {
  550. content: '';
  551. position: absolute;
  552. top: 50%;
  553. left: 0;
  554. transform: translateY(-50%);
  555. width: 8rpx;
  556. height: 32rpx;
  557. background: #388BFF;
  558. }
  559. .primary-text {
  560. font-weight: 500;
  561. }
  562. }
  563. .primary-text {
  564. font-size: 28rpx;
  565. color: #666;
  566. }
  567. }
  568. }
  569. .secondary-list {
  570. width: 60%;
  571. padding: 0 20rpx;
  572. .secondary-item {
  573. display: flex;
  574. justify-content: space-between;
  575. align-items: center;
  576. padding: 28rpx 10rpx;
  577. font-size: 28rpx;
  578. color: #333;
  579. &.secondary-active {
  580. font-weight: 500;
  581. color: #388BFF;
  582. }
  583. }
  584. }
  585. }
  586. .popup-footer {
  587. padding: 20rpx 30rpx 40rpx;
  588. background-color: #fff;
  589. border-top: 1rpx solid #f5f5f5;
  590. flex-shrink: 0;
  591. .confirm-btn {
  592. width: 100%;
  593. height: 88rpx;
  594. line-height: 88rpx;
  595. background-color: #2979ff;
  596. color: #fff;
  597. font-size: 32rpx;
  598. border-radius: 200rpx 200rpx 200rpx 200rpx;
  599. &:active {
  600. opacity: 0.8;
  601. }
  602. }
  603. }
  604. }
  605. @media (prefers-color-scheme: dark) {
  606. .popup-content {
  607. background-color: #1e1e1e;
  608. .popup-header {
  609. .title,
  610. .popup-title {
  611. color: #fff;
  612. }
  613. }
  614. .two-level-container {
  615. .primary-list {
  616. background-color: #2d2d2d;
  617. border-right-color: #3d3d3d;
  618. .primary-item {
  619. border-bottom-color: #3d3d3d;
  620. &:active {
  621. background-color: #3d3d3d;
  622. }
  623. &.primary-active {
  624. background-color: #3d3d3d;
  625. .primary-text {
  626. color: #2979ff;
  627. }
  628. }
  629. .primary-text {
  630. color: #ccc;
  631. }
  632. }
  633. }
  634. .secondary-list {
  635. .secondary-item {
  636. border-bottom-color: #3d3d3d;
  637. &:active {
  638. background-color: #3d3d3d;
  639. }
  640. &.secondary-active {
  641. background-color: #2d2d2d;
  642. }
  643. .secondary-text {
  644. color: #fff;
  645. }
  646. }
  647. }
  648. }
  649. .popup-footer {
  650. background-color: #1e1e1e;
  651. border-top-color: #3d3d3d;
  652. }
  653. }
  654. }
  655. </style>