achievement.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <div class="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
  5. <custom-form v-model="form" :fields="formFields" :rules="rules" @save="toSave" @draftSave="toDraftSave">
  6. <template #is_use>
  7. <el-radio v-for="i in isUseList" :key="i.id" :label="i.value">{{ i.label }}</el-radio>
  8. </template>
  9. <template #field>
  10. <el-option v-for="i in fieldList" :key="i.id" :label="i.label" :value="i.label"></el-option>
  11. </template>
  12. <template #attribute>
  13. <el-option v-for="i in attributeList" :key="i.id" :label="i.label" :value="i.value"></el-option>
  14. </template>
  15. <template #mature>
  16. <el-option v-for="i in matureList" :key="i.id" :label="i.label" :value="i.value"></el-option>
  17. </template>
  18. <template #sell>
  19. <el-option v-for="i in sellList" :key="i.id" :label="i.label" :value="i.value"></el-option>
  20. </template>
  21. <template #technology>
  22. <el-option v-for="i in technologyList" :key="i.id" :label="i.label" :value="i.value"></el-option>
  23. </template>
  24. <template #area>
  25. <el-cascader v-model="form.area" :props="{ value: 'name', label: 'name' }" :options="cityList" style="width: 100%" />
  26. </template>
  27. <template #file>
  28. <custom-upload model="file" :list="form.file" :limit="1" url="/files/web/cxyy_achievement/upload" @change="onUpload"></custom-upload>
  29. </template>
  30. <template #industry>
  31. <el-option v-for="i in sectorList" :key="i.id" :label="i.title" :value="i.title"></el-option>
  32. </template>
  33. <template #tags>
  34. <el-select v-model="form.tags" multiple filterable allow-create default-first-option :reserve-keyword="false" placeholder="请选择标签" style="width: 100%">
  35. <el-option v-for="item in tagsList" :key="item.id" :label="item.title" :value="item.title" />
  36. </el-select>
  37. </template>
  38. </custom-form>
  39. </el-col>
  40. </el-row>
  41. <el-dialog v-model="dialog.show" :title="dialog.title" :destroy-on-close="false" @close="toClose" :width="width">
  42. <el-row>
  43. <transition name="why">
  44. <el-col :span="24" v-if="dialog.type == '2'" class="dialog" v-loading="isLoading" element-loading-text="智能推荐中..." :element-loading-svg="svg" element-loading-svg-view-box="-10,-10,50,50">
  45. <el-empty v-if="demandtotal == 0" description="暂无数据" />
  46. <div class="list" v-for="(item, index) in demandList" :key="index" @click="toView(item)">
  47. <h2 class="name textMore">
  48. <span>{{ item.name || '暂无' }}</span>
  49. </h2>
  50. <div class="other">
  51. <span class="other_1">{{ getDict(item.urgent, 'urgent') || '暂无' }}</span>
  52. <div class="other_2">
  53. <span>应用行业:</span>
  54. {{ item.field || '暂无' }}
  55. </div>
  56. <div class="other_2">
  57. <span>资金预算:</span>
  58. {{ item.money || '面议' }}
  59. </div>
  60. <div class="other_2">
  61. <span>推荐指数:</span>
  62. <el-rate size="large" v-model="item._recommend" disabled show-score text-color="#ff9900" :score-template="`${item._recommend} 星`" />
  63. </div>
  64. <div class="other_2 textOne">
  65. <el-icon color="#0085f5"><Location /></el-icon>
  66. {{ getArea(item.area) }}
  67. <span class="state">{{ getDict(item.status, 'status') || '未解决' }}</span>
  68. </div>
  69. </div>
  70. </div>
  71. <el-col :span="24" class="page">
  72. <el-pagination background layout="prev, pager, next" :total="demandtotal" :page-size="demandlimit" v-model:current-page="dcurrentPage" @current-change="dchangePage" @size-change="dsizeChange" />
  73. </el-col>
  74. </el-col>
  75. </transition>
  76. </el-row>
  77. </el-dialog>
  78. </div>
  79. </template>
  80. <script setup>
  81. const router = useRouter()
  82. import { cloneDeep, get } from 'lodash-es'
  83. const $checkRes = inject('$checkRes')
  84. import { UserStore } from '@/store/user'
  85. const userStore = UserStore()
  86. const user = computed(() => userStore.user)
  87. // 接口
  88. import { AchievementStore } from '@/store/api/platform/achievement'
  89. import { DictDataStore } from '@/store/api/system/dictData'
  90. import { TagsStore } from '@/store/api/system/tags'
  91. import { SectorStore } from '@/store/api/platform/sector'
  92. import { RegionStore } from '@/store/api/system/region'
  93. import { EsStore } from '@/store/api/es'
  94. const esStore = EsStore()
  95. const regionStore = RegionStore()
  96. const store = AchievementStore()
  97. const dictDataStore = DictDataStore()
  98. const tagsStore = TagsStore()
  99. const sectorStore = SectorStore()
  100. // 加载中
  101. const loading = ref(false)
  102. // 字典表
  103. const isUseList = ref([])
  104. const statusList = ref([])
  105. const fieldList = ref([])
  106. const attributeList = ref([])
  107. const matureList = ref([])
  108. const sellList = ref([])
  109. const technologyList = ref([])
  110. const cityList = ref([])
  111. const achievementList = ref([])
  112. const tagsList = ref([])
  113. const sectorList = ref([])
  114. const urgentList = ref([])
  115. const formFields = ref([
  116. { label: '成果名称', model: 'name' },
  117. { label: '标签', model: 'tags', custom: true, mark: 'tags' },
  118. { label: '所属产业', model: 'industry', type: 'select' },
  119. { label: '专利号', model: 'patent' },
  120. { label: '行业领域', model: 'field' },
  121. { label: '属性', model: 'attribute', type: 'select', mark: 'dict', code: 'attribute' },
  122. { label: '成熟度', model: 'mature', type: 'select', mark: 'dict', code: 'mature' },
  123. { label: '出让方式', model: 'sell', type: 'select', mark: 'dict', code: 'sell' },
  124. { label: '技术分类', model: 'technology', type: 'select', mark: 'dict', code: 'technology' },
  125. { label: '成果地区', model: 'area', custom: true, mark: 'area' },
  126. { label: '发布时间', model: 'time', type: 'date' },
  127. { label: '价格(万元)', model: 'money' },
  128. { label: '项目来源', model: 'source' },
  129. { label: '联系人', model: 'person' },
  130. { label: '联系电话', model: 'tel' },
  131. { label: '是否公开', model: 'is_use', type: 'radio', mark: 'dict', code: 'isUse' },
  132. { label: '简介', model: 'brief', type: 'textarea' },
  133. { label: '附件', model: 'file', custom: true, mark: 'file' }
  134. ])
  135. const form = ref({ file: [] })
  136. const rules = reactive({
  137. name: [{ required: true, message: '请输入成果名称', trigger: 'blur' }],
  138. field: [{ required: true, message: '请输入行业领域', trigger: 'blur' }],
  139. attribute: [{ required: true, message: '请选择属性', trigger: 'blur' }],
  140. mature: [{ required: true, message: '请选择成熟度', trigger: 'blur' }],
  141. sell: [{ required: true, message: '请选择出让方式', trigger: 'blur' }],
  142. technology: [{ required: true, message: '请选择技术分类', trigger: 'blur' }],
  143. area: [{ required: true, message: '请选择成果地区', trigger: 'blur' }],
  144. time: [{ required: true, message: '请选择发布时间', trigger: 'blur' }],
  145. money: [{ required: true, message: '请输入价格', trigger: 'blur' }],
  146. source: [{ required: true, message: '请输入项目来源', trigger: 'blur' }],
  147. person: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
  148. tel: [{ required: true, message: '请输入联系电话', trigger: 'blur' }]
  149. })
  150. // 加载中
  151. const isLoading = ref(false)
  152. const svg = ref(`
  153. <path class="path" d="
  154. M 30 15
  155. L 28 17
  156. M 25.61 25.61
  157. A 15 15, 0, 0, 1, 15 30
  158. A 15 15, 0, 1, 1, 27.99 7.5
  159. L 15 15
  160. " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
  161. `)
  162. // 推荐需求列表
  163. const demandList = ref([])
  164. let demandskip = 0
  165. let demandlimit = 4
  166. const demandtotal = ref(0)
  167. const key = ref('')
  168. const width = ref('50%')
  169. const dialog = ref({ type: '1', show: false, title: '需求智能推荐' })
  170. // 请求
  171. onMounted(async () => {
  172. loading.value = true
  173. await searchOther()
  174. loading.value = false
  175. })
  176. const searchOther = async () => {
  177. let result
  178. // 是否使用
  179. result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
  180. if ($checkRes(result)) isUseList.value = result.data
  181. // 状态
  182. result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
  183. if ($checkRes(result)) statusList.value = result.data
  184. // 成熟度
  185. result = await dictDataStore.query({ code: 'mature', is_use: '0' })
  186. if ($checkRes(result)) matureList.value = result.data
  187. // 出让方式
  188. result = await dictDataStore.query({ code: 'sell', is_use: '0' })
  189. if ($checkRes(result)) sellList.value = result.data
  190. // 技术领域
  191. result = await dictDataStore.query({ code: 'field', is_use: '0' })
  192. if ($checkRes(result)) fieldList.value = result.data
  193. // 属性
  194. result = await dictDataStore.query({ code: 'attribute', is_use: '0' })
  195. if ($checkRes(result)) attributeList.value = result.data
  196. // 技术分类
  197. result = await dictDataStore.query({ code: 'technology', is_use: '0' })
  198. if ($checkRes(result)) technologyList.value = result.data
  199. // 成果状态
  200. result = await dictDataStore.query({ code: 'demandStatus', is_use: '0' })
  201. if ($checkRes(result)) achievementList.value = result.data
  202. // 标签
  203. result = await tagsStore.query({ is_use: '0' })
  204. if ($checkRes(result)) tagsList.value = result.data
  205. // 行业
  206. result = await sectorStore.query({ is_use: '0' })
  207. if ($checkRes(result)) sectorList.value = result.data
  208. // 城市
  209. result = await regionStore.area({ level: 'province', code: 22 })
  210. if ($checkRes(result)) cityList.value = result.data
  211. // 需求紧急度
  212. result = await dictDataStore.query({ code: 'urgent', is_use: '0' })
  213. if ($checkRes(result)) urgentList.value = result.data
  214. }
  215. // 上传图片
  216. const onUpload = (e) => {
  217. const { model, value } = e
  218. form.value[model] = value
  219. }
  220. const toSave = async () => {
  221. const data = cloneDeep(form.value)
  222. const other = { status: '0', user: user.value.id }
  223. let res
  224. if (get(data, 'id')) res = await store.update({ ...data, ...other })
  225. else res = await store.create({ ...data, ...other })
  226. if (res.errcode == 0) {
  227. ElMessage({ message: `发布成功可以上历史发布查看`, type: 'success' })
  228. key.value = form.value.name
  229. await toClose()
  230. await searchDemand({ demandskip, demandlimit })
  231. width.value = '90%'
  232. dialog.value = { type: '2', show: true, title: '相关需求推荐' }
  233. }
  234. }
  235. const toDraftSave = async () => {
  236. const data = cloneDeep(form.value)
  237. const other = { status: '-2', user: user.value.id }
  238. let res
  239. if (get(data, 'id')) res = await store.update({ ...data, ...other })
  240. else res = await store.create({ ...data, ...other })
  241. if (res.errcode == 0) {
  242. ElMessage({ message: `发布成功可以上历史发布查看`, type: 'success' })
  243. key.value = form.value.name
  244. await toClose()
  245. await searchDemand({ demandskip, demandlimit })
  246. width.value = '90%'
  247. dialog.value = { type: '2', show: true, title: '相关需求推荐' }
  248. }
  249. }
  250. const toClose = () => {
  251. form.value = {}
  252. width.value = '50%'
  253. dialog.value = { show: false }
  254. }
  255. // 地区
  256. const getArea = (data) => {
  257. if (data) return data.join('-')
  258. else return '暂无地区'
  259. }
  260. // 字典数据转换
  261. const getDict = (data, model) => {
  262. if (data) {
  263. let res
  264. if (model == 'status') res = statusList.value.find((f) => f.value == data)
  265. else if (model == 'urgent') res = urgentList.value.find((f) => f.value == data)
  266. return get(res, 'label')
  267. }
  268. }
  269. // 需求列表查询
  270. const searchDemand = async (query = { demandskip, demandlimit }) => {
  271. demandskip = query.demandskip
  272. demandlimit = query.demandlimit
  273. isLoading.value = true
  274. const info = { skip: demandskip, limit: demandlimit, keyword: key.value }
  275. const res = await esStore.demand(info)
  276. if (res.errcode == '0') {
  277. demandList.value = res.data
  278. demandtotal.value = res.total
  279. }
  280. setTimeout(() => {
  281. isLoading.value = false
  282. }, 3000) // 假设3秒后加载完成
  283. }
  284. // 查看详情
  285. const toView = (item) => {
  286. router.push({ path: '/demand/detail', query: { id: item.id || item._id } })
  287. }
  288. const dcurrentPage = ref(1)
  289. // 分页
  290. const dchangePage = (page = dcurrentPage.value) => {
  291. searchDemand({ demandskip: (page - 1) * demandlimit, demandlimit: demandlimit })
  292. }
  293. const dsizeChange = (limits) => {
  294. demandlimit = limits
  295. dcurrentPage.value = 1
  296. searchDemand({ demandskip: 0, demandlimit: demandlimit })
  297. }
  298. </script>
  299. <style scoped lang="scss">
  300. .why-enter-from,
  301. .why-leave-to {
  302. opacity: 0;
  303. transform: scale(0.6);
  304. }
  305. .why-enter-to,
  306. .why-leave-from {
  307. opacity: 1;
  308. transform: scale(1);
  309. }
  310. .why-enter-active,
  311. .why-leave-active {
  312. transition: all 2s ease;
  313. }
  314. .dialog {
  315. display: flex;
  316. justify-content: space-between;
  317. flex-wrap: wrap;
  318. margin-top: 20px;
  319. .list {
  320. position: relative;
  321. margin-right: 10px;
  322. margin-bottom: 10px;
  323. width: 380px;
  324. box-shadow: 0 0 13px 0 rgba(5, 88, 219, 0.18);
  325. .name {
  326. padding: 10px 20px;
  327. width: 380px;
  328. height: 71px;
  329. background-color: #dce5ff;
  330. font-size: 16px;
  331. line-height: 24px;
  332. color: #0d0d0d;
  333. display: flex;
  334. align-items: center;
  335. }
  336. .other {
  337. padding: 10px 20px 20px;
  338. .other_1 {
  339. padding: 0 10px;
  340. height: 25px;
  341. background-color: #e6f2fd;
  342. border-radius: 2px;
  343. border: solid 1px #cae0f5;
  344. font-size: $global-font-size-14;
  345. line-height: 25px;
  346. color: #0085f5;
  347. }
  348. .other_2 {
  349. display: flex;
  350. align-items: center;
  351. margin-top: 15px;
  352. font-size: $global-font-size-16;
  353. span {
  354. color: #909090;
  355. }
  356. .state {
  357. position: absolute;
  358. right: 20px;
  359. bottom: 15px;
  360. display: inline-block;
  361. vertical-align: middle;
  362. padding: 0 20px;
  363. height: 30px;
  364. line-height: 30px;
  365. background-image: linear-gradient(90deg, #ff8a00 0, #ff5a00 100%), linear-gradient(#ff7800, #ff7800);
  366. background-blend-mode: normal, normal;
  367. border-radius: 14px;
  368. border: solid 1px #e5e5e5;
  369. color: #fff;
  370. }
  371. }
  372. }
  373. }
  374. .list:hover {
  375. box-shadow: 0 0 5px 0 $global-color-107;
  376. .name {
  377. background-color: $global-color-107;
  378. color: $global-color-fff;
  379. }
  380. }
  381. .page {
  382. margin: 10px 0;
  383. display: flex;
  384. justify-content: center;
  385. }
  386. }
  387. </style>