supply.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <div class="main">
  3. <div class="w_1300">
  4. <!-- <div class="active">
  5. <div class="active_1" v-show="industry && industry.length > 0">
  6. <div class="active_left">行业:</div>
  7. <div class="active_right">
  8. <div class="active_label" v-for="(item, index) in industry" :key="index">
  9. {{ item.title }}<el-icon @click="toDel(item, '1')"><Close /></el-icon>
  10. </div>
  11. </div>
  12. </div>
  13. <div class="active_1" v-show="field && field.length > 0">
  14. <div class="active_left">技术领域:</div>
  15. <div class="active_right">
  16. <div class="active_label" v-for="(item, index) in field" :key="index">
  17. {{ item.label }}<el-icon @click="toDel(item, '2')"><Close /></el-icon>
  18. </div>
  19. </div>
  20. </div>
  21. <div class="active_1" v-show="city && city.length > 0">
  22. <div class="active_left">所在地:</div>
  23. <div class="active_right">
  24. <div class="active_label" v-for="(item, index) in city" :key="index">
  25. {{ item.name }}<el-icon @click="toDel(item, '3')"><Close /></el-icon>
  26. </div>
  27. </div>
  28. </div>
  29. </div> -->
  30. <div class="demand">
  31. <div class="demandOne">
  32. <div class="demandSeacher">
  33. <div class="demandOneLeft">
  34. <span>行业</span>
  35. </div>
  36. <div v-if="!oneShow" class="demandOneRight">
  37. <div class="label" :class="[item.is_active ? 'show' : '']" v-for="(item, index) in plateList.slice(0, 6)" :key="index" @click="toSelect(item, '1')">
  38. {{ item.title }}
  39. </div>
  40. </div>
  41. <div v-else class="demandOneRight">
  42. <div class="label" :class="[item.is_active ? 'show' : '']" v-for="(item, index) in plateList" :key="index" @click="toSelect(item, '1')">
  43. {{ item.title }}
  44. </div>
  45. </div>
  46. <div class="button">
  47. <span v-if="!oneShow" @click="oneShow = true">
  48. <el-icon><ArrowDown /></el-icon>
  49. </span>
  50. <span v-else @click="oneShow = false">
  51. <el-icon><ArrowUp /></el-icon>
  52. </span>
  53. </div>
  54. </div>
  55. <div class="demandSeacher">
  56. <div class="demandOneLeft">
  57. <span>技术领域</span>
  58. </div>
  59. <div v-if="!twoShow" class="demandOneRight">
  60. <div class="label" :class="[item.is_active ? 'show' : '']" v-for="(item, index) in typeList.slice(0, 10)" :key="index" @click="toSelect(item, '2')">
  61. {{ item.label }}
  62. </div>
  63. </div>
  64. <div v-else class="demandOneRight">
  65. <div class="label" :class="[item.is_active ? 'show' : '']" v-for="(item, index) in typeList" :key="index" @click="toSelect(item, '2')">
  66. {{ item.label }}
  67. </div>
  68. </div>
  69. <div class="button">
  70. <span v-if="!twoShow" @click="twoShow = true">
  71. <el-icon><ArrowDown /></el-icon>
  72. </span>
  73. <span v-else @click="twoShow = false">
  74. <el-icon><ArrowUp /></el-icon>
  75. </span>
  76. </div>
  77. </div>
  78. <div class="demandSeacher border">
  79. <div class="demandOneLeft">
  80. <span>所在地</span>
  81. </div>
  82. <div class="demandOneRight">
  83. <div class="label" :class="[item.is_active ? 'show' : '']" v-for="(item, index) in cityList" :key="index" @click="toSelect(item, '3')">
  84. {{ item.name }}
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="demandIpunt">
  90. <el-input class="input" size="large" v-model:value="searchForm.name" placeholder="供应名称" />
  91. <el-input class="input" size="large" v-model:value="searchForm.tags" placeholder="标签名称" />
  92. <el-input class="input" size="large" v-model:value="searchForm.industry" placeholder="所属产业" />
  93. <el-input class="input" size="large" v-model:value="searchForm.source" placeholder="所属来源" />
  94. <el-button class="button" size="large" type="primary" @click="toSearchInfo(searchForm, '1')">检索</el-button>
  95. </div>
  96. <div class="demandTwo">
  97. <div class="demandTable">
  98. <div class="label" v-for="(item, index) in column" :key="index" :style="item.style">
  99. {{ item.name }}
  100. </div>
  101. </div>
  102. <div class="demandValue">
  103. <div class="value" v-for="(item, index) in list" :key="index">
  104. <div class="table-colunm table-colunm1 textOne">{{ index + 1 }}</div>
  105. <div class="table-colunm table-colunm2 textOne">{{ item.name || '暂无' }}</div>
  106. <div class="table-colunm textOne">{{ item.field || '暂无' }}</div>
  107. <div class="table-colunm table-colunm4 textOne">{{ item.industry || '暂无' }}</div>
  108. <!-- <div class="table-colunm">{{ item.status || '暂无' }}</div> -->
  109. <div class="table-colunm table-colunm3 textOne">{{ item.source || '暂无' }}</div>
  110. <div class="table-colunm textOne table-colunm3 button" @click="toView(item)">查看详情</div>
  111. </div>
  112. </div>
  113. <div class="demandTotal">
  114. <el-pagination background layout="prev, pager, next" :total="total" :page-size="limit" v-model:current-page="currentPage" @current-change="changePage" @size-change="sizeChange" />
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </template>
  121. <script setup>
  122. import { SupplyStore } from '@/store/api/platform/supply'
  123. import { RegionStore } from '@/store/api/system/region'
  124. import { SectorStore } from '@/store/api/platform/sector'
  125. import { DictDataStore } from '@/store/api/system/dictData'
  126. const regionStore = RegionStore()
  127. const sectorStore = SectorStore()
  128. const supplyStore = SupplyStore()
  129. const dictDataStore = DictDataStore()
  130. const router = useRouter()
  131. const searchValue = inject('searchValue')
  132. // 加载中
  133. const loading = ref(false)
  134. // 字典表
  135. const cityList = ref([])
  136. const typeList = ref([])
  137. const plateList = ref([])
  138. const statusList = ref([])
  139. // 列表
  140. const list = ref([])
  141. let skip = 0
  142. let limit = inject('limit')
  143. const total = ref(0)
  144. const searchForm = ref({})
  145. // 查询
  146. const industry = ref([])
  147. const field = ref([])
  148. const city = ref([])
  149. // 请求
  150. onMounted(async () => {
  151. loading.value = true
  152. await searchOther()
  153. await search({ skip, limit })
  154. loading.value = false
  155. })
  156. const searchOther = async () => {
  157. let res
  158. res = await regionStore.list({ level: 'city', parent_code: 22 })
  159. if (res.errcode == '0') cityList.value = res.data
  160. cityList.value.unshift({ id: '-1', code: '-1', name: '不限', is_active: true })
  161. res = await sectorStore.query({ is_use: '0' })
  162. if (res.errcode == '0') plateList.value = res.data
  163. plateList.value.unshift({ id: '-1', title: '不限', is_active: true })
  164. // 技术领域
  165. res = await dictDataStore.query({ code: 'field', is_use: '0' })
  166. if (res.errcode == '0') typeList.value = res.data
  167. typeList.value.unshift({ id: '-1', value: '-1', label: '不限', is_active: true })
  168. // 状态
  169. res = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
  170. if (res.errcode == '0') statusList.value = res.data
  171. }
  172. const search = async (query = { skip, limit }) => {
  173. skip = query.skip
  174. limit = query.limit
  175. const info = {
  176. skip: query.skip,
  177. limit: query.limit,
  178. is_use: '0',
  179. status: '1',
  180. ...searchForm.value
  181. }
  182. if (searchValue.value) info.tags = searchValue.value
  183. let res = await supplyStore.query(info)
  184. if (res.errcode == '0') {
  185. list.value = res.data
  186. total.value = res.total
  187. }
  188. }
  189. // 搜索
  190. const toSearchInfo = async (data) => {
  191. searchForm.value = data
  192. await search({ skip, limit })
  193. }
  194. const currentPage = ref(1)
  195. // 分页
  196. const changePage = (page = currentPage.value) => {
  197. search({ skip: (page - 1) * limit, limit: limit })
  198. }
  199. const sizeChange = (limits) => {
  200. limit = limits
  201. currentPage.value = 1
  202. search({ skip: 0, limit: limit })
  203. }
  204. // 是否展开
  205. const oneShow = ref(false)
  206. const twoShow = ref(false)
  207. const column = ref([
  208. { name: '序号', style: { width: '100px' }, key: 'num' },
  209. { name: '供方内容', style: { width: '320px' }, key: 'name' },
  210. { name: '技术领域', style: { width: '220px' }, key: 'field' },
  211. { name: '所属产业', style: { width: '240px' }, key: 'industry' },
  212. { name: '来源', style: { width: '200px' }, key: 'source' },
  213. { name: '操作', style: { width: '200px' }, key: 'operation' }
  214. ])
  215. // 查看详情
  216. const toView = (item) => {
  217. router.push({ path: '/supply/detail', query: { id: item.id || item._id } })
  218. }
  219. // 筛选条件
  220. const toSearchFind = async () => {
  221. if (industry.value && industry.value.length > 0) {
  222. searchForm.value.industry = industry.value.map((i) => {
  223. return i.title
  224. })
  225. } else delete searchForm.value.industry
  226. if (field.value && field.value.length > 0) {
  227. searchForm.value.field = field.value.map((i) => {
  228. return i.label
  229. })
  230. } else delete searchForm.value.field
  231. if (city.value && city.value.length > 0) {
  232. searchForm.value.area = city.value.map((i) => {
  233. return i.name
  234. })
  235. } else delete searchForm.value.area
  236. await search({ skip, limit })
  237. }
  238. const toSelect = async (data, type) => {
  239. if (data.is_active) {
  240. toDel(data, type)
  241. } else {
  242. if (data.id != '-1') {
  243. if (type == '1') {
  244. for (const val of plateList.value) {
  245. if (data.id == val.id) val.is_active = true
  246. if (val.id == '-1') val.is_active = false
  247. }
  248. const res = industry.value.find((i) => i.id == data.id)
  249. if (!res) industry.value.push(data)
  250. } else if (type == '2') {
  251. for (const val of typeList.value) {
  252. if (data.id == val.id) val.is_active = true
  253. if (val.id == '-1') val.is_active = false
  254. }
  255. const res = field.value.find((i) => i.id == data.id)
  256. if (!res) field.value.push(data)
  257. } else {
  258. for (const val of cityList.value) {
  259. if (data.id == val.id) val.is_active = true
  260. if (val.id == '-1') val.is_active = false
  261. }
  262. const res = city.value.find((i) => i.id == data.id)
  263. if (!res) city.value.push(data)
  264. }
  265. } else {
  266. if (type == '1') {
  267. for (const val of plateList.value) {
  268. if (val.id == '-1') val.is_active = true
  269. else val.is_active = false
  270. }
  271. industry.value = []
  272. } else if (type == '2') {
  273. for (const val of typeList.value) {
  274. if (val.id == '-1') val.is_active = true
  275. else val.is_active = false
  276. }
  277. field.value = []
  278. } else {
  279. for (const val of cityList.value) {
  280. if (val.id == '-1') val.is_active = true
  281. else val.is_active = false
  282. }
  283. city.value = []
  284. }
  285. }
  286. }
  287. await toSearchFind()
  288. }
  289. const toDel = async (data, type) => {
  290. if (type == '1') {
  291. for (const val of plateList.value) {
  292. if (data.id == val.id) val.is_active = false
  293. }
  294. industry.value = industry.value.filter((f) => f.id != data.id)
  295. if (industry.value.length == 0) {
  296. for (const val of plateList.value) {
  297. if (val.id == '-1') val.is_active = true
  298. }
  299. }
  300. } else if (type == '2') {
  301. for (const val of typeList.value) {
  302. if (data.id == val.id) val.is_active = false
  303. }
  304. field.value = field.value.filter((f) => f.id != data.id)
  305. if (field.value.length == 0) {
  306. for (const val of typeList.value) {
  307. if (val.id == '-1') val.is_active = true
  308. }
  309. }
  310. } else {
  311. for (const val of cityList.value) {
  312. if (data.id == val.id) val.is_active = false
  313. }
  314. city.value = city.value.filter((f) => f.id != data.id)
  315. if (city.value.length == 0) {
  316. for (const val of cityList.value) {
  317. if (val.id == '-1') val.is_active = true
  318. }
  319. }
  320. }
  321. await toSearchFind()
  322. }
  323. defineExpose({
  324. search
  325. })
  326. </script>
  327. <style scoped lang="scss">
  328. .main {
  329. background: url(/images/demand.png) no-repeat top center;
  330. background-size: 100% 100%;
  331. .active {
  332. .active_1 {
  333. display: inline-flex;
  334. background: #f5f7f9;
  335. border-radius: 2px;
  336. min-height: 28px;
  337. line-height: 28px;
  338. margin: 10px 10px 0 0;
  339. position: relative;
  340. background-color: #fff;
  341. padding: 10px;
  342. .active_left {
  343. flex: 0 0 auto;
  344. font-family: PingFangSC-Regular;
  345. color: #525a68;
  346. line-height: 36px;
  347. }
  348. .active_right {
  349. font-family: PingFangSC-Regular;
  350. color: rgba(0, 0, 0, 0.85);
  351. line-height: 28px;
  352. padding-right: 4px;
  353. display: flex;
  354. flex-wrap: wrap;
  355. overflow: hidden;
  356. .active_label {
  357. overflow: hidden;
  358. display: inline-block;
  359. margin-right: 10px;
  360. margin-top: 3px;
  361. margin-bottom: 3px;
  362. padding: 10px;
  363. display: flex;
  364. align-items: center;
  365. flex: none;
  366. box-sizing: border-box;
  367. max-width: 100%;
  368. height: 30px;
  369. background: #f5f5f5;
  370. border: 1px solid #f0f0f0;
  371. border-radius: 2px;
  372. cursor: default;
  373. }
  374. }
  375. }
  376. }
  377. .demand {
  378. padding: 10px 0;
  379. .demandOne {
  380. background-color: $global-color-fff;
  381. .demandSeacher {
  382. display: flex;
  383. justify-content: center;
  384. align-items: stretch;
  385. position: relative;
  386. border: solid 1px #e5e5e5;
  387. border-bottom: 0;
  388. font-size: $global-font-size-18;
  389. color: #666;
  390. min-height: 60px;
  391. overflow: hidden;
  392. .demandOneLeft {
  393. display: flex;
  394. justify-content: center;
  395. align-items: center;
  396. flex-shrink: 0;
  397. width: 110px;
  398. text-align: center;
  399. color: #000;
  400. font-weight: bold;
  401. background-color: #fafafa;
  402. }
  403. .demandOneRight {
  404. display: flex;
  405. flex-wrap: wrap;
  406. align-items: center;
  407. padding: 12px;
  408. flex: 1;
  409. border-left: solid 1px #e5e5e5;
  410. background-color: #fff;
  411. .label {
  412. margin-right: 3px;
  413. color: #313131;
  414. margin-bottom: 10px;
  415. padding: 8px 10px;
  416. border-radius: 3px;
  417. background-color: #fff;
  418. border: solid 1px transparent;
  419. cursor: pointer;
  420. }
  421. .label:hover {
  422. color: $global-color-107;
  423. }
  424. .show {
  425. color: #0a58c2;
  426. border: solid 1px #006dd2;
  427. }
  428. }
  429. .button {
  430. display: flex;
  431. align-items: center;
  432. margin: 0 5px 0 0;
  433. }
  434. }
  435. .border {
  436. border: solid 1px #e5e5e5;
  437. border-bottom: 1 !important;
  438. }
  439. }
  440. .demandIpunt {
  441. display: flex;
  442. align-items: center;
  443. justify-content: space-between;
  444. margin: 10px 0;
  445. .input {
  446. margin: 0 5px 0 0;
  447. }
  448. .button {
  449. margin: 0 0 0 5px;
  450. }
  451. }
  452. .demandTwo {
  453. margin: 10px 0;
  454. .demandTable {
  455. display: flex;
  456. justify-content: space-between;
  457. color: $global-color-fff;
  458. font-size: $global-font-size-20;
  459. background-color: rgba(255, 255, 255, 0.1);
  460. padding: 12px 0;
  461. .label {
  462. text-align: center;
  463. }
  464. }
  465. .demandValue {
  466. color: $global-color-fff;
  467. font-size: $global-font-size-20;
  468. .value {
  469. display: flex;
  470. justify-content: space-between;
  471. padding: 12px 0;
  472. .table-colunm {
  473. width: 220px;
  474. text-align: center;
  475. }
  476. .table-colunm1 {
  477. width: 100px !important;
  478. }
  479. .table-colunm2 {
  480. width: 320px !important;
  481. }
  482. .table-colunm3 {
  483. width: 200px !important;
  484. }
  485. .table-colunm4 {
  486. width: 240px !important;
  487. }
  488. .button {
  489. cursor: pointer; /* 改变鼠标样式为手形 */
  490. }
  491. .button:hover {
  492. color: $global-color-107;
  493. }
  494. }
  495. .value:nth-child(2n) {
  496. background-color: rgba(255, 255, 255, 0.1);
  497. }
  498. }
  499. .demandTotal {
  500. display: flex;
  501. justify-content: center;
  502. margin: 20px 0;
  503. }
  504. }
  505. }
  506. }
  507. </style>