Demand.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <template>
  2. <div class="demand">
  3. <el-tabs v-model="form.activeName" class="demo-tabs" @tab-click="handleClick">
  4. <el-tab-pane v-for="tab in tabs" :key="tab.name" :label="$t(tab.label)" :name="tab.name">
  5. <div class="demand-list">
  6. <div v-for="(item, index) in list" :key="index" @click.stop="toDetail(item)" class="li">
  7. <div class="flex-center-between">
  8. <div class="flex-align-center">
  9. <div v-if="form.activeName == 1" class="tag"
  10. :class="{ 'tag_red': item.applyStatus == 2 || item.applyStatus == null }">{{
  11. item.applyStatus == 1 ? $t('workflowTrade.demandStatusSignUping') : $t('workflowTrade.demandStatusEnded') }}</div>
  12. <div class="title">{{ item.title }}</div>
  13. </div>
  14. <div class="price" v-if="item.budgetMin || item.budgetMax">¥{{ item.budgetMin }}-{{ item.budgetMax }}
  15. </div>
  16. </div>
  17. <div class="flex-align-center content" v-if="item.categoryName3">
  18. <div class="flex-align-center">
  19. <!-- <el-button type="primary" size="small" plain>{{ item.categoryName1 }}</el-button> -->
  20. <!-- <el-button type="primary" size="small" plain>{{ item.categoryName2 }}</el-button> -->
  21. <el-button type="primary" size="small" plain>{{ item.categoryName3 }}</el-button>
  22. </div>
  23. <div class="flex-align-center list">
  24. <div class="lis">
  25. <img src="/src/assets/imgs/yuangong.png" alt="">
  26. <div class="">{{ item.questApplyCount || 0 }}{{ $t('common.renbaoming') }}</div>
  27. </div>
  28. <div class="lis">
  29. <img src="/src/assets/imgs/rili.png" alt="">
  30. <div class="">{{ $t('common.signUpDeadline') }}:{{ item.deadline }}</div>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="description">{{ item.requirements }}</div>
  35. <div class="info">
  36. <div class="info-left">
  37. <el-avatar :size="30" :src="item.userAvatar || appStore.avatarDefault" />
  38. <div class="name">{{ item.nickName }}</div>
  39. <div class="date">{{ item.publishTime }} {{ $t('common.publish') }}</div>
  40. </div>
  41. <div class="info-right flex-align-center">
  42. <template v-if="form.activeName === 0">
  43. <div class="btn" @click.stop="changeItem(item, index, 0)">
  44. <img src="/src/assets/imgs/my/jilu@2x.png" alt="">
  45. <div>{{ $t('personalCenter.viewSignUpRecord') }}</div>
  46. </div>
  47. <template v-if="item.applyStatus == 1">
  48. <div class="btn" @click.stop="changeItem(item, index, 1)">
  49. <img src="/src/assets/imgs/my/bianji@2x.png" alt="">
  50. <div>{{ $t('common.edit') }}</div>
  51. </div>
  52. <div class="btn" @click.stop="changeItem(item, index, 2)">
  53. <img src="/src/assets/imgs/my/guanbi@2x.png" alt="">
  54. <div class="red">{{ $t('personalCenter.endActivity') }}</div>
  55. </div>
  56. </template>
  57. <div class="btn" @click.stop="changeItem(item, index, 3)">
  58. <img src="/src/assets/imgs/my/shanchu@2x.png" alt="">
  59. <div class="red">{{ $t('common.delete') }}</div>
  60. </div>
  61. </template>
  62. <div class="btn" v-else @click.stop="changeItem(item, index, 4)">
  63. <img src="/src/assets/imgs/my/quxiao@2x.png" alt="">
  64. <div class="red">{{ $t('personalCenter.cancelSignUp') }}</div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </el-tab-pane>
  71. </el-tabs>
  72. <template v-if="list.length">
  73. <Pagination :total="form.total" :page-size="form.pageSize" :current-page="form.pageNum"
  74. @page-change="handlePageChange" />
  75. </template>
  76. <el-empty v-else :description="$t('common.empty')" />
  77. <el-dialog v-model="dialogVisible" :title="$t('personalCenter.viewSignUpRecord')" width="1138">
  78. <div class="detail">
  79. <div class="detail-top">
  80. <div class="flex-center-between">
  81. <div class="flex-align-center">
  82. <div class="tag" :class="{ 'tag_red': itemData.applyStatus == '2' }">{{ itemData.applyStatus == 1 ? $t('workflowTrade.demandStatusSignUping')
  83. :
  84. $t('workflowTrade.demandStatusEnded')
  85. }}</div>
  86. <div class="name">{{ itemData.title }}</div>
  87. </div>
  88. <div class="price">¥{{ itemData.budgetMin }}-{{ itemData.budgetMax }}</div>
  89. </div>
  90. <div class="flex-align-center content">
  91. <div class="flex-align-center">
  92. <!-- <el-button type="primary" size="small" plain>一级分类名称</el-button> -->
  93. <el-button type="primary" size="small" plain>{{ itemData.categoryName3 }}</el-button>
  94. </div>
  95. <ul class="flex-align-center list">
  96. <div class="li">
  97. <img src="/src/assets/imgs/yuangong.png" alt="">
  98. <div class="">{{ itemData.questApplyCount || 0 }}{{ $t('common.renbaoming') }}</div>
  99. </div>
  100. <div class="li">
  101. <img src="/src/assets/imgs/rili.png" alt="">
  102. <div class="">{{ $t('common.signUpDeadline') }}:{{ itemData.deadline }}</div>
  103. </div>
  104. </ul>
  105. </div>
  106. <div class="desc">{{ itemData.requirements }}
  107. </div>
  108. <div class="time">{{ itemData.publishTime }} {{ $t('common.publish') }}</div>
  109. </div>
  110. <div class="detail-txt">{{ $t('personalCenter.baomiliang') }}({{ itemData.questApplyCount || 0 }} {{
  111. $t('personalCenter.ren') }})</div>
  112. <div class="detail-list">
  113. <div v-for="(item, index) in recordList" :key="index" class="li">
  114. <div class="flex-align-center detail-list-left">
  115. <el-avatar :size="20" :src="item.userAvatar" />
  116. <div class="">{{ item.applyUserName }}</div>
  117. <div class="">{{ item.userPhone }}</div>
  118. </div>
  119. <div class="detail-list-number">{{ $t('personalCenter.gongzuoliuliang') }}:{{ item.publishCount }}</div>
  120. <div class="flex-align-center detail-list-right">
  121. <template v-if="item.applyStatus == 0">
  122. <div @click.stop="changeDemand(item, index, 1)" class="lex-align-center btn green">
  123. <img src="/src/assets/imgs/my/dui@2x.png" alt="">
  124. <div class="">{{ $t('common.agree') }}</div>
  125. </div>
  126. <div @click.stop="changeDemand(item, index, 2)" class="lex-align-center btn red">
  127. <img src="/src/assets/imgs/my/quxiao@2x.png" alt="">
  128. <div class="">{{ $t('common.reject') }}</div>
  129. </div>
  130. </template>
  131. <!-- <div @click="changeDemand(item, index, 3)" class="lex-align-center btn blue">
  132. <img src="/src/assets/imgs/my/jilu@2x.png" alt="">
  133. <div class="">{{ $t('common.viewHomepage') }}</div>
  134. </div> -->
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. <template #footer>
  140. <div class="dialog-footer flex-center">
  141. <el-button @click.prevent="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
  142. <el-button type="primary" class="gradient" @click.prevent="dialogVisible = false">
  143. {{ $t('common.confirm') }}
  144. </el-button>
  145. </div>
  146. </template>
  147. </el-dialog>
  148. </div>
  149. </template>
  150. <script lang="ts" setup>
  151. import { ref, onMounted } from 'vue'
  152. import { useAppStore } from '@/pinia/appStore'
  153. import type { TabsPaneContext } from 'element-plus'
  154. import Pagination from '@/components/Pagination.vue'
  155. import { getWorkflowApplyByUserId, userQuestList, appliList, updateQuestStatus, delectQuest, cancelApply, applyUpdateQuestStatus } from '@/api/my.js'
  156. import { useRoute, useRouter } from 'vue-router'
  157. import DGTMessage from '@/utils/message'
  158. import { ElMessageBox } from 'element-plus'
  159. import { useI18n } from 'vue-i18n'
  160. const { t } = useI18n()
  161. const appStore = useAppStore();
  162. const route = useRoute()
  163. const router = useRouter()
  164. const tabs = ref([
  165. { label: 'personalCenter.publishDemandRecord', name: 0 },
  166. { label: 'personalCenter.myDemandRecord', name: 1 }
  167. ])
  168. const dialogVisible = ref(false)
  169. const list = ref([])
  170. const form = ref({
  171. pageNum: 1,
  172. pageSize: 10,
  173. total: 0,
  174. activeName: 0,
  175. orderByColumn: 'create_time',
  176. isAsc: 'desc'
  177. })
  178. const itemData = ref({})
  179. const recordList = ref([])//报名记录
  180. // 同意拒绝
  181. const changeDemand = async (item, index, applyStatus) => {
  182. if (applyStatus == 3) {
  183. } else {
  184. let res = await applyUpdateQuestStatus({
  185. id: item.id,
  186. applyUserId: item.applyUserId,
  187. applyStatus
  188. })
  189. if (res.code === 200) {
  190. DGTMessage.success(`${t('common.success')}`)
  191. dialogVisible.value = false;
  192. }
  193. }
  194. }
  195. const changeItem = async (item, index, type) => {
  196. itemData.value = item;
  197. if (type == 0) {
  198. let res = await appliList({ questId: item.questId })
  199. recordList.value = res.rows;
  200. dialogVisible.value = true;
  201. } else if (type == 1) {
  202. router.push({ path: `/workflow-trade/workflow-trade-add`, query: { id: item.questId } });
  203. } else if (type == 2) {
  204. ElMessageBox.confirm(
  205. t('personalCenter.jieshuxuqiu') + '?',
  206. t('common.warning'),
  207. {
  208. confirmButtonText: t('common.confirm'),
  209. cancelButtonText: t('common.cancel'),
  210. type: 'warning',
  211. }
  212. )
  213. .then(async () => {
  214. let res = await updateQuestStatus({
  215. questId: item.questId
  216. })
  217. if (res.code === 200) {
  218. getList()
  219. DGTMessage.success(`${t('common.success')}`)
  220. }
  221. })
  222. .catch(() => {
  223. })
  224. } else if (type == 3) {
  225. ElMessageBox.confirm(
  226. t('personalCenter.shifoushanchu'),
  227. t('common.warning'),
  228. {
  229. confirmButtonText: t('common.confirm'),
  230. cancelButtonText: t('common.cancel'),
  231. type: 'warning',
  232. }
  233. )
  234. .then(async () => {
  235. let res = await delectQuest(item.questId)
  236. if (res.code === 200) {
  237. getList()
  238. DGTMessage.success(`${t('common.delete')}${t('common.success')}`)
  239. }
  240. })
  241. .catch(() => {
  242. })
  243. } else if (type == 4) {
  244. ElMessageBox.confirm(
  245. t('personalCenter.sfqxbm'),
  246. t('common.warning'),
  247. {
  248. confirmButtonText: t('common.confirm'),
  249. cancelButtonText: t('common.cancel'),
  250. type: 'warning',
  251. }
  252. )
  253. .then(async () => {
  254. let res = await cancelApply(item.id)
  255. if (res.code === 200) {
  256. getList()
  257. DGTMessage.success(`${t('common.cancel')}${t('common.success')}`)
  258. }
  259. })
  260. .catch(() => {
  261. })
  262. }
  263. }
  264. const toDetail = (item) => {
  265. if (item.title) {
  266. router.push({
  267. path: `/workflow-trade/workflow-trade-detail`,
  268. query: {
  269. questId: item.questId,
  270. metaTitle: item.title
  271. }
  272. })
  273. } else {
  274. DGTMessage.warning(t('personalCenter.gxxybsc'))
  275. }
  276. }
  277. const handleClick = (tab: TabsPaneContext) => {
  278. list.value = []
  279. form.value.pageNum = 1;
  280. form.value.activeName = tab.props.name;
  281. getList()
  282. }
  283. // 获取列表
  284. const getList = async () => {
  285. let res = await (form.value.activeName === 0 ? userQuestList(form.value) : getWorkflowApplyByUserId(form.value))
  286. list.value = res.rows || [];
  287. form.value.total = res.total;
  288. }
  289. const handlePageChange = (page) => {
  290. list.value = []
  291. form.value.pageNum = page;
  292. getList()
  293. }
  294. onMounted(() => {
  295. getList()
  296. })
  297. </script>
  298. <style scoped lang="scss">
  299. .demand {
  300. padding-bottom: 20px;
  301. div {
  302. line-height: 1;
  303. }
  304. .demand-list {
  305. .li {
  306. padding: 16px;
  307. cursor: pointer;
  308. margin-bottom: 16px;
  309. background: #F5F7FA;
  310. border-radius: 16px;
  311. &:last-child {
  312. margin-bottom: 0;
  313. }
  314. .title {
  315. font-size: 18px;
  316. font-weight: bold;
  317. color: #333333;
  318. }
  319. .tag {
  320. padding: 0 12px;
  321. line-height: 30px;
  322. color: #FFFFFF;
  323. font-size: 14px;
  324. background: #2D71FF;
  325. border-radius: 4px;
  326. margin-right: 8px;
  327. }
  328. .tag_red {
  329. background: #E43434;
  330. }
  331. .description {
  332. font-size: 16px;
  333. color: #666666;
  334. line-height: 24px;
  335. margin: 8px 0;
  336. }
  337. .info {
  338. display: flex;
  339. justify-content: space-between;
  340. align-items: center;
  341. .info-left {
  342. display: flex;
  343. align-items: center;
  344. .name {
  345. font-size: 16px;
  346. margin: 0 8px;
  347. }
  348. .date {
  349. font-size: 14px;
  350. color: #666666;
  351. }
  352. }
  353. .info-right {
  354. .btn {
  355. height: 32px;
  356. display: flex;
  357. align-items: center;
  358. padding: 0px 16px;
  359. background: #FFFFFF;
  360. border-radius: 4px;
  361. cursor: pointer;
  362. margin-left: 8px;
  363. img {
  364. width: 14px;
  365. height: 14px;
  366. margin-right: 4px;
  367. }
  368. div {
  369. font-size: 14px;
  370. color: #2D71FF;
  371. }
  372. .red {
  373. color: #E43434;
  374. }
  375. }
  376. }
  377. }
  378. .price {
  379. font-size: 24px;
  380. color: #FD5F3C;
  381. }
  382. }
  383. }
  384. }
  385. .content {
  386. margin-top: 8px;
  387. .list {
  388. .lis {
  389. display: flex;
  390. align-items: center;
  391. img {
  392. width: 16px;
  393. height: 16px;
  394. margin-right: 4px;
  395. }
  396. margin-left: 8px;
  397. div {
  398. font-size: 12px;
  399. }
  400. }
  401. }
  402. }
  403. .detail {
  404. padding: 16px;
  405. border-top: 1px solid #EBEEF5;
  406. .detail-top {
  407. padding: 16px;
  408. background: #F5F7FA;
  409. border-radius: 16px;
  410. border: 1px solid #FFFFFF;
  411. .tag {
  412. padding: 0 12px;
  413. line-height: 30px;
  414. font-size: 14px;
  415. color: #FFFFFF;
  416. background: #2D71FF;
  417. border-radius: 4px;
  418. }
  419. .tag_red {
  420. background: #E43434;
  421. }
  422. .name {
  423. font-size: 18px;
  424. font-weight: bold;
  425. color: #333333;
  426. margin-left: 8px;
  427. }
  428. .price {
  429. color: #FD5F3C;
  430. font-size: 24px;
  431. }
  432. .desc {
  433. margin: 8px 0;
  434. line-height: 24px;
  435. font-size: 16px;
  436. color: #666666;
  437. }
  438. .time {
  439. font-size: 14px;
  440. color: #666666;
  441. }
  442. }
  443. .detail-txt {
  444. line-height: 58px;
  445. font-size: 18px;
  446. font-weight: bold;
  447. }
  448. .detail-list {
  449. .li {
  450. display: flex;
  451. padding: 0 16px;
  452. align-items: center;
  453. justify-content: space-between;
  454. margin-bottom: 16px;
  455. height: 64px;
  456. background: #F5F7FA;
  457. border-radius: 8px;
  458. &:last-child {
  459. margin-bottom: 0;
  460. }
  461. .detail-list-left {
  462. div {
  463. color: #666666;
  464. font-size: 14px;
  465. &:nth-child(2) {
  466. margin: 0 8px;
  467. font-size: 16px;
  468. color: #333333;
  469. }
  470. }
  471. }
  472. .detail-list-number {
  473. font-size: 14px;
  474. color: #333333;
  475. }
  476. .detail-list-right {
  477. .btn {
  478. display: flex;
  479. margin-left: 8px;
  480. align-items: center;
  481. cursor: pointer;
  482. padding: 0px 16px;
  483. height: 32px;
  484. border-radius: 4px;
  485. font-size: 14px;
  486. &:hover {
  487. opacity: 0.7;
  488. }
  489. img {
  490. width: 14px;
  491. height: 14px;
  492. margin-right: 4px;
  493. }
  494. }
  495. .green {
  496. background: #E9F7EF;
  497. div {
  498. color: #1FB362;
  499. }
  500. }
  501. .red {
  502. background: #FCEBEB;
  503. div {
  504. color: #E43434;
  505. }
  506. }
  507. .blue {
  508. background: #EAF0FF;
  509. div {
  510. color: #2D71FF;
  511. }
  512. }
  513. }
  514. }
  515. }
  516. }
  517. </style>